pub trait LeafValueEncoder {
type Value;
type DeferredEncoder: DeferredValueEncoder;
// Required method
fn deferred_encoder(
&mut self,
key: B256,
value: Self::Value,
) -> Self::DeferredEncoder;
}Expand description
A trait for RLP-encoding values for proof calculation. This trait is designed to allow the lazy computation of leaf values in a generic way.
When calculating a leaf value in a storage trie the DeferredValueEncoder simply holds onto
the slot value, and the encode method synchronously RLP-encodes it.
When calculating a leaf value in the accounts trie we create a DeferredValueEncoder to
initiate any asynchronous computation of the account’s storage root we want to do. Later we call
DeferredValueEncoder::encode to obtain the result of that computation and RLP-encode it.
Required Associated Types§
Sourcetype DeferredEncoder: DeferredValueEncoder
type DeferredEncoder: DeferredValueEncoder
The type that will compute and encode the value when needed.
Required Methods§
Sourcefn deferred_encoder(
&mut self,
key: B256,
value: Self::Value,
) -> Self::DeferredEncoder
fn deferred_encoder( &mut self, key: B256, value: Self::Value, ) -> Self::DeferredEncoder
Returns an encoder that will RLP-encode the value when its encode method is called.
§Arguments
key- The key the value was stored at in the DBvalue- The value to encode
The returned deferred encoder will be called as late as possible in the algorithm to maximize the time available for parallel computation (e.g., storage root calculation).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".