Include post balance information for rewards (#12598)
* Include post balance information for rewards * Add post-balance to stored Reward struct * Handle extended Reward in bigtable Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@@ -87,6 +87,8 @@ pub struct Reward {
|
||||
pub pubkey: std::string::String,
|
||||
#[prost(int64, tag = "2")]
|
||||
pub lamports: i64,
|
||||
#[prost(uint64, tag = "3")]
|
||||
pub post_balance: u64,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct UnixTimestamp {
|
||||
|
@@ -60,6 +60,7 @@ message CompiledInstruction {
|
||||
message Reward {
|
||||
string pubkey = 1;
|
||||
int64 lamports = 2;
|
||||
uint64 post_balance = 3;
|
||||
}
|
||||
|
||||
message UnixTimestamp {
|
||||
|
@@ -23,6 +23,7 @@ impl From<Reward> for generated::Reward {
|
||||
Self {
|
||||
pubkey: reward.pubkey,
|
||||
lamports: reward.lamports,
|
||||
post_balance: reward.post_balance,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +33,7 @@ impl From<generated::Reward> for Reward {
|
||||
Self {
|
||||
pubkey: reward.pubkey,
|
||||
lamports: reward.lamports,
|
||||
post_balance: reward.post_balance,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ use solana_sdk::{
|
||||
transaction::{Transaction, TransactionError},
|
||||
};
|
||||
use solana_transaction_status::{
|
||||
ConfirmedBlock, ConfirmedTransaction, ConfirmedTransactionStatusWithSignature, Rewards,
|
||||
ConfirmedBlock, ConfirmedTransaction, ConfirmedTransactionStatusWithSignature, Reward,
|
||||
TransactionStatus, TransactionStatusMeta, TransactionWithStatusMeta,
|
||||
};
|
||||
use std::{collections::HashMap, convert::TryInto};
|
||||
@@ -86,7 +86,7 @@ struct StoredConfirmedBlock {
|
||||
blockhash: String,
|
||||
parent_slot: Slot,
|
||||
transactions: Vec<StoredConfirmedBlockTransaction>,
|
||||
rewards: Rewards,
|
||||
rewards: StoredConfirmedBlockRewards,
|
||||
block_time: Option<UnixTimestamp>,
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ impl From<ConfirmedBlock> for StoredConfirmedBlock {
|
||||
blockhash,
|
||||
parent_slot,
|
||||
transactions: transactions.into_iter().map(|tx| tx.into()).collect(),
|
||||
rewards,
|
||||
rewards: rewards.into_iter().map(|reward| reward.into()).collect(),
|
||||
block_time,
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ impl From<StoredConfirmedBlock> for ConfirmedBlock {
|
||||
blockhash,
|
||||
parent_slot,
|
||||
transactions: transactions.into_iter().map(|tx| tx.into()).collect(),
|
||||
rewards,
|
||||
rewards: rewards.into_iter().map(|reward| reward.into()).collect(),
|
||||
block_time,
|
||||
}
|
||||
}
|
||||
@@ -206,6 +206,34 @@ impl From<TransactionStatusMeta> for StoredConfirmedBlockTransactionStatusMeta {
|
||||
}
|
||||
}
|
||||
|
||||
type StoredConfirmedBlockRewards = Vec<StoredConfirmedBlockReward>;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct StoredConfirmedBlockReward {
|
||||
pubkey: String,
|
||||
lamports: i64,
|
||||
}
|
||||
|
||||
impl From<StoredConfirmedBlockReward> for Reward {
|
||||
fn from(value: StoredConfirmedBlockReward) -> Self {
|
||||
let StoredConfirmedBlockReward { pubkey, lamports } = value;
|
||||
Self {
|
||||
pubkey,
|
||||
lamports,
|
||||
post_balance: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Reward> for StoredConfirmedBlockReward {
|
||||
fn from(value: Reward) -> Self {
|
||||
let Reward {
|
||||
pubkey, lamports, ..
|
||||
} = value;
|
||||
Self { pubkey, lamports }
|
||||
}
|
||||
}
|
||||
|
||||
// A serialized `TransactionInfo` is stored in the `tx` table
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct TransactionInfo {
|
||||
|
Reference in New Issue
Block a user