State-db refactoring (#12239)

* Prune discarded blocks immediately

* state-db refactoring part 1

* Some renames

* Get rid of pending state

* Revert "Prune discarded blocks immediately"

This reverts commit b60d98c569e8af18d99087da93f0911d4f24006e.

* Cleanup

* Make clippy happy

* Minor changes
This commit is contained in:
Arkadiy Paronyan
2022-11-08 11:58:02 +01:00
committed by GitHub
parent ec6a428ade
commit 617fa6c0ba
4 changed files with 181 additions and 557 deletions
+9 -9
View File
@@ -1994,15 +1994,15 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
let usage = operation.old_state.usage_info();
self.state_usage.merge_sm(usage);
match self.try_commit_operation(operation) {
Ok(_) => {
self.storage.state_db.apply_pending();
Ok(())
},
e @ Err(_) => {
self.storage.state_db.revert_pending();
e
},
if let Err(e) = self.try_commit_operation(operation) {
let state_meta_db = StateMetaDb(self.storage.db.clone());
self.storage
.state_db
.reset(state_meta_db)
.map_err(sp_blockchain::Error::from_state_db)?;
Err(e)
} else {
Ok(())
}
}