Skip to content

Instantly share code, notes, and snippets.

@cfromknecht
Last active Jun 28, 2021
Embed
What would you like to do?
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