mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 01:36:24 +01:00
channeldb: bucket not found during .Wipe() is no longer an error
This commit changes the current behavior around channeldb.Wipe(). Previously if a channel had never been closed, and a wipe was attempted, then wipe operation would fail and the transaction would be rolled back. This commit fixes this behavior by checking for bolt.ErrBucketNotFound error, and handling the specific error as a noop.
This commit is contained in:
parent
6283eb29bf
commit
504c8bf5f3
1 changed files with 8 additions and 2 deletions
|
@ -77,11 +77,17 @@ func (d *DB) RegisterCryptoSystem(ed EncryptorDecryptor) {
|
|||
// operation is fully atomic.
|
||||
func (d *DB) Wipe() error {
|
||||
return d.store.Update(func(tx *bolt.Tx) error {
|
||||
if err := tx.DeleteBucket(openChannelBucket); err != nil {
|
||||
err := tx.DeleteBucket(openChannelBucket)
|
||||
if err != nil && err != bolt.ErrBucketNotFound {
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.DeleteBucket(closedChannelBucket)
|
||||
err = tx.DeleteBucket(closedChannelBucket)
|
||||
if err != nil && err != bolt.ErrBucketNotFound {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue