Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Add new geyser BlockInfo version to hold new rewards field
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Jan 12, 2024
1 parent 5ee7283 commit c8d2383
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
32 changes: 29 additions & 3 deletions geyser-plugin-interface/src/geyser_plugin_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
signature::Signature,
transaction::SanitizedTransaction,
},
solana_transaction_status::{Reward, TransactionStatusMeta},
solana_transaction_status::{Reward, RewardType, TransactionStatusMeta},
std::{any::Any, error, io},
thiserror::Error,
};
Expand Down Expand Up @@ -217,7 +217,7 @@ pub enum ReplicaEntryInfoVersions<'a> {
pub struct ReplicaBlockInfo<'a> {
pub slot: Slot,
pub blockhash: &'a str,
pub rewards: &'a [Reward],
pub rewards: &'a [DeprecatedReward],
pub block_time: Option<UnixTimestamp>,
pub block_height: Option<u64>,
}
Expand All @@ -230,7 +230,7 @@ pub struct ReplicaBlockInfoV2<'a> {
pub parent_blockhash: &'a str,
pub slot: Slot,
pub blockhash: &'a str,
pub rewards: &'a [Reward],
pub rewards: &'a [DeprecatedReward],
pub block_time: Option<UnixTimestamp>,
pub block_height: Option<u64>,
pub executed_transaction_count: u64,
Expand All @@ -240,6 +240,31 @@ pub struct ReplicaBlockInfoV2<'a> {
#[derive(Clone, Debug)]
#[repr(C)]
pub struct ReplicaBlockInfoV3<'a> {
pub parent_slot: Slot,
pub parent_blockhash: &'a str,
pub slot: Slot,
pub blockhash: &'a str,
pub rewards: &'a [DeprecatedReward],
pub block_time: Option<UnixTimestamp>,
pub block_height: Option<u64>,
pub executed_transaction_count: u64,
pub entry_count: u64,
}

#[derive(Clone, Debug)]
#[repr(C)]
pub struct DeprecatedReward {
pub pubkey: String,
pub lamports: i64,
pub post_balance: u64,
pub reward_type: Option<RewardType>,
pub commission: Option<u8>,
}

/// Adding num_partitions field to each Reward.
#[derive(Clone, Debug)]
#[repr(C)]
pub struct ReplicaBlockInfoV4<'a> {
pub parent_slot: Slot,
pub parent_blockhash: &'a str,
pub slot: Slot,
Expand All @@ -256,6 +281,7 @@ pub enum ReplicaBlockInfoVersions<'a> {
V0_0_1(&'a ReplicaBlockInfo<'a>),
V0_0_2(&'a ReplicaBlockInfoV2<'a>),
V0_0_3(&'a ReplicaBlockInfoV3<'a>),
V0_0_4(&'a ReplicaBlockInfoV4<'a>),
}

/// Errors returned by plugin calls
Expand Down
8 changes: 4 additions & 4 deletions geyser-plugin-manager/src/block_metadata_notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use {
log::*,
solana_accounts_db::stake_rewards::RewardInfo,
solana_geyser_plugin_interface::geyser_plugin_interface::{
ReplicaBlockInfoV3, ReplicaBlockInfoVersions,
ReplicaBlockInfoV4, ReplicaBlockInfoVersions,
},
solana_measure::measure::Measure,
solana_metrics::*,
Expand Down Expand Up @@ -52,7 +52,7 @@ impl BlockMetadataNotifier for BlockMetadataNotifierImpl {
executed_transaction_count,
entry_count,
);
let block_info = ReplicaBlockInfoVersions::V0_0_3(&block_info);
let block_info = ReplicaBlockInfoVersions::V0_0_4(&block_info);
match plugin.notify_block_metadata(block_info) {
Err(err) => {
error!(
Expand Down Expand Up @@ -107,8 +107,8 @@ impl BlockMetadataNotifierImpl {
block_height: Option<u64>,
executed_transaction_count: u64,
entry_count: u64,
) -> ReplicaBlockInfoV3<'a> {
ReplicaBlockInfoV3 {
) -> ReplicaBlockInfoV4<'a> {
ReplicaBlockInfoV4 {
parent_slot,
parent_blockhash,
slot,
Expand Down

0 comments on commit c8d2383

Please sign in to comment.