Bitcoin Core 29.99.0
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, P2WPKH, P2WSH). More...

#include <interpreter.h>

Public Member Functions

bool Load (int32_t hash_type, const CScript &script_code, HashWriter &writer) const noexcept
 Load into writer the SHA256 midstate if found in this cache. More...
 
void Store (int32_t 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 (int32_t hash_type) const noexcept
 Given a hash_type, find which of the 6 cache entries is to be used. More...
 

Private Attributes

std::optional< std::pair< CScript, HashWriter > > m_cache_entries [6]
 For each sighash mode (ALL, SINGLE, NONE, ALL|ANYONE, SINGLE|ANYONE, NONE|ANYONE), 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, P2WPKH, P2WSH).

Definition at line 244 of file interpreter.h.

Member Function Documentation

◆ CacheIndex()

int SigHashCache::CacheIndex ( int32_t  hash_type) const
privatenoexcept

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

Definition at line 1567 of file interpreter.cpp.

◆ Load()

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

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

Definition at line 1576 of file interpreter.cpp.

Here is the caller graph for this function:

◆ Store()

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

Store into this cache object the provided SHA256 midstate.

Definition at line 1588 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[6]
private

For each sighash mode (ALL, SINGLE, NONE, ALL|ANYONE, SINGLE|ANYONE, NONE|ANYONE), 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 249 of file interpreter.h.


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