Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Adds documentation for wipe and commit (#5053)
Browse files Browse the repository at this point in the history
* Adds documentation for `wipe` and `commit`

This adds documentation to `wipe` and `commit` of `Externalities`.
Besides that it removes the default implementation that would just panic
and requires that all implementers of the trait implement the functions.

* Update primitives/externalities/src/lib.rs

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
  • Loading branch information
bkchr and joepetrowski authored Feb 26, 2020
1 parent 78224bd commit 4d61dc7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 14 additions & 6 deletions primitives/externalities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,21 @@ pub trait Externalities: ExtensionStore {
/// Returns the SCALE encoded hash.
fn storage_changes_root(&mut self, parent: &[u8]) -> Result<Option<Vec<u8>>, ()>;

fn wipe(&mut self) {
unimplemented!()
}
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/// Benchmarking related functionality and shouldn't be used anywhere else!
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
///
/// Wipes all changes from caches and the database.
///
/// The state will be reset to genesis.
fn wipe(&mut self);

fn commit(&mut self) {
unimplemented!()
}
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/// Benchmarking related functionality and shouldn't be used anywhere else!
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
///
/// Commits all changes to the database and clears all caches.
fn commit(&mut self);
}

/// Extension for the [`Externalities`] trait.
Expand Down
4 changes: 4 additions & 0 deletions primitives/state-machine/src/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ impl Externalities for BasicExternalities {
fn storage_changes_root(&mut self, _parent: &[u8]) -> Result<Option<Vec<u8>>, ()> {
Ok(None)
}

fn wipe(&mut self) {}

fn commit(&mut self) {}
}

impl sp_externalities::ExtensionStore for BasicExternalities {
Expand Down

0 comments on commit 4d61dc7

Please sign in to comment.