[][src]Trait sp_core::offchain::OffchainStorage

pub trait OffchainStorage: Clone + Send + Sync {
    fn set(&mut self, prefix: &[u8], key: &[u8], value: &[u8]);
fn remove(&mut self, prefix: &[u8], key: &[u8]);
fn get(&self, prefix: &[u8], key: &[u8]) -> Option<Vec<u8>>;
fn compare_and_set(
        &mut self,
        prefix: &[u8],
        key: &[u8],
        old_value: Option<&[u8]>,
        new_value: &[u8]
    ) -> bool; }

Offchain workers local storage.

Required methods

fn set(&mut self, prefix: &[u8], key: &[u8], value: &[u8])

Persist a value in storage under given key and prefix.

fn remove(&mut self, prefix: &[u8], key: &[u8])

Clear a storage entry under given key and prefix.

fn get(&self, prefix: &[u8], key: &[u8]) -> Option<Vec<u8>>

Retrieve a value from storage under given key and prefix.

fn compare_and_set(
    &mut self,
    prefix: &[u8],
    key: &[u8],
    old_value: Option<&[u8]>,
    new_value: &[u8]
) -> bool

Replace the value in storage if given old_value matches the current one.

Returns true if the value has been set and false otherwise.

Loading content...

Implementors

impl OffchainStorage for InMemOffchainStorage[src]

impl OffchainStorage for TestPersistentOffchainDB[src]

Loading content...