Trait sc_light::blockchain::BlockchainCache[][src]

pub trait BlockchainCache<Block>: Send + Sync where
    Block: Block
{ fn initialize(
        &self,
        key: &[u8; 4],
        value_at_genesis: Vec<u8, Global>
    ) -> Result<(), Error>;
fn get_at(
        &self,
        key: &[u8; 4],
        block: &BlockId<Block>
    ) -> Result<Option<((<<Block as Block>::Header as Header>::Number, <Block as Block>::Hash), Option<(<<Block as Block>::Header as Header>::Number, <Block as Block>::Hash)>, Vec<u8, Global>)>, Error>; }
Expand description

Blockchain optional data cache.

Required methods

Initialize genesis value for the given cache.

The operation should be performed once before anything else is inserted in the cache. Otherwise cache may end up in inconsistent state.

Returns cached value by the given key.

Returned tuple is the range where value has been active and the value itself. Fails if read from cache storage fails or if the value for block is discarded (i.e. if block is earlier that best finalized, but it is not in canonical chain).

Implementors