Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ static int run(int argc, char* argv[]) {
color(Color::Yellow)})
: (tab_index == 1)
? hbox({refresh_indicator,
text(" [↓] select block [Tab/←/→] switch [/] search [q] quit ") |
text(" [↓] select [Tab/←/→] switch [/] search [q] quit ") |
color(Color::GrayDark)})
: (tab_index == 3 && peer_selected >= 0)
? hbox({refresh_indicator, text(" [\u2191/\u2193] navigate [\u23ce] details [a] "
Expand Down
73 changes: 28 additions & 45 deletions src/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <iomanip>
#include <limits>
#include <sstream>
#include <string>

#include <ftxui/dom/elements.hpp>
#include <ftxui/screen/color.hpp>
Expand Down Expand Up @@ -36,6 +37,31 @@ Element label_value(const std::string& lbl, const std::string& val, Color val_co
});
}

static Element mempool_stats_box(const AppState& s) {
double usage_frac = s.mempool_max > 0 ? static_cast<double>(s.mempool_usage) /
static_cast<double>(s.mempool_max)
: 0.0;
Color usage_color = usage_frac > 0.8 ? Color::Red
: usage_frac > 0.5 ? Color::Yellow
: Color::Cyan;
return section_box(
"Mempool",
{
label_value(" Transactions : ", fmt_int(s.mempool_tx)),
label_value(" Virtual size : ", fmt_bytes(s.mempool_bytes)),
label_value(" Total fees : ", fmt_btc(s.total_fee)),
label_value(" Min relay fee : ", fmt_satsvb(s.mempool_min_fee)),
hbox({
text(" Memory usage : ") | color(Color::GrayDark),
text(fmt_bytes(s.mempool_usage) + " / " + fmt_bytes(s.mempool_max)) | bold,
text(" "),
gauge(static_cast<float>(usage_frac)) | flex | color(usage_color),
text(" " + std::to_string(static_cast<int>(usage_frac * 100)) + "% ") | bold |
color(usage_color),
}),
});
}

// --- Dashboard --------------------------------------------------------------
Element render_dashboard(const AppState& s) {
// Chain section
Expand Down Expand Up @@ -74,24 +100,7 @@ Element render_dashboard(const AppState& s) {
label_value(" Relay fee : ", fmt_satsvb(s.relay_fee)),
});

// Mempool section
double usage_frac = s.mempool_max > 0 ? static_cast<double>(s.mempool_usage) /
static_cast<double>(s.mempool_max)
: 0.0;
auto mempool_section = section_box(
"Mempool",
{
label_value(" Transactions: ", fmt_int(s.mempool_tx)),
label_value(" Size : ", fmt_bytes(s.mempool_bytes)),
label_value(" Total fee : ", fmt_btc(s.total_fee, 4)),
label_value(" Min fee : ", fmt_satsvb(s.mempool_min_fee)),
hbox({
text(" Memory : ") | color(Color::GrayDark),
gauge(static_cast<float>(usage_frac)) | flex |
color(usage_frac > 0.8 ? Color::Red : Color::Cyan),
text(" " + fmt_bytes(s.mempool_usage) + " / " + fmt_bytes(s.mempool_max)) | bold,
}),
});
auto mempool_section = mempool_stats_box(s);

return vbox({
hbox({
Expand All @@ -105,33 +114,7 @@ Element render_dashboard(const AppState& s) {

// --- Mempool ----------------------------------------------------------------
Element render_mempool(const AppState& s, int mempool_sel) {
double usage_frac = s.mempool_max > 0 ? static_cast<double>(s.mempool_usage) /
static_cast<double>(s.mempool_max)
: 0.0;
Color usage_color = usage_frac > 0.8 ? Color::Red
: usage_frac > 0.5 ? Color::Yellow
: Color::Cyan;

auto stats_section = section_box(
"Mempool", {
label_value(" Transactions : ", fmt_int(s.mempool_tx)),
label_value(" Virtual size : ", fmt_bytes(s.mempool_bytes)),
label_value(" Total fees : ", fmt_btc(s.total_fee)),
label_value(" Min relay fee : ", fmt_satsvb(s.mempool_min_fee)),
separator(),
text(" Memory usage") | color(Color::GrayDark),
hbox({
text(" "),
gauge(static_cast<float>(usage_frac)) | flex | color(usage_color),
text(" "),
}),
hbox({
text(" Used : ") | color(Color::GrayDark),
text(fmt_bytes(s.mempool_usage)) | bold,
text(" / Max : ") | color(Color::GrayDark),
text(fmt_bytes(s.mempool_max)) | bold,
}),
});
auto stats_section = mempool_stats_box(s);

// Block visualization — vertical fill bars, one column per block.
Element blocks_section;
Expand Down
Loading