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:
Andras Banki-Horvath
2020-10-26 14:06:32 +01:00
parent 2a358327f4
commit d89f51d1d0
44 changed files with 208 additions and 162 deletions

View File

@@ -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