Skip to content

Commit

Permalink
Faster re-requesting of recovered sigs
Browse files Browse the repository at this point in the history
These are quite important and waiting for 2 minutes when the first peer
did not send it is not acceptable.
  • Loading branch information
codablock committed Jan 21, 2019
1 parent c38f889 commit 316b6bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ class CNode
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();
Expand Down
9 changes: 8 additions & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 316b6bf

Please sign in to comment.