diff options
author | fanquake <fanquake@gmail.com> | 2022-05-28 09:40:50 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-05-28 09:41:00 +0100 |
commit | ba48fcf4a40c5b9888459511fb4233a1b89184cc (patch) | |
tree | f1fba290e7f8e144ca76434df9998f5a05c94cd7 | |
parent | 345457b542b6a980ccfbc868af0970a6f91d1b82 (diff) | |
parent | fa27ee88edbf696b7eef2efbfcf1446ec522fd85 (diff) | |
download | bitcoin-ba48fcf4a40c5b9888459511fb4233a1b89184cc.tar.xz |
Merge bitcoin/bitcoin#25224: Get time less often in AddrManImpl::ResolveCollisions_()
fa27ee88edbf696b7eef2efbfcf1446ec522fd85 Get time less often in AddrManImpl::ResolveCollisions_() (MarcoFalke)
Pull request description:
First commit split out from https://github.com/bitcoin/bitcoin/pull/24697
ACKs for top commit:
sipa:
utACK fa27ee88edbf696b7eef2efbfcf1446ec522fd85
fanquake:
ACK fa27ee88edbf696b7eef2efbfcf1446ec522fd85
Tree-SHA512: 40c8594d2a5ce02a392ac5f9f120c24c6bcd495b0bcc901fd6064dde9f6123cd109504cee7b612a9555b70cfd7759cbd6cd496d007bb374c27610d01b464191c
-rw-r--r-- | src/addrman.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp index f74729d47b..ed823eeb05 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -866,25 +866,27 @@ void AddrManImpl::ResolveCollisions_() int id_old = vvTried[tried_bucket][tried_bucket_pos]; AddrInfo& info_old = mapInfo[id_old]; + const auto current_time{GetAdjustedTime()}; + // Has successfully connected in last X hours - if (GetAdjustedTime() - info_old.nLastSuccess < ADDRMAN_REPLACEMENT_HOURS*(60*60)) { + if (current_time - info_old.nLastSuccess < ADDRMAN_REPLACEMENT_HOURS*(60*60)) { erase_collision = true; - } else if (GetAdjustedTime() - info_old.nLastTry < ADDRMAN_REPLACEMENT_HOURS*(60*60)) { // attempted to connect and failed in last X hours + } else if (current_time - info_old.nLastTry < ADDRMAN_REPLACEMENT_HOURS*(60*60)) { // attempted to connect and failed in last X hours // Give address at least 60 seconds to successfully connect - if (GetAdjustedTime() - info_old.nLastTry > 60) { + if (current_time - info_old.nLastTry > 60) { LogPrint(BCLog::ADDRMAN, "Replacing %s with %s in tried table\n", info_old.ToString(), info_new.ToString()); // Replaces an existing address already in the tried table with the new address - Good_(info_new, false, GetAdjustedTime()); + Good_(info_new, false, current_time); erase_collision = true; } - } else if (GetAdjustedTime() - info_new.nLastSuccess > ADDRMAN_TEST_WINDOW) { + } else if (current_time - info_new.nLastSuccess > ADDRMAN_TEST_WINDOW) { // If the collision hasn't resolved in some reasonable amount of time, // just evict the old entry -- we must not be able to // connect to it for some reason. LogPrint(BCLog::ADDRMAN, "Unable to test; replacing %s with %s in tried table anyway\n", info_old.ToString(), info_new.ToString()); - Good_(info_new, false, GetAdjustedTime()); + Good_(info_new, false, current_time); erase_collision = true; } } else { // Collision is not actually a collision anymore |