Skip to content

Commit

Permalink
channeldb: set restored chan status within RestoreChannelShells
Browse files Browse the repository at this point in the history
In this commit, we move the location where we restore the channel status
to within the `RestoreChannelShells` method itself. Before this commit,
we attempted to use `ApplyChanStatus` which creates a DB transaction and
relies on a fully populated channel state, which in the restoration
case, we don't yet have.
  • Loading branch information
Roasbeef committed Mar 29, 2019
1 parent 13e7244 commit b93ff26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 6 additions & 0 deletions channeldb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,12 @@ func (d *DB) RestoreChannelShells(channelShells ...*ChannelShell) error {
for _, channelShell := range channelShells {
channel := channelShell.Chan

// When we make a channel, we mark that the channel has
// been restored, this will signal to other sub-systems
// to not attempt to use the channel as if it was a
// regular one.
channel.chanStatus |= ChanStatusRestored

// First, we'll attempt to create a new open channel
// and link node for this channel. If the channel
// already exists, then in order to ensure this method
Expand Down
10 changes: 0 additions & 10 deletions chanrestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,6 @@ func (c *chanDBRestorer) openChannelShell(backup chanbackup.Single) (
},
}

// TODO(roasbeef): move this mapping elsewhere?

// When we make a channel, we mark that the channel has been restored,
// this will signal to other sub-systems to not attempt to use the
// channel as if it was a regular one.
chanStatus := channeldb.ChanStatusDefault |
channeldb.ChanStatusRestored

chanShell.Chan.ApplyChanStatus(chanStatus)

return &chanShell, nil
}

Expand Down

0 comments on commit b93ff26

Please sign in to comment.