From bc8300a3089ca024c12429aa9fcbf23d2f894029 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 17 Dec 2020 10:04:53 -0800 Subject: [PATCH] Add transactionCount field to GetEpochInfo (cherry picked from commit efc091e28adffe0839faa9a7bc0dd36ba36a33b6) --- cli-output/src/cli_output.rs | 3 +++ client/src/mock_sender.rs | 1 + runtime/src/bank.rs | 2 ++ sdk/src/epoch_info.rs | 3 +++ 4 files changed, 9 insertions(+) diff --git a/cli-output/src/cli_output.rs b/cli-output/src/cli_output.rs index b7f8d6a875..4462513be1 100644 --- a/cli-output/src/cli_output.rs +++ b/cli-output/src/cli_output.rs @@ -241,6 +241,9 @@ impl fmt::Display for CliEpochInfo { )?; writeln_name_value(f, "Slot:", &self.epoch_info.absolute_slot.to_string())?; writeln_name_value(f, "Epoch:", &self.epoch_info.epoch.to_string())?; + if let Some(transaction_count) = &self.epoch_info.transaction_count { + writeln_name_value(f, "Transaction Count:", &transaction_count.to_string())?; + } let start_slot = self.epoch_info.absolute_slot - self.epoch_info.slot_index; let end_slot = start_slot + self.epoch_info.slots_in_epoch; writeln_name_value( diff --git a/client/src/mock_sender.rs b/client/src/mock_sender.rs index 1ec492b849..7e690c74c7 100644 --- a/client/src/mock_sender.rs +++ b/client/src/mock_sender.rs @@ -65,6 +65,7 @@ impl RpcSender for MockSender { slots_in_epoch: 32, absolute_slot: 34, block_height: 34, + transaction_count: Some(123), })?, RpcRequest::GetFeeCalculatorForBlockhash => { let value = if self.url == "blockhash_expired" { diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 0b88046e07..d60968e5d0 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -4358,12 +4358,14 @@ impl Bank { let block_height = self.block_height(); let (epoch, slot_index) = self.get_epoch_and_slot_index(absolute_slot); let slots_in_epoch = self.get_slots_in_epoch(epoch); + let transaction_count = Some(self.transaction_count()); EpochInfo { epoch, slot_index, slots_in_epoch, absolute_slot, block_height, + transaction_count, } } diff --git a/sdk/src/epoch_info.rs b/sdk/src/epoch_info.rs index 943c4a5513..781249e062 100644 --- a/sdk/src/epoch_info.rs +++ b/sdk/src/epoch_info.rs @@ -17,4 +17,7 @@ pub struct EpochInfo { /// The current block height pub block_height: u64, + + /// Total number of transactions processed without error since genesis + pub transaction_count: Option, }