Mercurial > hg > bitcoin
changeset 2400:70a2b1660d0a draft
Merge pull request #1214 from TheBlueMatt/debian
Update changelog to match reality.
author | Jeff Garzik <jgarzik@exmulti.com> |
---|---|
date | Sun, 06 May 2012 18:35:42 -0700 |
parents | 24c27008018b (diff) dd5cc8b3cbc1 (current diff) |
children | 845b17b57b0c |
files | |
diffstat | 1 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.cpp +++ b/src/main.cpp @@ -2391,6 +2391,12 @@ return error("message inv size() = %d", vInv.size()); } + // find last block in inv vector + unsigned int nLastBlock = (unsigned int)(-1); + for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) { + if (vInv[vInv.size() - 1 - nInv].type == MSG_BLOCK) + nLastBlock = vInv.size() - 1 - nInv; + } CTxDB txdb("r"); for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) { @@ -2407,9 +2413,15 @@ // 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)) + if (fAlreadyHave && nInv == nLastBlock) { + // bypass mapAskFor, and send request directly; it must go through. + std::vector<CInv> vGetData(1,inv); + pfrom->PushMessage("getdata", vGetData); + } + + if (!fAlreadyHave) pfrom->AskFor(inv); - if (inv.type == MSG_BLOCK && mapOrphanBlocks.count(inv.hash)) + else if (inv.type == MSG_BLOCK && mapOrphanBlocks.count(inv.hash)) pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(mapOrphanBlocks[inv.hash])); // Track requests for our stuff