Auto merge of #4605 - daira:more-iterator-cleanups, r=daira
More iterator cleanups Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
commit
2ba4f16590
22
src/main.cpp
22
src/main.cpp
|
@ -3870,10 +3870,8 @@ bool ReceivedBlockTransactions(
|
||||||
}
|
}
|
||||||
std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex);
|
std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex);
|
||||||
while (range.first != range.second) {
|
while (range.first != range.second) {
|
||||||
std::multimap<CBlockIndex*, CBlockIndex*>::iterator it = range.first;
|
queue.push_back(range.first->second);
|
||||||
queue.push_back(it->second);
|
range.first = mapBlocksUnlinked.erase(range.first);
|
||||||
range.first++;
|
|
||||||
mapBlocksUnlinked.erase(it);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -4411,10 +4409,10 @@ void PruneOneBlockFile(const int fileNumber)
|
||||||
// mapBlocksUnlinked or setBlockIndexCandidates.
|
// mapBlocksUnlinked or setBlockIndexCandidates.
|
||||||
std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex->pprev);
|
std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex->pprev);
|
||||||
while (range.first != range.second) {
|
while (range.first != range.second) {
|
||||||
std::multimap<CBlockIndex *, CBlockIndex *>::iterator it = range.first;
|
if (range.first->second == pindex) {
|
||||||
range.first++;
|
range.first = mapBlocksUnlinked.erase(range.first);
|
||||||
if (it->second == pindex) {
|
} else {
|
||||||
mapBlocksUnlinked.erase(it);
|
++range.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5160,20 +5158,18 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskB
|
||||||
queue.pop_front();
|
queue.pop_front();
|
||||||
std::pair<std::multimap<uint256, CDiskBlockPos>::iterator, std::multimap<uint256, CDiskBlockPos>::iterator> range = mapBlocksUnknownParent.equal_range(head);
|
std::pair<std::multimap<uint256, CDiskBlockPos>::iterator, std::multimap<uint256, CDiskBlockPos>::iterator> range = mapBlocksUnknownParent.equal_range(head);
|
||||||
while (range.first != range.second) {
|
while (range.first != range.second) {
|
||||||
std::multimap<uint256, CDiskBlockPos>::iterator it = range.first;
|
if (ReadBlockFromDisk(block, range.first->second, chainparams.GetConsensus()))
|
||||||
if (ReadBlockFromDisk(block, it->second, chainparams.GetConsensus()))
|
|
||||||
{
|
{
|
||||||
LogPrintf("%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(),
|
LogPrintf("%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(),
|
||||||
head.ToString());
|
head.ToString());
|
||||||
CValidationState dummy;
|
CValidationState dummy;
|
||||||
if (ProcessNewBlock(dummy, chainparams, NULL, &block, true, &it->second))
|
if (ProcessNewBlock(dummy, chainparams, NULL, &block, true, &(range.first->second)))
|
||||||
{
|
{
|
||||||
nLoaded++;
|
nLoaded++;
|
||||||
queue.push_back(block.GetHash());
|
queue.push_back(block.GetHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
range.first++;
|
range.first = mapBlocksUnknownParent.erase(range.first);
|
||||||
mapBlocksUnknownParent.erase(it);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
|
Loading…
Reference in New Issue