Bladeren bron

store-tool: Adds verbose cli option (#1628)

Brooks 1 jaar geleden
bovenliggende
commit
f423d5b685
1 gewijzigde bestanden met toevoegingen van 21 en 9 verwijderingen
  1. 21 9
      accounts-db/store-tool/src/main.rs

+ 21 - 9
accounts-db/store-tool/src/main.rs

@@ -14,10 +14,18 @@ fn main() {
                 .index(1)
                 .takes_value(true)
                 .value_name("PATH")
-                .help("account storage file to open"),
+                .help("Account storage file to open"),
+        )
+        .arg(
+            Arg::with_name("verbose")
+                .short("v")
+                .long("verbose")
+                .takes_value(false)
+                .help("Show additional account information"),
         )
         .get_matches();
 
+    let verbose = matches.is_present("verbose");
     let file = value_t_or_exit!(matches, "file", String);
     let store = AppendVec::new_for_store_tool(&file).unwrap_or_else(|err| {
         eprintln!("failed to open storage file '{file}': {err}");
@@ -35,14 +43,18 @@ fn main() {
     let mut num_accounts = Saturating(0usize);
     let mut stored_accounts_size = Saturating(0);
     store.scan_accounts(|account| {
-        println!(
-            "{:#0offset_width$x}: {:44}, owner: {:44}, data size: {:data_size_width$}, lamports: {}",
-            account.offset(),
-            account.pubkey().to_string(),
-            account.owner().to_string(),
-            account.data_len(),
-            account.lamports(),
-        );
+        if verbose {
+            println!("{account:?}");
+        } else {
+            println!(
+                "{:#0offset_width$x}: {:44}, owner: {:44}, data size: {:data_size_width$}, lamports: {}",
+                account.offset(),
+                account.pubkey().to_string(),
+                account.owner().to_string(),
+                account.data_len(),
+                account.lamports(),
+            );
+        }
         num_accounts += 1;
         stored_accounts_size += account.stored_size();
     });