added at_latest (#900)

* added at_latest

* change some documentation

* remove inline
This commit is contained in:
Tadeo Hepperle
2023-04-11 13:07:12 +02:00
committed by GitHub
parent a69b3e45e7
commit 3b9fd72b26
18 changed files with 83 additions and 55 deletions
+1 -1
View File
@@ -287,7 +287,7 @@ where
Some(events) => events.clone(),
None => {
events::EventsClient::new(client.clone())
.at(Some(block_hash))
.at(block_hash)
.await?
}
};
+17 -2
View File
@@ -39,8 +39,7 @@ where
T: Config,
Client: OnlineClientT<T>,
{
/// Obtain block details given the provided block hash, or the latest block if `None` is
/// provided.
/// Obtain block details given the provided block hash.
///
/// # Warning
///
@@ -48,6 +47,22 @@ where
/// runtime upgrade. You can attempt to retrieve older blocks,
/// but may run into errors attempting to work with them.
pub fn at(
&self,
block_hash: T::Hash,
) -> impl Future<Output = Result<Block<T, Client>, Error>> + Send + 'static {
self.at_or_latest(Some(block_hash))
}
/// Obtain block details of the latest block hash.
pub fn at_latest(
&self,
) -> impl Future<Output = Result<Block<T, Client>, Error>> + Send + 'static {
self.at_or_latest(None)
}
/// Obtain block details given the provided block hash, or the latest block if `None` is
/// provided.
fn at_or_latest(
&self,
block_hash: Option<T::Hash>,
) -> impl Future<Output = Result<Block<T, Client>, Error>> + Send + 'static {