mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 08:51:09 +00:00
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:
committed by
Andrew Jones
parent
a9df35c570
commit
923013628b
@@ -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
@@ -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(_) => {
|
||||
|
||||
Reference in New Issue
Block a user