refactor: Remove redundant addrman time checks #25303
pull maflcko wants to merge 2 commits into bitcoin:master from maflcko:2206-less-addrman-time-checks-🚶 changing 1 files +8 −4-
maflcko commented at 7:16 am on June 8, 2022: memberSplit out from #24697 because it makes sense on its own.
-
Remove redundant nTime checks
nTime is always initialized on deserialization or default-initialized with TIME_INIT, so special casing 0 does not make sense.
-
maflcko force-pushed on Jun 8, 2022
-
DrahtBot added the label P2P on Jun 8, 2022
-
DrahtBot added the label Refactoring on Jun 8, 2022
-
fanquake requested review from mzumsande on Jun 8, 2022
-
fanquake requested review from dergoegge on Jun 8, 2022
-
fanquake requested review from naumenkogs on Jun 8, 2022
-
in src/addrman.cpp:69 in fa8bdb7505 outdated
65@@ -66,14 +66,16 @@ int AddrInfo::GetBucketPosition(const uint256& nKey, bool fNew, int nBucket) con 66 67 bool AddrInfo::IsTerrible(int64_t nNow) const 68 { 69- if (nLastTry && nLastTry >= nNow - 60) // never remove things tried in the last minute 70+ if (nNow - nLastTry <= 60) { // never remove things tried in the last minute
dergoegge commented at 11:23 am on June 8, 2022:mega nit: fa8bdb7505e12afee4bc21e08ca17c36aaf7edcf calls itm_last_try
but the member is still callednLastTry
.
maflcko commented at 11:36 am on June 8, 2022:Thx, fixed.
Riahiamirreza commented at 11:58 am on June 8, 2022:What is the purpose of checking thenLastTry
in the previous version? Can it be null or something with false value? IF yes, why you don’t check it in the current version? (sorry if it’s a trivial question, it is my first time reviewing code)
maflcko commented at 12:15 pm on June 9, 2022:@RiahiamirrezanLastTry
is a plain integral value, so it can’t be null or false. At most it can be0
, but it seems odd to treat0
(seconds) differently, from say1
(seconds).nNow - 0 <= 60
ornNow - 1 <= 60
should be false either way.dergoegge commented at 11:33 am on June 8, 2022: memberCode review ACK fa8bdb7505e12afee4bc21e08ca17c36aaf7edcf
CI failure seems unrelated.
Remove redundant nLastTry check
All other places calculate "now - nLastTry", which is safe and correct to do when nLastTry is 0. So do the same here.
maflcko force-pushed on Jun 8, 2022DrahtBot commented at 3:10 pm on June 8, 2022: contributorThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #24697 (refactor address relay time by MarcoFalke)
- #23829 (refactor: use braced init for integer literals instead of c style casts by PastaPastaPasta)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
dergoegge commented at 3:35 pm on June 8, 2022: memberre-ACK 8888bd43c100f9f0ca1122fcc896fb7b999d61c6naumenkogs commented at 11:05 am on June 9, 2022: memberutACK 8888bd43c100f9f0ca1122fcc896fb7b999d61c6fanquake merged this on Jun 9, 2022fanquake closed this on Jun 9, 2022
maflcko deleted the branch on Jun 9, 2022mzumsande commented at 1:58 pm on June 9, 2022: contributorsidhujag referenced this in commit 56db887052 on Jun 13, 2022Fabcien referenced this in commit 4030b963f1 on Jan 5, 2024PastaPastaPasta referenced this in commit 24bce63db1 on Jan 17, 2024PastaPastaPasta referenced this in commit 11b2595b8f on Jan 19, 2024PastaPastaPasta referenced this in commit b57482b510 on Jan 19, 2024bitcoin locked this on Apr 19, 2024
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-18 03:12 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-18 03:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me