mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 06:07:16 +01:00
multi: add reset closure to kvdb.Update
Similarly as with kvdb.View this commits adds a reset closure to the kvdb.Update call in order to be able to reset external state if the underlying db backend needs to retry the transaction.
This commit is contained in:
@@ -62,7 +62,7 @@ func NewRootKeyStorage(db kvdb.Backend) (*RootKeyStorage, error) {
|
||||
err := kvdb.Update(db, func(tx kvdb.RwTx) error {
|
||||
_, err := tx.CreateTopLevelBucket(rootKeyBucketName)
|
||||
return err
|
||||
})
|
||||
}, func() {})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -123,7 +123,7 @@ func (r *RootKeyStorage) CreateUnlock(password *[]byte) error {
|
||||
|
||||
r.encKey = encKey
|
||||
return nil
|
||||
})
|
||||
}, func() {})
|
||||
}
|
||||
|
||||
// Get implements the Get method for the bakery.RootKeyStorage interface.
|
||||
@@ -211,6 +211,8 @@ func (r *RootKeyStorage) RootKey(ctx context.Context) ([]byte, []byte, error) {
|
||||
return err
|
||||
}
|
||||
return ns.Put(id, encKey)
|
||||
}, func() {
|
||||
rootKey = nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -310,6 +312,8 @@ func (r *RootKeyStorage) DeleteMacaroonID(
|
||||
rootKeyIDDeleted = rootKeyID
|
||||
|
||||
return nil
|
||||
}, func() {
|
||||
rootKeyIDDeleted = nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user