From 5a9e3ffd1dd9dac8b1c1b48680427e453edb859a Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 19 Dec 2023 14:39:38 -0700 Subject: [PATCH] Support show_entries --- ledger-tool/src/bigtable.rs | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/ledger-tool/src/bigtable.rs b/ledger-tool/src/bigtable.rs index e9baabf1c4d749..8fd28fae7bfdc8 100644 --- a/ledger-tool/src/bigtable.rs +++ b/ledger-tool/src/bigtable.rs @@ -1,6 +1,9 @@ //! The `bigtable` subcommand use { - crate::{ledger_path::canonicalize_ledger_path, output::CliEntries}, + crate::{ + ledger_path::canonicalize_ledger_path, + output::{CliBlockWithEntries, CliEntries, EncodedConfirmedBlockWithEntries}, + }, clap::{ value_t, value_t_or_exit, values_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand, }, @@ -23,8 +26,8 @@ use { solana_sdk::{clock::Slot, pubkey::Pubkey, signature::Signature}, solana_storage_bigtable::CredentialType, solana_transaction_status::{ - BlockEncodingOptions, ConfirmedBlock, EncodeError, TransactionDetails, - UiTransactionEncoding, VersionedConfirmedBlock, + BlockEncodingOptions, ConfirmedBlock, EncodeError, EncodedConfirmedBlock, + TransactionDetails, UiTransactionEncoding, VersionedConfirmedBlock, }, std::{ cmp::min, @@ -113,7 +116,7 @@ async fn first_available_block( async fn block( slot: Slot, output_format: OutputFormat, - _show_entries: bool, + show_entries: bool, config: solana_storage_bigtable::LedgerStorageConfig, ) -> Result<(), Box> { let bigtable = solana_storage_bigtable::LedgerStorage::new_with_config(config) @@ -135,12 +138,25 @@ async fn block( format!("Failed to process unsupported transaction version ({version}) in block") } })?; - - let cli_block = CliBlock { - encoded_confirmed_block: encoded_block.into(), - slot, - }; - println!("{}", output_format.formatted_string(&cli_block)); + let encoded_block: EncodedConfirmedBlock = encoded_block.into(); + + if show_entries { + let entries = bigtable.get_entries(slot).await?; + let cli_block = CliBlockWithEntries { + encoded_confirmed_block: EncodedConfirmedBlockWithEntries::try_from( + encoded_block, + entries, + )?, + slot, + }; + println!("{}", output_format.formatted_string(&cli_block)); + } else { + let cli_block = CliBlock { + encoded_confirmed_block: encoded_block, + slot, + }; + println!("{}", output_format.formatted_string(&cli_block)); + } Ok(()) }