From 36aa554584dcf3c2178f49bfe70faaa24d1e4e9e Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Sat, 16 Sep 2017 22:40:07 +0200 Subject: [PATCH] Temporarily fix build error cased by out-of-order backporting Can be removed when we catch up with backporting. You'll notice it's time for this when you get conflicts while merging the affected backported PR. --- src/net_processing.cpp | 17 ++++++++++++++++- src/validation.cpp | 27 ++++++++++++++++++--------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 4254b793c5..f6f8176be3 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -520,6 +520,21 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals) // mapOrphanTransactions // +// TODO This is a temporary solution while backporting Bitcoin 0.13 changes into Dash +// See caller of this method +void LoopMapOrphanTransactionsByPrev(const CTransaction &tx, std::vector &vOrphanErase) +{ + for (size_t j = 0; j < tx.vin.size(); j++) { + auto itByPrev = mapOrphanTransactionsByPrev.find(tx.vin[j].prevout); + if (itByPrev == mapOrphanTransactionsByPrev.end()) continue; + for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) { + const CTransaction& orphanTx = (*mi)->second.tx; + const uint256& orphanHash = orphanTx.GetHash(); + vOrphanErase.push_back(orphanHash); + } + } +} + bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { uint256 hash = tx.GetHash(); @@ -551,7 +566,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(c return true; } -int static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) +int EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { map::iterator it = mapOrphanTransactions.find(hash); if (it == mapOrphanTransactions.end()) diff --git a/src/validation.cpp b/src/validation.cpp index 15c2f8419d..37295058ca 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -102,6 +102,10 @@ CTxMemPool mempool(::minRelayTxFee); FeeFilterRounder filterRounder(::minRelayTxFee); map mapRejectedBlocks GUARDED_BY(cs_main); +// TODO temporary hack for backporting +void LoopMapOrphanTransactionsByPrev(const CTransaction &tx, std::vector &vOrphanErase); +int EraseOrphanTx(uint256 hash); + /** * Returns true if there are nRequired or more blocks of minVersion or above * in the last Consensus::Params::nMajorityWindow blocks, starting at pstart and going backwards. @@ -2119,15 +2123,20 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd } // Which orphan pool entries must we evict? - for (size_t j = 0; j < tx.vin.size(); j++) { - auto itByPrev = mapOrphanTransactionsByPrev.find(tx.vin[j].prevout); - if (itByPrev == mapOrphanTransactionsByPrev.end()) continue; - for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) { - const CTransaction& orphanTx = (*mi)->second.tx; - const uint256& orphanHash = orphanTx.GetHash(); - vOrphanErase.push_back(orphanHash); - } - } + //for (size_t j = 0; j < tx.vin.size(); j++) { + // auto itByPrev = mapOrphanTransactionsByPrev.find(tx.vin[j].prevout); + // if (itByPrev == mapOrphanTransactionsByPrev.end()) continue; + // for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) { + // const CTransaction& orphanTx = (*mi)->second.tx; + // const uint256& orphanHash = orphanTx.GetHash(); + // vOrphanErase.push_back(orphanHash); + // } + //} + // TODO This is a temporary solution while backporting Bitcoin 0.13 changes into Dash + // It is needed because the splitting of main.cpp into validation.cpp/net_processing.cpp was done out of order + // When we catch up with backporting, the above loop will be at the correct place in net_processing.cpp + // and this hack can be removed + LoopMapOrphanTransactionsByPrev(tx, vOrphanErase); if (!SequenceLocks(tx, nLockTimeFlags, &prevheights, *pindex)) { return state.DoS(100, error("%s: contains a non-BIP68-final transaction", __func__),