Skip to content

Commit

Permalink
Support show_entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Dec 19, 2023
1 parent 0111162 commit 5a9e3ff
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions ledger-tool/src/bigtable.rs
Original file line number Diff line number Diff line change
@@ -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,
},
Expand All @@ -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,
Expand Down Expand Up @@ -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<dyn std::error::Error>> {
let bigtable = solana_storage_bigtable::LedgerStorage::new_with_config(config)
Expand All @@ -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(())
}

Expand Down

0 comments on commit 5a9e3ff

Please sign in to comment.