rpcserver: don't skip pending channels in backup subscription

The synchronous call to get all channel backups also include
channels that are pending at the moment of the call. A previous
commit added pending channels to the file based backup as well. So
this is the last backup method that needs to be adjusted to also
contain unconfirmed channels.
This commit is contained in:
Oliver Gugger 2020-02-12 13:41:48 +01:00
parent 8a2c02f8ea
commit 4e0c276154
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
2 changed files with 8 additions and 7 deletions

View File

@ -13675,9 +13675,9 @@ func testChannelBackupUpdates(net *lntest.NetworkHarness, t *harnessTest) {
} }
} }
// As these two channels were just open, we should've got two // As these two channels were just opened, we should've got two times
// notifications for channel backups. // the pending and open notifications for channel backups.
assertBackupNtfns(2) assertBackupNtfns(2 * 2)
// The on disk file should also exactly match the latest backup that we // The on disk file should also exactly match the latest backup that we
// have. // have.

View File

@ -5605,7 +5605,7 @@ func (r *rpcServer) SubscribeChannelBackups(req *lnrpc.ChannelBackupSubscription
updateStream lnrpc.Lightning_SubscribeChannelBackupsServer) error { updateStream lnrpc.Lightning_SubscribeChannelBackupsServer) error {
// First, we'll subscribe to the primary channel notifier so we can // First, we'll subscribe to the primary channel notifier so we can
// obtain events for new opened/closed channels. // obtain events for new pending/opened/closed channels.
chanSubscription, err := r.server.channelNotifier.SubscribeChannelEvents() chanSubscription, err := r.server.channelNotifier.SubscribeChannelEvents()
if err != nil { if err != nil {
return err return err
@ -5622,9 +5622,10 @@ func (r *rpcServer) SubscribeChannelBackups(req *lnrpc.ChannelBackupSubscription
switch e.(type) { switch e.(type) {
// We only care about new/closed channels, so we'll // We only care about new/closed channels, so we'll
// skip any events for pending/active/inactive channels. // skip any events for active/inactive channels.
case channelnotifier.PendingOpenChannelEvent: // To make the subscription behave the same way as the
continue // synchronous call and the file based backup, we also
// include pending channels in the update.
case channelnotifier.ActiveChannelEvent: case channelnotifier.ActiveChannelEvent:
continue continue
case channelnotifier.InactiveChannelEvent: case channelnotifier.InactiveChannelEvent: