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.
This commit is contained in:
Alexander Block 2017-09-16 22:40:07 +02:00
parent 808936cc30
commit 36aa554584
2 changed files with 34 additions and 10 deletions

View File

@ -520,6 +520,21 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals)
// mapOrphanTransactions // 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<uint256> &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) bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{ {
uint256 hash = tx.GetHash(); uint256 hash = tx.GetHash();
@ -551,7 +566,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(c
return true; return true;
} }
int static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) int EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{ {
map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.find(hash); map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.find(hash);
if (it == mapOrphanTransactions.end()) if (it == mapOrphanTransactions.end())

View File

@ -102,6 +102,10 @@ CTxMemPool mempool(::minRelayTxFee);
FeeFilterRounder filterRounder(::minRelayTxFee); FeeFilterRounder filterRounder(::minRelayTxFee);
map<uint256, int64_t> mapRejectedBlocks GUARDED_BY(cs_main); map<uint256, int64_t> mapRejectedBlocks GUARDED_BY(cs_main);
// TODO temporary hack for backporting
void LoopMapOrphanTransactionsByPrev(const CTransaction &tx, std::vector<uint256> &vOrphanErase);
int EraseOrphanTx(uint256 hash);
/** /**
* Returns true if there are nRequired or more blocks of minVersion or above * 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. * 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? // Which orphan pool entries must we evict?
for (size_t j = 0; j < tx.vin.size(); j++) { //for (size_t j = 0; j < tx.vin.size(); j++) {
auto itByPrev = mapOrphanTransactionsByPrev.find(tx.vin[j].prevout); // auto itByPrev = mapOrphanTransactionsByPrev.find(tx.vin[j].prevout);
if (itByPrev == mapOrphanTransactionsByPrev.end()) continue; // if (itByPrev == mapOrphanTransactionsByPrev.end()) continue;
for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) { // for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) {
const CTransaction& orphanTx = (*mi)->second.tx; // const CTransaction& orphanTx = (*mi)->second.tx;
const uint256& orphanHash = orphanTx.GetHash(); // const uint256& orphanHash = orphanTx.GetHash();
vOrphanErase.push_back(orphanHash); // 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)) { if (!SequenceLocks(tx, nLockTimeFlags, &prevheights, *pindex)) {
return state.DoS(100, error("%s: contains a non-BIP68-final transaction", __func__), return state.DoS(100, error("%s: contains a non-BIP68-final transaction", __func__),