Skip to content

Commit

Permalink
gossipd: prune channels unless *both* peers have refreshed.
Browse files Browse the repository at this point in the history
See lightning/bolts#767

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: channels now pruned after two weeks unless both peers refresh it (see lightning-rfc#767)
  • Loading branch information
rustyrussell committed Aug 24, 2020
1 parent 7ad8fde commit 57dd5be
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CCANDIR := ccan

# Where we keep the BOLT RFCs
BOLTDIR := ../lightning-rfc/
BOLTVERSION := b4132ff24025742ad8e175d52b68380520e9f0b7
BOLTVERSION := 7e8c478aef0d23a445845b7d297b0e804583697c

-include config.vars

Expand Down
2 changes: 1 addition & 1 deletion common/gossip_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
/* BOLT #7:
*
* A node:
* - if a channel's latest `channel_update`s `timestamp` is older than two weeks
* - if a channel's oldest `channel_update`s `timestamp` is older than two weeks
* (1209600 seconds):
* - MAY prune the channel.
* - MAY ignore the channel.
Expand Down
2 changes: 1 addition & 1 deletion gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ static void gossip_send_keepalive_update(struct daemon *daemon,
/* BOLT #7:
*
* A node:
* - if a channel's latest `channel_update`s `timestamp` is older than two weeks
* - if a channel's oldest `channel_update`s `timestamp` is older than two weeks
* (1209600 seconds):
* - MAY prune the channel.
* - MAY ignore the channel.
Expand Down
14 changes: 10 additions & 4 deletions gossipd/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -2777,10 +2777,16 @@ void route_prune(struct routing_state *rstate)
if (!is_chan_public(chan))
continue;

if ((!is_halfchan_defined(&chan->half[0])
|| chan->half[0].bcast.timestamp < highwater)
&& (!is_halfchan_defined(&chan->half[1])
|| chan->half[1].bcast.timestamp < highwater)) {
/* BOLT #7:
* - if a channel's oldest `channel_update`s `timestamp` is
* older than two weeks (1209600 seconds):
* - MAY prune the channel.
*/
/* This is a fancy way of saying "both ends must refresh!" */
if (!is_halfchan_defined(&chan->half[0])
|| chan->half[0].bcast.timestamp < highwater
|| !is_halfchan_defined(&chan->half[1])
|| chan->half[1].bcast.timestamp < highwater) {
status_debug(
"Pruning channel %s from network view (ages %"PRIu64" and %"PRIu64"s)",
type_to_string(tmpctx, struct short_channel_id,
Expand Down

0 comments on commit 57dd5be

Please sign in to comment.