Skip to content

Commit

Permalink
chore(cli): print an hex encoded string instead on `reth db get ... -…
Browse files Browse the repository at this point in the history
…-raw` (#11195)
  • Loading branch information
joshieDo authored Sep 25, 2024
1 parent 4884c00 commit 2350403
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/cli/commands/src/db/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use reth_db::{
use reth_db_api::table::{Decompress, DupSort, Table};
use reth_db_common::DbTool;
use reth_node_builder::NodeTypesWithDB;
use reth_primitives::Header;
use reth_primitives::{hex, Header};
use reth_provider::StaticFileProviderFactory;
use reth_static_file_types::StaticFileSegment;
use tracing::error;
Expand Down Expand Up @@ -92,14 +92,14 @@ impl Command {
match content {
Some(content) => {
if raw {
println!("{content:?}");
println!("{}", hex::encode_prefixed(&content[0]));
} else {
match segment {
StaticFileSegment::Headers => {
let header = Header::decompress(content[0].as_slice())?;
let block_hash = BlockHash::decompress(content[1].as_slice())?;
println!(
"{}\n{}",
"Header\n{}\n\nBlockHash\n{}",
serde_json::to_string_pretty(&header)?,
serde_json::to_string_pretty(&block_hash)?
);
Expand Down Expand Up @@ -157,7 +157,7 @@ impl<N: NodeTypesWithDB<ChainSpec = ChainSpec>> TableViewer<()> for GetValueView
let content = if self.raw {
self.tool
.get::<RawTable<T>>(RawKey::from(key))?
.map(|content| format!("{:?}", content.raw_value()))
.map(|content| hex::encode_prefixed(content.raw_value()))
} else {
self.tool.get::<T>(key)?.as_ref().map(serde_json::to_string_pretty).transpose()?
};
Expand Down

0 comments on commit 2350403

Please sign in to comment.