Skip to content

Commit

Permalink
rusk: add rewards in provisioners http API
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Mar 12, 2024
1 parent f87df68 commit 837679f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 5 additions & 3 deletions rusk/src/lib/http/rusk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ impl Rusk {
let prov: Vec<_> = self
.provisioners(None)
.expect("Cannot query state for provisioners")
.filter_map(|(key, stake)| {
.map(|(key, stake)| {
let key = bs58::encode(key.to_bytes()).into_string();
let (amount, eligibility) = stake.amount.unwrap_or_default();
(amount > 0).then_some(Provisioner {
Provisioner {
amount,
eligibility,
key,
})
reward,
}
})
.collect();

Expand All @@ -121,4 +122,5 @@ struct Provisioner {
key: String,
amount: u64,
eligibility: u64,
reward: u64,
}
7 changes: 3 additions & 4 deletions rusk/tests/common/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,11 @@ impl wallet::StateClient for TestStateClient {
.ok_or(Error::OpeningPositionNotFound(*note.pos()))
}

fn fetch_stake(&self, _pk: &PublicKey) -> Result<StakeInfo, Self::Error> {
fn fetch_stake(&self, pk: &PublicKey) -> Result<StakeInfo, Self::Error> {
let stake = self
.rusk
.provisioners(None)?
.find(|(pk, _)| pk == _pk)
.map(|(_, stake)| StakeInfo {
.provisioner(pk)?
.map(|stake| StakeInfo {
amount: stake.amount,
counter: stake.counter,
reward: stake.reward,
Expand Down

0 comments on commit 837679f

Please sign in to comment.