[][src]Trait sc_service::client::light::blockchain::BlockchainCache

pub trait BlockchainCache<Block>: Send + Sync where
    Block: Block
{ fn initialize(
        &self,
        key: &[u8; 4],
        value_at_genesis: Vec<u8>
    ) -> 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>)>, Error>; }

Blockchain optional data cache.

Required methods

fn initialize(
    &self,
    key: &[u8; 4],
    value_at_genesis: Vec<u8>
) -> Result<(), Error>

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.

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>)>, Error>

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).

Loading content...

Implementors

Loading content...