htlcswitch: convert to use new kvdb abstraction
This commit is contained in:
7 files changed
+61
-58
No files matched your search
@@ -3,9 +3,9 @@ package htlcswitch
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/coreos/bbolt"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/kvdb"
|
||||
)
|
||||
|
||||
// defaultSequenceBatchSize specifies the window of sequence numbers that are
|
||||
@@ -87,8 +87,8 @@ func (s *persistentSequencer) NextID() (uint64, error) {
|
||||
// allocated will start from the last known tip on disk, which is fine
|
||||
// as we only require uniqueness of the allocated numbers.
|
||||
var nextHorizonID uint64
|
||||
if err := s.db.Update(func(tx *bbolt.Tx) error {
|
||||
nextIDBkt := tx.Bucket(nextPaymentIDKey)
|
||||
if err := kvdb.Update(s.db, func(tx kvdb.RwTx) error {
|
||||
nextIDBkt := tx.ReadWriteBucket(nextPaymentIDKey)
|
||||
if nextIDBkt == nil {
|
||||
return ErrSequencerCorrupted
|
||||
}
|
||||
@@ -121,8 +121,8 @@ func (s *persistentSequencer) NextID() (uint64, error) {
|
||||
|
||||
// initDB populates the bucket used to generate payment sequence numbers.
|
||||
func (s *persistentSequencer) initDB() error {
|
||||
return s.db.Update(func(tx *bbolt.Tx) error {
|
||||
_, err := tx.CreateBucketIfNotExists(nextPaymentIDKey)
|
||||
return kvdb.Update(s.db, func(tx kvdb.RwTx) error {
|
||||
_, err := tx.CreateTopLevelBucket(nextPaymentIDKey)
|
||||
return err
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user