From 316b6bf0debd36d046106340c0a6467d3c104409 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Fri, 26 Oct 2018 16:01:38 +0200 Subject: [PATCH] Faster re-requesting of recovered sigs These are quite important and waiting for 2 minutes when the first peer did not send it is not acceptable. --- src/net.cpp | 4 ++-- src/net.h | 2 +- src/net_processing.cpp | 9 ++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 6062bb6d3..1349a2450 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2990,7 +2990,7 @@ CNode::~CNode() delete pfilter; } -void CNode::AskFor(const CInv& inv) +void CNode::AskFor(const CInv& inv, int64_t doubleRequestDelay) { if (mapAskFor.size() > MAPASKFOR_MAX_SZ || setAskFor.size() > SETASKFOR_MAX_SZ) { int64_t nNow = GetTime(); @@ -3028,7 +3028,7 @@ void CNode::AskFor(const CInv& inv) nLastTime = nNow; // Each retry is 2 minutes after the last - nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow); + nRequestTime = std::max(nRequestTime + doubleRequestDelay, nNow); if (it != mapAlreadyAskedFor.end()) mapAlreadyAskedFor.update(it, nRequestTime); else diff --git a/src/net.h b/src/net.h index 177a0cd10..d6cd95f52 100644 --- a/src/net.h +++ b/src/net.h @@ -948,7 +948,7 @@ public: vBlockHashesToAnnounce.push_back(hash); } - void AskFor(const CInv& inv); + void AskFor(const CInv& inv, int64_t doubleRequestDelay = 2 * 60 * 1000000); void RemoveAskFor(const uint256& hash); void CloseSocketDisconnect(); diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 8eb1c6acd..f6480d651 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1781,7 +1781,14 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr } else if (!fAlreadyHave) { bool allowWhileInIBD = allowWhileInIBDObjs.count(inv.type); if (allowWhileInIBD || (!fImporting && !fReindex && !IsInitialBlockDownload())) { - pfrom->AskFor(inv); + int64_t doubleRequestDelay = 2 * 60 * 1000000; + // some messages need to be re-requested faster when the first announcing peer did not answer to GETDATA + switch (inv.type) { + case MSG_QUORUM_RECOVERED_SIG: + doubleRequestDelay = 5 * 1000000; + break; + } + pfrom->AskFor(inv, doubleRequestDelay); } } }