Struct sp_state_machine::OverlayedChanges
source · [−]pub struct OverlayedChanges { /* private fields */ }
Expand description
The set of changes that are overlaid onto the backend.
It allows changes to be modified using nestable transactions.
Implementations
Whether no changes are contained in the top nor in any of the child changes.
Ask to collect/not to collect extrinsics indices where key(s) has been changed.
Returns a double-Option: None if the key is unknown (i.e. and the query should be referred to the backend); Some(None) if the key has been deleted. Some(Some(…)) for a key whose value has been set.
pub fn value_mut_or_insert_with(
&mut self,
key: &[u8],
init: impl Fn() -> StorageValue
) -> &mut StorageValue
pub fn value_mut_or_insert_with(
&mut self,
key: &[u8],
init: impl Fn() -> StorageValue
) -> &mut StorageValue
Returns mutable reference to current value. If there is no value in the overlay, the given callback is used to initiate the value. Warning this function registers a change, so the mutable reference MUST be modified.
Can be rolled back or committed when called inside a transaction.
Returns a double-Option: None if the key is unknown (i.e. and the query should be referred to the backend); Some(None) if the key has been deleted. Some(Some(…)) for a key whose value has been set.
Set a new value for the specified key.
Can be rolled back or committed when called inside a transaction.
Returns the current nesting depth of the transaction stack.
A value of zero means that no transaction is open and changes are committed on write.
Start a new nested transaction.
This allows to either commit or roll back all changes that where made while this
transaction was open. Any transaction must be closed by either rollback_transaction
or
commit_transaction
before this overlay can be converted into storage changes.
Changes made without any open transaction are committed immediately.
Rollback the last transaction started by start_transaction
.
Any changes made during that transaction are discarded. Returns an error if there is no open transaction that can be rolled back.
Commit the last transaction started by start_transaction
.
Any changes made during that transaction are committed. Returns an error if there is no open transaction that can be committed.
Call this before transfering control to the runtime.
This protects all existing transactions from being removed by the runtime. Calling this while already inside the runtime will return an error.
Call this when control returns from the runtime.
This commits all dangling transaction left open by the runtime. Calling this while outside the runtime will return an error.
pub fn offchain_drain_committed(
&mut self
) -> impl Iterator<Item = ((StorageKey, StorageKey), OffchainOverlayedChange)>
pub fn offchain_drain_committed(
&mut self
) -> impl Iterator<Item = ((StorageKey, StorageKey), OffchainOverlayedChange)>
Consume all changes (top + children) and return them.
After calling this function no more changes are contained in this changeset.
Panics:
Panics if transaction_depth() > 0
Get an iterator over all child changes as seen by the current transaction.
pub fn changes(
&self
) -> impl Iterator<Item = (&StorageKey, &OverlayedEntry<Option<StorageValue>>)>
pub fn changes(
&self
) -> impl Iterator<Item = (&StorageKey, &OverlayedEntry<Option<StorageValue>>)>
Get an iterator over all top changes as been by the current transaction.
pub fn child_changes(
&self,
key: &[u8]
) -> Option<(impl Iterator<Item = (&StorageKey, &OverlayedEntry<Option<StorageValue>>)>, &ChildInfo)>
pub fn child_changes(
&self,
key: &[u8]
) -> Option<(impl Iterator<Item = (&StorageKey, &OverlayedEntry<Option<StorageValue>>)>, &ChildInfo)>
Get an optional iterator over all child changes stored under the supplied key.
Get an list of all index operations.
pub fn into_storage_changes<B: Backend<H>, H: Hasher>(
self,
backend: &B,
parent_hash: H::Out,
cache: StorageTransactionCache<B::Transaction, H>
) -> Result<StorageChanges<B::Transaction, H>, DefaultError> where
H::Out: Ord + Encode + 'static,
pub fn into_storage_changes<B: Backend<H>, H: Hasher>(
self,
backend: &B,
parent_hash: H::Out,
cache: StorageTransactionCache<B::Transaction, H>
) -> Result<StorageChanges<B::Transaction, H>, DefaultError> where
H::Out: Ord + Encode + 'static,
Convert this instance with all changes into a StorageChanges
instance.
pub fn drain_storage_changes<B: Backend<H>, H: Hasher>(
&mut self,
backend: &B,
_parent_hash: H::Out,
cache: &mut StorageTransactionCache<B::Transaction, H>
) -> Result<StorageChanges<B::Transaction, H>, DefaultError> where
H::Out: Ord + Encode + 'static,
pub fn drain_storage_changes<B: Backend<H>, H: Hasher>(
&mut self,
backend: &B,
_parent_hash: H::Out,
cache: &mut StorageTransactionCache<B::Transaction, H>
) -> Result<StorageChanges<B::Transaction, H>, DefaultError> where
H::Out: Ord + Encode + 'static,
Drain all changes into a StorageChanges
instance. Leave empty overlay in place.
pub fn storage_root<H: Hasher, B: Backend<H>>(
&self,
backend: &B,
cache: &mut StorageTransactionCache<B::Transaction, H>
) -> H::Out where
H::Out: Ord + Encode,
pub fn storage_root<H: Hasher, B: Backend<H>>(
&self,
backend: &B,
cache: &mut StorageTransactionCache<B::Transaction, H>
) -> H::Out where
H::Out: Ord + Encode,
Generate the storage root using backend
and all changes
as seen by the current transaction.
Returns the storage root and caches storage transaction in the given cache
.
Returns an iterator over the keys (in lexicographic order) following key
(excluding key
)
alongside its value.
Returns an iterator over the keys (in lexicographic order) following key
(excluding key
)
alongside its value for the given storage_key
child.
Read only access ot offchain overlay.
Write a key value pair to the offchain storage overlay.
Add transaction index operation.
Trait Implementations
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl !RefUnwindSafe for OverlayedChanges
impl Send for OverlayedChanges
impl !Sync for OverlayedChanges
impl Unpin for OverlayedChanges
impl UnwindSafe for OverlayedChanges
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘimpl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘimpl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
The counterpart to unchecked_from
.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more