@ -6527,7 +6527,7 @@ bool SendMessages(CNode* pto, CConnman& connman)
// Ping automatically sent as a latency probe & keepalive.
// Ping automatically sent as a latency probe & keepalive.
pingSend = true ;
pingSend = true ;
}
}
if ( pingSend & & ! pto - > fDisconnect ) {
if ( pingSend ) {
uint64_t nonce = 0 ;
uint64_t nonce = 0 ;
while ( nonce = = 0 ) {
while ( nonce = = 0 ) {
GetRandBytes ( ( unsigned char * ) & nonce , sizeof ( nonce ) ) ;
GetRandBytes ( ( unsigned char * ) & nonce , sizeof ( nonce ) ) ;
@ -6610,7 +6610,7 @@ bool SendMessages(CNode* pto, CConnman& connman)
if ( pindexBestHeader = = NULL )
if ( pindexBestHeader = = NULL )
pindexBestHeader = chainActive . Tip ( ) ;
pindexBestHeader = chainActive . Tip ( ) ;
bool fFetch = state . fPreferredDownload | | ( nPreferredDownload = = 0 & & ! pto - > fClient & & ! pto - > fOneShot ) ; // Download if this is a nice peer, or we have no nice peers and this one might do.
bool fFetch = state . fPreferredDownload | | ( nPreferredDownload = = 0 & & ! pto - > fClient & & ! pto - > fOneShot ) ; // Download if this is a nice peer, or we have no nice peers and this one might do.
if ( ! state . fSyncStarted & & ! pto - > fClient & & ! pto - > fDisconnect & & ! fImporting & & ! fReindex ) {
if ( ! state . fSyncStarted & & ! pto - > fClient & & ! fImporting & & ! fReindex ) {
// Only actively request headers from a single peer, unless we're close to today.
// Only actively request headers from a single peer, unless we're close to today.
if ( ( nSyncStarted = = 0 & & fFetch ) | | pindexBestHeader - > GetBlockTime ( ) > GetAdjustedTime ( ) - 24 * 60 * 60 ) {
if ( ( nSyncStarted = = 0 & & fFetch ) | | pindexBestHeader - > GetBlockTime ( ) > GetAdjustedTime ( ) - 24 * 60 * 60 ) {
state . fSyncStarted = true ;
state . fSyncStarted = true ;
@ -6897,7 +6897,7 @@ bool SendMessages(CNode* pto, CConnman& connman)
// Detect whether we're stalling
// Detect whether we're stalling
nNow = GetTimeMicros ( ) ;
nNow = GetTimeMicros ( ) ;
if ( ! pto - > fDisconnect & & state . nStallingSince & & state . nStallingSince < nNow - 1000000 * BLOCK_STALLING_TIMEOUT ) {
if ( state . nStallingSince & & state . nStallingSince < nNow - 1000000 * BLOCK_STALLING_TIMEOUT ) {
// Stalling only triggers when the block download window cannot move. During normal steady state,
// Stalling only triggers when the block download window cannot move. During normal steady state,
// the download window should be much larger than the to-be-downloaded set of blocks, so disconnection
// the download window should be much larger than the to-be-downloaded set of blocks, so disconnection
// should only happen during initial block download.
// should only happen during initial block download.
@ -6910,7 +6910,7 @@ bool SendMessages(CNode* pto, CConnman& connman)
// We compensate for other peers to prevent killing off peers due to our own downstream link
// We compensate for other peers to prevent killing off peers due to our own downstream link
// being saturated. We only count validated in-flight blocks so peers can't advertise non-existing block hashes
// being saturated. We only count validated in-flight blocks so peers can't advertise non-existing block hashes
// to unreasonably increase our timeout.
// to unreasonably increase our timeout.
if ( ! pto - > fDisconnect & & state . vBlocksInFlight . size ( ) > 0 ) {
if ( state . vBlocksInFlight . size ( ) > 0 ) {
QueuedBlock & queuedBlock = state . vBlocksInFlight . front ( ) ;
QueuedBlock & queuedBlock = state . vBlocksInFlight . front ( ) ;
int nOtherPeersWithValidatedDownloads = nPeersWithValidatedDownloads - ( state . nBlocksInFlightValidHeaders > 0 ) ;
int nOtherPeersWithValidatedDownloads = nPeersWithValidatedDownloads - ( state . nBlocksInFlightValidHeaders > 0 ) ;
if ( nNow > state . nDownloadingSince + consensusParams . nPowTargetSpacing * ( BLOCK_DOWNLOAD_TIMEOUT_BASE + BLOCK_DOWNLOAD_TIMEOUT_PER_PEER * nOtherPeersWithValidatedDownloads ) ) {
if ( nNow > state . nDownloadingSince + consensusParams . nPowTargetSpacing * ( BLOCK_DOWNLOAD_TIMEOUT_BASE + BLOCK_DOWNLOAD_TIMEOUT_PER_PEER * nOtherPeersWithValidatedDownloads ) ) {
@ -6924,7 +6924,7 @@ bool SendMessages(CNode* pto, CConnman& connman)
// Message: getdata (blocks)
// Message: getdata (blocks)
//
//
vector < CInv > vGetData ;
vector < CInv > vGetData ;
if ( ! pto - > fDisconnect & & ! pto - > f Client & & ( fFetch | | ! IsInitialBlockDownload ( ) ) & & state . nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER ) {
if ( ! pto - > fClient & & ( fFetch | | ! IsInitialBlockDownload ( ) ) & & state . nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER ) {
vector < CBlockIndex * > vToDownload ;
vector < CBlockIndex * > vToDownload ;
NodeId staller = - 1 ;
NodeId staller = - 1 ;
FindNextBlocksToDownload ( pto - > GetId ( ) , MAX_BLOCKS_IN_TRANSIT_PER_PEER - state . nBlocksInFlight , vToDownload , staller , consensusParams ) ;
FindNextBlocksToDownload ( pto - > GetId ( ) , MAX_BLOCKS_IN_TRANSIT_PER_PEER - state . nBlocksInFlight , vToDownload , staller , consensusParams ) ;
@ -6946,7 +6946,7 @@ bool SendMessages(CNode* pto, CConnman& connman)
//
//
// Message: getdata (non-blocks)
// Message: getdata (non-blocks)
//
//
while ( ! pto - > fDisconnect & & ! pto - > mapAskFor . empty ( ) & & ( * pto - > mapAskFor . begin ( ) ) . first < = nNow )
while ( ! pto - > mapAskFor . empty ( ) & & ( * pto - > mapAskFor . begin ( ) ) . first < = nNow )
{
{
const CInv & inv = ( * pto - > mapAskFor . begin ( ) ) . second ;
const CInv & inv = ( * pto - > mapAskFor . begin ( ) ) . second ;
if ( ! AlreadyHave ( inv ) )
if ( ! AlreadyHave ( inv ) )
@ -6972,7 +6972,7 @@ bool SendMessages(CNode* pto, CConnman& connman)
// Message: feefilter
// Message: feefilter
//
//
// We don't want white listed peers to filter txs to us if we have -whitelistforcerelay
// We don't want white listed peers to filter txs to us if we have -whitelistforcerelay
if ( ! pto - > fDisconnect & & pto - > nVersion > = FEEFILTER_VERSION & & GetBoolArg ( " -feefilter " , DEFAULT_FEEFILTER ) & &
if ( pto - > nVersion > = FEEFILTER_VERSION & & GetBoolArg ( " -feefilter " , DEFAULT_FEEFILTER ) & &
! ( pto - > fWhitelisted & & GetBoolArg ( " -whitelistforcerelay " , DEFAULT_WHITELISTFORCERELAY ) ) ) {
! ( pto - > fWhitelisted & & GetBoolArg ( " -whitelistforcerelay " , DEFAULT_WHITELISTFORCERELAY ) ) ) {
CAmount currentFilter = mempool . GetMinFee ( GetArg ( " -maxmempool " , DEFAULT_MAX_MEMPOOL_SIZE ) * 1000000 ) . GetFeePerK ( ) ;
CAmount currentFilter = mempool . GetMinFee ( GetArg ( " -maxmempool " , DEFAULT_MAX_MEMPOOL_SIZE ) * 1000000 ) . GetFeePerK ( ) ;
int64_t timeNow = GetTimeMicros ( ) ;
int64_t timeNow = GetTimeMicros ( ) ;