mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
lightningd: set last_stable_connection 1 minute after channel reestablished.
This is a nice reflection of channel stability: in particular, worse case ping time is 45 seconds, so we should have had some traffic. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
0575f8a544
commit
95bc730894
3 changed files with 17 additions and 1 deletions
|
@ -314,6 +314,7 @@ struct channel *new_unsaved_channel(struct peer *peer,
|
|||
channel->lease_commit_sig = NULL;
|
||||
channel->ignore_fee_limits = ld->config.ignore_fee_limits;
|
||||
channel->last_stable_connection = 0;
|
||||
channel->stable_conn_timer = NULL;
|
||||
|
||||
/* No shachain yet */
|
||||
channel->their_shachain.id = 0;
|
||||
|
@ -603,6 +604,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
|||
channel->state_change_cause = reason;
|
||||
channel->ignore_fee_limits = ignore_fee_limits;
|
||||
channel->last_stable_connection = last_stable_connection;
|
||||
channel->stable_conn_timer = NULL;
|
||||
/* Populate channel->channel_gossip */
|
||||
channel_gossip_init(channel, take(peer_update));
|
||||
|
||||
|
|
|
@ -313,6 +313,7 @@ struct channel {
|
|||
|
||||
/* Last time we had a stable connection, if any (0 = none) */
|
||||
u64 last_stable_connection;
|
||||
struct oneshot *stable_conn_timer;
|
||||
};
|
||||
|
||||
/* Is channel owned (and should be talking to peer) */
|
||||
|
|
|
@ -841,10 +841,23 @@ void channel_gossip_init_done(struct lightningd *ld)
|
|||
}
|
||||
}
|
||||
|
||||
static void channel_reestablished_stable(struct channel *channel)
|
||||
{
|
||||
channel->stable_conn_timer = NULL;
|
||||
channel->last_stable_connection = time_now().ts.tv_sec;
|
||||
wallet_channel_save(channel->peer->ld->wallet, channel);
|
||||
}
|
||||
|
||||
/* Peer has connected and successfully reestablished channel. */
|
||||
void channel_gossip_channel_reestablished(struct channel *channel)
|
||||
{
|
||||
channel->reestablished = true;
|
||||
tal_free(channel->stable_conn_timer);
|
||||
channel->stable_conn_timer = new_reltimer(channel->peer->ld->timers,
|
||||
channel, time_from_sec(60),
|
||||
channel_reestablished_stable,
|
||||
channel);
|
||||
|
||||
log_debug(channel->log, "channel_gossip: reestablished");
|
||||
|
||||
/* Ignore unsaved channels */
|
||||
|
@ -882,7 +895,7 @@ void channel_gossip_channel_reestablished(struct channel *channel)
|
|||
|
||||
void channel_gossip_channel_disconnect(struct channel *channel)
|
||||
{
|
||||
log_debug(channel->log, "channel_gossip: NO LONGER reestablished");
|
||||
channel->stable_conn_timer = tal_free(channel->stable_conn_timer);
|
||||
channel->reestablished = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue