fix: support multiple pools in stake snapshot query (#396)

This commit is contained in:
Alexsander Falcucci 2024-02-11 16:51:35 +01:00 committed by GitHub
parent 43cdb74ee0
commit 4362341b43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 7 deletions

View file

@ -99,7 +99,7 @@ impl Encode<()> for BlockQuery {
e.u16(20)?;
if !pools.is_empty() {
e.array(Vec::len(pools) as u64)?;
e.array(1)?;
e.tag(Tag::Unassigned(258))?;
}

View file

@ -1,6 +1,7 @@
// TODO: this should move to pallas::ledger crate at some point
use pallas_crypto::hash::Hash;
use std::collections::BTreeSet;
use std::hash::Hash as StdHash;
// required for derive attrs to work
use pallas_codec::minicbor::{self};
@ -210,7 +211,7 @@ pub type Addr = Bytes;
pub type Addrs = Vec<Addr>;
pub type Pools = Vec<Option<Bytes>>;
pub type Pools = BTreeSet<Bytes>;
pub type Coin = AnyUInt;
@ -388,7 +389,7 @@ pub async fn get_utxo_by_address(
pub async fn get_stake_snapshots(
client: &mut Client,
era: u16,
pools: Vec<Option<Bytes>>,
pools: BTreeSet<Bytes>,
) -> Result<StakeSnapshot, ClientError> {
let query = BlockQuery::GetStakeSnapshots(pools);
let query = LedgerQuery::BlockQuery(era, query);

View file

@ -1,3 +1,4 @@
use std::collections::BTreeSet;
use std::fs;
use std::net::{Ipv4Addr, SocketAddrV4};
use std::time::Duration;
@ -673,7 +674,7 @@ pub async fn local_state_query_server_and_client_happy_path() {
localstate::queries_v16::Request::LedgerQuery(
localstate::queries_v16::LedgerQuery::BlockQuery(
5,
localstate::queries_v16::BlockQuery::GetStakeSnapshots(vec![]),
localstate::queries_v16::BlockQuery::GetStakeSnapshots(BTreeSet::new()),
),
)
);
@ -923,7 +924,7 @@ pub async fn local_state_query_server_and_client_happy_path() {
let request = AnyCbor::from_encode(localstate::queries_v16::Request::LedgerQuery(
localstate::queries_v16::LedgerQuery::BlockQuery(
5,
localstate::queries_v16::BlockQuery::GetStakeSnapshots(vec![]),
localstate::queries_v16::BlockQuery::GetStakeSnapshots(BTreeSet::new()),
),
));