aboutsummaryrefslogtreecommitdiff
path: root/main.h
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-11-24 21:04:50 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-11-24 21:04:50 +0000
commit70918a6645a324c635925fb68a0d41f7c7b40403 (patch)
treeb394260db71c75751026b76be87c3703eddf437c /main.h
parente4db374421cac4c6fd0d9f9b337d9073e5207c21 (diff)
minor fix to batched initial download in case requester has more than 500 block non-main branch
Diffstat (limited to 'main.h')
-rw-r--r--main.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/main.h b/main.h
index 79f14c6861..822045a573 100644
--- a/main.h
+++ b/main.h
@@ -1298,6 +1298,27 @@ public:
vHave.push_back(hashGenesisBlock);
}
+ int GetDistanceBack()
+ {
+ // Retrace how far back it was in the sender's branch
+ int nDistance = 0;
+ int nStep = 1;
+ foreach(const uint256& hash, vHave)
+ {
+ map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
+ if (mi != mapBlockIndex.end())
+ {
+ CBlockIndex* pindex = (*mi).second;
+ if (pindex->IsInMainChain())
+ return nDistance;
+ }
+ nDistance += nStep;
+ if (nDistance > 10)
+ nStep *= 2;
+ }
+ return nDistance;
+ }
+
CBlockIndex* GetBlockIndex()
{
// Find the first block the caller has in the main chain