Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Commit

Permalink
allow header sync from more than one peer during IBD (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg-Griffith committed Jun 12, 2019
1 parent 6614002 commit 4584d59
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 15 deletions.
1 change: 0 additions & 1 deletion src/chain/chainman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ void CChainManager::UnloadBlockIndex()
pindexBestInvalid = nullptr;
pindexBestHeader = nullptr;
mempool.clear();
nSyncStarted = 0;
mapBlocksUnlinked.clear();
vinfoBlockFile.clear();
nLastBlockFile = 0;
Expand Down
3 changes: 0 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ CBlockIndex *pindexBestInvalid;
*/
std::set<CBlockIndex *, CBlockIndexWorkComparator> setBlockIndexCandidates;

/** Number of nodes with fSyncStarted. */
int nSyncStarted = 0;

/** All pairs A->B, where A (or one of its ancestors) misses transactions, but B has transactions.
* Pruned nodes may have entries where B is missing data.
*/
Expand Down
1 change: 0 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ enum FlushStateMode
};
bool FlushStateToDisk(CValidationState &state, FlushStateMode mode);
extern int nPreferredDownload;
extern int nSyncStarted;
extern int64_t nTimeBestReceived;
extern int nPeersWithValidatedDownloads;

Expand Down
11 changes: 1 addition & 10 deletions src/net/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,6 @@ void FinalizeNode(NodeId nodeid, bool &fUpdateConnectionTime)
fUpdateConnectionTime = false;
CNodeStateAccessor state(nodestateman, nodeid);

if (state->fSyncStarted)
{
nSyncStarted--;
}

if (state->nMisbehavior == 0 && state->fCurrentlyConnected)
{
fUpdateConnectionTime = true;
Expand Down Expand Up @@ -2391,13 +2386,9 @@ bool SendMessages(CNode *pto, CConnman &connman)

if (!nodestate->fSyncStarted && !pto->fClient && !fImporting && !fReindex)
{
// Only actively request headers from a single peer, unless we're close
// to today.
if ((nSyncStarted == 0 && fFetch) ||
pnetMan->getChainActive()->pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60)
if (fFetch || pnetMan->getChainActive()->pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60)
{
nodestate->fSyncStarted = true;
nSyncStarted++;
const CBlockIndex *pindexStart = pnetMan->getChainActive()->pindexBestHeader;
/**
* If possible, start at the block preceding the currently best
Expand Down

0 comments on commit 4584d59

Please sign in to comment.