Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

BlockId removal: refactor: StorageProvider #6160

Merged
merged 4 commits into from
Oct 18, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions node/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,66 +418,69 @@ impl sc_client_api::BlockBackend<Block> for Client {
}
}

impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client
where
Block: BlockT,
{
michalkucharczyk marked this conversation as resolved.
Show resolved Hide resolved
fn storage(
&self,
id: &BlockId<Block>,
hash: &<Block as BlockT>::Hash,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hash: &<Block as BlockT>::Hash,
hash: &Block::Hash,

You don't need to fully qualify the trait.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't compile:

   --> node/client/src/lib.rs:427:10
    |
427 |         hash: &Block::Hash,
    |                ^^^^^^^^^^^ help: use fully-qualified syntax: `<sp_runtime::generic::Block<sp_runtime::generic::Header<u32, BlakeTwo256>, OpaqueExtrinsic> as Trait>::Hash`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yeah, I thought Block is a generic type here. However, it is the actual type. So, this doesn't work. Sorry!

key: &StorageKey,
) -> sp_blockchain::Result<Option<StorageData>> {
with_client! {
self,
client,
{
client.storage(id, key)
client.storage(hash, key)
}
}
}

fn storage_keys(
&self,
id: &BlockId<Block>,
hash: &<Block as BlockT>::Hash,
key_prefix: &StorageKey,
) -> sp_blockchain::Result<Vec<StorageKey>> {
with_client! {
self,
client,
{
client.storage_keys(id, key_prefix)
client.storage_keys(hash, key_prefix)
}
}
}

fn storage_hash(
&self,
id: &BlockId<Block>,
hash: &<Block as BlockT>::Hash,
key: &StorageKey,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
with_client! {
self,
client,
{
client.storage_hash(id, key)
client.storage_hash(hash, key)
}
}
}

fn storage_pairs(
&self,
id: &BlockId<Block>,
hash: &<Block as BlockT>::Hash,
key_prefix: &StorageKey,
) -> sp_blockchain::Result<Vec<(StorageKey, StorageData)>> {
with_client! {
self,
client,
{
client.storage_pairs(id, key_prefix)
client.storage_pairs(hash, key_prefix)
}
}
}

fn storage_keys_iter<'a>(
&self,
id: &BlockId<Block>,
hash: &<Block as BlockT>::Hash,
prefix: Option<&'a StorageKey>,
start_key: Option<&StorageKey>,
) -> sp_blockchain::Result<
Expand All @@ -487,44 +490,44 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
self,
client,
{
client.storage_keys_iter(id, prefix, start_key)
client.storage_keys_iter(hash, prefix, start_key)
}
}
}

fn child_storage(
&self,
id: &BlockId<Block>,
hash: &<Block as BlockT>::Hash,
child_info: &ChildInfo,
key: &StorageKey,
) -> sp_blockchain::Result<Option<StorageData>> {
with_client! {
self,
client,
{
client.child_storage(id, child_info, key)
client.child_storage(hash, child_info, key)
}
}
}

fn child_storage_keys(
&self,
id: &BlockId<Block>,
hash: &<Block as BlockT>::Hash,
child_info: &ChildInfo,
key_prefix: &StorageKey,
) -> sp_blockchain::Result<Vec<StorageKey>> {
with_client! {
self,
client,
{
client.child_storage_keys(id, child_info, key_prefix)
client.child_storage_keys(hash, child_info, key_prefix)
}
}
}

fn child_storage_keys_iter<'a>(
&self,
id: &BlockId<Block>,
hash: &<Block as BlockT>::Hash,
child_info: ChildInfo,
prefix: Option<&'a StorageKey>,
start_key: Option<&StorageKey>,
Expand All @@ -535,22 +538,22 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
self,
client,
{
client.child_storage_keys_iter(id, child_info, prefix, start_key)
client.child_storage_keys_iter(hash, child_info, prefix, start_key)
}
}
}

fn child_storage_hash(
&self,
id: &BlockId<Block>,
hash: &<Block as BlockT>::Hash,
child_info: &ChildInfo,
key: &StorageKey,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
with_client! {
self,
client,
{
client.child_storage_hash(id, child_info, key)
client.child_storage_hash(hash, child_info, key)
}
}
}
Expand Down