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

Data structure to cache SHA256 midstates for the ECDSA sighash calculations (bare, P2SH) More...

#include <interpreter.h>

Public Member Functions

bool Load (const SigHashType &hash_type, const CScript &script_code, HashWriter &writer) const noexcept
 Load into writer the SHA256 midstate if found in this cache. More...
 
void Store (const SigHashType &hash_type, const CScript &script_code, const HashWriter &writer) noexcept
 Store into this cache object the provided SHA256 midstate. More...
 

Private Member Functions

int CacheIndex (const SigHashType &hash_type) const noexcept
 Given a hash_type, find which of the 12 cache entries is to be used. More...
 

Private Attributes

std::optional< std::pair< CScript, HashWriter > > m_cache_entries [12]
 For each sighash mode: [0] ALL [1] NONE [2] SINGLE [3] ALL|ANYONE [4] NONE|ANYONE [5] SINGLE|ANYONE [6] ALL|FORKID [7] NONE|FORKID [8] SINGLE|FORKID [9] ALL|ANYONE|FORKID [10] NONE|ANYONE|FORKID [11] SINGLE|ANYONE|FORKID optionally store a scriptCode which the hash is for, plus a midstate for the SHA256 computation just before adding the hash_type itself. More...
 

Detailed Description

Data structure to cache SHA256 midstates for the ECDSA sighash calculations (bare, P2SH)

Definition at line 33 of file interpreter.h.

Member Function Documentation

◆ CacheIndex()

int SigHashCache::CacheIndex ( const SigHashType hash_type) const
privatenoexcept

Given a hash_type, find which of the 12 cache entries is to be used.

Definition at line 1535 of file interpreter.cpp.

◆ Load()

bool SigHashCache::Load ( const SigHashType hash_type,
const CScript script_code,
HashWriter writer 
) const
noexcept

Load into writer the SHA256 midstate if found in this cache.

Definition at line 1541 of file interpreter.cpp.

Here is the caller graph for this function:

◆ Store()

void SigHashCache::Store ( const SigHashType hash_type,
const CScript script_code,
const HashWriter writer 
)
noexcept

Store into this cache object the provided SHA256 midstate.

Definition at line 1552 of file interpreter.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ m_cache_entries

std::optional<std::pair<CScript, HashWriter> > SigHashCache::m_cache_entries[12]
private

For each sighash mode: [0] ALL [1] NONE [2] SINGLE [3] ALL|ANYONE [4] NONE|ANYONE [5] SINGLE|ANYONE [6] ALL|FORKID [7] NONE|FORKID [8] SINGLE|FORKID [9] ALL|ANYONE|FORKID [10] NONE|ANYONE|FORKID [11] SINGLE|ANYONE|FORKID optionally store a scriptCode which the hash is for, plus a midstate for the SHA256 computation just before adding the hash_type itself.

Definition at line 51 of file interpreter.h.


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