From c98b7f0c46ebea0a9d212eb5f5a8d90c07a2344b Mon Sep 17 00:00:00 2001 From: Tyera Date: Tue, 4 Apr 2023 18:00:47 -0600 Subject: [PATCH] Only pass num_transactions to EntryNotifier (#31053) * Add EntrySummary struct * Add new entry struct to send to notifier --- entry/src/entry.rs | 16 ++++++++++++++++ geyser-plugin-manager/src/entry_notifier.rs | 8 ++++---- rpc/src/entry_notifier_interface.rs | 4 ++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/entry/src/entry.rs b/entry/src/entry.rs index 786b38622a..8d7304b7d2 100644 --- a/entry/src/entry.rs +++ b/entry/src/entry.rs @@ -146,6 +146,22 @@ pub struct Entry { pub transactions: Vec, } +pub struct EntrySummary { + pub num_hashes: u64, + pub hash: Hash, + pub num_transactions: u64, +} + +impl From for EntrySummary { + fn from(entry: Entry) -> Self { + Self { + num_hashes: entry.num_hashes, + hash: entry.hash, + num_transactions: entry.transactions.len() as u64, + } + } +} + /// Typed entry to distinguish between transaction and tick entries pub enum EntryType { Transactions(Vec), diff --git a/geyser-plugin-manager/src/entry_notifier.rs b/geyser-plugin-manager/src/entry_notifier.rs index 13598b55ac..26a2db2382 100644 --- a/geyser-plugin-manager/src/entry_notifier.rs +++ b/geyser-plugin-manager/src/entry_notifier.rs @@ -2,7 +2,7 @@ use { crate::geyser_plugin_manager::GeyserPluginManager, log::*, - solana_entry::entry::Entry, + solana_entry::entry::EntrySummary, solana_geyser_plugin_interface::geyser_plugin_interface::{ ReplicaEntryInfo, ReplicaEntryInfoVersions, }, @@ -18,7 +18,7 @@ pub(crate) struct EntryNotifierImpl { } impl EntryNotifier for EntryNotifierImpl { - fn notify_entry<'a>(&'a self, slot: Slot, index: usize, entry: &'a Entry) { + fn notify_entry<'a>(&'a self, slot: Slot, index: usize, entry: &'a EntrySummary) { let mut measure = Measure::start("geyser-plugin-notify_plugins_of_entry_info"); let plugin_manager = self.plugin_manager.read().unwrap(); @@ -63,14 +63,14 @@ impl EntryNotifierImpl { fn build_replica_entry_info( slot: Slot, index: usize, - entry: &'_ Entry, + entry: &'_ EntrySummary, ) -> ReplicaEntryInfo<'_> { ReplicaEntryInfo { slot, index, num_hashes: entry.num_hashes, hash: entry.hash.as_ref(), - executed_transaction_count: entry.transactions.len() as u64, + executed_transaction_count: entry.num_transactions, } } } diff --git a/rpc/src/entry_notifier_interface.rs b/rpc/src/entry_notifier_interface.rs index 2b6ba72357..de523fc979 100644 --- a/rpc/src/entry_notifier_interface.rs +++ b/rpc/src/entry_notifier_interface.rs @@ -1,11 +1,11 @@ use { - solana_entry::entry::Entry, + solana_entry::entry::EntrySummary, solana_sdk::clock::Slot, std::sync::{Arc, RwLock}, }; pub trait EntryNotifier { - fn notify_entry(&self, slot: Slot, index: usize, entry: &Entry); + fn notify_entry(&self, slot: Slot, index: usize, entry: &EntrySummary); } pub type EntryNotifierLock = Arc>;