From 8ab425f8b27e2801023e33d6421fd6f63764a928 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Sep 2017 18:34:43 +0200 Subject: [PATCH] Test --- src/main.cpp | 8 ++++++-- src/net.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6d831173b..1e9be1a06 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5158,8 +5158,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // Headers message had its maximum size; the peer may have more headers. // TODO: optimize: if pindexLast is an ancestor of chainActive.Tip or pindexBestHeader, continue // from there instead. - LogPrint("net", "more getheaders (%d) to end to peer=%d (startheight:%d)\n", pindexLast->nHeight, pfrom->id, pfrom->nStartingHeight); - pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexLast), uint256()); + if ( pfrom->sendhdrsreq >= chainActive.Height()-MAX_HEADERS_RESULTS || pindexLast->nHeight != pfrom->sendhdrsreq ) + { + pfrom->sendhdrsreq = (int32_t)pindexLast->nHeight; + LogPrint("net", "more getheaders (%d) to end to peer=%d (startheight:%d)\n", pindexLast->nHeight, pfrom->id, pfrom->nStartingHeight); + pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexLast), uint256()); + } } CheckBlockIndex(); diff --git a/src/net.h b/src/net.h index 5674bd40d..bb79acf17 100644 --- a/src/net.h +++ b/src/net.h @@ -264,7 +264,7 @@ public: std::string addrName; CService addrLocal; int nVersion; - int lasthdrsreq; + int lasthdrsreq,sendhdrsreq; // strSubVer is whatever byte array we read from the wire. However, this field is intended // to be printed out, displayed to humans in various forms and so on. So we sanitize it and // store the sanitized version in cleanSubVer. The original should be used when dealing with