Skip to content

Commit

Permalink
lightningd: simplify lease update blockheight code.
Browse files Browse the repository at this point in the history
Move the "no lease, return" to the top, to avoid testing twice.  Also,
we won't spam now for most channels.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Oct 17, 2023
1 parent 91699d8 commit 19c581c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lightningd/channel_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ static void try_update_blockheight(struct lightningd *ld,
{
u8 *msg;

/* We don't update the blockheight for non-leased chans */
if (channel->lease_expiry == 0)
return;

log_debug(channel->log, "attempting update blockheight %s",
type_to_string(tmpctx, struct channel_id, &channel->cid));

Expand All @@ -104,8 +108,7 @@ static void try_update_blockheight(struct lightningd *ld,

/* If they're offline, check that we're not too far behind anyway */
if (!channel->owner) {
if (channel->opener == REMOTE
&& channel->lease_expiry > 0) {
if (channel->opener == REMOTE) {
u32 peer_height
= get_blockheight(channel->blockheight_states,
channel->opener, REMOTE);
Expand Down Expand Up @@ -133,10 +136,6 @@ static void try_update_blockheight(struct lightningd *ld,
if (!channel_state_can_add_htlc(channel->state))
return;

/* We don't update the blockheight for non-leased chans */
if (channel->lease_expiry == 0)
return;

log_debug(ld->log, "update_blockheight: height = %u", blockheight);

msg = towire_channeld_blockheight(NULL, blockheight);
Expand Down

0 comments on commit 19c581c

Please sign in to comment.