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:
44 files changed
+208
-162
No files matched your search
@@ -227,7 +227,7 @@ func (cm *circuitMap) initBuckets() error {
|
||||
|
||||
_, err = tx.CreateTopLevelBucket(circuitAddKey)
|
||||
return err
|
||||
})
|
||||
}, func() {})
|
||||
}
|
||||
|
||||
// restoreMemState loads the contents of the half circuit and full circuit
|
||||
@@ -240,8 +240,8 @@ func (cm *circuitMap) restoreMemState() error {
|
||||
log.Infof("Restoring in-memory circuit state from disk")
|
||||
|
||||
var (
|
||||
opened = make(map[CircuitKey]*PaymentCircuit)
|
||||
pending = make(map[CircuitKey]*PaymentCircuit)
|
||||
opened map[CircuitKey]*PaymentCircuit
|
||||
pending map[CircuitKey]*PaymentCircuit
|
||||
)
|
||||
|
||||
if err := kvdb.Update(cm.cfg.DB, func(tx kvdb.RwTx) error {
|
||||
@@ -331,6 +331,9 @@ func (cm *circuitMap) restoreMemState() error {
|
||||
|
||||
return nil
|
||||
|
||||
}, func() {
|
||||
opened = make(map[CircuitKey]*PaymentCircuit)
|
||||
pending = make(map[CircuitKey]*PaymentCircuit)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -483,7 +486,7 @@ func (cm *circuitMap) TrimOpenCircuits(chanID lnwire.ShortChannelID,
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}, func() {})
|
||||
}
|
||||
|
||||
// LookupByHTLC looks up the payment circuit by the outgoing channel and HTLC
|
||||
@@ -730,7 +733,7 @@ func (cm *circuitMap) OpenCircuits(keystones ...Keystone) error {
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}, func() {})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -131,7 +131,7 @@ func (d *DecayedLog) initBuckets() error {
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}, func() {})
|
||||
}
|
||||
|
||||
// Stop halts the garbage collector and closes boltdb.
|
||||
|
||||
@@ -305,5 +305,5 @@ func (store *networkResultStore) cleanStore(keep map[uint64]struct{}) error {
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}, func() {})
|
||||
}
|
||||
@@ -100,6 +100,8 @@ func (s *persistentSequencer) NextID() (uint64, error) {
|
||||
nextIDBkt.SetSequence(nextHorizonID)
|
||||
|
||||
return nil
|
||||
}, func() {
|
||||
nextHorizonID = 0
|
||||
}); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -124,5 +126,5 @@ func (s *persistentSequencer) initDB() error {
|
||||
return kvdb.Update(s.db, func(tx kvdb.RwTx) error {
|
||||
_, err := tx.CreateTopLevelBucket(nextPaymentIDKey)
|
||||
return err
|
||||
})
|
||||
}, func() {})
|
||||
}
|
||||
Reference in new issue
Block a user