Trait frame_support::traits::StorePreimage
source · pub trait StorePreimage: QueryPreimage {
const MAX_LENGTH: usize;
// Required method
fn note(bytes: Cow<'_, [u8]>) -> Result<Hash, DispatchError>;
// Provided methods
fn unnote(hash: &Hash) { ... }
fn bound<T: Encode>(t: T) -> Result<Bounded<T>, 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§
sourceconst 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§
sourcefn unnote(hash: &Hash)
fn unnote(hash: &Hash)
Attempt to clear a previously noted preimage. Exactly the same as unrequest
but is
provided for symmetry.
sourcefn bound<T: Encode>(t: T) -> Result<Bounded<T>, DispatchError>
fn bound<T: Encode>(t: T) -> Result<Bounded<T>, 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
.