mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
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.
This commit is contained in:
18
src/main.cpp
18
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.
|
||||
|
||||
Reference in New Issue
Block a user