diff options
author | glozow <gloriajzhao@gmail.com> | 2021-09-02 13:09:11 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2021-10-28 15:58:54 +0100 |
commit | 36a8441912bf84b4da9c74826dcd42533d8abaaa (patch) | |
tree | 0d65ed2f257ad67ec05732e839fe7a4c8ba87c15 /src/validation.h | |
parent | 8fa2936b34fda9c0bea963311fa80a04b4bf5867 (diff) | |
download | bitcoin-36a8441912bf84b4da9c74826dcd42533d8abaaa.tar.xz |
[validation/rpc] cache + use vsize calculated in PreChecks
This is not only cleaner but also helps make sure we are always using
the virtual size measure that includes the sigop weight heuristic (which
is the vsize the mempool would return).
Diffstat (limited to 'src/validation.h')
-rw-r--r-- | src/validation.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/validation.h b/src/validation.h index 4da8ec8d24..256981224a 100644 --- a/src/validation.h +++ b/src/validation.h @@ -158,14 +158,16 @@ struct MempoolAcceptResult { // The following fields are only present when m_result_type = ResultType::VALID /** Mempool transactions replaced by the tx per BIP 125 rules. */ const std::optional<std::list<CTransactionRef>> m_replaced_transactions; + /** Virtual size as used by the mempool, calculated using serialized size and sigops. */ + const std::optional<int64_t> m_vsize; /** Raw base fees in satoshis. */ const std::optional<CAmount> m_base_fees; static MempoolAcceptResult Failure(TxValidationState state) { return MempoolAcceptResult(state); } - static MempoolAcceptResult Success(std::list<CTransactionRef>&& replaced_txns, CAmount fees) { - return MempoolAcceptResult(std::move(replaced_txns), fees); + static MempoolAcceptResult Success(std::list<CTransactionRef>&& replaced_txns, int64_t vsize, CAmount fees) { + return MempoolAcceptResult(std::move(replaced_txns), vsize, fees); } // Private constructors. Use static methods MempoolAcceptResult::Success, etc. to construct. @@ -177,9 +179,9 @@ private: } /** Constructor for success case */ - explicit MempoolAcceptResult(std::list<CTransactionRef>&& replaced_txns, CAmount fees) + explicit MempoolAcceptResult(std::list<CTransactionRef>&& replaced_txns, int64_t vsize, CAmount fees) : m_result_type(ResultType::VALID), - m_replaced_transactions(std::move(replaced_txns)), m_base_fees(fees) {} + m_replaced_transactions(std::move(replaced_txns)), m_vsize{vsize}, m_base_fees(fees) {} }; /** |