Trait frame_support::traits::StorePreimage

source ·
pub trait StorePreimage: QueryPreimage {
    const MAX_LENGTH: usize;

    // Required method
    fn note(
        bytes: Cow<'_, [u8]>,
    ) -> Result<<Self::H as Hasher>::Out, DispatchError>;

    // Provided methods
    fn unnote(hash: &<Self::H as Hasher>::Out) { ... }
    fn bound<T: Encode>(t: T) -> Result<Bounded<T, Self::H>, DispatchError> { ... }
}
Expand description

A interface for managing preimages to hashes on chain.

Note that this API does not assume any underlying user is calling, and thus does not handle any preimage ownership or fees. Other system level logic that uses this API should implement that on their own side.

Required Associated Constants§

source

const MAX_LENGTH: usize

The maximum length of preimage we can store.

This is the maximum length of the encoded value that can be passed to bound.

Required Methods§

source

fn note(bytes: Cow<'_, [u8]>) -> Result<<Self::H as Hasher>::Out, DispatchError>

Request and attempt to store the bytes of a preimage on chain.

May return DispatchError::Exhausted if the preimage is just too big.

Provided Methods§

source

fn unnote(hash: &<Self::H as Hasher>::Out)

Attempt to clear a previously noted preimage. Exactly the same as unrequest but is provided for symmetry.

source

fn bound<T: Encode>(t: T) -> Result<Bounded<T, Self::H>, DispatchError>

Convert an otherwise unbounded or large value into a type ready for placing in storage.

The result is a type whose MaxEncodedLen is 131 bytes.

NOTE: Once this API is used, you should use either drop or realize. The value is also noted using Self::note.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl StorePreimage for ()

Implementors§