Add sigops adjusted weight calculator
This commit is contained in:
1 parent
c18c68a950
commit
1bf3b51396
2 files changed
+11
-1
No files matched your search
@@ -373,9 +373,14 @@ bool SpendsNonAnchorWitnessProg(const CTransaction& tx, const CCoinsViewCache& p
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t GetSigOpsAdjustedWeight(int64_t weight, int64_t sigop_cost, unsigned int bytes_per_sigop)
|
||||||
|
{
|
||||||
|
return std::max(weight, sigop_cost * bytes_per_sigop);
|
||||||
|
}
|
||||||
|
|
||||||
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
|
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
|
||||||
{
|
{
|
||||||
return (std::max(nWeight, nSigOpCost * bytes_per_sigop) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR;
|
return (GetSigOpsAdjustedWeight(nWeight, nSigOpCost, bytes_per_sigop) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost, unsigned int bytes_per_sigop)
|
int64_t GetVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost, unsigned int bytes_per_sigop)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <primitives/transaction.h>
|
#include <primitives/transaction.h>
|
||||||
#include <script/interpreter.h>
|
#include <script/interpreter.h>
|
||||||
#include <script/solver.h>
|
#include <script/solver.h>
|
||||||
|
#include <util/feefrac.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -188,4 +189,8 @@ static inline int64_t GetVirtualTransactionInputSize(const CTxIn& tx)
|
|||||||
return GetVirtualTransactionInputSize(tx, 0, 0);
|
return GetVirtualTransactionInputSize(tx, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t GetSigOpsAdjustedWeight(int64_t weight, int64_t sigop_cost, unsigned int bytes_per_sigop);
|
||||||
|
|
||||||
|
static inline FeePerVSize ToFeePerVSize(FeePerWeight feerate) { return {feerate.fee, (feerate.size + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR}; }
|
||||||
|
|
||||||
#endif // BITCOIN_POLICY_POLICY_H
|
#endif // BITCOIN_POLICY_POLICY_H
|
||||||
Reference in new issue
Block a user