decred / dcrlnd

Decred Lightning Network Daemon ⚡️
MIT License
36 stars 24 forks source link

Autoclose channels that have not been reestablished for a long time #196

Closed matheusd closed 9 months ago

matheusd commented 10 months ago

This adds automation for closing channels that haven't been reestablished for some time.

We add tracking for how long a peer has been online, while NOT reestablishing a channel through the use of ChannelReestablish P2P messages. Channels with peers that have been online for some time but which have NOT been reestablished though the use of ChannelReestablish messages are good candidates for being force closed, because it is likely the remote peer has lost the ability to use them (for example, due to restoring the node after data loss without the use of an SCB file).

Given that the metric tracks the total time across restarts and only while the remote peer is online, we use a default of 72h for the threshold to auto close the channel. This should be a reasonable compromise between not closing too fast on hubs (that are online 24/7) and ephemeral nodes (that may be online only for an hour or two a day)

A config parameter is added to control the threshold time used for autoclosing and an itest is added that asserts the correct behavior.