Struct sp_state_machine::OverlayedChanges [−][src]
pub struct OverlayedChanges { /* fields omitted */ }
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
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
Causes self
to use its Binary
implementation when Debug
-formatted.
Causes self
to use its Display
implementation when
Debug
-formatted. Read more
Causes self
to use its LowerExp
implementation when
Debug
-formatted. Read more
Causes self
to use its LowerHex
implementation when
Debug
-formatted. Read more
Causes self
to use its Octal
implementation when Debug
-formatted.
Causes self
to use its Pointer
implementation when
Debug
-formatted. Read more
Causes self
to use its UpperExp
implementation when
Debug
-formatted. Read more
Causes self
to use its UpperHex
implementation when
Debug
-formatted. Read more
Pipes by value. This is generally the method you want to use. Read more
Borrows self
and passes that borrow into the pipe function. Read more
Mutably borrows self
and passes that borrow into the pipe function. Read more
Borrows self
, then passes self.borrow()
into the pipe function. Read more
Mutably borrows self
, then passes self.borrow_mut()
into the pipe
function. Read more
Borrows self
, then passes self.as_ref()
into the pipe function.
Mutably borrows self
, then passes self.as_mut()
into the pipe
function. Read more
Borrows self
, then passes self.deref()
into the pipe function.
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
Pipes a dereference into a function that cannot normally be called in suffix position. Read more
Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more
Immutable access to the Borrow<B>
of a value. Read more
Mutable access to the BorrowMut<B>
of a value. Read more
Immutable access to the AsRef<R>
view of a value. Read more
Mutable access to the AsMut<R>
view of a value. Read more
Immutable access to the Deref::Target
of a value. Read more
Mutable access to the Deref::Target
of a value. Read more
Calls .tap()
only in debug builds, and is erased in release builds.
Calls .tap_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_borrow()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_ref()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_deref()
only in debug builds, and is erased in release
builds. Read more
Provides immutable access to the reference for inspection.
Calls tap_ref
in debug builds, and does nothing in release builds.
Provides mutable access to the reference for modification.
Calls tap_ref_mut
in debug builds, and does nothing in release builds.
Provides immutable access to the borrow for inspection. Read more
Calls tap_borrow
in debug builds, and does nothing in release builds.
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Provides mutable access to the borrow for modification.
Immutably dereferences self
for inspection.
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Calls tap_deref
in debug builds, and does nothing in release builds.
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Mutably dereferences self
for modification.
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