feat(network): implement GetChainBlockNo local state query (#441)

This commit is contained in:
Alexsander Falcucci 2024-04-16 14:27:23 +02:00 committed by GitHub
parent 4a3a8fb0da
commit 9e7cafbcac
4 changed files with 62 additions and 2 deletions

View file

@ -91,6 +91,15 @@ pub struct SystemStart {
pub picoseconds_of_day: u64,
}
#[derive(Debug, Encode, Decode, PartialEq)]
pub struct ChainBlockNumber {
#[n(0)]
pub slot_timeline: u32,
#[n(1)]
pub block_number: u32,
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct RationalNumber {
pub numerator: u64,
@ -368,6 +377,14 @@ pub async fn get_system_start(client: &mut Client) -> Result<SystemStart, Client
Ok(result)
}
/// Get the block number for the current tip.
pub async fn get_chain_block_no(client: &mut Client) -> Result<ChainBlockNumber, ClientError> {
let query = Request::GetChainBlockNo;
let result = client.query(query).await?;
Ok(result)
}
/// Get the current protocol parameters.
pub async fn get_current_pparams(
client: &mut Client,