bitcoin: implement is_scid_depth_announceable helper.

The math is a bit tricky, so encapsulate it.

Includes the extra 'e' in 'announcable' as noted by @cdecker :)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-09-22 11:38:43 +09:30
parent 2a74d53841
commit 45381bba33
2 changed files with 14 additions and 3 deletions

View File

@@ -376,9 +376,9 @@ void peer_start_channeld(struct channel *channel,
if (channel->scid) {
scid = *channel->scid;
/* Subtle: depth=1 at funding height. */
reached_announce_depth = get_block_height(ld->topology) + 1 >=
short_channel_id_blocknum(&scid) + ANNOUNCE_MIN_DEPTH;
reached_announce_depth
= is_scid_depth_announceable(&scid,
get_block_height(ld->topology));
log_debug(channel->log, "Already have funding locked in%s",
reached_announce_depth
? " (and ready to announce)" : "");