Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Correct comparison of addr count #15345

Merged
merged 1 commit into from Feb 4, 2019

Conversation

@dongcarl
Copy link
Contributor

@dongcarl dongcarl commented Feb 4, 2019

LOCAL_NONE is supposed to be an enum indicating the nScore of a
LocalServiceInfo rather than the count of an addr in mapLocalHost.

LOCAL_NONE is supposed to be an enum indicating the score of a
LocalServiceInfo rather than the count of an addr in mapLocalHost.
@@ -174,8 +174,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer, ServiceFlags nLocalServices)
static int GetnScore(const CService& addr)
{
LOCK(cs_mapLocalHost);
if (mapLocalHost.count(addr) == LOCAL_NONE)
Copy link
Member

@laanwj laanwj Feb 4, 2019

Huh, this is really strange. I guess it's correct because LOCAL_NONE effectively is 0 but it's certainly not right.

@laanwj
Copy link
Member

@laanwj laanwj commented Feb 4, 2019

utACK 107623c

@MarcoFalke
Copy link
Member

@MarcoFalke MarcoFalke commented Feb 4, 2019

ACK 107623c (also checked that this commit doesn't change the binary produced by clang7 on my system, so tagged with "refactoring")

@MarcoFalke MarcoFalke added this to the 0.18.0 milestone Feb 4, 2019
@promag
Copy link
Member

@promag promag commented Feb 4, 2019

utACK 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
Copy link
Contributor

@jonasschnelli jonasschnelli commented Feb 4, 2019

utACK 107623c

@laanwj
Copy link
Member

@laanwj laanwj commented Feb 4, 2019

utACK 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 laanwj merged commit 107623c into bitcoin:master Feb 4, 2019
1 of 2 checks passed
laanwj added a commit that referenced this issue Feb 4, 2019
107623c net: Correct comparison of addr count (Carl Dong)

Pull request description:

  `LOCAL_NONE` is supposed to be an enum indicating the `nScore` of a
  `LocalServiceInfo` rather than the count of an addr in `mapLocalHost`.

Tree-SHA512: a47a0859dd11c991d75b54e96b08c502e3d235f7a6522a2355053f377d05e7853483996919292f458d917a561b23951e6945d6bf0ff5a2f29513c477c640bdd2
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue May 30, 2020
Summary:
107623c26c2113428446effaa24edb986a3e780c net: Correct comparison of addr count (Carl Dong)

Pull request description:

  `LOCAL_NONE` is supposed to be an enum indicating the `nScore` of a
  `LocalServiceInfo` rather than the count of an addr in `mapLocalHost`.

Tree-SHA512: a47a0859dd11c991d75b54e96b08c502e3d235f7a6522a2355053f377d05e7853483996919292f458d917a561b23951e6945d6bf0ff5a2f29513c477c640bdd2

Backport of Core [[bitcoin/bitcoin#15345 | PR15345]]

Test Plan: `ninja check` for sanity

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6301
ftrader added a commit to bitcoin-cash-node/bitcoin-cash-node that referenced this issue Aug 17, 2020
Summary:
107623c26c2113428446effaa24edb986a3e780c net: Correct comparison of addr count (Carl Dong)

Pull request description:

  `LOCAL_NONE` is supposed to be an enum indicating the `nScore` of a
  `LocalServiceInfo` rather than the count of an addr in `mapLocalHost`.

Tree-SHA512: a47a0859dd11c991d75b54e96b08c502e3d235f7a6522a2355053f377d05e7853483996919292f458d917a561b23951e6945d6bf0ff5a2f29513c477c640bdd2

Backport of Core [[bitcoin/bitcoin#15345 | PR15345]]

Test Plan: `ninja check` for sanity

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6301
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this issue Jun 25, 2021
107623c net: Correct comparison of addr count (Carl Dong)

Pull request description:

  `LOCAL_NONE` is supposed to be an enum indicating the `nScore` of a
  `LocalServiceInfo` rather than the count of an addr in `mapLocalHost`.

Tree-SHA512: a47a0859dd11c991d75b54e96b08c502e3d235f7a6522a2355053f377d05e7853483996919292f458d917a561b23951e6945d6bf0ff5a2f29513c477c640bdd2
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this issue Jun 25, 2021
107623c net: Correct comparison of addr count (Carl Dong)

Pull request description:

  `LOCAL_NONE` is supposed to be an enum indicating the `nScore` of a
  `LocalServiceInfo` rather than the count of an addr in `mapLocalHost`.

Tree-SHA512: a47a0859dd11c991d75b54e96b08c502e3d235f7a6522a2355053f377d05e7853483996919292f458d917a561b23951e6945d6bf0ff5a2f29513c477c640bdd2
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this issue Jun 27, 2021
107623c net: Correct comparison of addr count (Carl Dong)

Pull request description:

  `LOCAL_NONE` is supposed to be an enum indicating the `nScore` of a
  `LocalServiceInfo` rather than the count of an addr in `mapLocalHost`.

Tree-SHA512: a47a0859dd11c991d75b54e96b08c502e3d235f7a6522a2355053f377d05e7853483996919292f458d917a561b23951e6945d6bf0ff5a2f29513c477c640bdd2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants