From d1d89047bffc1d308cd6440eb6aa8d191497230c Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Thu, 9 Feb 2023 12:36:18 +0100 Subject: [PATCH] summary: sort output by scid per default The sort order got changed to random(?) I think when cln changed to have multiple channels per peer supprt. This restores the old sort by scid order, which is nice since old channels are upfront. Maybe we can add other orderings in later commits by copfig options and `summary` method paramters. --- summary/summary.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/summary/summary.py b/summary/summary.py index 60e702d..f51790f 100755 --- a/summary/summary.py +++ b/summary/summary.py @@ -2,6 +2,7 @@ from pyln.client import Plugin, Millisatoshi from packaging import version from collections import namedtuple +from operator import attrgetter from summary_avail import trace_availability, addpeer import pyln.client import requests @@ -180,7 +181,8 @@ def summary(plugin, exclude=''): reply['avail_in'] += ' ({})'.format(to_fiatstr(avail_in)) reply['fees_collected'] += ' ({})'.format(to_fiatstr(info['fees_collected_msat'])) - if chans != []: + if len(chans) > 0: + chans = sorted(chans, key=attrgetter('scid')) reply['channels_flags'] = 'P:private O:offline' reply['channels'] = ["\n"] biggest = max(max(int(c.ours), int(c.theirs)) for c in chans)