diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2013-04-05 00:43:04 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2013-04-07 19:19:13 +0200 |
commit | 6ed71b5e4faa2ea6d739eefa9c3dcc15db80439c (patch) | |
tree | 4ae32dd9b5153c1fd1cad299518ede52a9f1bf69 /src/main.cpp | |
parent | 31dead887d7658660e89d14c22d494baeca874e9 (diff) |
Make sure we always have a node to do IBD from
This introduces the concept of the 'sync node', which is the one we
asked for missing blocks. In case the sync node goes away, a new one
will be selected.
For now, the heuristic is very simple, but it can easily be extended
later to add better policies.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp index 7f408c4d1b..06957ba526 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3235,18 +3235,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } } - // Ask the first connected node for block updates - static int nAskedForBlocks = 0; - if (!pfrom->fClient && !pfrom->fOneShot && !fImporting && !fReindex && - (pfrom->nStartingHeight > (nBestHeight - 144)) && - (pfrom->nVersion < NOBLKS_VERSION_START || - pfrom->nVersion >= NOBLKS_VERSION_END) && - (nAskedForBlocks < 1 || vNodes.size() <= 1)) - { - nAskedForBlocks++; - pfrom->PushGetBlocks(pindexBest, uint256(0)); - } - // Relay alerts { LOCK(cs_mapAlerts); @@ -3855,6 +3843,12 @@ bool SendMessages(CNode* pto, bool fSendTrickle) pto->PushMessage("ping"); } + // Start block sync + if (pto->fStartSync && !fImporting && !fReindex) { + pto->fStartSync = false; + pto->PushGetBlocks(pindexBest, uint256(0)); + } + // Resend wallet transactions that haven't gotten in a block yet // Except during reindex, importing and IBD, when old wallet // transactions become unconfirmed and spams other nodes. |