Browse Source

Do not accept orphan blocks in -loadblock mode

miguelfreitas
Pieter Wuille 13 years ago
parent
commit
5c88e3c108
  1. 7
      src/main.cpp

7
src/main.cpp

@ -1920,17 +1920,20 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)
} }
// If don't already have its previous block, shunt it off to holding area until we get it // If we don't already have its previous block, shunt it off to holding area until we get it
if (!mapBlockIndex.count(pblock->hashPrevBlock)) if (!mapBlockIndex.count(pblock->hashPrevBlock))
{ {
printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().substr(0,20).c_str()); printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().substr(0,20).c_str());
// Accept orphans as long as there is a node to request its parents from
if (pfrom) {
CBlock* pblock2 = new CBlock(*pblock); CBlock* pblock2 = new CBlock(*pblock);
mapOrphanBlocks.insert(make_pair(hash, pblock2)); mapOrphanBlocks.insert(make_pair(hash, pblock2));
mapOrphanBlocksByPrev.insert(make_pair(pblock2->hashPrevBlock, pblock2)); mapOrphanBlocksByPrev.insert(make_pair(pblock2->hashPrevBlock, pblock2));
// Ask this guy to fill in what we're missing // Ask this guy to fill in what we're missing
if (pfrom)
pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(pblock2)); pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(pblock2));
}
return true; return true;
} }

Loading…
Cancel
Save