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.
This commit is contained in:
Alexander Block 2018-10-26 16:01:38 +02:00
parent c38f889e77
commit 316b6bf0de
3 changed files with 11 additions and 4 deletions

View File

@ -2990,7 +2990,7 @@ CNode::~CNode()
delete pfilter; 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) { if (mapAskFor.size() > MAPASKFOR_MAX_SZ || setAskFor.size() > SETASKFOR_MAX_SZ) {
int64_t nNow = GetTime(); int64_t nNow = GetTime();
@ -3028,7 +3028,7 @@ void CNode::AskFor(const CInv& inv)
nLastTime = nNow; nLastTime = nNow;
// Each retry is 2 minutes after the last // 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()) if (it != mapAlreadyAskedFor.end())
mapAlreadyAskedFor.update(it, nRequestTime); mapAlreadyAskedFor.update(it, nRequestTime);
else else

View File

@ -948,7 +948,7 @@ public:
vBlockHashesToAnnounce.push_back(hash); 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 RemoveAskFor(const uint256& hash);
void CloseSocketDisconnect(); void CloseSocketDisconnect();

View File

@ -1781,7 +1781,14 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
} else if (!fAlreadyHave) { } else if (!fAlreadyHave) {
bool allowWhileInIBD = allowWhileInIBDObjs.count(inv.type); bool allowWhileInIBD = allowWhileInIBDObjs.count(inv.type);
if (allowWhileInIBD || (!fImporting && !fReindex && !IsInitialBlockDownload())) { 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);
} }
} }
} }