mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 17:57:56 +00:00
Implement nested storage transactions (#6269)
* Add transactional storage functionality to OverlayChanges A collection already has a natural None state. No need to wrap it with an option. * Add storage transactions runtime interface * Add frame support for transactions * Fix committed typo * Rename 'changes' variable to 'overlay' * Fix renaming change * Fixed strange line break * Rename clear to clear_where * Add comment regarding delete value on mutation * Add comment which changes are covered by a transaction * Do force the arg to with_transaction return a Result * Use rust doc comments on every documentable place * Fix wording of insert_diry doc * Improve doc on start_transaction * Rename value to overlayed in close_transaction * Inline negation * Improve wording of close_transaction comments * Get rid of an expect by using get_or_insert_with * Remove trailing whitespace * Rename should to expected in tests * Rolling back a transaction must mark the overlay as dirty * Protect client initiated storage tx from being droped by runtime * Review nits * Return Err when entering or exiting runtime fails * Documentation fixup * Remove close type * Move enter/exit runtime to excute_aux in the state-machine * Rename Discard -> Rollback * Move child changeset creation to constructor * Move child spawning into the closure * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fixup for code suggestion * Unify re-exports * Rename overlay_changes to mod.rs and move into subdir * Change proof wording * Adapt a new test from master to storage-tx * Suggestions from the latest round of review * Fix warning message Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
6aa8965f33
commit
bb2df2122e
@@ -195,6 +195,29 @@ pub trait Externalities: ExtensionStore {
|
||||
/// The returned hash is defined by the `Block` and is SCALE encoded.
|
||||
fn storage_changes_root(&mut self, parent: &[u8]) -> Result<Option<Vec<u8>>, ()>;
|
||||
|
||||
/// Start a new nested transaction.
|
||||
///
|
||||
/// This allows to either commit or roll back all changes made after this call to the
|
||||
/// top changes or the default child changes. For every transaction there cam be a
|
||||
/// matching call to either `storage_rollback_transaction` or `storage_commit_transaction`.
|
||||
/// Any transactions that are still open after returning from runtime are committed
|
||||
/// automatically.
|
||||
///
|
||||
/// Changes made without any open transaction are committed immediately.
|
||||
fn storage_start_transaction(&mut self);
|
||||
|
||||
/// Rollback the last transaction started by `storage_start_transaction`.
|
||||
///
|
||||
/// Any changes made during that storage transaction are discarded. Returns an error when
|
||||
/// no transaction is open that can be closed.
|
||||
fn storage_rollback_transaction(&mut self) -> Result<(), ()>;
|
||||
|
||||
/// Commit the last transaction started by `storage_start_transaction`.
|
||||
///
|
||||
/// Any changes made during that storage transaction are committed. Returns an error when
|
||||
/// no transaction is open that can be closed.
|
||||
fn storage_commit_transaction(&mut self) -> Result<(), ()>;
|
||||
|
||||
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
/// Benchmarking related functionality and shouldn't be used anywhere else!
|
||||
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
Reference in New Issue
Block a user