BlockId removal: CallApiAt::state_at (#13394)

* BlockId removal: CallApiAt::state_at

It changes the arguments of:
- `CallApiAt::state_at`,
- `Client::code_at`,
- `Client::state_at`

from: `BlockId<Block>` to: `Block::Hash`

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <git@kchr.de>

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: parity-processbot <>
This commit is contained in:
Michal Kucharczyk
2023-02-16 23:21:15 +01:00
committed by GitHub
parent 0669b8bb05
commit 2e4ea01311
3 changed files with 6 additions and 8 deletions
@@ -481,8 +481,7 @@ where
}
/// Get the code at a given block.
pub fn code_at(&self, id: &BlockId<Block>) -> sp_blockchain::Result<Vec<u8>> {
let hash = self.backend.blockchain().expect_block_hash_from_id(id)?;
pub fn code_at(&self, hash: Block::Hash) -> sp_blockchain::Result<Vec<u8>> {
Ok(StorageProvider::storage(self, hash, &StorageKey(well_known_keys::CODE.to_vec()))?
.expect(
"None is returned if there's no value stored for the given key;\
@@ -1746,9 +1745,8 @@ where
CallExecutor::runtime_version(&self.executor, hash).map_err(Into::into)
}
fn state_at(&self, at: &BlockId<Block>) -> Result<Self::StateBackend, sp_api::ApiError> {
let hash = self.backend.blockchain().expect_block_hash_from_id(at)?;
self.state_at(hash).map_err(Into::into)
fn state_at(&self, at: Block::Hash) -> Result<Self::StateBackend, sp_api::ApiError> {
self.state_at(at).map_err(Into::into)
}
}