p2p, rpc, test: address rate-limiting follow-ups

(cherry picked from commit bitcoin/bitcoin@d930c7f5b0)
This commit is contained in:
Jon Atack 2021-07-31 21:56:59 +02:00 committed by Kris Nuttycombe
parent 1dddc1337c
commit 9555b5e8a4
1 changed files with 3 additions and 2 deletions

View File

@ -6680,11 +6680,12 @@ bool static ProcessMessage(const CChainParams& chainparams, CNode* pfrom, string
boost::this_thread::interruption_point();
// Apply rate limiting if the address is not whitelisted
if (!pfrom->IsWhitelistedRange(addr)) {
if (pfrom->m_addr_token_bucket < 1.0) {
if (pfrom->m_addr_token_bucket < 1.0) {
if (!pfrom->IsWhitelistedRange(addr)) {
++num_rate_limit;
continue;
}
} else {
pfrom->m_addr_token_bucket -= 1.0;
}