mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
Merge pull request #948 from sipa/unstuck
Prevent stuck block download in large reorganisations
This commit is contained in:
commit
b2fe3a5ca6
11
src/main.cpp
11
src/main.cpp
@ -2359,8 +2359,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CTxDB txdb("r");
|
CTxDB txdb("r");
|
||||||
BOOST_FOREACH(const CInv& inv, vInv)
|
for (int nInv = 0; nInv < vInv.size(); nInv++)
|
||||||
{
|
{
|
||||||
|
const CInv &inv = vInv[nInv];
|
||||||
|
|
||||||
if (fShutdown)
|
if (fShutdown)
|
||||||
return true;
|
return true;
|
||||||
pfrom->AddInventoryKnown(inv);
|
pfrom->AddInventoryKnown(inv);
|
||||||
@ -2369,9 +2371,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
if (fDebug)
|
if (fDebug)
|
||||||
printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new");
|
printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new");
|
||||||
|
|
||||||
if (!fAlreadyHave)
|
// Always request the last block in an inv bundle (even if we already have it), as it is the
|
||||||
|
// trigger for the other side to send further invs. If we are stuck on a (very long) side chain,
|
||||||
|
// this is necessary to connect earlier received orphan blocks to the chain again.
|
||||||
|
if (!fAlreadyHave || (inv.type == MSG_BLOCK && nInv==vInv.size()-1))
|
||||||
pfrom->AskFor(inv);
|
pfrom->AskFor(inv);
|
||||||
else if (inv.type == MSG_BLOCK && mapOrphanBlocks.count(inv.hash))
|
if (inv.type == MSG_BLOCK && mapOrphanBlocks.count(inv.hash))
|
||||||
pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(mapOrphanBlocks[inv.hash]));
|
pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(mapOrphanBlocks[inv.hash]));
|
||||||
|
|
||||||
// Track requests for our stuff
|
// Track requests for our stuff
|
||||||
|
Loading…
Reference in New Issue
Block a user