CCF
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
ccf::historical::StateCacheImpl Class Reference

#include <historical_queries.h>

Inherited by ccf::historical::StateCache.

Classes

struct  Request
 
struct  StoreDetails
 
struct  VersionedSecret
 

Public Member Functions

 StateCacheImpl (ccf::kv::Store &store, const std::shared_ptr< ccf::LedgerSecrets > &secrets, const ringbuffer::WriterPtr &host_writer)
 
ccf::kv::ReadOnlyStorePtr get_store_at (const CompoundHandle &handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry)
 
ccf::kv::ReadOnlyStorePtr get_store_at (const CompoundHandle &handle, ccf::SeqNo seqno)
 
StatePtr get_state_at (const CompoundHandle &handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry)
 
StatePtr get_state_at (const CompoundHandle &handle, ccf::SeqNo seqno)
 
std::vector< ccf::kv::ReadOnlyStorePtrget_store_range (const CompoundHandle &handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno, ExpiryDuration seconds_until_expiry)
 
std::vector< ccf::kv::ReadOnlyStorePtrget_store_range (const CompoundHandle &handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno)
 
std::vector< StatePtrget_state_range (const CompoundHandle &handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno, ExpiryDuration seconds_until_expiry)
 
std::vector< StatePtrget_state_range (const CompoundHandle &handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno)
 
std::vector< ccf::kv::ReadOnlyStorePtrget_stores_for (const CompoundHandle &handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry)
 
std::vector< ccf::kv::ReadOnlyStorePtrget_stores_for (const CompoundHandle &handle, const SeqNoCollection &seqnos)
 
std::vector< StatePtrget_states_for (const CompoundHandle &handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry)
 
std::vector< StatePtrget_states_for (const CompoundHandle &handle, const SeqNoCollection &seqnos)
 
void set_default_expiry_duration (ExpiryDuration duration)
 
void set_soft_cache_limit (CacheSize cache_limit)
 
void track_deletes_on_missing_keys (bool track)
 
bool drop_cached_states (const CompoundHandle &handle)
 
bool handle_ledger_entry (ccf::SeqNo seqno, const std::vector< uint8_t > &data)
 
bool handle_ledger_entry (ccf::SeqNo seqno, const uint8_t *data, size_t size)
 
bool handle_ledger_entries (ccf::SeqNo from_seqno, ccf::SeqNo to_seqno, const LedgerEntry &data)
 
bool handle_ledger_entries (ccf::SeqNo from_seqno, ccf::SeqNo to_seqno, const uint8_t *data, size_t size)
 
void handle_no_entry (ccf::SeqNo seqno)
 
void handle_no_entry_range (ccf::SeqNo from_seqno, ccf::SeqNo to_seqno)
 
ccf::kv::StorePtr deserialise_ledger_entry (ccf::SeqNo seqno, const uint8_t *data, size_t size, ccf::kv::ApplyResult &result, ccf::ClaimsDigest &claims_digest, bool &has_commit_evidence)
 
void tick (const std::chrono::milliseconds &elapsed_ms)
 

Protected Types

enum class  StoreStage { Fetching , Trusted }
 
using LedgerEntry = std::vector< uint8_t >
 
using StoreDetailsPtr = std::shared_ptr< StoreDetails >
 
using RequestedStores = std::map< ccf::SeqNo, StoreDetailsPtr >
 
using WeakStoreDetailsPtr = std::weak_ptr< StoreDetails >
 
using AllRequestedStores = std::map< ccf::SeqNo, WeakStoreDetailsPtr >
 

Protected Member Functions

void update_earliest_known_ledger_secret ()
 
void add_request_ref (SeqNo seq, CompoundHandle handle)
 
void add_request_refs (CompoundHandle handle)
 
void remove_request_ref (SeqNo seq, CompoundHandle handle)
 
void remove_request_refs (CompoundHandle handle)
 
void lru_promote (CompoundHandle handle)
 
void lru_shrink_to_fit (size_t threshold)
 
void lru_evict (CompoundHandle handle)
 
void update_store_raw_size (SeqNo seq, size_t new_size)
 
void fetch_entry_at (ccf::SeqNo seqno)
 
void fetch_entries_range (ccf::SeqNo from, ccf::SeqNo to)
 
std::optional< ccf::SeqNofetch_supporting_secret_if_needed (ccf::SeqNo seqno)
 
void process_deserialised_store (const StoreDetailsPtr &details, const ccf::kv::StorePtr &store, const ccf::crypto::Sha256Hash &entry_digest, ccf::SeqNo seqno, bool is_signature, ccf::ClaimsDigest &&claims_digest, bool has_commit_evidence)
 
bool handle_encrypted_past_ledger_secret (const ccf::kv::StorePtr &store, LedgerSecretPtr encrypting_secret)
 
SeqNoCollection collection_from_single_range (ccf::SeqNo start_seqno, ccf::SeqNo end_seqno)
 
std::vector< StatePtrget_states_internal (const CompoundHandle &handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry, bool include_receipts)
 
void delete_all_interested_requests (ccf::SeqNo seqno)
 
std::vector< ccf::kv::ReadOnlyStorePtrstates_to_stores (const std::vector< StatePtr > &states)
 

Protected Attributes

ccf::kv::Storesource_store
 
std::shared_ptr< ccf::LedgerSecretssource_ledger_secrets
 
ringbuffer::WriterPtr to_host
 
std::shared_ptr< ccf::LedgerSecretshistorical_ledger_secrets
 
std::shared_ptr< ccf::NodeEncryptorhistorical_encryptor
 
bool track_deletes_on_missing_keys_v = false
 
VersionedSecret earliest_secret_ = {}
 
StoreDetailsPtr next_secret_fetch_handle = nullptr
 
ccf::pal::Mutex requests_lock
 
std::map< CompoundHandle, Requestrequests
 
AllRequestedStores all_stores
 
ExpiryDuration default_expiry_duration = std::chrono::seconds(1800)
 
std::list< CompoundHandlelru_requests
 
std::map< CompoundHandle, std::list< CompoundHandle >::iterator > lru_lookup
 
std::unordered_map< SeqNo, std::set< CompoundHandle > > store_to_requests
 
std::unordered_map< ccf::SeqNo, size_t > raw_store_sizes {}
 
CacheSize soft_store_cache_limit {std::numeric_limits<size_t>::max()}
 
CacheSize soft_store_cache_limit_raw
 
CacheSize estimated_store_cache_size {0}
 

Member Typedef Documentation

◆ AllRequestedStores

◆ LedgerEntry

using ccf::historical::StateCacheImpl::LedgerEntry = std::vector<uint8_t>
protected

◆ RequestedStores

◆ StoreDetailsPtr

◆ WeakStoreDetailsPtr

Member Enumeration Documentation

◆ StoreStage

enum class ccf::historical::StateCacheImpl::StoreStage
strongprotected
Enumerator
Fetching 
Trusted 

Constructor & Destructor Documentation

◆ StateCacheImpl()

ccf::historical::StateCacheImpl::StateCacheImpl ( ccf::kv::Store store,
const std::shared_ptr< ccf::LedgerSecrets > &  secrets,
const ringbuffer::WriterPtr host_writer 
)
inline

Member Function Documentation

◆ add_request_ref()

void ccf::historical::StateCacheImpl::add_request_ref ( SeqNo  seq,
CompoundHandle  handle 
)
inlineprotected

◆ add_request_refs()

void ccf::historical::StateCacheImpl::add_request_refs ( CompoundHandle  handle)
inlineprotected

◆ collection_from_single_range()

SeqNoCollection ccf::historical::StateCacheImpl::collection_from_single_range ( ccf::SeqNo  start_seqno,
ccf::SeqNo  end_seqno 
)
inlineprotected

◆ delete_all_interested_requests()

void ccf::historical::StateCacheImpl::delete_all_interested_requests ( ccf::SeqNo  seqno)
inlineprotected

◆ deserialise_ledger_entry()

ccf::kv::StorePtr ccf::historical::StateCacheImpl::deserialise_ledger_entry ( ccf::SeqNo  seqno,
const uint8_t *  data,
size_t  size,
ccf::kv::ApplyResult result,
ccf::ClaimsDigest claims_digest,
bool &  has_commit_evidence 
)
inline

◆ drop_cached_states()

bool ccf::historical::StateCacheImpl::drop_cached_states ( const CompoundHandle handle)
inline

◆ fetch_entries_range()

void ccf::historical::StateCacheImpl::fetch_entries_range ( ccf::SeqNo  from,
ccf::SeqNo  to 
)
inlineprotected

◆ fetch_entry_at()

void ccf::historical::StateCacheImpl::fetch_entry_at ( ccf::SeqNo  seqno)
inlineprotected

◆ fetch_supporting_secret_if_needed()

std::optional< ccf::SeqNo > ccf::historical::StateCacheImpl::fetch_supporting_secret_if_needed ( ccf::SeqNo  seqno)
inlineprotected

◆ get_state_at() [1/2]

StatePtr ccf::historical::StateCacheImpl::get_state_at ( const CompoundHandle handle,
ccf::SeqNo  seqno 
)
inline

◆ get_state_at() [2/2]

StatePtr ccf::historical::StateCacheImpl::get_state_at ( const CompoundHandle handle,
ccf::SeqNo  seqno,
ExpiryDuration  seconds_until_expiry 
)
inline

◆ get_state_range() [1/2]

std::vector< StatePtr > ccf::historical::StateCacheImpl::get_state_range ( const CompoundHandle handle,
ccf::SeqNo  start_seqno,
ccf::SeqNo  end_seqno 
)
inline

◆ get_state_range() [2/2]

std::vector< StatePtr > ccf::historical::StateCacheImpl::get_state_range ( const CompoundHandle handle,
ccf::SeqNo  start_seqno,
ccf::SeqNo  end_seqno,
ExpiryDuration  seconds_until_expiry 
)
inline

◆ get_states_for() [1/2]

std::vector< StatePtr > ccf::historical::StateCacheImpl::get_states_for ( const CompoundHandle handle,
const SeqNoCollection seqnos 
)
inline

◆ get_states_for() [2/2]

std::vector< StatePtr > ccf::historical::StateCacheImpl::get_states_for ( const CompoundHandle handle,
const SeqNoCollection seqnos,
ExpiryDuration  seconds_until_expiry 
)
inline

◆ get_states_internal()

std::vector< StatePtr > ccf::historical::StateCacheImpl::get_states_internal ( const CompoundHandle handle,
const SeqNoCollection seqnos,
ExpiryDuration  seconds_until_expiry,
bool  include_receipts 
)
inlineprotected

◆ get_store_at() [1/2]

ccf::kv::ReadOnlyStorePtr ccf::historical::StateCacheImpl::get_store_at ( const CompoundHandle handle,
ccf::SeqNo  seqno 
)
inline

◆ get_store_at() [2/2]

ccf::kv::ReadOnlyStorePtr ccf::historical::StateCacheImpl::get_store_at ( const CompoundHandle handle,
ccf::SeqNo  seqno,
ExpiryDuration  seconds_until_expiry 
)
inline

◆ get_store_range() [1/2]

std::vector< ccf::kv::ReadOnlyStorePtr > ccf::historical::StateCacheImpl::get_store_range ( const CompoundHandle handle,
ccf::SeqNo  start_seqno,
ccf::SeqNo  end_seqno 
)
inline

◆ get_store_range() [2/2]

std::vector< ccf::kv::ReadOnlyStorePtr > ccf::historical::StateCacheImpl::get_store_range ( const CompoundHandle handle,
ccf::SeqNo  start_seqno,
ccf::SeqNo  end_seqno,
ExpiryDuration  seconds_until_expiry 
)
inline

◆ get_stores_for() [1/2]

std::vector< ccf::kv::ReadOnlyStorePtr > ccf::historical::StateCacheImpl::get_stores_for ( const CompoundHandle handle,
const SeqNoCollection seqnos 
)
inline

◆ get_stores_for() [2/2]

std::vector< ccf::kv::ReadOnlyStorePtr > ccf::historical::StateCacheImpl::get_stores_for ( const CompoundHandle handle,
const SeqNoCollection seqnos,
ExpiryDuration  seconds_until_expiry 
)
inline

◆ handle_encrypted_past_ledger_secret()

bool ccf::historical::StateCacheImpl::handle_encrypted_past_ledger_secret ( const ccf::kv::StorePtr store,
LedgerSecretPtr  encrypting_secret 
)
inlineprotected

◆ handle_ledger_entries() [1/2]

bool ccf::historical::StateCacheImpl::handle_ledger_entries ( ccf::SeqNo  from_seqno,
ccf::SeqNo  to_seqno,
const LedgerEntry data 
)
inline

◆ handle_ledger_entries() [2/2]

bool ccf::historical::StateCacheImpl::handle_ledger_entries ( ccf::SeqNo  from_seqno,
ccf::SeqNo  to_seqno,
const uint8_t *  data,
size_t  size 
)
inline

◆ handle_ledger_entry() [1/2]

bool ccf::historical::StateCacheImpl::handle_ledger_entry ( ccf::SeqNo  seqno,
const std::vector< uint8_t > &  data 
)
inline

◆ handle_ledger_entry() [2/2]

bool ccf::historical::StateCacheImpl::handle_ledger_entry ( ccf::SeqNo  seqno,
const uint8_t *  data,
size_t  size 
)
inline

◆ handle_no_entry()

void ccf::historical::StateCacheImpl::handle_no_entry ( ccf::SeqNo  seqno)
inline

◆ handle_no_entry_range()

void ccf::historical::StateCacheImpl::handle_no_entry_range ( ccf::SeqNo  from_seqno,
ccf::SeqNo  to_seqno 
)
inline

◆ lru_evict()

void ccf::historical::StateCacheImpl::lru_evict ( CompoundHandle  handle)
inlineprotected

◆ lru_promote()

void ccf::historical::StateCacheImpl::lru_promote ( CompoundHandle  handle)
inlineprotected

◆ lru_shrink_to_fit()

void ccf::historical::StateCacheImpl::lru_shrink_to_fit ( size_t  threshold)
inlineprotected

◆ process_deserialised_store()

void ccf::historical::StateCacheImpl::process_deserialised_store ( const StoreDetailsPtr details,
const ccf::kv::StorePtr store,
const ccf::crypto::Sha256Hash entry_digest,
ccf::SeqNo  seqno,
bool  is_signature,
ccf::ClaimsDigest &&  claims_digest,
bool  has_commit_evidence 
)
inlineprotected

◆ remove_request_ref()

void ccf::historical::StateCacheImpl::remove_request_ref ( SeqNo  seq,
CompoundHandle  handle 
)
inlineprotected

◆ remove_request_refs()

void ccf::historical::StateCacheImpl::remove_request_refs ( CompoundHandle  handle)
inlineprotected

◆ set_default_expiry_duration()

void ccf::historical::StateCacheImpl::set_default_expiry_duration ( ExpiryDuration  duration)
inline

◆ set_soft_cache_limit()

void ccf::historical::StateCacheImpl::set_soft_cache_limit ( CacheSize  cache_limit)
inline

◆ states_to_stores()

std::vector< ccf::kv::ReadOnlyStorePtr > ccf::historical::StateCacheImpl::states_to_stores ( const std::vector< StatePtr > &  states)
inlineprotected

◆ tick()

void ccf::historical::StateCacheImpl::tick ( const std::chrono::milliseconds &  elapsed_ms)
inline

◆ track_deletes_on_missing_keys()

void ccf::historical::StateCacheImpl::track_deletes_on_missing_keys ( bool  track)
inline

◆ update_earliest_known_ledger_secret()

void ccf::historical::StateCacheImpl::update_earliest_known_ledger_secret ( )
inlineprotected

◆ update_store_raw_size()

void ccf::historical::StateCacheImpl::update_store_raw_size ( SeqNo  seq,
size_t  new_size 
)
inlineprotected

Member Data Documentation

◆ all_stores

AllRequestedStores ccf::historical::StateCacheImpl::all_stores
protected

◆ default_expiry_duration

ExpiryDuration ccf::historical::StateCacheImpl::default_expiry_duration = std::chrono::seconds(1800)
protected

◆ earliest_secret_

VersionedSecret ccf::historical::StateCacheImpl::earliest_secret_ = {}
protected

◆ estimated_store_cache_size

CacheSize ccf::historical::StateCacheImpl::estimated_store_cache_size {0}
protected

◆ historical_encryptor

std::shared_ptr<ccf::NodeEncryptor> ccf::historical::StateCacheImpl::historical_encryptor
protected

◆ historical_ledger_secrets

std::shared_ptr<ccf::LedgerSecrets> ccf::historical::StateCacheImpl::historical_ledger_secrets
protected

◆ lru_lookup

std::map<CompoundHandle, std::list<CompoundHandle>::iterator> ccf::historical::StateCacheImpl::lru_lookup
protected

◆ lru_requests

std::list<CompoundHandle> ccf::historical::StateCacheImpl::lru_requests
protected

◆ next_secret_fetch_handle

StoreDetailsPtr ccf::historical::StateCacheImpl::next_secret_fetch_handle = nullptr
protected

◆ raw_store_sizes

std::unordered_map<ccf::SeqNo, size_t> ccf::historical::StateCacheImpl::raw_store_sizes {}
protected

◆ requests

std::map<CompoundHandle, Request> ccf::historical::StateCacheImpl::requests
protected

◆ requests_lock

ccf::pal::Mutex ccf::historical::StateCacheImpl::requests_lock
protected

◆ soft_store_cache_limit

CacheSize ccf::historical::StateCacheImpl::soft_store_cache_limit {std::numeric_limits<size_t>::max()}
protected

◆ soft_store_cache_limit_raw

CacheSize ccf::historical::StateCacheImpl::soft_store_cache_limit_raw
protected
Initial value:
=
soft_store_cache_limit / soft_to_raw_ratio
CacheSize soft_store_cache_limit
Definition historical_queries.h:522

◆ source_ledger_secrets

std::shared_ptr<ccf::LedgerSecrets> ccf::historical::StateCacheImpl::source_ledger_secrets
protected

◆ source_store

ccf::kv::Store& ccf::historical::StateCacheImpl::source_store
protected

◆ store_to_requests

std::unordered_map<SeqNo, std::set<CompoundHandle> > ccf::historical::StateCacheImpl::store_to_requests
protected

◆ to_host

ringbuffer::WriterPtr ccf::historical::StateCacheImpl::to_host
protected

◆ track_deletes_on_missing_keys_v

bool ccf::historical::StateCacheImpl::track_deletes_on_missing_keys_v = false
protected

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