aboutsummaryrefslogtreecommitdiff
path: root/src/validation.h
diff options
context:
space:
mode:
authorglozow <gzhao408@berkeley.edu>2021-05-20 21:22:35 +0100
committerglozow <gzhao408@berkeley.edu>2021-05-20 21:34:31 +0100
commit578148ded62828a9820398165c41670f4dbb523d (patch)
treed8fd7377ba8777ccfa475f777090a53b807144d5 /src/validation.h
parentb88d77aec5e7bef5305a668d15031351c0548b4d (diff)
downloadbitcoin-578148ded62828a9820398165c41670f4dbb523d.tar.xz
[validation] explicit Success/Failure ctors for MempoolAcceptResult
Makes code more clear and prevents accidentally calling the wrong ctor.
Diffstat (limited to 'src/validation.h')
-rw-r--r--src/validation.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/validation.h b/src/validation.h
index 4deaf1830f..231f55d827 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -169,9 +169,7 @@ void PruneBlockFilesManual(CChainState& active_chainstate, int nManualPruneHeigh
* Validation result for a single transaction mempool acceptance.
*/
struct MempoolAcceptResult {
- /** Used to indicate the results of mempool validation,
- * including the possibility of unfinished validation.
- */
+ /** Used to indicate the results of mempool validation. */
enum class ResultType {
VALID, //!> Fully validated, valid.
INVALID, //!> Invalid.
@@ -184,7 +182,16 @@ struct MempoolAcceptResult {
const std::optional<std::list<CTransactionRef>> m_replaced_transactions;
/** 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);
+ }
+// Private constructors. Use static methods MempoolAcceptResult::Success, etc. to construct.
+private:
/** Constructor for failure case */
explicit MempoolAcceptResult(TxValidationState state)
: m_result_type(ResultType::INVALID), m_state(state) {