Refactor to use only chain info (#4516)

This commit is contained in:
Nikolay Volf
2020-01-02 14:46:07 +03:00
committed by Bastian Köcher
parent 8ecc450fd9
commit 6d06a19f41
30 changed files with 178 additions and 175 deletions
+3 -3
View File
@@ -102,7 +102,7 @@ impl<B, E, P, Block, RA> AuthorApi<Block::Hash, Block::Hash> for Author<B, E, P,
}
fn rotate_keys(&self) -> Result<Bytes> {
let best_block_hash = self.client.info().chain.best_hash;
let best_block_hash = self.client.chain_info().best_hash;
self.client.runtime_api().generate_session_keys(
&generic::BlockId::Hash(best_block_hash),
None,
@@ -114,7 +114,7 @@ impl<B, E, P, Block, RA> AuthorApi<Block::Hash, Block::Hash> for Author<B, E, P,
Ok(xt) => xt,
Err(err) => return Box::new(result(Err(err.into()))),
};
let best_block_hash = self.client.info().chain.best_hash;
let best_block_hash = self.client.chain_info().best_hash;
Box::new(self.pool
.submit_one(&generic::BlockId::hash(best_block_hash), xt)
.compat()
@@ -157,7 +157,7 @@ impl<B, E, P, Block, RA> AuthorApi<Block::Hash, Block::Hash> for Author<B, E, P,
xt: Bytes,
) {
let submit = || -> Result<_> {
let best_block_hash = self.client.info().chain.best_hash;
let best_block_hash = self.client.chain_info().best_hash;
let dxt = TransactionFor::<P>::decode(&mut &xt[..])
.map_err(error::Error::from)?;
Ok(
+5 -5
View File
@@ -63,7 +63,7 @@ trait ChainBackend<B, E, Block: BlockT, RA>: Send + Sync + 'static
/// Tries to unwrap passed block hash, or uses best block hash otherwise.
fn unwrap_or_best(&self, hash: Option<Block::Hash>) -> Block::Hash {
match hash.into() {
None => self.client().info().chain.best_hash,
None => self.client().chain_info().best_hash,
Some(hash) => hash,
}
}
@@ -82,7 +82,7 @@ trait ChainBackend<B, E, Block: BlockT, RA>: Send + Sync + 'static
number: Option<NumberOrHex<NumberFor<Block>>>,
) -> Result<Option<Block::Hash>> {
Ok(match number {
None => Some(self.client().info().chain.best_hash),
None => Some(self.client().chain_info().best_hash),
Some(num_or_hex) => self.client()
.header(&BlockId::number(num_or_hex.to_number()?))
.map_err(client_err)?
@@ -92,7 +92,7 @@ trait ChainBackend<B, E, Block: BlockT, RA>: Send + Sync + 'static
/// Get hash of the last finalized block in the canon chain.
fn finalized_head(&self) -> Result<Block::Hash> {
Ok(self.client().info().chain.finalized_hash)
Ok(self.client().chain_info().finalized_hash)
}
/// New head subscription
@@ -105,7 +105,7 @@ trait ChainBackend<B, E, Block: BlockT, RA>: Send + Sync + 'static
self.client(),
self.subscriptions(),
subscriber,
|| self.client().info().chain.best_hash,
|| self.client().chain_info().best_hash,
|| self.client().import_notification_stream()
.filter(|notification| future::ready(notification.is_new_best))
.map(|notification| Ok::<_, ()>(notification.header))
@@ -132,7 +132,7 @@ trait ChainBackend<B, E, Block: BlockT, RA>: Send + Sync + 'static
self.client(),
self.subscriptions(),
subscriber,
|| self.client().info().chain.finalized_hash,
|| self.client().chain_info().finalized_hash,
|| self.client().finality_notification_stream()
.map(|notification| Ok::<_, ()>(notification.header))
.compat(),
+4 -4
View File
@@ -83,7 +83,7 @@ impl<B, E, Block: BlockT, RA> FullState<B, E, Block, RA>
/// Returns given block hash or best block hash if None is passed.
fn block_or_best(&self, hash: Option<Block::Hash>) -> ClientResult<Block::Hash> {
Ok(hash.unwrap_or_else(|| self.client.info().chain.best_hash))
Ok(hash.unwrap_or_else(|| self.client.chain_info().best_hash))
}
/// Splits the `query_storage` block range into 'filtered' and 'unfiltered' subranges.
@@ -403,9 +403,9 @@ impl<B, E, Block, RA> StateBackend<B, E, Block, RA> for FullState<B, E, Block, R
let stream = stream
.filter_map(move |_| {
let info = client.info();
let info = client.chain_info();
let version = client
.runtime_version_at(&BlockId::hash(info.chain.best_hash))
.runtime_version_at(&BlockId::hash(info.best_hash))
.map_err(client_err)
.map_err(Into::into);
if previous_version != version {
@@ -457,7 +457,7 @@ impl<B, E, Block, RA> StateBackend<B, E, Block, RA> for FullState<B, E, Block, R
// initial values
let initial = stream::iter_result(keys
.map(|keys| {
let block = self.client.info().chain.best_hash;
let block = self.client.chain_info().best_hash;
let changes = keys
.into_iter()
.map(|key| self.storage(Some(block.clone()).into(), key.clone())
@@ -168,7 +168,7 @@ impl<Block: BlockT, F: Fetcher<Block> + 'static, B, E, RA> LightState<Block, F,
/// Returns given block hash or best block hash if None is passed.
fn block_or_best(&self, hash: Option<Block::Hash>) -> Block::Hash {
hash.unwrap_or_else(|| self.client.info().chain.best_hash)
hash.unwrap_or_else(|| self.client.chain_info().best_hash)
}
}