Convert Blockstore Rewards cf to protobuf (#12860)
* Add Blockstore protobuf cf type * Add Rewards message to proto and make generated pub * Convert Rewards cf to ProtobufColumn * Add bench * Adjust tags * Move solana proto definitions and conversion methods to new crate
This commit is contained in:
52
storage-proto/src/lib.rs
Normal file
52
storage-proto/src/lib.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_sdk::deserialize_utils::default_on_eof;
|
||||
use solana_transaction_status::{Reward, RewardType};
|
||||
|
||||
pub mod convert;
|
||||
|
||||
pub type StoredExtendedRewards = Vec<StoredExtendedReward>;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct StoredExtendedReward {
|
||||
pubkey: String,
|
||||
lamports: i64,
|
||||
#[serde(deserialize_with = "default_on_eof")]
|
||||
post_balance: u64,
|
||||
#[serde(deserialize_with = "default_on_eof")]
|
||||
reward_type: Option<RewardType>,
|
||||
}
|
||||
|
||||
impl From<StoredExtendedReward> for Reward {
|
||||
fn from(value: StoredExtendedReward) -> Self {
|
||||
let StoredExtendedReward {
|
||||
pubkey,
|
||||
lamports,
|
||||
post_balance,
|
||||
reward_type,
|
||||
} = value;
|
||||
Self {
|
||||
pubkey,
|
||||
lamports,
|
||||
post_balance,
|
||||
reward_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Reward> for StoredExtendedReward {
|
||||
fn from(value: Reward) -> Self {
|
||||
let Reward {
|
||||
pubkey,
|
||||
lamports,
|
||||
post_balance,
|
||||
reward_type,
|
||||
..
|
||||
} = value;
|
||||
Self {
|
||||
pubkey,
|
||||
lamports,
|
||||
post_balance,
|
||||
reward_type,
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user