clboss-xrebalance-view: add an On column showing peer online/offline
Some checks are pending
Code Base Sanity Check / tests (push) Waiting to run
Code Base Sanity Check / coverage (push) Waiting to run
Code Base Sanity Check / build-clang (push) Waiting to run

Adds an "On" column immediately after the opener "O" column: "." when the
peer is connected, "X" when it is offline. Sourced from listpeerchannels'
peer_connected field. Offline peers cannot be rebalanced through, so flagging
them makes it obvious why a suggested source/dest endpoint is unreachable.

The TOTALS rows and CSV output are updated to keep column alignment.
This commit is contained in:
Ken Sedgwick 2026-06-03 15:52:00 -07:00
parent f58bdc54bf
commit 692c80db90
No known key found for this signature in database
GPG key ID: DBD2AF0849D711A9

View file

@ -224,6 +224,8 @@ def compute_row(channel, peer, window_days):
"alias": peer.get("alias") or "",
"scid": channel.get("scid"),
"opener": "L" if channel.get("opener") == "local" else "R",
# '.' connected, 'X' offline -- offline peers can't be rebalanced through
"online": "." if channel.get("peer_connected") else "X",
"cap_sat": cap_sat,
"pct_local": pct_local,
"local_sat": local_sat,
@ -380,6 +382,7 @@ def main():
"scid": scid,
"peer_id": peer_id,
"opener": ch.get("opener"),
"peer_connected": ch.get("peer_connected", False),
"to_us_msat": ch.get("to_us_msat", 0),
"total_msat": ch.get("total_msat", 0),
}
@ -473,7 +476,7 @@ def main():
rows.sort(key=sort_keys[args.sort])
headers = [
"Alias", "SCID", "O",
"Alias", "SCID", "O", "On",
"Cap sat", "Loc %", "LocalBal", "RemoteBal", "TgtFill", "TgtDrain",
"Age d", "Ops d",
"InFwd sat", "InEarn", "InExp", "InNet", "InPpm", "InNetPpm",
@ -485,6 +488,7 @@ def main():
r["alias"],
r["scid"],
r["opener"],
r["online"],
fmt_int(r["cap_sat"]),
fmt_pct(r["pct_local"]),
fmt_int(r["local_sat"]),
@ -539,6 +543,7 @@ def main():
pad_string(label, max_alias), # Alias
f"n={len(subset)}", # SCID (reused for count)
"", # O
"", # On
fmt_int(total_cap), # Cap sat
"", # Loc %
fmt_int(total_local), # LocalBal