Trait polkadot_sdk_frame::traits::StorePreimage
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>(t: T) -> Result<Bounded<T, Self::H>, DispatchError>
where T: Encode { ... }
}
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§
const MAX_LENGTH: usize
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§
Provided Methods§
fn unnote(hash: &<Self::H as Hasher>::Out)
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.
fn bound<T>(t: T) -> Result<Bounded<T, Self::H>, DispatchError>where
T: Encode,
fn bound<T>(t: T) -> Result<Bounded<T, Self::H>, DispatchError>where
T: Encode,
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.