Add a method to fetch current finalized head hash (#57)

* chore: Update to latest substrate master renames

* feat: Introduce Client::finalized_head
This commit is contained in:
Maciej Hirsz
2019-12-19 17:58:08 +01:00
committed by Andrew Jones
parent a9df35c570
commit 923013628b
2 changed files with 14 additions and 1 deletions
+6
View File
@@ -207,6 +207,12 @@ impl<T: System + Balances + 'static, S: 'static> Client<T, S> {
.and_then(|rpc| rpc.block_hash(hash.map(|h| h)))
}
/// Get a block hash of the latest finalized block
pub fn finalized_head(&self) -> impl Future<Item = T::Hash, Error = Error> {
self.connect()
.and_then(|rpc| rpc.finalized_head())
}
/// Get a block
pub fn block<H>(
&self,
+8 -1
View File
@@ -168,6 +168,13 @@ impl<T: System> Rpc<T> {
})
}
/// Get a block hash of the latest finalized block
pub fn finalized_head(&self) -> impl Future<Item = T::Hash, Error = Error> {
self.chain
.finalized_head()
.map_err(Into::into)
}
/// Get a Block
pub fn block(
&self,
@@ -286,7 +293,7 @@ impl<T: System + Balances + 'static> Rpc<T> {
TransactionStatus::Future
| TransactionStatus::Ready
| TransactionStatus::Broadcast(_) => None,
TransactionStatus::Finalized(block_hash) => {
TransactionStatus::InBlock(block_hash) => {
Some(Ok(block_hash))
}
TransactionStatus::Usurped(_) => {