Sync from many nodes

This commit is contained in:
R E Broadley 2014-06-22 08:36:43 +07:00 committed by Evan Duffield
parent 4fcaa57368
commit f780f3ae80
3 changed files with 12 additions and 3 deletions

View File

@ -47,6 +47,7 @@ uint256 hashBestChain = 0;
CBlockIndex* pindexBest = NULL;
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid; // may contain all CBlockIndex*'s that have validness >=BLOCK_VALID_TRANSACTIONS, and must contain those who aren't failed
int64 nTimeBestReceived = 0;
int nAskedForBlocks = 0;
int nScriptCheckThreads = 0;
bool fImporting = false;
bool fReindex = false;
@ -4876,9 +4877,14 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
}
// Start block sync
if (pto->fStartSync && !fImporting && !fReindex) {
pto->fStartSync = false;
pto->PushGetBlocks(pindexBest, uint256(0));
if (!pto->fAskedForBlocks && !fImporting && !fReindex && !pto->fClient && !pto->fOneShot &&
!pto->fDisconnect && pto->fSuccessfullyConnected &&
(pto->nStartingHeight > (nBestHeight - 144)) &&
(pto->nVersion < NOBLKS_VERSION_START || pto->nVersion >= NOBLKS_VERSION_END)) {
nAskedForBlocks++;
pto->fAskedForBlocks = true;
if (pto->PushGetBlocks(pindexBest, uint256(0)))
printf("send initial getblocks peer=%d\n", pto->id);
}
// Resend wallet transactions that haven't gotten in a block yet

View File

@ -121,6 +121,7 @@ extern bool fImporting;
extern bool fReindex;
extern bool fBenchmark;
extern int nScriptCheckThreads;
extern int nAskedForBlocks; // Nodes sent a getblocks 0
extern bool fTxIndex;
extern unsigned int nCoinCacheSize;
extern CDarkSendPool darkSendPool;

View File

@ -194,6 +194,7 @@ public:
bool fNetworkNode;
bool fSuccessfullyConnected;
bool fDisconnect;
bool fAskedForBlocks; // true when getblocks 0 sent
// We use fRelayTxes for two purposes -
// a) it allows us to not relay tx invs before receiving the peer's version message
// b) the peer may tell us in their version message that we should not relay tx invs
@ -255,6 +256,7 @@ public:
fSuccessfullyConnected = false;
fDisconnect = false;
hashCheckpointKnown = 0;
fAskedForBlocks = false;
nRefCount = 0;
nSendSize = 0;
nSendOffset = 0;