CCF
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
ccf::historical::AbstractStateCache Class Referenceabstract

#include <historical_queries_interface.h>

Inherits ccf::AbstractNodeSubSystem.

Inherited by ccf::historical::StateCache.

Public Member Functions

virtual ~AbstractStateCache ()=default
 
virtual void set_default_expiry_duration (ExpiryDuration seconds_until_expiry)=0
 
virtual void set_soft_cache_limit (CacheSize cache_limit)=0
 
virtual void track_deletes_on_missing_keys (bool track)=0
 
virtual ccf::kv::ReadOnlyStorePtr get_store_at (RequestHandle handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry)=0
 
virtual ccf::kv::ReadOnlyStorePtr get_store_at (RequestHandle handle, ccf::SeqNo seqno)=0
 
virtual StatePtr get_state_at (RequestHandle handle, ccf::SeqNo seqno, ExpiryDuration seconds_until_expiry)=0
 
virtual StatePtr get_state_at (RequestHandle handle, ccf::SeqNo seqno)=0
 
virtual std::vector< ccf::kv::ReadOnlyStorePtrget_store_range (RequestHandle handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno, ExpiryDuration seconds_until_expiry)=0
 
virtual std::vector< ccf::kv::ReadOnlyStorePtrget_store_range (RequestHandle handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno)=0
 
virtual std::vector< StatePtrget_state_range (RequestHandle handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno, ExpiryDuration seconds_until_expiry)=0
 
virtual std::vector< StatePtrget_state_range (RequestHandle handle, ccf::SeqNo start_seqno, ccf::SeqNo end_seqno)=0
 
virtual std::vector< ccf::kv::ReadOnlyStorePtrget_stores_for (RequestHandle handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry)=0
 
virtual std::vector< ccf::kv::ReadOnlyStorePtrget_stores_for (RequestHandle handle, const SeqNoCollection &seqnos)=0
 
virtual std::vector< StatePtrget_states_for (RequestHandle handle, const SeqNoCollection &seqnos, ExpiryDuration seconds_until_expiry)=0
 
virtual std::vector< StatePtrget_states_for (RequestHandle handle, const SeqNoCollection &seqnos)=0
 
virtual bool drop_cached_states (RequestHandle handle)=0
 
- Public Member Functions inherited from ccf::AbstractNodeSubSystem
virtual ~AbstractNodeSubSystem ()=default
 

Static Public Member Functions

static char const * get_subsystem_name ()
 

Detailed Description

Stores the progress of historical query requests.

A request will generally need to be made multiple times (with the same handle and range) before the response is available, as the historical state is asynchronously retrieved from the ledger and then validated. If the same handle is used for a new range, the state for the old range will be discarded. State is also discarded after the handle's expiry duration, or when drop_cached_states is called for a given handle. The management of requests (how many unique handles are concurrently active, how they are correlated across HTTP requests, how the active quota is divided between callers) is left to the calling system.

Constructor & Destructor Documentation

◆ ~AbstractStateCache()

virtual ccf::historical::AbstractStateCache::~AbstractStateCache ( )
virtualdefault

Member Function Documentation

◆ drop_cached_states()

virtual bool ccf::historical::AbstractStateCache::drop_cached_states ( RequestHandle  handle)
pure virtual

Drop state for the given handle.

May be used to free up space once a historical query has been resolved, more aggressively than waiting for the states to expire.

Implemented in ccf::historical::StateCache.

◆ get_state_at() [1/2]

virtual StatePtr ccf::historical::AbstractStateCache::get_state_at ( RequestHandle  handle,
ccf::SeqNo  seqno 
)
pure virtual

Same as get_state_at but uses default expiry value.

See also
get_state_at

Implemented in ccf::historical::StateCache.

◆ get_state_at() [2/2]

virtual StatePtr ccf::historical::AbstractStateCache::get_state_at ( RequestHandle  handle,
ccf::SeqNo  seqno,
ExpiryDuration  seconds_until_expiry 
)
pure virtual

Retrieve a full state at a given seqno, including the Store, the TxID assigned by consensus, and an offline-verifiable receipt for the Tx.

Implemented in ccf::historical::StateCache.

◆ get_state_range() [1/2]

virtual std::vector< StatePtr > ccf::historical::AbstractStateCache::get_state_range ( RequestHandle  handle,
ccf::SeqNo  start_seqno,
ccf::SeqNo  end_seqno 
)
pure virtual

Same as get_state_range but uses default expiry value.

See also
get_state_range

Implemented in ccf::historical::StateCache.

◆ get_state_range() [2/2]

virtual std::vector< StatePtr > ccf::historical::AbstractStateCache::get_state_range ( RequestHandle  handle,
ccf::SeqNo  start_seqno,
ccf::SeqNo  end_seqno,
ExpiryDuration  seconds_until_expiry 
)
pure virtual

Retrieve a range of states at the given indices, including the Store, the TxID assigned by consensus, and an offline-verifiable receipt for the Tx.

Implemented in ccf::historical::StateCache.

◆ get_states_for() [1/2]

virtual std::vector< StatePtr > ccf::historical::AbstractStateCache::get_states_for ( RequestHandle  handle,
const SeqNoCollection seqnos 
)
pure virtual

Implemented in ccf::historical::StateCache.

◆ get_states_for() [2/2]

virtual std::vector< StatePtr > ccf::historical::AbstractStateCache::get_states_for ( RequestHandle  handle,
const SeqNoCollection seqnos,
ExpiryDuration  seconds_until_expiry 
)
pure virtual

Retrieve states for a set of given indices.

Implemented in ccf::historical::StateCache.

◆ get_store_at() [1/2]

virtual ccf::kv::ReadOnlyStorePtr ccf::historical::AbstractStateCache::get_store_at ( RequestHandle  handle,
ccf::SeqNo  seqno 
)
pure virtual

Same as get_store_at but uses default expiry value.

See also
get_store_at

Implemented in ccf::historical::StateCache.

◆ get_store_at() [2/2]

virtual ccf::kv::ReadOnlyStorePtr ccf::historical::AbstractStateCache::get_store_at ( RequestHandle  handle,
ccf::SeqNo  seqno,
ExpiryDuration  seconds_until_expiry 
)
pure virtual

Retrieve a Store containing the state written at the given seqno.

See get_store_range for a description of the caching behaviour. This is equivalent to get_store_at(handle, seqno, seqno), but returns nullptr if the state is currently unavailable.

Implemented in ccf::historical::StateCache.

◆ get_store_range() [1/2]

virtual std::vector< ccf::kv::ReadOnlyStorePtr > ccf::historical::AbstractStateCache::get_store_range ( RequestHandle  handle,
ccf::SeqNo  start_seqno,
ccf::SeqNo  end_seqno 
)
pure virtual

Same as get_store_range but uses default expiry value.

See also
get_store_range

Implemented in ccf::historical::StateCache.

◆ get_store_range() [2/2]

virtual std::vector< ccf::kv::ReadOnlyStorePtr > ccf::historical::AbstractStateCache::get_store_range ( RequestHandle  handle,
ccf::SeqNo  start_seqno,
ccf::SeqNo  end_seqno,
ExpiryDuration  seconds_until_expiry 
)
pure virtual

Retrieve a range of Stores containing the state written at the given indices.

If this is not currently available, this function returns an empty vector and begins fetching the ledger entry asynchronously. This will generally be true for the first call for a given seqno, and it may take some time to completely fetch and validate. The call should be repeated later with the same arguments to retrieve the requested entries. This state is kept until it is deleted for one of the following reasons:

  • A call to drop_cached_states
  • seconds_until_expiry seconds elapse without calling this function
  • This handle is used to request a different seqno or range

The range is inclusive of both start_seqno and end_seqno. If a non-empty vector is returned, it will always contain the full requested range; the vector will be of length (end_seqno - start_seqno + 1) and will contain no nullptrs.

Implemented in ccf::historical::StateCache.

◆ get_stores_for() [1/2]

virtual std::vector< ccf::kv::ReadOnlyStorePtr > ccf::historical::AbstractStateCache::get_stores_for ( RequestHandle  handle,
const SeqNoCollection seqnos 
)
pure virtual

Implemented in ccf::historical::StateCache.

◆ get_stores_for() [2/2]

virtual std::vector< ccf::kv::ReadOnlyStorePtr > ccf::historical::AbstractStateCache::get_stores_for ( RequestHandle  handle,
const SeqNoCollection seqnos,
ExpiryDuration  seconds_until_expiry 
)
pure virtual

Retrieve stores for a set of given indices.

Implemented in ccf::historical::StateCache.

◆ get_subsystem_name()

static char const * ccf::historical::AbstractStateCache::get_subsystem_name ( )
inlinestatic

◆ set_default_expiry_duration()

virtual void ccf::historical::AbstractStateCache::set_default_expiry_duration ( ExpiryDuration  seconds_until_expiry)
pure virtual

Set the default time after which a request's state will be deleted, and will not be accessible without retrieving it again from the ledger. Any call to get_store_XXX which doesn't pass an explicit seconds_until_expiry will reset the timer to this default duration.

Implemented in ccf::historical::StateCache.

◆ set_soft_cache_limit()

virtual void ccf::historical::AbstractStateCache::set_soft_cache_limit ( CacheSize  cache_limit)
pure virtual

Set the cache limit (in bytes) to evict least recently used requests from the cache after its size grows beyond this limit. The limit is not strict. It is estimated based on serialized states' sizes approximation and is checked once per tick, and so it can overflow for a short time.

Implemented in ccf::historical::StateCache.

◆ track_deletes_on_missing_keys()

virtual void ccf::historical::AbstractStateCache::track_deletes_on_missing_keys ( bool  track)
pure virtual

EXPERIMENTAL: Set the tracking of deletes on missing keys for historical queries.

This is experimental but setting this to true ensures that the tx_diff available in index handlers can observe deleted values.

Implemented in ccf::historical::StateCache.


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