Skip to content

Instantly share code, notes, and snippets.

@cfromknecht
Last active June 28, 2021 12:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfromknecht/6ee9f3beed97878112909771d1c847c2 to your computer and use it in GitHub Desktop.
Save cfromknecht/6ee9f3beed97878112909771d1c847c2 to your computer and use it in GitHub Desktop.
Stricter Graph Pruning

edge count:

lncli describegraph | jq '.edges | length'

32055

node count:

lncli describegraph | jq '.nodes | length'

5672

recent edge count:

lncli describegraph | jq '[.edges[] | select(.node1_policy.last_update > now-60*60*24*7*2 and .node2_policy.last_update > now-60*60*24*7*2)] | length'

23070 (71.97%)

stale edge count:

lncli describegraph | jq '[.edges[] | select((.node1_policy.last_update > now-60*60*24*7*2 and .node2_policy.last_update > now-60*60*24*7*2) | not)] | length'

8985 (28.03%)

only one stale edge count:

lncli describegraph | jq '[.edges[] | select((.node1_policy.last_update > now-60*60*24*7*2 and .node2_policy.last_update <= now-60*60*24*7*2) or (.node1_policy.last_update <= now-60*60*24*7*2 and .node2_policy.last_update > now-60*60*24*7*2))] | length'

8410 (26.24%)

both stale edge count:

lncli describegraph | jq '[.edges[] | select((.node1_policy.last_update < now-60*60*24*7*2) and (.node2_policy.last_update < now-60*60*24*7*2))] | length'

575 (1.79%)

only one stale, channels by node:

lncli describegraph | jq '[[.edges[] | select((.node1_policy.last_update > now-60*60*24*7*2 and .node2_policy.last_update <= now-60*60*24*7*2) or (.node1_policy.last_update <= now-60*60*24*7*2 and .node2_policy.last_update > now-60*60*24*7*2))] | map([{pubkey: .node1_pub, last_update: .node1_policy.last_update, chanid: .channel_id}, {pubkey: .node2_pub, last_update: .node2_policy.last_update, chanid: .channel_id}]) | add[] | select(.last_update <= now-60*60*24*7*2)] | group_by(.pubkey)[] | {(.[0].pubkey): [.[] | {chanid: .chanid, last_update: .last_update}]}'

only one stale, channels by node, sorted by highest count:

lncli describegraph | jq '[[[.edges[] | select((.node1_policy.last_update > now-60*60*24*7*2 and .node2_policy.last_update <= now-60*60*24*7*2) or (.node1_policy.last_update <= now-60*60*24*7*2 and .node2_policy.last_update > now-60*60*24*7*2))] | map([{pubkey: .node1_pub, last_update: .node1_policy.last_update, chanid: .channel_id}, {pubkey: .node2_pub, last_update: .node2_policy.last_update, chanid: .channel_id}]) | add[] | select(.last_update <= now-60*60*24*7*2)] | group_by(.pubkey)[] | {pubkey: (.[0].pubkey), length: length}] | sort_by(.length) | reverse'

nodes that participate in a channel where only one end is stale

lncli describegraph | jq '[[[.edges[] | select((.node1_policy.last_update > now-60*60*24*7*2 and .node2_policy.last_update <= now-60*60*24*7*2) or (.node1_policy.last_update <= now-60*60*24*7*2 and .node2_policy.last_update > now-60*60*24*7*2))] | map([{pubkey: .node1_pub, last_update: .node1_policy.last_update, chanid: .channel_id}, {pubkey: .node2_pub, last_update: .node2_policy.last_update, chanid: .channel_id}]) | add[] | select(.last_update <= now-60*60*24*7*2)] | group_by(.pubkey)[] | {pubkey: (.[0].pubkey), length: length}] | length'

2633 (46.42%)

nodes that participate in no more than X channels where only one end is stale:

lncli describegraph | jq '[[[[.edges[] | select((.node1_policy.last_update > now-60*60*24*7*2 and .node2_policy.last_update <= now-60*60*24*7*2) or (.node1_policy.last_update <= now-60*60*24*7*2 and .node2_policy.last_update > now-60*60*24*7*2))] | map([{pubkey: .node1_pub, last_update: .node1_policy.last_update, chanid: .channel_id}, {pubkey: .node2_pub, last_update: .node2_policy.last_update, chanid: .channel_id}]) | add[] | select(.last_update <= now-60*60*24*7*2)] | group_by(.pubkey)[] | {pubkey: (.[0].pubkey), length: length}] | sort_by(.length) | reverse[] | select(.length < X)] | length'

for X <= 3: 1758 (30.99%)

for X <= 2: 1257 (22.16%)

nodes that participate in at least X channels where only one end is stale:

lncli describegraph | jq '[[[.edges[] | select((.node1_policy.last_update > now-60*60*24*7*2 and .node2_policy.last_update <= now-60*60*24*7*2) or (.node1_policy.last_update <= now-60*60*24*7*2 and .node2_policy.last_update > now-60*60*24*7*2))] | map([{pubkey: .node1_pub, last_update: .node1_policy.last_update, chanid: .channel_id}, {pubkey: .node2_pub, last_update: .node2_policy.last_update, chanid: .channel_id}]) | add[] | select(.last_update <= now-60*60*24*7*2)] | group_by(.pubkey)[] | {pubkey: (.[0].pubkey), length: length} | select(.length >= X)] | length'

for X >= 3: 875 (15.42%)

for X >= 2: 1376 (24.26%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment