feat: format table sizes (#1543)

This commit is contained in:
Bjerg
2023-02-24 18:36:49 +01:00
committed by GitHub
parent a0c82c55b2
commit c54db4f757
3 changed files with 12 additions and 3 deletions

7
Cargo.lock generated
View File

@ -2529,6 +2529,12 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
[[package]]
name = "human_bytes"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39b528196c838e8b3da8b665e08c30958a6f2ede91d79f2ffcd0d4664b9c64eb"
[[package]]
name = "humantime"
version = "2.1.0"
@ -4349,6 +4355,7 @@ dependencies = [
"eyre",
"fdlimit",
"futures",
"human_bytes",
"jsonrpsee",
"metrics",
"metrics-exporter-prometheus",

View File

@ -63,4 +63,5 @@ backon = "0.4"
comfy-table = "6.1.4"
crossterm = "0.25.0"
tui = "0.19.0"
jsonrpsee = { version = "0.16", features = ["server"] }
jsonrpsee = { version = "0.16", features = ["server"] }
human_bytes = "0.4.1"

View File

@ -3,6 +3,7 @@ use crate::dirs::{DbPath, PlatformPath};
use clap::{Parser, Subcommand};
use comfy_table::{Cell, Row, Table as ComfyTable};
use eyre::{Result, WrapErr};
use human_bytes::human_bytes;
use reth_db::{
cursor::{DbCursorRO, Walker},
database::Database,
@ -91,7 +92,7 @@ impl Command {
"Branch Pages",
"Leaf Pages",
"Overflow Pages",
"Total Size (KB)",
"Total Size",
]);
tool.db.view(|tx| {
@ -120,7 +121,7 @@ impl Command {
.add_cell(Cell::new(branch_pages))
.add_cell(Cell::new(leaf_pages))
.add_cell(Cell::new(overflow_pages))
.add_cell(Cell::new(table_size / 1024));
.add_cell(Cell::new(human_bytes(table_size as f64)));
stats_table.add_row(row);
}
Ok::<(), eyre::Report>(())