Skip to content

Commit

Permalink
Adjust the tx fetch timeout based on calculations by Tom Harding. Thi…
Browse files Browse the repository at this point in the history
…s improves robustness to DoS attacks based on tx withholding.
  • Loading branch information
mikehearn committed Aug 6, 2015
1 parent 0df4843 commit bba09af
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2027,8 +2027,10 @@ void CNode::AskFor(const CInv& inv)
nNow = std::max(nNow, nLastTime);
nLastTime = nNow;

// Each retry is 2 minutes after the last
nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow);
// Each retry is 20 seconds after the last. Calculations based on observed relay
// times as of July 2015 show that we will receive a transaction within 20 seconds
// 99% of the time.
nRequestTime = std::max(nRequestTime + (20 * 1000000), nNow);
if (it != mapAlreadyAskedFor.end())
mapAlreadyAskedFor.update(it, nRequestTime);
else
Expand Down

0 comments on commit bba09af

Please sign in to comment.