mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-06 19:23:41 +02:00
Add sigops adjusted weight calculator
This commit is contained in:
@@ -373,9 +373,14 @@ bool SpendsNonAnchorWitnessProg(const CTransaction& tx, const CCoinsViewCache& p
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <primitives/transaction.h>
|
||||
#include <script/interpreter.h>
|
||||
#include <script/solver.h>
|
||||
#include <util/feefrac.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
@@ -188,4 +189,8 @@ static inline int64_t GetVirtualTransactionInputSize(const CTxIn& tx)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user