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

#include <hasher.h>

Collaboration diagram for SaltedOutpointHasher:
[legend]

Public Member Functions

 SaltedOutpointHasher (bool deterministic=false)
 
size_t operator() (const COutPoint &id) const noexcept
 Having the hash noexcept allows libstdc++'s unordered_map to recalculate the hash during rehash, so it does not have to cache the value. More...
 

Private Attributes

const PresaltedSipHasher m_hasher
 

Detailed Description

Definition at line 57 of file hasher.h.

Constructor & Destructor Documentation

◆ SaltedOutpointHasher()

SaltedOutpointHasher::SaltedOutpointHasher ( bool  deterministic = false)

Definition at line 25 of file hasher.cpp.

Member Function Documentation

◆ operator()()

size_t SaltedOutpointHasher::operator() ( const COutPoint id) const
inlinenoexcept

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
https://gcc.gnu.org/onlinedocs/gcc-13.2.0/libstdc++/manual/manual/unordered_associative.html

Definition at line 73 of file hasher.h.

Member Data Documentation

◆ m_hasher

const PresaltedSipHasher SaltedOutpointHasher::m_hasher
private

Definition at line 59 of file hasher.h.


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