Client::info() no longer returns a Result (#2776)

This commit is contained in:
Pierre Krieger
2019-06-04 16:09:46 +02:00
committed by Bastian Köcher
parent 53e8ad8728
commit 5df89a8a6f
33 changed files with 235 additions and 274 deletions
+2 -2
View File
@@ -110,7 +110,7 @@ impl<B, E, P, RA> AuthorApi<ExHash<P>, BlockHash<P>> for Author<B, E, P, RA> whe
fn submit_extrinsic(&self, ext: Bytes) -> Result<ExHash<P>> {
let xt = Decode::decode(&mut &ext[..]).ok_or(error::Error::BadFormat)?;
let best_block_hash = self.client.info()?.chain.best_hash;
let best_block_hash = self.client.info().chain.best_hash;
self.pool
.submit_one(&generic::BlockId::hash(best_block_hash), xt)
.map_err(|e| e.into_pool_error()
@@ -144,7 +144,7 @@ impl<B, E, P, RA> AuthorApi<ExHash<P>, BlockHash<P>> for Author<B, E, P, RA> whe
fn watch_extrinsic(&self, _metadata: Self::Metadata, subscriber: Subscriber<Status<ExHash<P>, BlockHash<P>>>, xt: Bytes) {
let submit = || -> Result<_> {
let best_block_hash = self.client.info()?.chain.best_hash;
let best_block_hash = self.client.info().chain.best_hash;
let dxt = <<P as PoolChainApi>::Block as traits::Block>::Extrinsic::decode(&mut &xt[..])
.ok_or(error::Error::BadFormat)?;
self.pool
+4 -4
View File
@@ -124,7 +124,7 @@ impl<B, E, Block, RA> Chain<B, E, Block, RA> where
{
fn unwrap_or_best(&self, hash: Option<Block::Hash>) -> Result<Block::Hash> {
Ok(match hash.into() {
None => self.client.info()?.chain.best_hash,
None => self.client.info().chain.best_hash,
Some(hash) => hash,
})
}
@@ -188,13 +188,13 @@ impl<B, E, Block, RA> ChainApi<NumberFor<Block>, Block::Hash, Block::Header, Sig
fn block_hash(&self, number: Option<number::NumberOrHex<NumberFor<Block>>>) -> Result<Option<Block::Hash>> {
Ok(match number {
None => Some(self.client.info()?.chain.best_hash),
None => Some(self.client.info().chain.best_hash),
Some(num_or_hex) => self.client.header(&BlockId::number(num_or_hex.to_number()?))?.map(|h| h.hash()),
})
}
fn finalized_head(&self) -> Result<Block::Hash> {
Ok(self.client.info()?.chain.finalized_hash)
Ok(self.client.info().chain.finalized_hash)
}
fn subscribe_new_head(&self, _metadata: Self::Metadata, subscriber: Subscriber<Block::Header>) {
@@ -214,7 +214,7 @@ impl<B, E, Block, RA> ChainApi<NumberFor<Block>, Block::Hash, Block::Header, Sig
fn subscribe_finalized_heads(&self, _meta: Self::Metadata, subscriber: Subscriber<Block::Header>) {
self.subscribe_headers(
subscriber,
|| Ok(Some(self.client.info()?.chain.finalized_hash)),
|| Ok(Some(self.client.info().chain.finalized_hash)),
|| self.client.finality_notification_stream()
.map(|notification| notification.header),
)
+5 -5
View File
@@ -322,7 +322,7 @@ impl<B, E, Block, RA> State<B, E, Block, RA> where
E: CallExecutor<Block, Blake2Hasher>,
{
fn unwrap_or_best(&self, hash: Option<Block::Hash>) -> Result<Block::Hash> {
crate::helpers::unwrap_or_else(|| Ok(self.client.info()?.chain.best_hash), hash)
crate::helpers::unwrap_or_else(|| Ok(self.client.info().chain.best_hash), hash)
}
}
@@ -449,7 +449,7 @@ impl<B, E, Block, RA> StateApi<Block::Hash> for State<B, E, Block, RA> where
// initial values
let initial = stream::iter_result(keys
.map(|keys| {
let block = self.client.info().map(|info| info.chain.best_hash).unwrap_or_default();
let block = self.client.info().chain.best_hash;
let changes = keys
.into_iter()
.map(|key| self.storage(key.clone(), Some(block.clone()).into())
@@ -506,9 +506,9 @@ impl<B, E, Block, RA> StateApi<Block::Hash> for State<B, E, Block, RA> where
let stream = stream
.map_err(|e| warn!("Error creating storage notification stream: {:?}", e))
.filter_map(move |_| {
let version = client.info().and_then(|info| {
client.runtime_version_at(&BlockId::hash(info.chain.best_hash))
})
let info = client.info();
let version = client
.runtime_version_at(&BlockId::hash(info.chain.best_hash))
.map_err(error::Error::from)
.map_err(Into::into);
if previous_version != version {