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.
This commit is contained in:
Michael Schmoock
2023-02-09 12:36:18 +01:00
parent b207d2ca9f
commit d1d89047bf

View File

@@ -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)