Autoclose channels that have not been reestablished for a long time #196
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.