LOCAL_NONE is supposed to be an enum indicating the nScore of a
LocalServiceInfo rather than the count of an addr in mapLocalHost.
net: Correct comparison of addr count #15345
pull dongcarl wants to merge 1 commits into bitcoin:master from dongcarl:2019-02-getnscore-fix changing 1 files +1 −2-
dongcarl commented at 6:15 PM on February 4, 2019: member
-
107623c26c
net: Correct comparison of addr count
LOCAL_NONE is supposed to be an enum indicating the score of a LocalServiceInfo rather than the count of an addr in mapLocalHost.
-
in src/net.cpp:177 in 107623c26c
173 | @@ -174,8 +174,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer, ServiceFlags nLocalServices) 174 | static int GetnScore(const CService& addr) 175 | { 176 | LOCK(cs_mapLocalHost); 177 | - if (mapLocalHost.count(addr) == LOCAL_NONE)
laanwj commented at 6:19 PM on February 4, 2019:Huh, this is really strange. I guess it's correct because
LOCAL_NONEeffectively is0but it's certainly not right.laanwj commented at 6:21 PM on February 4, 2019: memberutACK 107623c26c2113428446effaa24edb986a3e780c
laanwj added the label P2P on Feb 4, 2019MarcoFalke added the label Refactoring on Feb 4, 2019MarcoFalke commented at 6:31 PM on February 4, 2019: memberACK 107623c26c (also checked that this commit doesn't change the binary produced by clang7 on my system, so tagged with "refactoring")
MarcoFalke added this to the milestone 0.18.0 on Feb 4, 2019promag commented at 6:58 PM on February 4, 2019: memberutACK 107623c, although it could improve a bit by avoiding 2nd lookup.
std::map<CNetAddr, LocalServiceInfo>::const_iterator it = mapLocalHost.find(addr); return it == mapLocalHost.end() ? 0 : it->second.nScore;jonasschnelli commented at 7:01 PM on February 4, 2019: contributorutACK 107623c26c2113428446effaa24edb986a3e780c
laanwj commented at 7:04 PM on February 4, 2019: memberutACK 107623c, although it could improve a bit by avoiding 2nd lookup.
I thought about commenting that, but I don't think that's really much of an improvement in readability (and this isn't exactly a critical path for perfomance).
laanwj merged this on Feb 4, 2019laanwj closed this on Feb 4, 2019laanwj referenced this in commit bfbe42585e on Feb 4, 2019deadalnix referenced this in commit 7df5863a23 on May 30, 2020ftrader referenced this in commit a5226ac3c4 on Aug 17, 2020PastaPastaPasta referenced this in commit 00afeff55d on Jun 25, 2021PastaPastaPasta referenced this in commit ae6ce01be6 on Jun 25, 2021PastaPastaPasta referenced this in commit 2796f46f3c on Jun 27, 2021MarcoFalke locked this on Dec 16, 2021
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: 2026-04-22 06:15 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: 2026-04-22 06:15 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