This commit is contained in:
jl777
2019-07-05 07:07:01 -11:00
parent 4fd98d4af3
commit ad842844d5

View File

@@ -8241,36 +8241,35 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
state.fShouldBan = false; state.fShouldBan = false;
} }
komodo_nSPV(pto); komodo_nSPV(pto);
bool fFetch = false; if ( KOMODO_NSPV != 0 )
if ( KOMODO_NSPV == 0 ) return(true);
{ BOOST_FOREACH(const CBlockReject& reject, state.rejects)
BOOST_FOREACH(const CBlockReject& reject, state.rejects) pto->PushMessage("reject", (string)"block", reject.chRejectCode, reject.strRejectReason, reject.hashBlock);
pto->PushMessage("reject", (string)"block", reject.chRejectCode, reject.strRejectReason, reject.hashBlock); state.rejects.clear();
state.rejects.clear();
// Start block sync
// Start block sync 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.
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 && !fImporting && !fReindex && pindexBestHeader!=0) {
if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex && pindexBestHeader!=0) { // 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; nSyncStarted++;
nSyncStarted++; CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader;
CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; LogPrint("net", "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->GetHeight(), pto->id, pto->nStartingHeight);
LogPrint("net", "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->GetHeight(), pto->id, pto->nStartingHeight); pto->PushMessage("getheaders", chainActive.GetLocator(pindexStart), uint256());
pto->PushMessage("getheaders", chainActive.GetLocator(pindexStart), uint256());
}
}
// 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.
if (!fReindex && !fImporting && !IsInitialBlockDownload())
{
GetMainSignals().Broadcast(nTimeBestReceived);
} }
} }
// 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.
if (!fReindex && !fImporting && !IsInitialBlockDownload())
{
GetMainSignals().Broadcast(nTimeBestReceived);
}
// //
// Message: inventory // Message: inventory
// //
@@ -8317,12 +8316,8 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
pto->vInventoryToSend = vInvWait; pto->vInventoryToSend = vInvWait;
} }
if (!vInv.empty()) if (!vInv.empty())
{
fprintf(stderr,"send inv message\n");
pto->PushMessage("inv", vInv); pto->PushMessage("inv", vInv);
}
if ( KOMODO_NSPV != 0 )
return(true);
// Detect whether we're stalling // Detect whether we're stalling
int64_t nNow = GetTimeMicros(); int64_t nNow = GetTimeMicros();
if (!pto->fDisconnect && state.nStallingSince && state.nStallingSince < nNow - 1000000 * BLOCK_STALLING_TIMEOUT) { if (!pto->fDisconnect && state.nStallingSince && state.nStallingSince < nNow - 1000000 * BLOCK_STALLING_TIMEOUT) {