net: Simplify `AddressPosition` comparitor
What changed, and why it matters
This is a small code cleanup in Bitcoin Core's address manager. It changes how one internal data structure compares equality so it works correctly when used with const references, and removes an unused header include. There is no security bug being fixed and no exploit possible.
No security action needed. Treat as normal code-quality/maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit replaces a hand-written operator== for AddressPosition in src/addrman.h with a defaulted const comparison operator. The old operator took its parameter by value and was non-const, which meant comparing two const AddressPosition objects (e.g., in BOOST_CHECK(addr_pos1 == addr_pos2)) failed to compile. The new operator== is const-qualified and takes a const reference, matching modern C++ best practice and enabling the comparison. The unused
Changed components
src/addrman.hAddressPosition equality comparisonInspect captured patch +1 / −5
diff --git a/src/addrman.h b/src/addrman.h
index f7143386..9449c938 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -16,7 +16,6 @@
#include <memory>
#include <optional>
#include <string>
-#include <tuple>
#include <unordered_set>
#include <utility>
#include <vector>
@@ -73,10 +72,7 @@ struct AddressPosition {
const int bucket;
const int position;
- bool operator==(AddressPosition other) {
- return std::tie(tried, multiplicity, bucket, position) ==
- std::tie(other.tried, other.multiplicity, other.bucket, other.position);
- }
+ bool operator==(const AddressPosition&) const = default;
explicit AddressPosition(bool tried_in, int multiplicity_in, int bucket_in, int position_in)
: tried{tried_in}, multiplicity{multiplicity_in}, bucket{bucket_in}, position{position_in} {}
};
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.