From 19c581c33f1e08b25dcf48508c81188bda4be359 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 17 Oct 2023 10:18:44 +1030 Subject: [PATCH] lightningd: simplify lease update blockheight code. 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 --- lightningd/channel_control.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 71682b157190..0682f9f7a8c4 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -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)); @@ -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); @@ -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);