Expose all rewards (fees, rent, voting and staking) in RPC getConfirmedBlock and the cli

This commit is contained in:
Michael Vines
2020-10-09 12:55:35 -07:00
parent 403790760c
commit c5c8da1ac0
13 changed files with 239 additions and 75 deletions

View File

@@ -91,9 +91,20 @@ pub struct Reward {
pub lamports: i64,
#[prost(uint64, tag = "3")]
pub post_balance: u64,
#[prost(enumeration = "RewardType", tag = "4")]
pub reward_type: i32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UnixTimestamp {
#[prost(int64, tag = "1")]
pub timestamp: i64,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum RewardType {
Unspecified = 0,
Fee = 1,
Rent = 2,
Staking = 3,
Voting = 4,
}

View File

@@ -57,10 +57,19 @@ message CompiledInstruction {
bytes data = 3;
}
enum RewardType {
Unspecified = 0;
Fee = 1;
Rent = 2;
Staking = 3;
Voting = 4;
}
message Reward {
string pubkey = 1;
int64 lamports = 2;
uint64 post_balance = 3;
RewardType reward_type = 4;
}
message UnixTimestamp {

View File

@@ -7,7 +7,8 @@ use solana_sdk::{
transaction::Transaction,
};
use solana_transaction_status::{
ConfirmedBlock, InnerInstructions, Reward, TransactionStatusMeta, TransactionWithStatusMeta,
ConfirmedBlock, InnerInstructions, Reward, RewardType, TransactionStatusMeta,
TransactionWithStatusMeta,
};
use std::convert::{TryFrom, TryInto};
@@ -24,6 +25,13 @@ impl From<Reward> for generated::Reward {
pubkey: reward.pubkey,
lamports: reward.lamports,
post_balance: reward.post_balance,
reward_type: match reward.reward_type {
None => generated::RewardType::Unspecified,
Some(RewardType::Fee) => generated::RewardType::Fee,
Some(RewardType::Rent) => generated::RewardType::Rent,
Some(RewardType::Staking) => generated::RewardType::Staking,
Some(RewardType::Voting) => generated::RewardType::Voting,
} as i32,
}
}
}
@@ -34,6 +42,14 @@ impl From<generated::Reward> for Reward {
pubkey: reward.pubkey,
lamports: reward.lamports,
post_balance: reward.post_balance,
reward_type: match reward.reward_type {
0 => None,
1 => Some(RewardType::Fee),
2 => Some(RewardType::Rent),
3 => Some(RewardType::Voting),
4 => Some(RewardType::Staking),
_ => None,
},
}
}
}

View File

@@ -222,6 +222,7 @@ impl From<StoredConfirmedBlockReward> for Reward {
pubkey,
lamports,
post_balance: 0,
reward_type: None,
}
}
}