Skip to content

Commit f6ffeac

Browse files
committed
fix(db): make db get --raw work with DupSort tables
1 parent 7957131 commit f6ffeac

File tree

1 file changed

+19
-4
lines changed
  • crates/cli/commands/src/db

1 file changed

+19
-4
lines changed

crates/cli/commands/src/db/get.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
use alloy_consensus::Header;
22
use alloy_primitives::{hex, BlockHash};
33
use clap::Parser;
4-
use reth_db::static_file::{
5-
ColumnSelectorOne, ColumnSelectorTwo, HeaderWithHashMask, ReceiptMask, TransactionMask,
4+
use reth_db::{
5+
static_file::{
6+
ColumnSelectorOne, ColumnSelectorTwo, HeaderWithHashMask, ReceiptMask, TransactionMask,
7+
},
8+
RawDupSort,
69
};
710
use reth_db_api::{
811
table::{Decompress, DupSort, Table},
@@ -177,9 +180,21 @@ impl<N: ProviderNodeTypes> TableViewer<()> for GetValueViewer<'_, N> {
177180
// process dupsort table
178181
let subkey = table_subkey::<T>(self.subkey.as_deref())?;
179182

180-
match self.tool.get_dup::<T>(key, subkey)? {
183+
let content = if self.raw {
184+
self.tool
185+
.get_dup::<RawDupSort<T>>(RawKey::from(key), RawKey::from(subkey))?
186+
.map(|content| hex::encode_prefixed(content.raw_value()))
187+
} else {
188+
self.tool
189+
.get_dup::<T>(key, subkey)?
190+
.as_ref()
191+
.map(serde_json::to_string_pretty)
192+
.transpose()?
193+
};
194+
195+
match content {
181196
Some(content) => {
182-
println!("{}", serde_json::to_string_pretty(&content)?);
197+
println!("{content}");
183198
}
184199
None => {
185200
error!(target: "reth::cli", "No content for the given table subkey.");

0 commit comments

Comments
 (0)