diff --git a/src/lib.rs b/src/lib.rs index 7c6eaf51cc..000cfbe0f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -207,6 +207,12 @@ impl Client { .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 { + self.connect() + .and_then(|rpc| rpc.finalized_head()) + } + /// Get a block pub fn block( &self, diff --git a/src/rpc.rs b/src/rpc.rs index 33f506a45e..808ebd98f1 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -168,6 +168,13 @@ impl Rpc { }) } + /// Get a block hash of the latest finalized block + pub fn finalized_head(&self) -> impl Future { + self.chain + .finalized_head() + .map_err(Into::into) + } + /// Get a Block pub fn block( &self, @@ -286,7 +293,7 @@ impl Rpc { TransactionStatus::Future | TransactionStatus::Ready | TransactionStatus::Broadcast(_) => None, - TransactionStatus::Finalized(block_hash) => { + TransactionStatus::InBlock(block_hash) => { Some(Ok(block_hash)) } TransactionStatus::Usurped(_) => {