mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 19:47:59 +00:00
BlockId removal: refactor: StorageProvider (#12510)
* BlockId removal: refactor: StorageProvider It changes the arguments of `Backend::StorageProvider` trait from: block: `BlockId<Block>` to: hash: `&Block::Hash` This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292) * Apply suggestions from code review Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/api/src/backend.rs Co-authored-by: Dmitrii Markin <dmitry@markin.tech> * GrandpaBlockImport::current_set_id reworked * ExportStateCmd reworked * trigger CI job * trigger CI job Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Dmitrii Markin <dmitry@markin.tech>
This commit is contained in:
committed by
GitHub
parent
2f341fcf15
commit
b16135f602
@@ -18,10 +18,7 @@
|
||||
use sc_cli::Result;
|
||||
use sc_client_api::{Backend as ClientBackend, StorageProvider, UsageProvider};
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_runtime::{
|
||||
generic::BlockId,
|
||||
traits::{Block as BlockT, Header as HeaderT},
|
||||
};
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
|
||||
|
||||
use log::info;
|
||||
use rand::prelude::*;
|
||||
@@ -41,12 +38,12 @@ impl StorageCmd {
|
||||
<<B as BlockT>::Header as HeaderT>::Number: From<u32>,
|
||||
{
|
||||
let mut record = BenchRecord::default();
|
||||
let block = BlockId::Hash(client.usage_info().chain.best_hash);
|
||||
let best_hash = client.usage_info().chain.best_hash;
|
||||
|
||||
info!("Preparing keys from block {}", block);
|
||||
info!("Preparing keys from block {}", best_hash);
|
||||
// Load all keys and randomly shuffle them.
|
||||
let empty_prefix = StorageKey(Vec::new());
|
||||
let mut keys = client.storage_keys(&block, &empty_prefix)?;
|
||||
let mut keys = client.storage_keys(&best_hash, &empty_prefix)?;
|
||||
let (mut rng, _) = new_rng(None);
|
||||
keys.shuffle(&mut rng);
|
||||
|
||||
@@ -58,7 +55,7 @@ impl StorageCmd {
|
||||
match (self.params.include_child_trees, self.is_child_key(key.clone().0)) {
|
||||
(true, Some(info)) => {
|
||||
// child tree key
|
||||
let child_keys = client.child_storage_keys(&block, &info, &empty_prefix)?;
|
||||
let child_keys = client.child_storage_keys(&best_hash, &info, &empty_prefix)?;
|
||||
for ck in child_keys {
|
||||
child_nodes.push((ck.clone(), info.clone()));
|
||||
}
|
||||
@@ -67,7 +64,7 @@ impl StorageCmd {
|
||||
// regular key
|
||||
let start = Instant::now();
|
||||
let v = client
|
||||
.storage(&block, &key)
|
||||
.storage(&best_hash, &key)
|
||||
.expect("Checked above to exist")
|
||||
.ok_or("Value unexpectedly empty")?;
|
||||
record.append(v.0.len(), start.elapsed())?;
|
||||
@@ -82,7 +79,7 @@ impl StorageCmd {
|
||||
for (key, info) in child_nodes.as_slice() {
|
||||
let start = Instant::now();
|
||||
let v = client
|
||||
.child_storage(&block, info, key)
|
||||
.child_storage(&best_hash, info, key)
|
||||
.expect("Checked above to exist")
|
||||
.ok_or("Value unexpectedly empty")?;
|
||||
record.append(v.0.len(), start.elapsed())?;
|
||||
|
||||
Reference in New Issue
Block a user