feat: implement GetCBOR local state query (#413)
This commit is contained in:
parent
94b37fd798
commit
655efad6c2
3 changed files with 22 additions and 2 deletions
|
|
@ -68,6 +68,13 @@ async fn do_localstate_query(client: &mut NodeClient) {
|
|||
let result = queries_v16::get_genesis_config(client, era).await.unwrap();
|
||||
println!("result: {:?}", result);
|
||||
|
||||
// Ensure decoding across version disparities by always receiving a valid
|
||||
// response using the wrap function for the query result with CBOR-in-CBOR
|
||||
// concept.
|
||||
let query = queries_v16::BlockQuery::GetCurrentPParams;
|
||||
let result = queries_v16::get_cbor(client, era, query).await.unwrap();
|
||||
println!("result: {:?}", result);
|
||||
|
||||
client.send_release().await.unwrap();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ impl<'b> Decode<'b, ()> for BlockQuery {
|
|||
6 => Ok(Self::GetUTxOByAddress(d.decode()?)),
|
||||
// 7 => Ok(Self::GetUTxOWhole),
|
||||
// 8 => Ok(Self::DebugEpochState),
|
||||
// 9 => Ok(Self::GetCBOR(())),
|
||||
9 => Ok(Self::GetCBOR(d.decode()?)),
|
||||
// 10 => Ok(Self::GetFilteredDelegationsAndRewardAccounts(())),
|
||||
11 => Ok(Self::GetGenesisConfig),
|
||||
// 12 => Ok(Self::DebugNewEpochState),
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ pub enum BlockQuery {
|
|||
GetUTxOByAddress(Addrs),
|
||||
GetUTxOWhole,
|
||||
DebugEpochState,
|
||||
GetCBOR(AnyCbor),
|
||||
GetCBOR(Box<BlockQuery>),
|
||||
GetFilteredDelegationsAndRewardAccounts(AnyCbor),
|
||||
GetGenesisConfig,
|
||||
DebugNewEpochState,
|
||||
|
|
@ -435,6 +435,19 @@ pub async fn get_stake_snapshots(
|
|||
Ok(result)
|
||||
}
|
||||
|
||||
pub async fn get_cbor(
|
||||
client: &mut Client,
|
||||
era: u16,
|
||||
query: BlockQuery,
|
||||
) -> Result<Vec<TagWrap<Bytes, 24>>, ClientError> {
|
||||
let query = BlockQuery::GetCBOR(Box::new(query));
|
||||
let query = LedgerQuery::BlockQuery(era, query);
|
||||
let query = Request::LedgerQuery(query);
|
||||
let result = client.query(query).await?;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Get the genesis configuration for the given era.
|
||||
pub async fn get_genesis_config(
|
||||
client: &mut Client,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue