Skip to content

Commit 8ad7ad3

Browse files
committed
[validation] make PackageMempoolAcceptResult members mutable
After the PackageMempoolAcceptResult is returned from AcceptMultipleTransactions, leave room for results to change due to LimitMempool() eviction.
1 parent 03b87c1 commit 8ad7ad3

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/validation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ class MemPoolAccept
655655
// The package may end up partially-submitted after size limiting; returns true if all
656656
// transactions are successfully added to the mempool, false otherwise.
657657
bool SubmitPackage(const ATMPArgs& args, std::vector<Workspace>& workspaces, PackageValidationState& package_state,
658-
std::map<const uint256, const MempoolAcceptResult>& results)
658+
std::map<uint256, MempoolAcceptResult>& results)
659659
EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_pool.cs);
660660

661661
// Compare a package's feerate against minimum allowed.
@@ -1132,7 +1132,7 @@ bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
11321132

11331133
bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>& workspaces,
11341134
PackageValidationState& package_state,
1135-
std::map<const uint256, const MempoolAcceptResult>& results)
1135+
std::map<uint256, MempoolAcceptResult>& results)
11361136
{
11371137
AssertLockHeld(cs_main);
11381138
AssertLockHeld(m_pool.cs);
@@ -1262,7 +1262,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
12621262
workspaces.reserve(txns.size());
12631263
std::transform(txns.cbegin(), txns.cend(), std::back_inserter(workspaces),
12641264
[](const auto& tx) { return Workspace(tx); });
1265-
std::map<const uint256, const MempoolAcceptResult> results;
1265+
std::map<uint256, MempoolAcceptResult> results;
12661266

12671267
LOCK(m_pool.cs);
12681268

@@ -1444,7 +1444,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptPackage(const Package& package,
14441444

14451445
LOCK(m_pool.cs);
14461446
// Stores final results that won't change
1447-
std::map<const uint256, const MempoolAcceptResult> results_final;
1447+
std::map<uint256, MempoolAcceptResult> results_final;
14481448
// Results from individual validation. "Nonfinal" because if a transaction fails by itself but
14491449
// succeeds later (i.e. when evaluated with a fee-bumping child), the result changes (though not
14501450
// reflected in this map). If a transaction fails more than once, we want to return the first

src/validation.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,21 @@ struct MempoolAcceptResult {
211211
*/
212212
struct PackageMempoolAcceptResult
213213
{
214-
const PackageValidationState m_state;
214+
PackageValidationState m_state;
215215
/**
216216
* Map from wtxid to finished MempoolAcceptResults. The client is responsible
217217
* for keeping track of the transaction objects themselves. If a result is not
218218
* present, it means validation was unfinished for that transaction. If there
219219
* was a package-wide error (see result in m_state), m_tx_results will be empty.
220220
*/
221-
std::map<const uint256, const MempoolAcceptResult> m_tx_results;
221+
std::map<uint256, MempoolAcceptResult> m_tx_results;
222222

223223
explicit PackageMempoolAcceptResult(PackageValidationState state,
224-
std::map<const uint256, const MempoolAcceptResult>&& results)
224+
std::map<uint256, MempoolAcceptResult>&& results)
225225
: m_state{state}, m_tx_results(std::move(results)) {}
226226

227227
explicit PackageMempoolAcceptResult(PackageValidationState state, CFeeRate feerate,
228-
std::map<const uint256, const MempoolAcceptResult>&& results)
228+
std::map<uint256, MempoolAcceptResult>&& results)
229229
: m_state{state}, m_tx_results(std::move(results)) {}
230230

231231
/** Constructor to create a PackageMempoolAcceptResult from a single MempoolAcceptResult */

0 commit comments

Comments
 (0)