Skip to content

Commit 5deb7ae

Browse files
committed
util: Rename FilterHeaderHasher to Uint256Hasher
With respect to `std::unordered_map` documentation, the `Hash` type defined in the template is over the `Key` and not `T`, the value. This hasher is incorrectly named as the `FilterHeader` is the value within this map. I consider this a bug as opposed to a refactor as the key and value relationship is implied to be `filter header -> block hash` when it is the opposite. ref: https://en.cppreference.com/w/cpp/container/unordered_map.html
1 parent c84c752 commit 5deb7ae

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/index/blockfilterindex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class BlockFilterIndex final : public BaseIndex
5151

5252
Mutex m_cs_headers_cache;
5353
/** cache of block hash to filter header, to avoid disk access when responding to getcfcheckpt. */
54-
std::unordered_map<uint256, uint256, FilterHeaderHasher> m_headers_cache GUARDED_BY(m_cs_headers_cache);
54+
std::unordered_map<uint256, uint256, Uint256Hasher> m_headers_cache GUARDED_BY(m_cs_headers_cache);
5555

5656
// Last computed header to avoid disk reads on every new block.
5757
uint256 m_last_header{};

src/util/hasher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class SaltedOutpointHasher
7676
}
7777
};
7878

79-
struct FilterHeaderHasher {
79+
struct Uint256Hasher {
8080
size_t operator()(const uint256& hash) const { return ReadLE64(hash.begin()); }
8181
};
8282

0 commit comments

Comments
 (0)