Merge bitcoin/bitcoin#21783: refactor: Make MempoolAcceptResult members const

363df758a9 doc/style followups in MempoolAcceptResult (glozow)

Pull request description:

  Follow up to #21062. Was going to be a part of #20833 but I'm trying to break it down as much as possible.

  - Make members const (https://github.com/bitcoin/bitcoin/pull/21062#discussion_r573659273)
  - List fee units (https://github.com/bitcoin/bitcoin/pull/21062#discussion_r569329362)
  - Use default value for `TxValidationState` in the success case (https://github.com/bitcoin/bitcoin/pull/21062#discussion_r573659801).

ACKs for top commit:
  jnewbery:
    ACK 363df758a9
  practicalswift:
    cr ACK 363df758a9: patch looks correct and `const` is better than non-`const` (where possible :))
  ariard:
    Code Review ACK 363df75

Tree-SHA512: 0ff1a0279e08e03204e48d0f4c92428d7f39c32f52c1d20fe6a0283d605839898297344be82ca69640ba9f878ca4ebd5da2d717e26d719a183b211d709334082
This commit is contained in:
MarcoFalke 2021-04-28 08:06:25 +02:00
commit edf679503c
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

View File

@ -195,14 +195,14 @@ struct MempoolAcceptResult {
VALID, //!> Fully validated, valid.
INVALID, //!> Invalid.
};
ResultType m_result_type;
TxValidationState m_state;
const ResultType m_result_type;
const TxValidationState m_state;
// The following fields are only present when m_result_type = ResultType::VALID
/** Mempool transactions replaced by the tx per BIP 125 rules. */
std::optional<std::list<CTransactionRef>> m_replaced_transactions;
/** Raw base fees. */
std::optional<CAmount> m_base_fees;
const std::optional<std::list<CTransactionRef>> m_replaced_transactions;
/** Raw base fees in satoshis. */
const std::optional<CAmount> m_base_fees;
/** Constructor for failure case */
explicit MempoolAcceptResult(TxValidationState state)
@ -212,7 +212,7 @@ struct MempoolAcceptResult {
/** Constructor for success case */
explicit MempoolAcceptResult(std::list<CTransactionRef>&& replaced_txns, CAmount fees)
: m_result_type(ResultType::VALID), m_state(TxValidationState{}),
: m_result_type(ResultType::VALID),
m_replaced_transactions(std::move(replaced_txns)), m_base_fees(fees) {}
};