cargo fmt with stable defaults (#876)

This commit is contained in:
James Wilson
2023-03-21 16:53:47 +00:00
committed by GitHub
parent c63ff6ec6d
commit 7c252fccf7
110 changed files with 663 additions and 1949 deletions
+12 -27
View File
@@ -3,19 +3,9 @@
// see LICENSE for license details.
use crate::{
client::{
OfflineClientT,
OnlineClientT,
},
config::{
Config,
Hasher,
Header,
},
error::{
BlockError,
Error,
},
client::{OfflineClientT, OnlineClientT},
config::{Config, Hasher, Header},
error::{BlockError, Error},
events,
rpc::types::ChainBlockResponse,
runtime_api::RuntimeApi,
@@ -135,15 +125,13 @@ where
.extrinsics
.iter()
.enumerate()
.map(|(idx, e)| {
Extrinsic {
index: idx as u32,
bytes: &e.0,
client: self.client.clone(),
block_hash: self.details.block.header.hash(),
cached_events: self.cached_events.clone(),
_marker: std::marker::PhantomData,
}
.map(|(idx, e)| Extrinsic {
index: idx as u32,
bytes: &e.0,
client: self.client.clone(),
block_hash: self.details.block.header.hash(),
cached_events: self.cached_events.clone(),
_marker: std::marker::PhantomData,
})
}
}
@@ -181,8 +169,7 @@ where
{
/// The events associated with the extrinsic.
pub async fn events(&self) -> Result<ExtrinsicEvents<T>, Error> {
let events =
get_events(&self.client, self.block_hash, &self.cached_events).await?;
let events = get_events(&self.client, self.block_hash, &self.cached_events).await?;
let ext_hash = T::Hasher::hash_of(&self.bytes);
Ok(ExtrinsicEvents::new(ext_hash, self.index, events))
}
@@ -248,9 +235,7 @@ impl<T: Config> ExtrinsicEvents<T> {
///
/// This works in the same way that [`events::Events::find()`] does, with the
/// exception that it filters out events not related to the submitted extrinsic.
pub fn find<Ev: events::StaticEvent>(
&self,
) -> impl Iterator<Item = Result<Ev, Error>> + '_ {
pub fn find<Ev: events::StaticEvent>(&self) -> impl Iterator<Item = Result<Ev, Error>> + '_ {
self.iter().filter_map(|ev| {
ev.and_then(|ev| ev.as_event::<Ev>().map_err(Into::into))
.transpose()
+11 -31
View File
@@ -5,27 +5,13 @@
use super::Block;
use crate::{
client::OnlineClientT,
config::{
Config,
Header,
},
error::{
BlockError,
Error,
},
config::{Config, Header},
error::{BlockError, Error},
utils::PhantomDataSendSync,
};
use derivative::Derivative;
use futures::{
future::Either,
stream,
Stream,
StreamExt,
};
use std::{
future::Future,
pin::Pin,
};
use futures::{future::Either, stream, Stream, StreamExt};
use std::{future::Future, pin::Pin};
type BlockStream<T> = Pin<Box<dyn Stream<Item = Result<T, Error>> + Send>>;
type BlockStreamRes<T> = Result<BlockStream<T>, Error>;
@@ -71,13 +57,11 @@ where
// for the latest block and use that.
let block_hash = match block_hash {
Some(hash) => hash,
None => {
client
.rpc()
.block_hash(None)
.await?
.expect("didn't pass a block number; qed")
}
None => client
.rpc()
.block_hash(None)
.await?
.expect("didn't pass a block number; qed"),
};
let block_header = match client.rpc().header(Some(block_hash)).await? {
@@ -145,12 +129,8 @@ where
// Adjust the subscription stream to fill in any missing blocks.
BlockStreamRes::Ok(
subscribe_to_block_headers_filling_in_gaps(
client,
last_finalized_block_num,
sub,
)
.boxed(),
subscribe_to_block_headers_filling_in_gaps(client, last_finalized_block_num, sub)
.boxed(),
)
})
}
+2 -9
View File
@@ -7,12 +7,5 @@
mod block_types;
mod blocks_client;
pub use block_types::{
Block,
Extrinsic,
ExtrinsicEvents,
};
pub use blocks_client::{
subscribe_to_block_headers_filling_in_gaps,
BlocksClient,
};
pub use block_types::{Block, Extrinsic, ExtrinsicEvents};
pub use blocks_client::{subscribe_to_block_headers_filling_in_gaps, BlocksClient};