multi: switch from bolt packge to bbolt package for all imports
This commit is contained in:
41 files changed
+404
-405
No files matched your search
@@ -212,7 +212,7 @@ func NewCircuitMap(cfg *CircuitMapConfig) (CircuitMap, error) {
|
||||
// initBuckets ensures that the primary buckets used by the circuit are
|
||||
// initialized so that we can assume their existence after startup.
|
||||
func (cm *circuitMap) initBuckets() error {
|
||||
return cm.cfg.DB.Update(func(tx *bolt.Tx) error {
|
||||
return cm.cfg.DB.Update(func(tx *bbolt.Tx) error {
|
||||
_, err := tx.CreateBucketIfNotExists(circuitKeystoneKey)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -237,7 +237,7 @@ func (cm *circuitMap) restoreMemState() error {
|
||||
pending = make(map[CircuitKey]*PaymentCircuit)
|
||||
)
|
||||
|
||||
if err := cm.cfg.DB.Update(func(tx *bolt.Tx) error {
|
||||
if err := cm.cfg.DB.Update(func(tx *bbolt.Tx) error {
|
||||
// Restore any of the circuits persisted in the circuit bucket
|
||||
// back into memory.
|
||||
circuitBkt := tx.Bucket(circuitAddKey)
|
||||
@@ -462,7 +462,7 @@ func (cm *circuitMap) TrimOpenCircuits(chanID lnwire.ShortChannelID,
|
||||
return nil
|
||||
}
|
||||
|
||||
return cm.cfg.DB.Update(func(tx *bolt.Tx) error {
|
||||
return cm.cfg.DB.Update(func(tx *bbolt.Tx) error {
|
||||
keystoneBkt := tx.Bucket(circuitKeystoneKey)
|
||||
if keystoneBkt == nil {
|
||||
return ErrCorruptedCircuitMap
|
||||
@@ -615,7 +615,7 @@ func (cm *circuitMap) CommitCircuits(circuits ...*PaymentCircuit) (
|
||||
// Write the entire batch of circuits to the persistent circuit bucket
|
||||
// using bolt's Batch write. This method must be called from multiple,
|
||||
// distinct goroutines to have any impact on performance.
|
||||
err := cm.cfg.DB.Batch(func(tx *bolt.Tx) error {
|
||||
err := cm.cfg.DB.Batch(func(tx *bbolt.Tx) error {
|
||||
circuitBkt := tx.Bucket(circuitAddKey)
|
||||
if circuitBkt == nil {
|
||||
return ErrCorruptedCircuitMap
|
||||
@@ -705,7 +705,7 @@ func (cm *circuitMap) OpenCircuits(keystones ...Keystone) error {
|
||||
}
|
||||
cm.mtx.RUnlock()
|
||||
|
||||
err := cm.cfg.DB.Update(func(tx *bolt.Tx) error {
|
||||
err := cm.cfg.DB.Update(func(tx *bbolt.Tx) error {
|
||||
// Now, load the circuit bucket to which we will write the
|
||||
// already serialized circuit.
|
||||
keystoneBkt := tx.Bucket(circuitKeystoneKey)
|
||||
@@ -846,7 +846,7 @@ func (cm *circuitMap) DeleteCircuits(inKeys ...CircuitKey) error {
|
||||
}
|
||||
cm.mtx.Unlock()
|
||||
|
||||
err := cm.cfg.DB.Batch(func(tx *bolt.Tx) error {
|
||||
err := cm.cfg.DB.Batch(func(tx *bbolt.Tx) error {
|
||||
for _, circuit := range removedCircuits {
|
||||
// If this htlc made it to an outgoing link, load the
|
||||
// keystone bucket from which we will remove the
|
||||
|
||||
@@ -81,7 +81,7 @@ func NewPaymentControl(strict bool, db *channeldb.DB) ControlTower {
|
||||
// payment identified by the same payment hash.
|
||||
func (p *paymentControl) ClearForTakeoff(htlc *lnwire.UpdateAddHTLC) error {
|
||||
var takeoffErr error
|
||||
err := p.db.Batch(func(tx *bolt.Tx) error {
|
||||
err := p.db.Batch(func(tx *bbolt.Tx) error {
|
||||
// Retrieve current status of payment from local database.
|
||||
paymentStatus, err := channeldb.FetchPaymentStatusTx(
|
||||
tx, htlc.PaymentHash,
|
||||
@@ -133,7 +133,7 @@ func (p *paymentControl) ClearForTakeoff(htlc *lnwire.UpdateAddHTLC) error {
|
||||
// attempts for the same payment hash.
|
||||
func (p *paymentControl) Success(paymentHash [32]byte) error {
|
||||
var updateErr error
|
||||
err := p.db.Batch(func(tx *bolt.Tx) error {
|
||||
err := p.db.Batch(func(tx *bbolt.Tx) error {
|
||||
paymentStatus, err := channeldb.FetchPaymentStatusTx(
|
||||
tx, paymentHash,
|
||||
)
|
||||
@@ -190,7 +190,7 @@ func (p *paymentControl) Success(paymentHash [32]byte) error {
|
||||
// for the same payment hash.
|
||||
func (p *paymentControl) Fail(paymentHash [32]byte) error {
|
||||
var updateErr error
|
||||
err := p.db.Batch(func(tx *bolt.Tx) error {
|
||||
err := p.db.Batch(func(tx *bbolt.Tx) error {
|
||||
paymentStatus, err := channeldb.FetchPaymentStatusTx(
|
||||
tx, paymentHash,
|
||||
)
|
||||
|
||||
@@ -56,7 +56,7 @@ type DecayedLog struct {
|
||||
|
||||
dbPath string
|
||||
|
||||
db *bolt.DB
|
||||
db *bbolt.DB
|
||||
|
||||
notifier chainntnfs.ChainNotifier
|
||||
|
||||
@@ -92,7 +92,7 @@ func (d *DecayedLog) Start() error {
|
||||
|
||||
// Open the boltdb for use.
|
||||
var err error
|
||||
if d.db, err = bolt.Open(d.dbPath, dbPermissions, nil); err != nil {
|
||||
if d.db, err = bbolt.Open(d.dbPath, dbPermissions, nil); err != nil {
|
||||
return fmt.Errorf("Could not open boltdb: %v", err)
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ func (d *DecayedLog) Start() error {
|
||||
// initBuckets initializes the primary buckets used by the decayed log, namely
|
||||
// the shared hash bucket, and batch replay
|
||||
func (d *DecayedLog) initBuckets() error {
|
||||
return d.db.Update(func(tx *bolt.Tx) error {
|
||||
return d.db.Update(func(tx *bbolt.Tx) error {
|
||||
_, err := tx.CreateBucketIfNotExists(sharedHashBucket)
|
||||
if err != nil {
|
||||
return ErrDecayedLogInit
|
||||
@@ -196,7 +196,7 @@ func (d *DecayedLog) garbageCollector(epochClient *chainntnfs.BlockEpochEvent) {
|
||||
func (d *DecayedLog) gcExpiredHashes(height uint32) (uint32, error) {
|
||||
var numExpiredHashes uint32
|
||||
|
||||
err := d.db.Batch(func(tx *bolt.Tx) error {
|
||||
err := d.db.Batch(func(tx *bbolt.Tx) error {
|
||||
numExpiredHashes = 0
|
||||
|
||||
// Grab the shared hash bucket
|
||||
@@ -246,7 +246,7 @@ func (d *DecayedLog) gcExpiredHashes(height uint32) (uint32, error) {
|
||||
// Delete removes a <shared secret hash, CLTV> key-pair from the
|
||||
// sharedHashBucket.
|
||||
func (d *DecayedLog) Delete(hash *sphinx.HashPrefix) error {
|
||||
return d.db.Batch(func(tx *bolt.Tx) error {
|
||||
return d.db.Batch(func(tx *bbolt.Tx) error {
|
||||
sharedHashes := tx.Bucket(sharedHashBucket)
|
||||
if sharedHashes == nil {
|
||||
return ErrDecayedLogCorrupted
|
||||
@@ -261,7 +261,7 @@ func (d *DecayedLog) Delete(hash *sphinx.HashPrefix) error {
|
||||
func (d *DecayedLog) Get(hash *sphinx.HashPrefix) (uint32, error) {
|
||||
var value uint32
|
||||
|
||||
err := d.db.View(func(tx *bolt.Tx) error {
|
||||
err := d.db.View(func(tx *bbolt.Tx) error {
|
||||
// Grab the shared hash bucket which stores the mapping from
|
||||
// truncated sha-256 hashes of shared secrets to CLTV's.
|
||||
sharedHashes := tx.Bucket(sharedHashBucket)
|
||||
@@ -294,7 +294,7 @@ func (d *DecayedLog) Put(hash *sphinx.HashPrefix, cltv uint32) error {
|
||||
var scratch [4]byte
|
||||
binary.BigEndian.PutUint32(scratch[:], cltv)
|
||||
|
||||
return d.db.Batch(func(tx *bolt.Tx) error {
|
||||
return d.db.Batch(func(tx *bbolt.Tx) error {
|
||||
sharedHashes := tx.Bucket(sharedHashBucket)
|
||||
if sharedHashes == nil {
|
||||
return ErrDecayedLogCorrupted
|
||||
@@ -327,7 +327,7 @@ func (d *DecayedLog) PutBatch(b *sphinx.Batch) (*sphinx.ReplaySet, error) {
|
||||
// to generate the complete replay set. If this batch was previously
|
||||
// processed, the replay set will be deserialized from disk.
|
||||
var replays *sphinx.ReplaySet
|
||||
if err := d.db.Batch(func(tx *bolt.Tx) error {
|
||||
if err := d.db.Batch(func(tx *bbolt.Tx) error {
|
||||
sharedHashes := tx.Bucket(sharedHashBucket)
|
||||
if sharedHashes == nil {
|
||||
return ErrDecayedLogCorrupted
|
||||
|
||||
@@ -4797,32 +4797,32 @@ type mockPackager struct {
|
||||
failLoadFwdPkgs bool
|
||||
}
|
||||
|
||||
func (*mockPackager) AddFwdPkg(tx *bolt.Tx, fwdPkg *channeldb.FwdPkg) error {
|
||||
func (*mockPackager) AddFwdPkg(tx *bbolt.Tx, fwdPkg *channeldb.FwdPkg) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*mockPackager) SetFwdFilter(tx *bolt.Tx, height uint64,
|
||||
func (*mockPackager) SetFwdFilter(tx *bbolt.Tx, height uint64,
|
||||
fwdFilter *channeldb.PkgFilter) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*mockPackager) AckAddHtlcs(tx *bolt.Tx,
|
||||
func (*mockPackager) AckAddHtlcs(tx *bbolt.Tx,
|
||||
addRefs ...channeldb.AddRef) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockPackager) LoadFwdPkgs(tx *bolt.Tx) ([]*channeldb.FwdPkg, error) {
|
||||
func (m *mockPackager) LoadFwdPkgs(tx *bbolt.Tx) ([]*channeldb.FwdPkg, error) {
|
||||
if m.failLoadFwdPkgs {
|
||||
return nil, fmt.Errorf("failing LoadFwdPkgs")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (*mockPackager) RemovePkg(tx *bolt.Tx, height uint64) error {
|
||||
func (*mockPackager) RemovePkg(tx *bbolt.Tx, height uint64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*mockPackager) AckSettleFails(tx *bolt.Tx,
|
||||
func (*mockPackager) AckSettleFails(tx *bbolt.Tx,
|
||||
settleFailRefs ...channeldb.SettleFailRef) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ 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 *bolt.Tx) error {
|
||||
if err := s.db.Update(func(tx *bbolt.Tx) error {
|
||||
nextIDBkt := tx.Bucket(nextPaymentIDKey)
|
||||
if nextIDBkt == nil {
|
||||
return ErrSequencerCorrupted
|
||||
@@ -121,7 +121,7 @@ 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 *bolt.Tx) error {
|
||||
return s.db.Update(func(tx *bbolt.Tx) error {
|
||||
_, err := tx.CreateBucketIfNotExists(nextPaymentIDKey)
|
||||
return err
|
||||
})
|
||||
|
||||
@@ -1350,7 +1350,7 @@ func (s *Switch) closeCircuit(pkt *htlcPacket) (*PaymentCircuit, error) {
|
||||
// we're the originator of the payment, so the link stops attempting to
|
||||
// re-broadcast.
|
||||
func (s *Switch) ackSettleFail(settleFailRef channeldb.SettleFailRef) error {
|
||||
return s.cfg.DB.Batch(func(tx *bolt.Tx) error {
|
||||
return s.cfg.DB.Batch(func(tx *bbolt.Tx) error {
|
||||
return s.cfg.SwitchPackager.AckSettleFails(tx, settleFailRef)
|
||||
})
|
||||
}
|
||||
@@ -1760,7 +1760,7 @@ func (s *Switch) reforwardResponses() error {
|
||||
func (s *Switch) loadChannelFwdPkgs(source lnwire.ShortChannelID) ([]*channeldb.FwdPkg, error) {
|
||||
|
||||
var fwdPkgs []*channeldb.FwdPkg
|
||||
if err := s.cfg.DB.Update(func(tx *bolt.Tx) error {
|
||||
if err := s.cfg.DB.Update(func(tx *bbolt.Tx) error {
|
||||
var err error
|
||||
fwdPkgs, err = s.cfg.SwitchPackager.LoadChannelFwdPkgs(
|
||||
tx, source,
|
||||
|
||||
@@ -405,7 +405,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
||||
aliceStoredChannels, err := dbAlice.FetchOpenChannels(aliceKeyPub)
|
||||
switch err {
|
||||
case nil:
|
||||
case bolt.ErrDatabaseNotOpen:
|
||||
case bbolt.ErrDatabaseNotOpen:
|
||||
dbAlice, err = channeldb.Open(dbAlice.Path())
|
||||
if err != nil {
|
||||
return nil, nil, errors.Errorf("unable to reopen alice "+
|
||||
@@ -444,7 +444,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
||||
bobStoredChannels, err := dbBob.FetchOpenChannels(bobKeyPub)
|
||||
switch err {
|
||||
case nil:
|
||||
case bolt.ErrDatabaseNotOpen:
|
||||
case bbolt.ErrDatabaseNotOpen:
|
||||
dbBob, err = channeldb.Open(dbBob.Path())
|
||||
if err != nil {
|
||||
return nil, nil, errors.Errorf("unable to reopen bob "+
|
||||
|
||||
Reference in new issue
Block a user