fix: support multiple pools in stake snapshot query (#396)
This commit is contained in:
parent
d4a8acfaa0
commit
83728a085d
4 changed files with 12 additions and 7 deletions
|
|
@ -1,4 +1,7 @@
|
||||||
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
use pallas::{
|
use pallas::{
|
||||||
|
codec::utils::Bytes,
|
||||||
ledger::{addresses::Address, traverse::MultiEraBlock},
|
ledger::{addresses::Address, traverse::MultiEraBlock},
|
||||||
network::{
|
network::{
|
||||||
facades::NodeClient,
|
facades::NodeClient,
|
||||||
|
|
@ -55,8 +58,8 @@ async fn do_localstate_query(client: &mut NodeClient) {
|
||||||
println!("result: {:?}", result);
|
println!("result: {:?}", result);
|
||||||
|
|
||||||
// Stake pool ID/verification key hash (either Bech32-decoded or hex-decoded).
|
// Stake pool ID/verification key hash (either Bech32-decoded or hex-decoded).
|
||||||
// Empty Vec means all pools.
|
// Empty Set means all pools.
|
||||||
let pools = vec![];
|
let pools: BTreeSet<Bytes> = BTreeSet::new();
|
||||||
let result = queries_v16::get_stake_snapshots(client, era, pools)
|
let result = queries_v16::get_stake_snapshots(client, era, pools)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ impl Encode<()> for BlockQuery {
|
||||||
e.u16(20)?;
|
e.u16(20)?;
|
||||||
|
|
||||||
if !pools.is_empty() {
|
if !pools.is_empty() {
|
||||||
e.array(Vec::len(pools) as u64)?;
|
e.array(1)?;
|
||||||
e.tag(Tag::Unassigned(258))?;
|
e.tag(Tag::Unassigned(258))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// TODO: this should move to pallas::ledger crate at some point
|
// TODO: this should move to pallas::ledger crate at some point
|
||||||
|
|
||||||
use pallas_crypto::hash::Hash;
|
use pallas_crypto::hash::Hash;
|
||||||
|
use std::collections::BTreeSet;
|
||||||
use std::hash::Hash as StdHash;
|
use std::hash::Hash as StdHash;
|
||||||
// required for derive attrs to work
|
// required for derive attrs to work
|
||||||
use pallas_codec::minicbor::{self};
|
use pallas_codec::minicbor::{self};
|
||||||
|
|
@ -210,7 +211,7 @@ pub type Addr = Bytes;
|
||||||
|
|
||||||
pub type Addrs = Vec<Addr>;
|
pub type Addrs = Vec<Addr>;
|
||||||
|
|
||||||
pub type Pools = Vec<Option<Bytes>>;
|
pub type Pools = BTreeSet<Bytes>;
|
||||||
|
|
||||||
pub type Coin = AnyUInt;
|
pub type Coin = AnyUInt;
|
||||||
|
|
||||||
|
|
@ -388,7 +389,7 @@ pub async fn get_utxo_by_address(
|
||||||
pub async fn get_stake_snapshots(
|
pub async fn get_stake_snapshots(
|
||||||
client: &mut Client,
|
client: &mut Client,
|
||||||
era: u16,
|
era: u16,
|
||||||
pools: Vec<Option<Bytes>>,
|
pools: BTreeSet<Bytes>,
|
||||||
) -> Result<StakeSnapshot, ClientError> {
|
) -> Result<StakeSnapshot, ClientError> {
|
||||||
let query = BlockQuery::GetStakeSnapshots(pools);
|
let query = BlockQuery::GetStakeSnapshots(pools);
|
||||||
let query = LedgerQuery::BlockQuery(era, query);
|
let query = LedgerQuery::BlockQuery(era, query);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::collections::BTreeSet;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::net::{Ipv4Addr, SocketAddrV4};
|
use std::net::{Ipv4Addr, SocketAddrV4};
|
||||||
use std::time::Duration;
|
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::Request::LedgerQuery(
|
||||||
localstate::queries_v16::LedgerQuery::BlockQuery(
|
localstate::queries_v16::LedgerQuery::BlockQuery(
|
||||||
5,
|
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(
|
let request = AnyCbor::from_encode(localstate::queries_v16::Request::LedgerQuery(
|
||||||
localstate::queries_v16::LedgerQuery::BlockQuery(
|
localstate::queries_v16::LedgerQuery::BlockQuery(
|
||||||
5,
|
5,
|
||||||
localstate::queries_v16::BlockQuery::GetStakeSnapshots(vec![]),
|
localstate::queries_v16::BlockQuery::GetStakeSnapshots(BTreeSet::new()),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue