-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dump was already dumping the keys and values, so we should keep that, but added in the option of calling the dump() method that produces a digraph of the trie. Additional changes: hashes and binary values are truncated to 6 characters, followed by an ellipsis, and the graphs are rotated so they go left-right. This makes the graphs a lot prettier. Partial paths can still be long but truncating them seemed like a bad idea, so they are the only long string in the boxes now.
- Loading branch information
Showing
4 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (C) 2023, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE.md for licensing terms. | ||
|
||
use clap::Args; | ||
use firewood::db::{Db, DbConfig}; | ||
use firewood::v2::api; | ||
use std::io::stdout; | ||
|
||
#[derive(Debug, Args)] | ||
pub struct Options { | ||
/// The database path (if no path is provided, return an error). Defaults to firewood. | ||
#[arg( | ||
value_name = "DB_NAME", | ||
default_value_t = String::from("firewood"), | ||
help = "Name of the database" | ||
)] | ||
pub db: String, | ||
} | ||
|
||
pub(super) async fn run(opts: &Options) -> Result<(), api::Error> { | ||
log::debug!("dump database {:?}", opts); | ||
let cfg = DbConfig::builder().truncate(false); | ||
|
||
let db = Db::new(opts.db.clone(), cfg.build()).await?; | ||
db.dump(&mut stdout())?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters