server: produces a channel backup upon shutdown

This is needed to keep channel.backup up-to-date if the node is stopped.
This commit is contained in:
Boris Nagaev 2024-03-25 20:30:57 -03:00
parent fb397c11f1
commit 29946df4e5
No known key found for this signature in database

View File

@ -2504,6 +2504,23 @@ func (s *server) Stop() error {
if err := s.htlcNotifier.Stop(); err != nil {
srvrLog.Warnf("failed to stop htlcNotifier: %v", err)
}
// Update channel.backup file. Make sure to do it before
// stopping chanSubSwapper.
singles, err := chanbackup.FetchStaticChanBackups(
s.chanStateDB, s.addrSource,
)
if err != nil {
srvrLog.Warnf("failed to fetch channel states: %v",
err)
} else {
err := s.chanSubSwapper.ManualUpdate(singles)
if err != nil {
srvrLog.Warnf("Manual update of channel "+
"backup failed: %v", err)
}
}
if err := s.chanSubSwapper.Stop(); err != nil {
srvrLog.Warnf("failed to stop chanSubSwapper: %v", err)
}