diff options
author | Matt Corallo <git@bluematt.me> | 2017-03-06 17:22:50 -0500 |
---|---|---|
committer | Matt Corallo <git@bluematt.me> | 2017-04-07 11:53:43 +0200 |
commit | a1476877ce7b0614a93b7ba48ebbe71075c0f27c (patch) | |
tree | 5bec153a17e6cdcbab9ee93816ef2393d2dcab35 /src | |
parent | d3167ba9bbefc2e5b7062f81c481547f21c5e44b (diff) |
Keep conflictedTxs in ConnectTrace per-block
Diffstat (limited to 'src')
-rw-r--r-- | src/validation.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index d91afbb714..cd9d941939 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2179,17 +2179,17 @@ static int64_t nTimePostConnect = 0; * part of a single ActivateBestChainStep call. * * This class also tracks transactions that are removed from the mempool as - * conflicts and can be used to pass all those transactions through - * SyncTransaction. + * conflicts (per block) and can be used to pass all those transactions + * through SyncTransaction. */ class ConnectTrace { private: std::vector<std::pair<CBlockIndex*, std::shared_ptr<const CBlock> > > blocksConnected; - std::vector<CTransactionRef> conflictedTxs; + std::vector<std::vector<CTransactionRef> > conflictedTxs; CTxMemPool &pool; public: - ConnectTrace(CTxMemPool &_pool) : pool(_pool) { + ConnectTrace(CTxMemPool &_pool) : conflictedTxs(1), pool(_pool) { pool.NotifyEntryRemoved.connect(boost::bind(&ConnectTrace::NotifyEntryRemoved, this, _1, _2)); } @@ -2199,6 +2199,7 @@ public: void BlockConnected(CBlockIndex* pindex, std::shared_ptr<const CBlock> pblock) { blocksConnected.emplace_back(pindex, std::move(pblock)); + conflictedTxs.emplace_back(); } std::vector<std::pair<CBlockIndex*, std::shared_ptr<const CBlock> > >& GetBlocksConnected() { @@ -2207,15 +2208,18 @@ public: void NotifyEntryRemoved(CTransactionRef txRemoved, MemPoolRemovalReason reason) { if (reason == MemPoolRemovalReason::CONFLICT) { - conflictedTxs.push_back(txRemoved); + conflictedTxs.back().push_back(txRemoved); } } void CallSyncTransactionOnConflictedTransactions() { - for (const auto& tx : conflictedTxs) { - GetMainSignals().SyncTransaction(*tx, NULL, CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK); + for (const auto& txRemovedForBlock : conflictedTxs) { + for (const auto& tx : txRemovedForBlock) { + GetMainSignals().SyncTransaction(*tx, NULL, CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK); + } } conflictedTxs.clear(); + conflictedTxs.emplace_back(); } }; |