mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 22:31:48 +01:00
channeld: delay sending channel_announcement by 60 seconds.
We currently send channel_announcement as soon as we and our peer agree it's 6 blocks deep. In theory, our other peers might not have seen that block yet though, so delay a little. This is mitigated by two factors: 1. lnd will stash any "not ready yet" channel_announcements anyway. 2. c-lightning doesn't enforce the 6 depth minimum at all. We should not rely on other nodes' generosity or laxity, however! Next release, we can start enforcing the depth limit, and maybe stashing ones which don't quite make it (or simply enforce depth 5, not 6). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
3e74ca4b86
commit
2b3003f25b
3 changed files with 14 additions and 3 deletions
|
@ -67,6 +67,7 @@ msgdata,channel_init,upfront_shutdown_script_len,u16,
|
|||
msgdata,channel_init,upfront_shutdown_script,u8,upfront_shutdown_script_len
|
||||
msgdata,channel_init,remote_ann_node_sig,?secp256k1_ecdsa_signature,
|
||||
msgdata,channel_init,remote_ann_bitcoin_sig,?secp256k1_ecdsa_signature,
|
||||
msgdata,channel_init,announce_delay,u32,
|
||||
|
||||
# master->channeld funding hit new depth(funding locked if >= lock depth)
|
||||
msgtype,channel_funding_depth,1002
|
||||
|
|
|
|
@ -110,6 +110,9 @@ struct peer {
|
|||
u64 commit_timer_attempts;
|
||||
u32 commit_msec;
|
||||
|
||||
/* How long to delay before broadcasting announcement? */
|
||||
u32 announce_delay;
|
||||
|
||||
/* Are we expecting a pong? */
|
||||
bool expecting_pong;
|
||||
|
||||
|
@ -500,7 +503,10 @@ static void channel_announcement_negotiate(struct peer *peer)
|
|||
&peer->announcement_node_sigs[REMOTE],
|
||||
&peer->announcement_bitcoin_sigs[REMOTE])));
|
||||
|
||||
announce_channel(peer);
|
||||
/* Give other nodes time to notice new block. */
|
||||
notleak(new_reltimer(&peer->timers, peer,
|
||||
time_from_sec(peer->announce_delay),
|
||||
announce_channel, peer));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2904,7 +2910,8 @@ static void init_channel(struct peer *peer)
|
|||
&peer->localfeatures,
|
||||
&peer->remote_upfront_shutdown_script,
|
||||
&remote_ann_node_sig,
|
||||
&remote_ann_bitcoin_sig)) {
|
||||
&remote_ann_bitcoin_sig,
|
||||
&peer->announce_delay)) {
|
||||
master_badmsg(WIRE_CHANNEL_INIT, msg);
|
||||
}
|
||||
/* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = HSM */
|
||||
|
|
|
@ -424,7 +424,10 @@ void peer_start_channeld(struct channel *channel,
|
|||
channel->peer->localfeatures,
|
||||
channel->remote_upfront_shutdown_script,
|
||||
remote_ann_node_sig,
|
||||
remote_ann_bitcoin_sig);
|
||||
remote_ann_bitcoin_sig,
|
||||
/* Delay announce by 60 seconds after
|
||||
* seeing block (adjustable if dev) */
|
||||
ld->topology->poll_seconds * 2);
|
||||
|
||||
/* We don't expect a response: we are triggered by funding_depth_cb. */
|
||||
subd_send_msg(channel->owner, take(initmsg));
|
||||
|
|
Loading…
Add table
Reference in a new issue