mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 05:49:11 +01:00
Sync from many nodes
This commit is contained in:
parent
4fcaa57368
commit
f780f3ae80
12
src/main.cpp
12
src/main.cpp
@ -47,6 +47,7 @@ uint256 hashBestChain = 0;
|
|||||||
CBlockIndex* pindexBest = NULL;
|
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
|
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;
|
int64 nTimeBestReceived = 0;
|
||||||
|
int nAskedForBlocks = 0;
|
||||||
int nScriptCheckThreads = 0;
|
int nScriptCheckThreads = 0;
|
||||||
bool fImporting = false;
|
bool fImporting = false;
|
||||||
bool fReindex = false;
|
bool fReindex = false;
|
||||||
@ -4876,9 +4877,14 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start block sync
|
// Start block sync
|
||||||
if (pto->fStartSync && !fImporting && !fReindex) {
|
if (!pto->fAskedForBlocks && !fImporting && !fReindex && !pto->fClient && !pto->fOneShot &&
|
||||||
pto->fStartSync = false;
|
!pto->fDisconnect && pto->fSuccessfullyConnected &&
|
||||||
pto->PushGetBlocks(pindexBest, uint256(0));
|
(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
|
// Resend wallet transactions that haven't gotten in a block yet
|
||||||
|
@ -121,6 +121,7 @@ extern bool fImporting;
|
|||||||
extern bool fReindex;
|
extern bool fReindex;
|
||||||
extern bool fBenchmark;
|
extern bool fBenchmark;
|
||||||
extern int nScriptCheckThreads;
|
extern int nScriptCheckThreads;
|
||||||
|
extern int nAskedForBlocks; // Nodes sent a getblocks 0
|
||||||
extern bool fTxIndex;
|
extern bool fTxIndex;
|
||||||
extern unsigned int nCoinCacheSize;
|
extern unsigned int nCoinCacheSize;
|
||||||
extern CDarkSendPool darkSendPool;
|
extern CDarkSendPool darkSendPool;
|
||||||
|
@ -194,6 +194,7 @@ public:
|
|||||||
bool fNetworkNode;
|
bool fNetworkNode;
|
||||||
bool fSuccessfullyConnected;
|
bool fSuccessfullyConnected;
|
||||||
bool fDisconnect;
|
bool fDisconnect;
|
||||||
|
bool fAskedForBlocks; // true when getblocks 0 sent
|
||||||
// We use fRelayTxes for two purposes -
|
// We use fRelayTxes for two purposes -
|
||||||
// a) it allows us to not relay tx invs before receiving the peer's version message
|
// 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
|
// b) the peer may tell us in their version message that we should not relay tx invs
|
||||||
@ -255,6 +256,7 @@ public:
|
|||||||
fSuccessfullyConnected = false;
|
fSuccessfullyConnected = false;
|
||||||
fDisconnect = false;
|
fDisconnect = false;
|
||||||
hashCheckpointKnown = 0;
|
hashCheckpointKnown = 0;
|
||||||
|
fAskedForBlocks = false;
|
||||||
nRefCount = 0;
|
nRefCount = 0;
|
||||||
nSendSize = 0;
|
nSendSize = 0;
|
||||||
nSendOffset = 0;
|
nSendOffset = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user