Remove Backend::destroy_state (#5068)

* Remove `Backend::destroy_state`

This removes the `destroy_state` function of `Backend` and instead moves
the functionality into the `Drop` implementation of the state. This
makes it much easier to work with the state, as the user no longer needs
to call` destroy_state` manually. However, it requires that we switch
from `RwLock` to `ReentrantMutex` as while importing a block we maybe
need to lock again in `drop`.

* Bring back the `RwLock` and some other clean ups

* Fix compilation
This commit is contained in:
Gavin Wood
2020-03-05 17:01:52 +01:00
committed by GitHub
parent 26fc97f635
commit a8441ff968
7 changed files with 318 additions and 100 deletions
+2 -8
View File
@@ -224,17 +224,11 @@ where
&state,
changes_trie_state.as_ref(),
parent_hash,
);
// We need to destroy the state, before we check if `storage_changes` is `Ok(_)`
{
let _lock = self.backend.get_import_lock().read();
self.backend.destroy_state(state)?;
}
)?;
Ok(BuiltBlock {
block: <Block as BlockT>::new(header, self.extrinsics),
storage_changes: storage_changes?,
storage_changes,
proof,
})
}