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

SipHash-1-3-UJ based hasher for the coins cache and related coins containers. More...

#include <coins.h>

Collaboration diagram for SaltedCoinsCacheHasher:
[legend]

Public Member Functions

 SaltedCoinsCacheHasher (bool deterministic=false)
 
size_t operator() (const Txid &id) const noexcept
 Hash a transaction ID, itself a cryptographic hash, as one jumbo block. More...
 
size_t operator() (const COutPoint &id) const noexcept
 Hash an outpoint as its txid jumbo block followed by the zero-extended index as one normal block. More...
 

Private Attributes

const SipHasher13UJ m_hasher
 

Detailed Description

SipHash-1-3-UJ based hasher for the coins cache and related coins containers.

Retained entries identify real transaction outputs, so their keys contain computed txids. Missing-input lookups may contain arbitrary claimed prevouts, but FetchCoin() immediately erases their temporary entries when the backend lookup fails, so non-hash keys cannot accumulate.

The assumeutxo loader assumes snapshot txids are valid while loading and verifies the complete snapshot's content hash before activation.

Hash values are process-local and must not be persisted, serialized, or compared across processes.

Having the hash noexcept lets libstdc++ recalculate it during rehash instead of storing it in each node.

Definition at line 239 of file coins.h.

Constructor & Destructor Documentation

◆ SaltedCoinsCacheHasher()

SaltedCoinsCacheHasher::SaltedCoinsCacheHasher ( bool  deterministic = false)

Definition at line 22 of file coins.cpp.

Member Function Documentation

◆ operator()() [1/2]

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

Hash an outpoint as its txid jumbo block followed by the zero-extended index as one normal block.

Definition at line 253 of file coins.h.

Here is the call graph for this function:

◆ operator()() [2/2]

size_t SaltedCoinsCacheHasher::operator() ( const Txid id) const
inlinenoexcept

Hash a transaction ID, itself a cryptographic hash, as one jumbo block.

Definition at line 247 of file coins.h.

Here is the call graph for this function:

Member Data Documentation

◆ m_hasher

const SipHasher13UJ SaltedCoinsCacheHasher::m_hasher
private

Definition at line 241 of file coins.h.


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