From 430ee36802136143cf2746aa1a123166cfb8f25a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 25 Feb 2020 16:40:08 +0100 Subject: [PATCH 1/2] 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. --- primitives/externalities/src/lib.rs | 20 ++++++++++++++------ primitives/state-machine/src/basic.rs | 4 ++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/primitives/externalities/src/lib.rs b/primitives/externalities/src/lib.rs index 431e449846c6e..22b73ab06c97a 100644 --- a/primitives/externalities/src/lib.rs +++ b/primitives/externalities/src/lib.rs @@ -203,13 +203,21 @@ pub trait Externalities: ExtensionStore { /// Returns the SCALE encoded hash. fn storage_changes_root(&mut self, parent: &[u8]) -> Result>, ()>; - 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 resetted 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. diff --git a/primitives/state-machine/src/basic.rs b/primitives/state-machine/src/basic.rs index d905657737a8a..966648bc8241a 100644 --- a/primitives/state-machine/src/basic.rs +++ b/primitives/state-machine/src/basic.rs @@ -298,6 +298,10 @@ impl Externalities for BasicExternalities { fn storage_changes_root(&mut self, _parent: &[u8]) -> Result>, ()> { Ok(None) } + + fn wipe(&mut self) {} + + fn commit(&mut self) {} } impl sp_externalities::ExtensionStore for BasicExternalities { From 9e284d1bc58e6b1eabe7763ad00369e9527582fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 25 Feb 2020 16:50:40 +0100 Subject: [PATCH 2/2] Update primitives/externalities/src/lib.rs Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- primitives/externalities/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/externalities/src/lib.rs b/primitives/externalities/src/lib.rs index 22b73ab06c97a..fa0f9e4454dd2 100644 --- a/primitives/externalities/src/lib.rs +++ b/primitives/externalities/src/lib.rs @@ -209,7 +209,7 @@ pub trait Externalities: ExtensionStore { /// /// Wipes all changes from caches and the database. /// - /// The state will be resetted to genesis. + /// The state will be reset to genesis. fn wipe(&mut self); /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!