Skip to content

Commit

Permalink
Merge bitcoin#21783: refactor: Make MempoolAcceptResult members const
Browse files Browse the repository at this point in the history
363df75 doc/style followups in MempoolAcceptResult (glozow)

Pull request description:

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

  - Make members const (bitcoin#21062 (comment))
  - List fee units (bitcoin#21062 (comment))
  - Use default value for `TxValidationState` in the success case (bitcoin#21062 (comment)).

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

Tree-SHA512: 0ff1a0279e08e03204e48d0f4c92428d7f39c32f52c1d20fe6a0283d605839898297344be82ca69640ba9f878ca4ebd5da2d717e26d719a183b211d709334082
  • Loading branch information
MarcoFalke committed Apr 28, 2021
2 parents bce09da + 363df75 commit edf6795
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {}
};

Expand Down

0 comments on commit edf6795

Please sign in to comment.