Expose all rewards (fees, rent, voting and staking) in RPC getConfirmedBlock and the cli
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -222,6 +222,7 @@ impl From<StoredConfirmedBlockReward> for Reward {
|
||||
pubkey,
|
||||
lamports,
|
||||
post_balance: 0,
|
||||
reward_type: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user