Bitcoin ABC  0.24.7
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
SaltedOutpointHasher Class Reference

#include <coins.h>

Public Member Functions

 SaltedOutpointHasher ()
size_t operator() (const COutPoint &outpoint) const noexcept
 This must return size_t. More...

Private Attributes

const uint64_t k0
 Salt. More...
const uint64_t k1

Detailed Description

Definition at line 72 of file coins.h.

Constructor & Destructor Documentation

◆ SaltedOutpointHasher()

SaltedOutpointHasher::SaltedOutpointHasher ( )

Definition at line 59 of file coins.cpp.

Member Function Documentation

◆ operator()()

size_t SaltedOutpointHasher::operator() ( const COutPoint outpoint) const

This must return size_t.

With Boost 1.46 on 32-bit systems the unordered_map will behave unpredictably if the custom hasher returns a uint64_t, resulting in failures when syncing the chain (#4634). Note: This information above might be outdated as the unordered map container type has meanwhile been switched to the C++ standard library implementation.

Having the hash noexcept allows libstdc++'s unordered_map to recalculate the hash during rehash, so it does not have to cache the value. This reduces node's memory by sizeof(size_t). The required recalculation has a slight performance penalty (around 1.6%), but this is compensated by memory savings of about 9% which allow for a larger dbcache setting.

See also

Definition at line 97 of file coins.h.

Here is the call graph for this function:

Member Data Documentation

◆ k0

const uint64_t SaltedOutpointHasher::k0


Definition at line 75 of file coins.h.

◆ k1

const uint64_t SaltedOutpointHasher::k1

Definition at line 75 of file coins.h.

The documentation for this class was generated from the following files: