diff options
author | glozow <gzhao408@berkeley.edu> | 2021-05-20 21:22:35 +0100 |
---|---|---|
committer | glozow <gzhao408@berkeley.edu> | 2021-05-20 21:34:31 +0100 |
commit | 578148ded62828a9820398165c41670f4dbb523d (patch) | |
tree | d8fd7377ba8777ccfa475f777090a53b807144d5 /src/validation.cpp | |
parent | b88d77aec5e7bef5305a668d15031351c0548b4d (diff) |
[validation] explicit Success/Failure ctors for MempoolAcceptResult
Makes code more clear and prevents accidentally calling the wrong ctor.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 3aa360987e..9165a1f1b3 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1040,7 +1040,7 @@ MempoolAcceptResult MemPoolAccept::AcceptSingleTransaction(const CTransactionRef Workspace ws(ptx); - if (!PreChecks(args, ws)) return MempoolAcceptResult(ws.m_state); + if (!PreChecks(args, ws)) return MempoolAcceptResult::Failure(ws.m_state); // Only compute the precomputed transaction data if we need to verify // scripts (ie, other policy checks pass). We perform the inexpensive @@ -1048,20 +1048,20 @@ MempoolAcceptResult MemPoolAccept::AcceptSingleTransaction(const CTransactionRef // checks pass, to mitigate CPU exhaustion denial-of-service attacks. PrecomputedTransactionData txdata; - if (!PolicyScriptChecks(args, ws, txdata)) return MempoolAcceptResult(ws.m_state); + if (!PolicyScriptChecks(args, ws, txdata)) return MempoolAcceptResult::Failure(ws.m_state); - if (!ConsensusScriptChecks(args, ws, txdata)) return MempoolAcceptResult(ws.m_state); + if (!ConsensusScriptChecks(args, ws, txdata)) return MempoolAcceptResult::Failure(ws.m_state); // Tx was accepted, but not added if (args.m_test_accept) { - return MempoolAcceptResult(std::move(ws.m_replaced_transactions), ws.m_base_fees); + return MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_base_fees); } - if (!Finalize(args, ws)) return MempoolAcceptResult(ws.m_state); + if (!Finalize(args, ws)) return MempoolAcceptResult::Failure(ws.m_state); GetMainSignals().TransactionAddedToMempool(ptx, m_pool.GetAndIncrementSequence()); - return MempoolAcceptResult(std::move(ws.m_replaced_transactions), ws.m_base_fees); + return MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_base_fees); } } // anon namespace |