mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +00:00
Documentation and small cleanup in panic-handler (#3249)
* Documentation and small cleanup in panic-handler * Apply suggestions from code review Co-Authored-By: Sergei Pepyakin <s.pepyakin@gmail.com>
This commit is contained in:
committed by
Gavin Wood
parent
de02aee156
commit
cb7383b6b6
@@ -173,35 +173,35 @@ where
|
||||
N: crate::changes_trie::BlockNumber,
|
||||
{
|
||||
fn storage(&self, key: &[u8]) -> Option<Vec<u8>> {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
self.overlay.storage(key).map(|x| x.map(|x| x.to_vec())).unwrap_or_else(||
|
||||
self.backend.storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL))
|
||||
}
|
||||
|
||||
fn storage_hash(&self, key: &[u8]) -> Option<H::Out> {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
self.overlay.storage(key).map(|x| x.map(|x| H::hash(x))).unwrap_or_else(||
|
||||
self.backend.storage_hash(key).expect(EXT_NOT_ALLOWED_TO_FAIL))
|
||||
}
|
||||
|
||||
fn original_storage(&self, key: &[u8]) -> Option<Vec<u8>> {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
self.backend.storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL)
|
||||
}
|
||||
|
||||
fn original_storage_hash(&self, key: &[u8]) -> Option<H::Out> {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
self.backend.storage_hash(key).expect(EXT_NOT_ALLOWED_TO_FAIL)
|
||||
}
|
||||
|
||||
fn child_storage(&self, storage_key: ChildStorageKey<H>, key: &[u8]) -> Option<Vec<u8>> {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
self.overlay.child_storage(storage_key.as_ref(), key).map(|x| x.map(|x| x.to_vec())).unwrap_or_else(||
|
||||
self.backend.child_storage(storage_key.as_ref(), key).expect(EXT_NOT_ALLOWED_TO_FAIL))
|
||||
}
|
||||
|
||||
fn exists_storage(&self, key: &[u8]) -> bool {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
match self.overlay.storage(key) {
|
||||
Some(x) => x.is_some(),
|
||||
_ => self.backend.exists_storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL),
|
||||
@@ -209,7 +209,7 @@ where
|
||||
}
|
||||
|
||||
fn exists_child_storage(&self, storage_key: ChildStorageKey<H>, key: &[u8]) -> bool {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
|
||||
match self.overlay.child_storage(storage_key.as_ref(), key) {
|
||||
Some(x) => x.is_some(),
|
||||
@@ -218,7 +218,7 @@ where
|
||||
}
|
||||
|
||||
fn place_storage(&mut self, key: Vec<u8>, value: Option<Vec<u8>>) {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
if is_child_storage_key(&key) {
|
||||
warn!(target: "trie", "Refuse to directly set child storage key");
|
||||
return;
|
||||
@@ -229,14 +229,14 @@ where
|
||||
}
|
||||
|
||||
fn place_child_storage(&mut self, storage_key: ChildStorageKey<H>, key: Vec<u8>, value: Option<Vec<u8>>) {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
|
||||
self.mark_dirty();
|
||||
self.overlay.set_child_storage(storage_key.into_owned(), key, value);
|
||||
}
|
||||
|
||||
fn kill_child_storage(&mut self, storage_key: ChildStorageKey<H>) {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
|
||||
self.mark_dirty();
|
||||
self.overlay.clear_child_storage(storage_key.as_ref());
|
||||
@@ -246,7 +246,7 @@ where
|
||||
}
|
||||
|
||||
fn clear_prefix(&mut self, prefix: &[u8]) {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
if is_child_storage_key(prefix) {
|
||||
warn!(target: "trie", "Refuse to directly clear prefix that is part of child storage key");
|
||||
return;
|
||||
@@ -264,7 +264,7 @@ where
|
||||
}
|
||||
|
||||
fn storage_root(&mut self) -> H::Out {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
if let Some((_, ref root)) = self.storage_transaction {
|
||||
return root.clone();
|
||||
}
|
||||
@@ -292,7 +292,7 @@ where
|
||||
}
|
||||
|
||||
fn child_storage_root(&mut self, storage_key: ChildStorageKey<H>) -> Vec<u8> {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
if self.storage_transaction.is_some() {
|
||||
self
|
||||
.storage(storage_key.as_ref())
|
||||
@@ -319,7 +319,7 @@ where
|
||||
}
|
||||
|
||||
fn storage_changes_root(&mut self, parent_hash: H::Out) -> Result<Option<H::Out>, ()> {
|
||||
let _guard = panic_handler::AbortGuard::new(true);
|
||||
let _guard = panic_handler::AbortGuard::force_abort();
|
||||
self.changes_trie_transaction = build_changes_trie::<_, T, H, N>(
|
||||
self.backend,
|
||||
self.changes_trie_storage.clone(),
|
||||
|
||||
Reference in New Issue
Block a user