multi: switch from bolt packge to bbolt package for all imports

This commit is contained in:
Olaoluwa Osuntokun 2018-11-29 20:04:21 -08:00
parent 0edf1ae081
commit 1fd3aac925
No known key found for this signature in database
GPG Key ID: CE58F7F8E20FD9A2
41 changed files with 404 additions and 405 deletions

@ -49,7 +49,7 @@ func ChannelGraphFromDatabase(db *channeldb.ChannelGraph) ChannelGraph {
// channeldb.LightningNode. The wrapper method implement the autopilot.Node
// interface.
type dbNode struct {
tx *bolt.Tx
tx *bbolt.Tx
node *channeldb.LightningNode
}
@ -82,7 +82,7 @@ func (d dbNode) Addrs() []net.Addr {
//
// NOTE: Part of the autopilot.Node interface.
func (d dbNode) ForEachChannel(cb func(ChannelEdge) error) error {
return d.node.ForEachChannel(d.tx, func(tx *bolt.Tx,
return d.node.ForEachChannel(d.tx, func(tx *bbolt.Tx,
ei *channeldb.ChannelEdgeInfo, ep, _ *channeldb.ChannelEdgePolicy) error {
// Skip channels for which no outgoing edge policy is available.
@ -119,7 +119,7 @@ func (d dbNode) ForEachChannel(cb func(ChannelEdge) error) error {
//
// NOTE: Part of the autopilot.ChannelGraph interface.
func (d *databaseChannelGraph) ForEachNode(cb func(Node) error) error {
return d.db.ForEachNode(nil, func(tx *bolt.Tx, n *channeldb.LightningNode) error {
return d.db.ForEachNode(nil, func(tx *bbolt.Tx, n *channeldb.LightningNode) error {
// We'll skip over any node that doesn't have any advertised
// addresses. As we won't be able to reach them to actually

@ -1152,7 +1152,7 @@ func newRetributionStore(db *channeldb.DB) *retributionStore {
// Add adds a retribution state to the retributionStore, which is then persisted
// to disk.
func (rs *retributionStore) Add(ret *retributionInfo) error {
return rs.db.Update(func(tx *bolt.Tx) error {
return rs.db.Update(func(tx *bbolt.Tx) error {
// If this is our first contract breach, the retributionBucket
// won't exist, in which case, we just create a new bucket.
retBucket, err := tx.CreateBucketIfNotExists(retributionBucket)
@ -1179,7 +1179,7 @@ func (rs *retributionStore) Add(ret *retributionInfo) error {
// startup and re-register for confirmation notifications.
func (rs *retributionStore) Finalize(chanPoint *wire.OutPoint,
finalTx *wire.MsgTx) error {
return rs.db.Update(func(tx *bolt.Tx) error {
return rs.db.Update(func(tx *bbolt.Tx) error {
justiceBkt, err := tx.CreateBucketIfNotExists(justiceTxnBucket)
if err != nil {
return err
@ -1206,7 +1206,7 @@ func (rs *retributionStore) GetFinalizedTxn(
chanPoint *wire.OutPoint) (*wire.MsgTx, error) {
var finalTxBytes []byte
if err := rs.db.View(func(tx *bolt.Tx) error {
if err := rs.db.View(func(tx *bbolt.Tx) error {
justiceBkt := tx.Bucket(justiceTxnBucket)
if justiceBkt == nil {
return nil
@ -1240,7 +1240,7 @@ func (rs *retributionStore) GetFinalizedTxn(
// that has already been breached.
func (rs *retributionStore) IsBreached(chanPoint *wire.OutPoint) (bool, error) {
var found bool
err := rs.db.View(func(tx *bolt.Tx) error {
err := rs.db.View(func(tx *bbolt.Tx) error {
retBucket := tx.Bucket(retributionBucket)
if retBucket == nil {
return nil
@ -1265,7 +1265,7 @@ func (rs *retributionStore) IsBreached(chanPoint *wire.OutPoint) (bool, error) {
// Remove removes a retribution state and finalized justice transaction by
// channel point from the retribution store.
func (rs *retributionStore) Remove(chanPoint *wire.OutPoint) error {
return rs.db.Update(func(tx *bolt.Tx) error {
return rs.db.Update(func(tx *bbolt.Tx) error {
retBucket := tx.Bucket(retributionBucket)
// We return an error if the bucket is not already created,
@ -1304,7 +1304,7 @@ func (rs *retributionStore) Remove(chanPoint *wire.OutPoint) error {
// ForAll iterates through all stored retributions and executes the passed
// callback function on each retribution.
func (rs *retributionStore) ForAll(cb func(*retributionInfo) error) error {
return rs.db.View(func(tx *bolt.Tx) error {
return rs.db.View(func(tx *bbolt.Tx) error {
// If the bucket does not exist, then there are no pending
// retributions.
retBucket := tx.Bucket(retributionBucket)

@ -628,36 +628,34 @@ func makeTestChannelDB() (*channeldb.DB, func(), error) {
// channeldb.DB, and tests its behavior using the general RetributionStore test
// suite.
func TestChannelDBRetributionStore(t *testing.T) {
db, cleanUp, err := makeTestChannelDB()
if err != nil {
t.Fatalf("unable to open channeldb: %v", err)
}
defer db.Close()
defer cleanUp()
restartDb := func() RetributionStore {
// Close and reopen channeldb
if err = db.Close(); err != nil {
t.Fatalf("unable to close channeldb during restart: %v",
err)
}
db, err = channeldb.Open(db.Path())
if err != nil {
t.Fatalf("unable to open channeldb: %v", err)
}
return newRetributionStore(db)
}
// Finally, instantiate retribution store and execute RetributionStore
// test suite.
for _, test := range retributionStoreTestSuite {
t.Run(
"channeldbDBRetributionStore."+test.name,
func(tt *testing.T) {
if err = db.Wipe(); err != nil {
t.Fatalf("unable to wipe channeldb: %v",
err)
db, cleanUp, err := makeTestChannelDB()
if err != nil {
t.Fatalf("unable to open channeldb: %v", err)
}
defer db.Close()
defer cleanUp()
restartDb := func() RetributionStore {
// Close and reopen channeldb
if err = db.Close(); err != nil {
t.Fatalf("unable to close "+
"channeldb during "+
"restart: %v",
err)
}
db, err = channeldb.Open(db.Path())
if err != nil {
t.Fatalf("unable to open "+
"channeldb: %v", err)
}
return newRetributionStore(db)
}
frs := newFailingRetributionStore(restartDb)
@ -818,7 +816,11 @@ func testRetributionStoreRemoves(
for i, retInfo := range retributions {
// Snapshot number of entries before and after the removal.
nbefore := countRetributions(t, frs)
if err := frs.Remove(&retInfo.chanPoint); err != nil {
err := frs.Remove(&retInfo.chanPoint)
switch {
case nbefore == 0 && err == nil:
case nbefore > 0 && err != nil:
t.Fatalf("unable to remove to retribution %v "+
"from store: %v", i, err)
}

@ -495,7 +495,7 @@ func (c *OpenChannel) RefreshShortChanID() error {
defer c.Unlock()
var sid lnwire.ShortChannelID
err := c.Db.View(func(tx *bolt.Tx) error {
err := c.Db.View(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -525,8 +525,8 @@ func (c *OpenChannel) RefreshShortChanID() error {
// fetchChanBucket is a helper function that returns the bucket where a
// channel's data resides in given: the public key for the node, the outpoint,
// and the chainhash that the channel resides on.
func fetchChanBucket(tx *bolt.Tx, nodeKey *btcec.PublicKey,
outPoint *wire.OutPoint, chainHash chainhash.Hash) (*bolt.Bucket, error) {
func fetchChanBucket(tx *bbolt.Tx, nodeKey *btcec.PublicKey,
outPoint *wire.OutPoint, chainHash chainhash.Hash) (*bbolt.Bucket, error) {
// First fetch the top level bucket which stores all data related to
// current, active channels.
@ -567,7 +567,7 @@ func fetchChanBucket(tx *bolt.Tx, nodeKey *btcec.PublicKey,
// fullSync is an internal version of the FullSync method which allows callers
// to sync the contents of an OpenChannel while re-using an existing database
// transaction.
func (c *OpenChannel) fullSync(tx *bolt.Tx) error {
func (c *OpenChannel) fullSync(tx *bbolt.Tx) error {
// First fetch the top level bucket which stores all data related to
// current, active channels.
openChanBucket, err := tx.CreateBucketIfNotExists(openChannelBucket)
@ -613,7 +613,7 @@ func (c *OpenChannel) MarkAsOpen(openLoc lnwire.ShortChannelID) error {
c.Lock()
defer c.Unlock()
if err := c.Db.Update(func(tx *bolt.Tx) error {
if err := c.Db.Update(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -649,7 +649,7 @@ func (c *OpenChannel) MarkDataLoss(commitPoint *btcec.PublicKey) error {
defer c.Unlock()
var status ChannelStatus
if err := c.Db.Update(func(tx *bolt.Tx) error {
if err := c.Db.Update(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -693,7 +693,7 @@ func (c *OpenChannel) MarkDataLoss(commitPoint *btcec.PublicKey) error {
func (c *OpenChannel) DataLossCommitPoint() (*btcec.PublicKey, error) {
var commitPoint *btcec.PublicKey
err := c.Db.View(func(tx *bolt.Tx) error {
err := c.Db.View(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -744,7 +744,7 @@ func (c *OpenChannel) MarkCommitmentBroadcasted() error {
}
func (c *OpenChannel) putChanStatus(status ChannelStatus) error {
if err := c.Db.Update(func(tx *bolt.Tx) error {
if err := c.Db.Update(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -774,7 +774,7 @@ func (c *OpenChannel) putChanStatus(status ChannelStatus) error {
// putChannel serializes, and stores the current state of the channel in its
// entirety.
func putOpenChannel(chanBucket *bolt.Bucket, channel *OpenChannel) error {
func putOpenChannel(chanBucket *bbolt.Bucket, channel *OpenChannel) error {
// First, we'll write out all the relatively static fields, that are
// decided upon initial channel creation.
if err := putChanInfo(chanBucket, channel); err != nil {
@ -798,7 +798,7 @@ func putOpenChannel(chanBucket *bolt.Bucket, channel *OpenChannel) error {
// fetchOpenChannel retrieves, and deserializes (including decrypting
// sensitive) the complete channel currently active with the passed nodeID.
func fetchOpenChannel(chanBucket *bolt.Bucket,
func fetchOpenChannel(chanBucket *bbolt.Bucket,
chanPoint *wire.OutPoint) (*OpenChannel, error) {
channel := &OpenChannel{
@ -845,7 +845,7 @@ func (c *OpenChannel) SyncPending(addr net.Addr, pendingHeight uint32) error {
c.FundingBroadcastHeight = pendingHeight
return c.Db.Update(func(tx *bolt.Tx) error {
return c.Db.Update(func(tx *bbolt.Tx) error {
// First, sync all the persistent channel state to disk.
if err := c.fullSync(tx); err != nil {
return err
@ -884,7 +884,7 @@ func (c *OpenChannel) UpdateCommitment(newCommitment *ChannelCommitment) error {
c.Lock()
defer c.Unlock()
err := c.Db.Update(func(tx *bolt.Tx) error {
err := c.Db.Update(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -1303,7 +1303,7 @@ func (c *OpenChannel) AppendRemoteCommitChain(diff *CommitDiff) error {
c.Lock()
defer c.Unlock()
return c.Db.Update(func(tx *bolt.Tx) error {
return c.Db.Update(func(tx *bbolt.Tx) error {
// First, we'll grab the writable bucket where this channel's
// data resides.
chanBucket, err := fetchChanBucket(
@ -1353,7 +1353,7 @@ func (c *OpenChannel) AppendRemoteCommitChain(diff *CommitDiff) error {
// these pointers, causing the tip and the tail to point to the same entry.
func (c *OpenChannel) RemoteCommitChainTip() (*CommitDiff, error) {
var cd *CommitDiff
err := c.Db.View(func(tx *bolt.Tx) error {
err := c.Db.View(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -1399,7 +1399,7 @@ func (c *OpenChannel) InsertNextRevocation(revKey *btcec.PublicKey) error {
c.RemoteNextRevocation = revKey
err := c.Db.Update(func(tx *bolt.Tx) error {
err := c.Db.Update(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -1429,7 +1429,7 @@ func (c *OpenChannel) AdvanceCommitChainTail(fwdPkg *FwdPkg) error {
var newRemoteCommit *ChannelCommitment
err := c.Db.Update(func(tx *bolt.Tx) error {
err := c.Db.Update(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -1537,7 +1537,7 @@ func (c *OpenChannel) LoadFwdPkgs() ([]*FwdPkg, error) {
defer c.RUnlock()
var fwdPkgs []*FwdPkg
if err := c.Db.View(func(tx *bolt.Tx) error {
if err := c.Db.View(func(tx *bbolt.Tx) error {
var err error
fwdPkgs, err = c.Packager.LoadFwdPkgs(tx)
return err
@ -1555,7 +1555,7 @@ func (c *OpenChannel) AckAddHtlcs(addRefs ...AddRef) error {
c.Lock()
defer c.Unlock()
return c.Db.Update(func(tx *bolt.Tx) error {
return c.Db.Update(func(tx *bbolt.Tx) error {
return c.Packager.AckAddHtlcs(tx, addRefs...)
})
}
@ -1568,7 +1568,7 @@ func (c *OpenChannel) AckSettleFails(settleFailRefs ...SettleFailRef) error {
c.Lock()
defer c.Unlock()
return c.Db.Update(func(tx *bolt.Tx) error {
return c.Db.Update(func(tx *bbolt.Tx) error {
return c.Packager.AckSettleFails(tx, settleFailRefs...)
})
}
@ -1579,7 +1579,7 @@ func (c *OpenChannel) SetFwdFilter(height uint64, fwdFilter *PkgFilter) error {
c.Lock()
defer c.Unlock()
return c.Db.Update(func(tx *bolt.Tx) error {
return c.Db.Update(func(tx *bbolt.Tx) error {
return c.Packager.SetFwdFilter(tx, height, fwdFilter)
})
}
@ -1592,7 +1592,7 @@ func (c *OpenChannel) RemoveFwdPkg(height uint64) error {
c.Lock()
defer c.Unlock()
return c.Db.Update(func(tx *bolt.Tx) error {
return c.Db.Update(func(tx *bbolt.Tx) error {
return c.Packager.RemovePkg(tx, height)
})
}
@ -1612,7 +1612,7 @@ func (c *OpenChannel) RevocationLogTail() (*ChannelCommitment, error) {
}
var commit ChannelCommitment
if err := c.Db.View(func(tx *bolt.Tx) error {
if err := c.Db.View(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -1659,7 +1659,7 @@ func (c *OpenChannel) CommitmentHeight() (uint64, error) {
defer c.RUnlock()
var height uint64
err := c.Db.View(func(tx *bolt.Tx) error {
err := c.Db.View(func(tx *bbolt.Tx) error {
// Get the bucket dedicated to storing the metadata for open
// channels.
chanBucket, err := fetchChanBucket(
@ -1694,7 +1694,7 @@ func (c *OpenChannel) FindPreviousState(updateNum uint64) (*ChannelCommitment, e
defer c.RUnlock()
var commit ChannelCommitment
err := c.Db.View(func(tx *bolt.Tx) error {
err := c.Db.View(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -1848,7 +1848,7 @@ func (c *OpenChannel) CloseChannel(summary *ChannelCloseSummary) error {
c.Lock()
defer c.Unlock()
return c.Db.Update(func(tx *bolt.Tx) error {
return c.Db.Update(func(tx *bbolt.Tx) error {
openChanBucket := tx.Bucket(openChannelBucket)
if openChanBucket == nil {
return ErrNoChanDBExists
@ -1992,7 +1992,7 @@ func (c *OpenChannel) Snapshot() *ChannelSnapshot {
// latest fully committed state is returned. The first commitment returned is
// the local commitment, and the second returned is the remote commitment.
func (c *OpenChannel) LatestCommitments() (*ChannelCommitment, *ChannelCommitment, error) {
err := c.Db.View(func(tx *bolt.Tx) error {
err := c.Db.View(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -2014,7 +2014,7 @@ func (c *OpenChannel) LatestCommitments() (*ChannelCommitment, *ChannelCommitmen
// acting on a possible contract breach to ensure, that the caller has the most
// up to date information required to deliver justice.
func (c *OpenChannel) RemoteRevocationStore() (shachain.Store, error) {
err := c.Db.View(func(tx *bolt.Tx) error {
err := c.Db.View(func(tx *bbolt.Tx) error {
chanBucket, err := fetchChanBucket(
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
)
@ -2031,7 +2031,7 @@ func (c *OpenChannel) RemoteRevocationStore() (shachain.Store, error) {
return c.RevocationStore, nil
}
func putChannelCloseSummary(tx *bolt.Tx, chanID []byte,
func putChannelCloseSummary(tx *bbolt.Tx, chanID []byte,
summary *ChannelCloseSummary, lastChanState *OpenChannel) error {
closedChanBucket, err := tx.CreateBucketIfNotExists(closedChannelBucket)
@ -2110,7 +2110,7 @@ func serializeChannelCloseSummary(w io.Writer, cs *ChannelCloseSummary) error {
return nil
}
func fetchChannelCloseSummary(tx *bolt.Tx,
func fetchChannelCloseSummary(tx *bbolt.Tx,
chanID []byte) (*ChannelCloseSummary, error) {
closedChanBucket, err := tx.CreateBucketIfNotExists(closedChannelBucket)
@ -2217,7 +2217,7 @@ func writeChanConfig(b io.Writer, c *ChannelConfig) error {
)
}
func putChanInfo(chanBucket *bolt.Bucket, channel *OpenChannel) error {
func putChanInfo(chanBucket *bbolt.Bucket, channel *OpenChannel) error {
var w bytes.Buffer
if err := WriteElements(&w,
channel.ChanType, channel.ChainHash, channel.FundingOutpoint,
@ -2260,7 +2260,7 @@ func serializeChanCommit(w io.Writer, c *ChannelCommitment) error {
return SerializeHtlcs(w, c.Htlcs...)
}
func putChanCommitment(chanBucket *bolt.Bucket, c *ChannelCommitment,
func putChanCommitment(chanBucket *bbolt.Bucket, c *ChannelCommitment,
local bool) error {
var commitKey []byte
@ -2278,7 +2278,7 @@ func putChanCommitment(chanBucket *bolt.Bucket, c *ChannelCommitment,
return chanBucket.Put(commitKey, b.Bytes())
}
func putChanCommitments(chanBucket *bolt.Bucket, channel *OpenChannel) error {
func putChanCommitments(chanBucket *bbolt.Bucket, channel *OpenChannel) error {
err := putChanCommitment(chanBucket, &channel.LocalCommitment, true)
if err != nil {
return err
@ -2287,7 +2287,7 @@ func putChanCommitments(chanBucket *bolt.Bucket, channel *OpenChannel) error {
return putChanCommitment(chanBucket, &channel.RemoteCommitment, false)
}
func putChanRevocationState(chanBucket *bolt.Bucket, channel *OpenChannel) error {
func putChanRevocationState(chanBucket *bbolt.Bucket, channel *OpenChannel) error {
var b bytes.Buffer
err := WriteElements(
@ -2322,7 +2322,7 @@ func readChanConfig(b io.Reader, c *ChannelConfig) error {
)
}
func fetchChanInfo(chanBucket *bolt.Bucket, channel *OpenChannel) error {
func fetchChanInfo(chanBucket *bbolt.Bucket, channel *OpenChannel) error {
infoBytes := chanBucket.Get(chanInfoKey)
if infoBytes == nil {
return ErrNoChanInfoFound
@ -2379,7 +2379,7 @@ func deserializeChanCommit(r io.Reader) (ChannelCommitment, error) {
return c, nil
}
func fetchChanCommitment(chanBucket *bolt.Bucket, local bool) (ChannelCommitment, error) {
func fetchChanCommitment(chanBucket *bbolt.Bucket, local bool) (ChannelCommitment, error) {
var commitKey []byte
if local {
commitKey = append(chanCommitmentKey, byte(0x00))
@ -2396,7 +2396,7 @@ func fetchChanCommitment(chanBucket *bolt.Bucket, local bool) (ChannelCommitment
return deserializeChanCommit(r)
}
func fetchChanCommitments(chanBucket *bolt.Bucket, channel *OpenChannel) error {
func fetchChanCommitments(chanBucket *bbolt.Bucket, channel *OpenChannel) error {
var err error
channel.LocalCommitment, err = fetchChanCommitment(chanBucket, true)
@ -2411,7 +2411,7 @@ func fetchChanCommitments(chanBucket *bolt.Bucket, channel *OpenChannel) error {
return nil
}
func fetchChanRevocationState(chanBucket *bolt.Bucket, channel *OpenChannel) error {
func fetchChanRevocationState(chanBucket *bbolt.Bucket, channel *OpenChannel) error {
revBytes := chanBucket.Get(revocationStateKey)
if revBytes == nil {
return ErrNoRevocationsFound
@ -2437,7 +2437,7 @@ func fetchChanRevocationState(chanBucket *bolt.Bucket, channel *OpenChannel) err
return ReadElements(r, &channel.RemoteNextRevocation)
}
func deleteOpenChannel(chanBucket *bolt.Bucket, chanPointBytes []byte) error {
func deleteOpenChannel(chanBucket *bbolt.Bucket, chanPointBytes []byte) error {
if err := chanBucket.Delete(chanInfoKey); err != nil {
return err
@ -2478,7 +2478,7 @@ func readLogKey(b []byte) uint64 {
return byteOrder.Uint64(b)
}
func appendChannelLogEntry(log *bolt.Bucket,
func appendChannelLogEntry(log *bbolt.Bucket,
commit *ChannelCommitment) error {
var b bytes.Buffer
@ -2490,7 +2490,7 @@ func appendChannelLogEntry(log *bolt.Bucket,
return log.Put(logEntrykey[:], b.Bytes())
}
func fetchChannelLogEntry(log *bolt.Bucket,
func fetchChannelLogEntry(log *bbolt.Bucket,
updateNum uint64) (ChannelCommitment, error) {
logEntrykey := makeLogKey(updateNum)
@ -2503,7 +2503,7 @@ func fetchChannelLogEntry(log *bolt.Bucket,
return deserializeChanCommit(commitReader)
}
func wipeChannelLogEntries(log *bolt.Bucket) error {
func wipeChannelLogEntries(log *bbolt.Bucket) error {
// TODO(roasbeef): comment
logCursor := log.Cursor()

@ -23,7 +23,7 @@ const (
// migration is a function which takes a prior outdated version of the database
// instances and mutates the key/bucket structure to arrive at a more
// up-to-date version of the database.
type migration func(tx *bolt.Tx) error
type migration func(tx *bbolt.Tx) error
type version struct {
number uint32
@ -103,7 +103,7 @@ var bufPool = &sync.Pool{
// information related to nodes, routing data, open/closed channels, fee
// schedules, and reputation data.
type DB struct {
*bolt.DB
*bbolt.DB
dbPath string
}
@ -118,7 +118,7 @@ func Open(dbPath string) (*DB, error) {
}
}
bdb, err := bolt.Open(path, dbFilePermission, nil)
bdb, err := bbolt.Open(path, dbFilePermission, nil)
if err != nil {
return nil, err
}
@ -146,41 +146,41 @@ func (d *DB) Path() string {
// database. The deletion is done in a single transaction, therefore this
// operation is fully atomic.
func (d *DB) Wipe() error {
return d.Update(func(tx *bolt.Tx) error {
return d.Update(func(tx *bbolt.Tx) error {
err := tx.DeleteBucket(openChannelBucket)
if err != nil && err != bolt.ErrBucketNotFound {
if err != nil && err != bbolt.ErrBucketNotFound {
return err
}
err = tx.DeleteBucket(closedChannelBucket)
if err != nil && err != bolt.ErrBucketNotFound {
if err != nil && err != bbolt.ErrBucketNotFound {
return err
}
err = tx.DeleteBucket(invoiceBucket)
if err != nil && err != bolt.ErrBucketNotFound {
if err != nil && err != bbolt.ErrBucketNotFound {
return err
}
err = tx.DeleteBucket(nodeInfoBucket)
if err != nil && err != bolt.ErrBucketNotFound {
if err != nil && err != bbolt.ErrBucketNotFound {
return err
}
err = tx.DeleteBucket(nodeBucket)
if err != nil && err != bolt.ErrBucketNotFound {
if err != nil && err != bbolt.ErrBucketNotFound {
return err
}
err = tx.DeleteBucket(edgeBucket)
if err != nil && err != bolt.ErrBucketNotFound {
if err != nil && err != bbolt.ErrBucketNotFound {
return err
}
err = tx.DeleteBucket(edgeIndexBucket)
if err != nil && err != bolt.ErrBucketNotFound {
if err != nil && err != bbolt.ErrBucketNotFound {
return err
}
err = tx.DeleteBucket(graphMetaBucket)
if err != nil && err != bolt.ErrBucketNotFound {
if err != nil && err != bbolt.ErrBucketNotFound {
return err
}
@ -200,12 +200,12 @@ func createChannelDB(dbPath string) error {
}
path := filepath.Join(dbPath, dbName)
bdb, err := bolt.Open(path, dbFilePermission, nil)
bdb, err := bbolt.Open(path, dbFilePermission, nil)
if err != nil {
return err
}
err = bdb.Update(func(tx *bolt.Tx) error {
err = bdb.Update(func(tx *bbolt.Tx) error {
if _, err := tx.CreateBucket(openChannelBucket); err != nil {
return err
}
@ -302,7 +302,7 @@ func fileExists(path string) bool {
// zero-length slice is returned.
func (d *DB) FetchOpenChannels(nodeID *btcec.PublicKey) ([]*OpenChannel, error) {
var channels []*OpenChannel
err := d.View(func(tx *bolt.Tx) error {
err := d.View(func(tx *bbolt.Tx) error {
var err error
channels, err = d.fetchOpenChannels(tx, nodeID)
return err
@ -315,7 +315,7 @@ func (d *DB) FetchOpenChannels(nodeID *btcec.PublicKey) ([]*OpenChannel, error)
// stored currently active/open channels associated with the target nodeID. In
// the case that no active channels are known to have been created with this
// node, then a zero-length slice is returned.
func (d *DB) fetchOpenChannels(tx *bolt.Tx,
func (d *DB) fetchOpenChannels(tx *bbolt.Tx,
nodeID *btcec.PublicKey) ([]*OpenChannel, error) {
// Get the bucket dedicated to storing the metadata for open channels.
@ -368,7 +368,7 @@ func (d *DB) fetchOpenChannels(tx *bolt.Tx,
// fetchNodeChannels retrieves all active channels from the target chainBucket
// which is under a node's dedicated channel bucket. This function is typically
// used to fetch all the active channels related to a particular node.
func (d *DB) fetchNodeChannels(chainBucket *bolt.Bucket) ([]*OpenChannel, error) {
func (d *DB) fetchNodeChannels(chainBucket *bbolt.Bucket) ([]*OpenChannel, error) {
var channels []*OpenChannel
@ -464,7 +464,7 @@ func (d *DB) FetchWaitingCloseChannels() ([]*OpenChannel, error) {
func fetchChannels(d *DB, pending, waitingClose bool) ([]*OpenChannel, error) {
var channels []*OpenChannel
err := d.View(func(tx *bolt.Tx) error {
err := d.View(func(tx *bbolt.Tx) error {
// Get the bucket dedicated to storing the metadata for open
// channels.
openChanBucket := tx.Bucket(openChannelBucket)
@ -551,7 +551,7 @@ func fetchChannels(d *DB, pending, waitingClose bool) ([]*OpenChannel, error) {
func (d *DB) FetchClosedChannels(pendingOnly bool) ([]*ChannelCloseSummary, error) {
var chanSummaries []*ChannelCloseSummary
if err := d.View(func(tx *bolt.Tx) error {
if err := d.View(func(tx *bbolt.Tx) error {
closeBucket := tx.Bucket(closedChannelBucket)
if closeBucket == nil {
return ErrNoClosedChannels
@ -589,7 +589,7 @@ var ErrClosedChannelNotFound = errors.New("unable to find closed channel summary
// point of the channel in question.
func (d *DB) FetchClosedChannel(chanID *wire.OutPoint) (*ChannelCloseSummary, error) {
var chanSummary *ChannelCloseSummary
if err := d.View(func(tx *bolt.Tx) error {
if err := d.View(func(tx *bbolt.Tx) error {
closeBucket := tx.Bucket(closedChannelBucket)
if closeBucket == nil {
return ErrClosedChannelNotFound
@ -623,7 +623,7 @@ func (d *DB) FetchClosedChannelForID(cid lnwire.ChannelID) (
*ChannelCloseSummary, error) {
var chanSummary *ChannelCloseSummary
if err := d.View(func(tx *bolt.Tx) error {
if err := d.View(func(tx *bbolt.Tx) error {
closeBucket := tx.Bucket(closedChannelBucket)
if closeBucket == nil {
return ErrClosedChannelNotFound
@ -671,7 +671,7 @@ func (d *DB) FetchClosedChannelForID(cid lnwire.ChannelID) (
// the pending funds in a channel that has been forcibly closed have been
// swept.
func (d *DB) MarkChanFullyClosed(chanPoint *wire.OutPoint) error {
return d.Update(func(tx *bolt.Tx) error {
return d.Update(func(tx *bbolt.Tx) error {
var b bytes.Buffer
if err := writeOutpoint(&b, chanPoint); err != nil {
return err
@ -724,7 +724,7 @@ func (d *DB) MarkChanFullyClosed(chanPoint *wire.OutPoint) error {
// pruneLinkNode determines whether we should garbage collect a link node from
// the database due to no longer having any open channels with it. If there are
// any left, then this acts as a no-op.
func (d *DB) pruneLinkNode(tx *bolt.Tx, remotePub *btcec.PublicKey) error {
func (d *DB) pruneLinkNode(tx *bbolt.Tx, remotePub *btcec.PublicKey) error {
openChannels, err := d.fetchOpenChannels(tx, remotePub)
if err != nil {
return fmt.Errorf("unable to fetch open channels for peer %x: "+
@ -744,7 +744,7 @@ func (d *DB) pruneLinkNode(tx *bolt.Tx, remotePub *btcec.PublicKey) error {
// PruneLinkNodes attempts to prune all link nodes found within the databse with
// whom we no longer have any open channels with.
func (d *DB) PruneLinkNodes() error {
return d.Update(func(tx *bolt.Tx) error {
return d.Update(func(tx *bbolt.Tx) error {
linkNodes, err := d.fetchAllLinkNodes(tx)
if err != nil {
return err
@ -803,7 +803,7 @@ func (d *DB) syncVersions(versions []version) error {
migrations, migrationVersions := getMigrationsToApply(
versions, meta.DbVersionNumber,
)
return d.Update(func(tx *bolt.Tx) error {
return d.Update(func(tx *bbolt.Tx) error {
for i, migration := range migrations {
if migration == nil {
continue

@ -111,7 +111,7 @@ func (f *ForwardingLog) AddForwardingEvents(events []ForwardingEvent) error {
var timestamp [8]byte
return f.db.Batch(func(tx *bolt.Tx) error {
return f.db.Batch(func(tx *bbolt.Tx) error {
// First, we'll fetch the bucket that stores our time series
// log.
logBucket, err := tx.CreateBucketIfNotExists(
@ -204,7 +204,7 @@ func (f *ForwardingLog) Query(q ForwardingEventQuery) (ForwardingLogTimeSlice, e
recordsToSkip := q.IndexOffset
recordOffset := q.IndexOffset
err := f.db.View(func(tx *bolt.Tx) error {
err := f.db.View(func(tx *bbolt.Tx) error {
// If the bucket wasn't found, then there aren't any events to
// be returned.
logBucket := tx.Bucket(forwardingLogBucket)

@ -318,7 +318,7 @@ type SettleFailRef struct {
type SettleFailAcker interface {
// AckSettleFails atomically updates the settle-fail filters in *other*
// channels' forwarding packages.
AckSettleFails(tx *bolt.Tx, settleFailRefs ...SettleFailRef) error
AckSettleFails(tx *bbolt.Tx, settleFailRefs ...SettleFailRef) error
}
// GlobalFwdPkgReader is an interface used to retrieve the forwarding packages
@ -326,7 +326,7 @@ type SettleFailAcker interface {
type GlobalFwdPkgReader interface {
// LoadChannelFwdPkgs loads all known forwarding packages for the given
// channel.
LoadChannelFwdPkgs(tx *bolt.Tx,
LoadChannelFwdPkgs(tx *bbolt.Tx,
source lnwire.ShortChannelID) ([]*FwdPkg, error)
}
@ -357,14 +357,14 @@ func NewSwitchPackager() *SwitchPackager {
// AckSettleFails atomically updates the settle-fail filters in *other*
// channels' forwarding packages, to mark that the switch has received a settle
// or fail residing in the forwarding package of a link.
func (*SwitchPackager) AckSettleFails(tx *bolt.Tx,
func (*SwitchPackager) AckSettleFails(tx *bbolt.Tx,
settleFailRefs ...SettleFailRef) error {
return ackSettleFails(tx, settleFailRefs)
}
// LoadChannelFwdPkgs loads all forwarding packages for a particular channel.
func (*SwitchPackager) LoadChannelFwdPkgs(tx *bolt.Tx,
func (*SwitchPackager) LoadChannelFwdPkgs(tx *bbolt.Tx,
source lnwire.ShortChannelID) ([]*FwdPkg, error) {
return loadChannelFwdPkgs(tx, source)
@ -376,19 +376,19 @@ func (*SwitchPackager) LoadChannelFwdPkgs(tx *bolt.Tx,
type FwdPackager interface {
// AddFwdPkg serializes and writes a FwdPkg for this channel at the
// remote commitment height included in the forwarding package.
AddFwdPkg(tx *bolt.Tx, fwdPkg *FwdPkg) error
AddFwdPkg(tx *bbolt.Tx, fwdPkg *FwdPkg) error
// SetFwdFilter looks up the forwarding package at the remote `height`
// and sets the `fwdFilter`, marking the Adds for which:
// 1) We are not the exit node
// 2) Passed all validation
// 3) Should be forwarded to the switch immediately after a failure
SetFwdFilter(tx *bolt.Tx, height uint64, fwdFilter *PkgFilter) error
SetFwdFilter(tx *bbolt.Tx, height uint64, fwdFilter *PkgFilter) error
// AckAddHtlcs atomically updates the add filters in this channel's
// forwarding packages to mark the resolution of an Add that was
// received from the remote party.
AckAddHtlcs(tx *bolt.Tx, addRefs ...AddRef) error
AckAddHtlcs(tx *bbolt.Tx, addRefs ...AddRef) error
// SettleFailAcker allows a link to acknowledge settle/fail HTLCs
// belonging to other channels.
@ -396,11 +396,11 @@ type FwdPackager interface {
// LoadFwdPkgs loads all known forwarding packages owned by this
// channel.
LoadFwdPkgs(tx *bolt.Tx) ([]*FwdPkg, error)
LoadFwdPkgs(tx *bbolt.Tx) ([]*FwdPkg, error)
// RemovePkg deletes a forwarding package owned by this channel at
// the provided remote `height`.
RemovePkg(tx *bolt.Tx, height uint64) error
RemovePkg(tx *bbolt.Tx, height uint64) error
}
// ChannelPackager is used by a channel to manage the lifecycle of its forwarding
@ -420,7 +420,7 @@ func NewChannelPackager(source lnwire.ShortChannelID) *ChannelPackager {
}
// AddFwdPkg writes a newly locked in forwarding package to disk.
func (*ChannelPackager) AddFwdPkg(tx *bolt.Tx, fwdPkg *FwdPkg) error {
func (*ChannelPackager) AddFwdPkg(tx *bbolt.Tx, fwdPkg *FwdPkg) error {
fwdPkgBkt, err := tx.CreateBucketIfNotExists(fwdPackagesKey)
if err != nil {
return err
@ -485,7 +485,7 @@ func (*ChannelPackager) AddFwdPkg(tx *bolt.Tx, fwdPkg *FwdPkg) error {
}
// putLogUpdate writes an htlc to the provided `bkt`, using `index` as the key.
func putLogUpdate(bkt *bolt.Bucket, idx uint16, htlc *LogUpdate) error {
func putLogUpdate(bkt *bbolt.Bucket, idx uint16, htlc *LogUpdate) error {
var b bytes.Buffer
if err := htlc.Encode(&b); err != nil {
return err
@ -497,12 +497,12 @@ func putLogUpdate(bkt *bolt.Bucket, idx uint16, htlc *LogUpdate) error {
// LoadFwdPkgs scans the forwarding log for any packages that haven't been
// processed, and returns their deserialized log updates in a map indexed by the
// remote commitment height at which the updates were locked in.
func (p *ChannelPackager) LoadFwdPkgs(tx *bolt.Tx) ([]*FwdPkg, error) {
func (p *ChannelPackager) LoadFwdPkgs(tx *bbolt.Tx) ([]*FwdPkg, error) {
return loadChannelFwdPkgs(tx, p.source)
}
// loadChannelFwdPkgs loads all forwarding packages owned by `source`.
func loadChannelFwdPkgs(tx *bolt.Tx, source lnwire.ShortChannelID) ([]*FwdPkg, error) {
func loadChannelFwdPkgs(tx *bbolt.Tx, source lnwire.ShortChannelID) ([]*FwdPkg, error) {
fwdPkgBkt := tx.Bucket(fwdPackagesKey)
if fwdPkgBkt == nil {
return nil, nil
@ -543,7 +543,7 @@ func loadChannelFwdPkgs(tx *bolt.Tx, source lnwire.ShortChannelID) ([]*FwdPkg, e
// loadFwPkg reads the packager's fwd pkg at a given height, and determines the
// appropriate FwdState.
func loadFwdPkg(fwdPkgBkt *bolt.Bucket, source lnwire.ShortChannelID,
func loadFwdPkg(fwdPkgBkt *bbolt.Bucket, source lnwire.ShortChannelID,
height uint64) (*FwdPkg, error) {
sourceKey := makeLogKey(source.ToUint64())
@ -649,7 +649,7 @@ func loadFwdPkg(fwdPkgBkt *bolt.Bucket, source lnwire.ShortChannelID,
// loadHtlcs retrieves all serialized htlcs in a bucket, returning
// them in order of the indexes they were written under.
func loadHtlcs(bkt *bolt.Bucket) ([]LogUpdate, error) {
func loadHtlcs(bkt *bbolt.Bucket) ([]LogUpdate, error) {
var htlcs []LogUpdate
if err := bkt.ForEach(func(_, v []byte) error {
var htlc LogUpdate
@ -674,7 +674,7 @@ func loadHtlcs(bkt *bolt.Bucket) ([]LogUpdate, error) {
// leaving this channel. After a restart, we skip validation of these Adds,
// since they are assumed to have already been validated, and make the switch or
// outgoing link responsible for handling replays.
func (p *ChannelPackager) SetFwdFilter(tx *bolt.Tx, height uint64,
func (p *ChannelPackager) SetFwdFilter(tx *bbolt.Tx, height uint64,
fwdFilter *PkgFilter) error {
fwdPkgBkt := tx.Bucket(fwdPackagesKey)
@ -713,7 +713,7 @@ func (p *ChannelPackager) SetFwdFilter(tx *bolt.Tx, height uint64,
// AckAddHtlcs accepts a list of references to add htlcs, and updates the
// AckAddFilter of those forwarding packages to indicate that a settle or fail
// has been received in response to the add.
func (p *ChannelPackager) AckAddHtlcs(tx *bolt.Tx, addRefs ...AddRef) error {
func (p *ChannelPackager) AckAddHtlcs(tx *bbolt.Tx, addRefs ...AddRef) error {
if len(addRefs) == 0 {
return nil
}
@ -753,7 +753,7 @@ func (p *ChannelPackager) AckAddHtlcs(tx *bolt.Tx, addRefs ...AddRef) error {
// ackAddHtlcsAtHeight updates the AddAckFilter of a single forwarding package
// with a list of indexes, writing the resulting filter back in its place.
func ackAddHtlcsAtHeight(sourceBkt *bolt.Bucket, height uint64,
func ackAddHtlcsAtHeight(sourceBkt *bbolt.Bucket, height uint64,
indexes []uint16) error {
heightKey := makeLogKey(height)
@ -796,12 +796,12 @@ func ackAddHtlcsAtHeight(sourceBkt *bolt.Bucket, height uint64,
// package. This should only be called after the source of the Add has locked in
// the settle/fail, or it becomes otherwise safe to forgo retransmitting the
// settle/fail after a restart.
func (p *ChannelPackager) AckSettleFails(tx *bolt.Tx, settleFailRefs ...SettleFailRef) error {
func (p *ChannelPackager) AckSettleFails(tx *bbolt.Tx, settleFailRefs ...SettleFailRef) error {
return ackSettleFails(tx, settleFailRefs)
}
// ackSettleFails persistently acknowledges a batch of settle fail references.
func ackSettleFails(tx *bolt.Tx, settleFailRefs []SettleFailRef) error {
func ackSettleFails(tx *bbolt.Tx, settleFailRefs []SettleFailRef) error {
if len(settleFailRefs) == 0 {
return nil
}
@ -855,7 +855,7 @@ func ackSettleFails(tx *bolt.Tx, settleFailRefs []SettleFailRef) error {
// ackSettleFailsAtHeight given a destination bucket, acks the provided indexes
// at particular a height by updating the settle fail filter.
func ackSettleFailsAtHeight(destBkt *bolt.Bucket, height uint64,
func ackSettleFailsAtHeight(destBkt *bbolt.Bucket, height uint64,
indexes []uint16) error {
heightKey := makeLogKey(height)
@ -895,7 +895,7 @@ func ackSettleFailsAtHeight(destBkt *bolt.Bucket, height uint64,
// RemovePkg deletes the forwarding package at the given height from the
// packager's source bucket.
func (p *ChannelPackager) RemovePkg(tx *bolt.Tx, height uint64) error {
func (p *ChannelPackager) RemovePkg(tx *bbolt.Tx, height uint64) error {
fwdPkgBkt := tx.Bucket(fwdPackagesKey)
if fwdPkgBkt == nil {
return nil

@ -207,7 +207,7 @@ func TestPackagerEmptyFwdPkg(t *testing.T) {
// Next, create and write a new forwarding package with no htlcs.
fwdPkg := channeldb.NewFwdPkg(shortChanID, 0, nil, nil)
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.AddFwdPkg(tx, fwdPkg)
}); err != nil {
t.Fatalf("unable to add fwd pkg: %v", err)
@ -226,7 +226,7 @@ func TestPackagerEmptyFwdPkg(t *testing.T) {
// Now, write the forwarding decision. In this case, its just an empty
// fwd filter.
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.SetFwdFilter(tx, fwdPkg.Height, fwdPkg.FwdFilter)
}); err != nil {
t.Fatalf("unable to set fwdfiter: %v", err)
@ -244,7 +244,7 @@ func TestPackagerEmptyFwdPkg(t *testing.T) {
assertAckFilterIsFull(t, fwdPkgs[0], true)
// Lastly, remove the completed forwarding package from disk.
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.RemovePkg(tx, fwdPkg.Height)
}); err != nil {
t.Fatalf("unable to remove fwdpkg: %v", err)
@ -279,7 +279,7 @@ func TestPackagerOnlyAdds(t *testing.T) {
nAdds := len(adds)
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.AddFwdPkg(tx, fwdPkg)
}); err != nil {
t.Fatalf("unable to add fwd pkg: %v", err)
@ -300,7 +300,7 @@ func TestPackagerOnlyAdds(t *testing.T) {
// added any adds to the fwdfilter, this would indicate that all of the
// adds were 1) settled locally by this link (exit hop), or 2) the htlc
// was failed locally.
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.SetFwdFilter(tx, fwdPkg.Height, fwdPkg.FwdFilter)
}); err != nil {
t.Fatalf("unable to set fwdfiter: %v", err)
@ -324,7 +324,7 @@ func TestPackagerOnlyAdds(t *testing.T) {
Index: uint16(i),
}
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.AckAddHtlcs(tx, addRef)
}); err != nil {
t.Fatalf("unable to ack add htlc: %v", err)
@ -343,7 +343,7 @@ func TestPackagerOnlyAdds(t *testing.T) {
assertAckFilterIsFull(t, fwdPkgs[0], true)
// Lastly, remove the completed forwarding package from disk.
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.RemovePkg(tx, fwdPkg.Height)
}); err != nil {
t.Fatalf("unable to remove fwdpkg: %v", err)
@ -381,7 +381,7 @@ func TestPackagerOnlySettleFails(t *testing.T) {
nSettleFails := len(settleFails)
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.AddFwdPkg(tx, fwdPkg)
}); err != nil {
t.Fatalf("unable to add fwd pkg: %v", err)
@ -402,7 +402,7 @@ func TestPackagerOnlySettleFails(t *testing.T) {
// added any adds to the fwdfilter, this would indicate that all of the
// adds were 1) settled locally by this link (exit hop), or 2) the htlc
// was failed locally.
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.SetFwdFilter(tx, fwdPkg.Height, fwdPkg.FwdFilter)
}); err != nil {
t.Fatalf("unable to set fwdfiter: %v", err)
@ -428,7 +428,7 @@ func TestPackagerOnlySettleFails(t *testing.T) {
Index: uint16(i),
}
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.AckSettleFails(tx, failSettleRef)
}); err != nil {
t.Fatalf("unable to ack add htlc: %v", err)
@ -448,7 +448,7 @@ func TestPackagerOnlySettleFails(t *testing.T) {
assertAckFilterIsFull(t, fwdPkgs[0], true)
// Lastly, remove the completed forwarding package from disk.
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.RemovePkg(tx, fwdPkg.Height)
}); err != nil {
t.Fatalf("unable to remove fwdpkg: %v", err)
@ -486,7 +486,7 @@ func TestPackagerAddsThenSettleFails(t *testing.T) {
nAdds := len(adds)
nSettleFails := len(settleFails)
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.AddFwdPkg(tx, fwdPkg)
}); err != nil {
t.Fatalf("unable to add fwd pkg: %v", err)
@ -507,7 +507,7 @@ func TestPackagerAddsThenSettleFails(t *testing.T) {
// added any adds to the fwdfilter, this would indicate that all of the
// adds were 1) settled locally by this link (exit hop), or 2) the htlc
// was failed locally.
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.SetFwdFilter(tx, fwdPkg.Height, fwdPkg.FwdFilter)
}); err != nil {
t.Fatalf("unable to set fwdfiter: %v", err)
@ -532,7 +532,7 @@ func TestPackagerAddsThenSettleFails(t *testing.T) {
Index: uint16(i),
}
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.AckAddHtlcs(tx, addRef)
}); err != nil {
t.Fatalf("unable to ack add htlc: %v", err)
@ -559,7 +559,7 @@ func TestPackagerAddsThenSettleFails(t *testing.T) {
Index: uint16(i),
}
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.AckSettleFails(tx, failSettleRef)
}); err != nil {
t.Fatalf("unable to remove settle/fail htlc: %v", err)
@ -579,7 +579,7 @@ func TestPackagerAddsThenSettleFails(t *testing.T) {
assertAckFilterIsFull(t, fwdPkgs[0], true)
// Lastly, remove the completed forwarding package from disk.
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.RemovePkg(tx, fwdPkg.Height)
}); err != nil {
t.Fatalf("unable to remove fwdpkg: %v", err)
@ -619,7 +619,7 @@ func TestPackagerSettleFailsThenAdds(t *testing.T) {
nAdds := len(adds)
nSettleFails := len(settleFails)
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.AddFwdPkg(tx, fwdPkg)
}); err != nil {
t.Fatalf("unable to add fwd pkg: %v", err)
@ -640,7 +640,7 @@ func TestPackagerSettleFailsThenAdds(t *testing.T) {
// added any adds to the fwdfilter, this would indicate that all of the
// adds were 1) settled locally by this link (exit hop), or 2) the htlc
// was failed locally.
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.SetFwdFilter(tx, fwdPkg.Height, fwdPkg.FwdFilter)
}); err != nil {
t.Fatalf("unable to set fwdfiter: %v", err)
@ -669,7 +669,7 @@ func TestPackagerSettleFailsThenAdds(t *testing.T) {
Index: uint16(i),
}
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.AckSettleFails(tx, failSettleRef)
}); err != nil {
t.Fatalf("unable to remove settle/fail htlc: %v", err)
@ -696,7 +696,7 @@ func TestPackagerSettleFailsThenAdds(t *testing.T) {
Index: uint16(i),
}
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.AckAddHtlcs(tx, addRef)
}); err != nil {
t.Fatalf("unable to ack add htlc: %v", err)
@ -716,7 +716,7 @@ func TestPackagerSettleFailsThenAdds(t *testing.T) {
assertAckFilterIsFull(t, fwdPkgs[0], true)
// Lastly, remove the completed forwarding package from disk.
if err := db.Update(func(tx *bolt.Tx) error {
if err := db.Update(func(tx *bbolt.Tx) error {
return packager.RemovePkg(tx, fwdPkg.Height)
}); err != nil {
t.Fatalf("unable to remove fwdpkg: %v", err)
@ -778,11 +778,11 @@ func assertSettleFailFilterIsFull(t *testing.T, fwdPkg *channeldb.FwdPkg, expect
// loadFwdPkgs is a helper method that reads all forwarding packages for a
// particular packager.
func loadFwdPkgs(t *testing.T, db *bolt.DB,
func loadFwdPkgs(t *testing.T, db *bbolt.DB,
packager channeldb.FwdPackager) []*channeldb.FwdPkg {
var fwdPkgs []*channeldb.FwdPkg
if err := db.View(func(tx *bolt.Tx) error {
if err := db.View(func(tx *bbolt.Tx) error {
var err error
fwdPkgs, err = packager.LoadFwdPkgs(tx)
return err
@ -795,7 +795,7 @@ func loadFwdPkgs(t *testing.T, db *bolt.DB,
// makeFwdPkgDB initializes a test database for forwarding packages. If the
// provided path is an empty, it will create a temp dir/file to use.
func makeFwdPkgDB(t *testing.T, path string) *bolt.DB {
func makeFwdPkgDB(t *testing.T, path string) *bbolt.DB {
if path == "" {
var err error
path, err = ioutil.TempDir("", "fwdpkgdb")
@ -806,7 +806,7 @@ func makeFwdPkgDB(t *testing.T, path string) *bolt.DB {
path = filepath.Join(path, "fwdpkg.db")
}
db, err := bolt.Open(path, 0600, nil)
db, err := bbolt.Open(path, 0600, nil)
if err != nil {
t.Fatalf("unable to open boltdb: %v", err)
}

@ -171,7 +171,7 @@ func (c *ChannelGraph) Database() *DB {
func (c *ChannelGraph) ForEachChannel(cb func(*ChannelEdgeInfo, *ChannelEdgePolicy, *ChannelEdgePolicy) error) error {
// TODO(roasbeef): ptr map to reduce # of allocs? no duplicates
return c.db.View(func(tx *bolt.Tx) error {
return c.db.View(func(tx *bbolt.Tx) error {
// First, grab the node bucket. This will be used to populate
// the Node pointers in each edge read from disk.
nodes := tx.Bucket(nodeBucket)
@ -229,8 +229,8 @@ func (c *ChannelGraph) ForEachChannel(cb func(*ChannelEdgeInfo, *ChannelEdgePoli
//
// TODO(roasbeef): add iterator interface to allow for memory efficient graph
// traversal when graph gets mega
func (c *ChannelGraph) ForEachNode(tx *bolt.Tx, cb func(*bolt.Tx, *LightningNode) error) error {
traversal := func(tx *bolt.Tx) error {
func (c *ChannelGraph) ForEachNode(tx *bbolt.Tx, cb func(*bbolt.Tx, *LightningNode) error) error {
traversal := func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.Bucket(nodeBucket)
@ -276,7 +276,7 @@ func (c *ChannelGraph) ForEachNode(tx *bolt.Tx, cb func(*bolt.Tx, *LightningNode
// node based off the source node.
func (c *ChannelGraph) SourceNode() (*LightningNode, error) {
var source *LightningNode
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
node, err := c.sourceNode(tx)
if err != nil {
return err
@ -296,7 +296,7 @@ func (c *ChannelGraph) SourceNode() (*LightningNode, error) {
// of the graph. The source node is treated as the center node within a
// star-graph. This method may be used to kick off a path finding algorithm in
// order to explore the reachability of another node based off the source node.
func (c *ChannelGraph) sourceNode(tx *bolt.Tx) (*LightningNode, error) {
func (c *ChannelGraph) sourceNode(tx *bbolt.Tx) (*LightningNode, error) {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.Bucket(nodeBucket)
@ -326,7 +326,7 @@ func (c *ChannelGraph) sourceNode(tx *bolt.Tx) (*LightningNode, error) {
func (c *ChannelGraph) SetSourceNode(node *LightningNode) error {
nodePubBytes := node.PubKeyBytes[:]
return c.db.Update(func(tx *bolt.Tx) error {
return c.db.Update(func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
@ -355,12 +355,12 @@ func (c *ChannelGraph) SetSourceNode(node *LightningNode) error {
//
// TODO(roasbeef): also need sig of announcement
func (c *ChannelGraph) AddLightningNode(node *LightningNode) error {
return c.db.Update(func(tx *bolt.Tx) error {
return c.db.Update(func(tx *bbolt.Tx) error {
return addLightningNode(tx, node)
})
}
func addLightningNode(tx *bolt.Tx, node *LightningNode) error {
func addLightningNode(tx *bbolt.Tx, node *LightningNode) error {
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
if err != nil {
return err
@ -386,7 +386,7 @@ func addLightningNode(tx *bolt.Tx, node *LightningNode) error {
func (c *ChannelGraph) LookupAlias(pub *btcec.PublicKey) (string, error) {
var alias string
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNodesNotFound
@ -419,14 +419,14 @@ func (c *ChannelGraph) LookupAlias(pub *btcec.PublicKey) (string, error) {
// from the database according to the node's public key.
func (c *ChannelGraph) DeleteLightningNode(nodePub *btcec.PublicKey) error {
// TODO(roasbeef): ensure dangling edges are removed...
return c.db.Update(func(tx *bolt.Tx) error {
return c.db.Update(func(tx *bbolt.Tx) error {
return c.deleteLightningNode(tx, nodePub.SerializeCompressed())
})
}
// deleteLightningNode uses an existing database transaction to remove a
// vertex/node from the database according to the node's public key.
func (c *ChannelGraph) deleteLightningNode(tx *bolt.Tx,
func (c *ChannelGraph) deleteLightningNode(tx *bbolt.Tx,
compressedPubKey []byte) error {
nodes := tx.Bucket(nodeBucket)
@ -485,7 +485,7 @@ func (c *ChannelGraph) AddChannelEdge(edge *ChannelEdgeInfo) error {
var chanKey [8]byte
binary.BigEndian.PutUint64(chanKey[:], edge.ChannelID)
return c.db.Update(func(tx *bolt.Tx) error {
return c.db.Update(func(tx *bbolt.Tx) error {
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
if err != nil {
return err
@ -591,7 +591,7 @@ func (c *ChannelGraph) HasChannelEdge(chanID uint64) (time.Time, time.Time, bool
exists bool
)
if err := c.db.View(func(tx *bolt.Tx) error {
if err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
@ -651,7 +651,7 @@ func (c *ChannelGraph) UpdateChannelEdge(edge *ChannelEdgeInfo) error {
var chanKey [8]byte
binary.BigEndian.PutUint64(chanKey[:], edge.ChannelID)
return c.db.Update(func(tx *bolt.Tx) error {
return c.db.Update(func(tx *bbolt.Tx) error {
edges, err := tx.CreateBucketIfNotExists(edgeBucket)
if err != nil {
return err
@ -690,7 +690,7 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
var chansClosed []*ChannelEdgeInfo
err := c.db.Update(func(tx *bolt.Tx) error {
err := c.db.Update(func(tx *bbolt.Tx) error {
// First grab the edges bucket which houses the information
// we'd like to delete
edges, err := tx.CreateBucketIfNotExists(edgeBucket)
@ -794,7 +794,7 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
// that we only maintain a graph of reachable nodes. In the event that a pruned
// node gains more channels, it will be re-added back to the graph.
func (c *ChannelGraph) PruneGraphNodes() error {
return c.db.Update(func(tx *bolt.Tx) error {
return c.db.Update(func(tx *bbolt.Tx) error {
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
if err != nil {
return err
@ -815,8 +815,8 @@ func (c *ChannelGraph) PruneGraphNodes() error {
// pruneGraphNodes attempts to remove any nodes from the graph who have had a
// channel closed within the current block. If the node still has existing
// channels in the graph, this will act as a no-op.
func (c *ChannelGraph) pruneGraphNodes(tx *bolt.Tx, nodes *bolt.Bucket,
edgeIndex *bolt.Bucket) error {
func (c *ChannelGraph) pruneGraphNodes(tx *bbolt.Tx, nodes *bbolt.Bucket,
edgeIndex *bbolt.Bucket) error {
log.Trace("Pruning nodes from graph with no open channels")
@ -939,7 +939,7 @@ func (c *ChannelGraph) DisconnectBlockAtHeight(height uint32) ([]*ChannelEdgeInf
// Keep track of the channels that are removed from the graph.
var removedChans []*ChannelEdgeInfo
if err := c.db.Update(func(tx *bolt.Tx) error {
if err := c.db.Update(func(tx *bbolt.Tx) error {
edges, err := tx.CreateBucketIfNotExists(edgeBucket)
if err != nil {
return err
@ -1022,7 +1022,7 @@ func (c *ChannelGraph) PruneTip() (*chainhash.Hash, uint32, error) {
tipHeight uint32
)
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
graphMeta := tx.Bucket(graphMetaBucket)
if graphMeta == nil {
return ErrGraphNotFound
@ -1063,7 +1063,7 @@ func (c *ChannelGraph) DeleteChannelEdge(chanPoint *wire.OutPoint) error {
// channels
// TODO(roasbeef): don't delete both edges?
return c.db.Update(func(tx *bolt.Tx) error {
return c.db.Update(func(tx *bbolt.Tx) error {
// First grab the edges bucket which houses the information
// we'd like to delete
edges, err := tx.CreateBucketIfNotExists(edgeBucket)
@ -1099,7 +1099,7 @@ func (c *ChannelGraph) ChannelID(chanPoint *wire.OutPoint) (uint64, error) {
return 0, nil
}
if err := c.db.View(func(tx *bolt.Tx) error {
if err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
@ -1132,7 +1132,7 @@ func (c *ChannelGraph) ChannelID(chanPoint *wire.OutPoint) (uint64, error) {
func (c *ChannelGraph) HighestChanID() (uint64, error) {
var cid uint64
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
@ -1191,7 +1191,7 @@ func (c *ChannelGraph) ChanUpdatesInHorizon(startTime, endTime time.Time) ([]Cha
edgesSeen := make(map[uint64]struct{})
var edgesInHorizon []ChannelEdge
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
@ -1293,7 +1293,7 @@ func (c *ChannelGraph) ChanUpdatesInHorizon(startTime, endTime time.Time) ([]Cha
func (c *ChannelGraph) NodeUpdatesInHorizon(startTime, endTime time.Time) ([]LightningNode, error) {
var nodesInHorizon []LightningNode
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNodesNotFound
@ -1355,7 +1355,7 @@ func (c *ChannelGraph) NodeUpdatesInHorizon(startTime, endTime time.Time) ([]Lig
func (c *ChannelGraph) FilterKnownChanIDs(chanIDs []uint64) ([]uint64, error) {
var newChanIDs []uint64
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
@ -1415,7 +1415,7 @@ func (c *ChannelGraph) FilterChannelRange(startHeight, endHeight uint32) ([]uint
byteOrder.PutUint64(chanIDStart[:], startChanID.ToUint64())
byteOrder.PutUint64(chanIDEnd[:], endChanID.ToUint64())
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
@ -1466,7 +1466,7 @@ func (c *ChannelGraph) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) {
cidBytes [8]byte
)
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
@ -1516,7 +1516,7 @@ func (c *ChannelGraph) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) {
return chanEdges, nil
}
func delEdgeUpdateIndexEntry(edgesBucket *bolt.Bucket, chanID uint64,
func delEdgeUpdateIndexEntry(edgesBucket *bbolt.Bucket, chanID uint64,
edge1, edge2 *ChannelEdgePolicy) error {
// First, we'll fetch the edge update index bucket which currently
@ -1555,8 +1555,8 @@ func delEdgeUpdateIndexEntry(edgesBucket *bolt.Bucket, chanID uint64,
return nil
}
func delChannelByEdge(edges *bolt.Bucket, edgeIndex *bolt.Bucket,
chanIndex *bolt.Bucket, nodes *bolt.Bucket, chanPoint *wire.OutPoint) error {
func delChannelByEdge(edges *bbolt.Bucket, edgeIndex *bbolt.Bucket,
chanIndex *bbolt.Bucket, nodes *bbolt.Bucket, chanPoint *wire.OutPoint) error {
var b bytes.Buffer
if err := writeOutpoint(&b, chanPoint); err != nil {
return err
@ -1630,7 +1630,7 @@ func delChannelByEdge(edges *bolt.Bucket, edgeIndex *bolt.Bucket,
// determined by the lexicographical ordering of the identity public keys of
// the nodes on either side of the channel.
func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error {
return c.db.Update(func(tx *bolt.Tx) error {
return c.db.Update(func(tx *bbolt.Tx) error {
edges, err := tx.CreateBucketIfNotExists(edgeBucket)
if err != nil {
return err
@ -1650,7 +1650,7 @@ func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error {
// updateEdgePolicy attempts to update an edge's policy within the relevant
// buckets using an existing database transaction.
func updateEdgePolicy(edges, edgeIndex, nodes *bolt.Bucket,
func updateEdgePolicy(edges, edgeIndex, nodes *bbolt.Bucket,
edge *ChannelEdgePolicy) error {
// Create the channelID key be converting the channel ID
@ -1808,14 +1808,14 @@ func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement,
// isPublic determines whether the node is seen as public within the graph from
// the source node's point of view. An existing database transaction can also be
// specified.
func (l *LightningNode) isPublic(tx *bolt.Tx, sourcePubKey []byte) (bool, error) {
func (l *LightningNode) isPublic(tx *bbolt.Tx, sourcePubKey []byte) (bool, error) {
// In order to determine whether this node is publicly advertised within
// the graph, we'll need to look at all of its edges and check whether
// they extend to any other node than the source node. errDone will be
// used to terminate the check early.
nodeIsPublic := false
errDone := errors.New("done")
err := l.ForEachChannel(tx, func(_ *bolt.Tx, info *ChannelEdgeInfo,
err := l.ForEachChannel(tx, func(_ *bbolt.Tx, info *ChannelEdgeInfo,
_, _ *ChannelEdgePolicy) error {
// If this edge doesn't extend to the source node, we'll
@ -1852,7 +1852,7 @@ func (l *LightningNode) isPublic(tx *bolt.Tx, sourcePubKey []byte) (bool, error)
func (c *ChannelGraph) FetchLightningNode(pub *btcec.PublicKey) (*LightningNode, error) {
var node *LightningNode
nodePub := pub.SerializeCompressed()
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.Bucket(nodeBucket)
@ -1898,7 +1898,7 @@ func (c *ChannelGraph) HasLightningNode(nodePub [33]byte) (time.Time, bool, erro
exists bool
)
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.Bucket(nodeBucket)
@ -1947,12 +1947,12 @@ func (c *ChannelGraph) HasLightningNode(nodePub [33]byte) (time.Time, bool, erro
// should be passed as the first argument. Otherwise the first argument should
// be nil and a fresh transaction will be created to execute the graph
// traversal.
func (l *LightningNode) ForEachChannel(tx *bolt.Tx,
cb func(*bolt.Tx, *ChannelEdgeInfo, *ChannelEdgePolicy, *ChannelEdgePolicy) error) error {
func (l *LightningNode) ForEachChannel(tx *bbolt.Tx,
cb func(*bbolt.Tx, *ChannelEdgeInfo, *ChannelEdgePolicy, *ChannelEdgePolicy) error) error {
nodePub := l.PubKeyBytes[:]
traversal := func(tx *bolt.Tx) error {
traversal := func(tx *bbolt.Tx) error {
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNotFound
@ -2217,7 +2217,7 @@ func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) (
// the target node in the channel. This is useful when one knows the pubkey of
// one of the nodes, and wishes to obtain the full LightningNode for the other
// end of the channel.
func (c *ChannelEdgeInfo) FetchOtherNode(tx *bolt.Tx, thisNodeKey []byte) (*LightningNode, error) {
func (c *ChannelEdgeInfo) FetchOtherNode(tx *bbolt.Tx, thisNodeKey []byte) (*LightningNode, error) {
// Ensure that the node passed in is actually a member of the channel.
var targetNodeBytes [33]byte
@ -2231,7 +2231,7 @@ func (c *ChannelEdgeInfo) FetchOtherNode(tx *bolt.Tx, thisNodeKey []byte) (*Ligh
}
var targetNode *LightningNode
fetchNodeFunc := func(tx *bolt.Tx) error {
fetchNodeFunc := func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.Bucket(nodeBucket)
@ -2482,7 +2482,7 @@ func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (*ChannelE
policy2 *ChannelEdgePolicy
)
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
// First, grab the node bucket. This will be used to populate
// the Node pointers in each edge read from disk.
nodes := tx.Bucket(nodeBucket)
@ -2561,7 +2561,7 @@ func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64) (*ChannelEdgeInfo, *
channelID [8]byte
)
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
// First, grab the node bucket. This will be used to populate
// the Node pointers in each edge read from disk.
nodes := tx.Bucket(nodeBucket)
@ -2613,7 +2613,7 @@ func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64) (*ChannelEdgeInfo, *
// source node's point of view.
func (c *ChannelGraph) IsPublicNode(pubKey [33]byte) (bool, error) {
var nodeIsPublic bool
err := c.db.View(func(tx *bolt.Tx) error {
err := c.db.View(func(tx *bbolt.Tx) error {
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNodesNotFound
@ -2699,7 +2699,7 @@ func (e *EdgePoint) String() string {
// closes on the resident blockchain.
func (c *ChannelGraph) ChannelView() ([]EdgePoint, error) {
var edgePoints []EdgePoint
if err := c.db.View(func(tx *bolt.Tx) error {
if err := c.db.View(func(tx *bbolt.Tx) error {
// We're going to iterate over the entire channel index, so
// we'll need to fetch the edgeBucket to get to the index as
// it's a sub-bucket.
@ -2762,8 +2762,8 @@ func (c *ChannelGraph) NewChannelEdgePolicy() *ChannelEdgePolicy {
return &ChannelEdgePolicy{db: c.db}
}
func putLightningNode(nodeBucket *bolt.Bucket, aliasBucket *bolt.Bucket,
updateIndex *bolt.Bucket, node *LightningNode) error {
func putLightningNode(nodeBucket *bbolt.Bucket, aliasBucket *bbolt.Bucket,
updateIndex *bbolt.Bucket, node *LightningNode) error {
var (
scratch [16]byte
@ -2885,7 +2885,7 @@ func putLightningNode(nodeBucket *bolt.Bucket, aliasBucket *bolt.Bucket,
return nodeBucket.Put(nodePub, b.Bytes())
}
func fetchLightningNode(nodeBucket *bolt.Bucket,
func fetchLightningNode(nodeBucket *bbolt.Bucket,
nodePub []byte) (LightningNode, error) {
nodeBytes := nodeBucket.Get(nodePub)
@ -2991,7 +2991,7 @@ func deserializeLightningNode(r io.Reader) (LightningNode, error) {
return node, nil
}
func putChanEdgeInfo(edgeIndex *bolt.Bucket, edgeInfo *ChannelEdgeInfo, chanID [8]byte) error {
func putChanEdgeInfo(edgeIndex *bbolt.Bucket, edgeInfo *ChannelEdgeInfo, chanID [8]byte) error {
var b bytes.Buffer
if _, err := b.Write(edgeInfo.NodeKey1Bytes[:]); err != nil {
@ -3057,7 +3057,7 @@ func putChanEdgeInfo(edgeIndex *bolt.Bucket, edgeInfo *ChannelEdgeInfo, chanID [
return edgeIndex.Put(chanID[:], b.Bytes())
}
func fetchChanEdgeInfo(edgeIndex *bolt.Bucket,
func fetchChanEdgeInfo(edgeIndex *bbolt.Bucket,
chanID []byte) (ChannelEdgeInfo, error) {
edgeInfoBytes := edgeIndex.Get(chanID)
@ -3146,7 +3146,7 @@ func deserializeChanEdgeInfo(r io.Reader) (ChannelEdgeInfo, error) {
return edgeInfo, nil
}
func putChanEdgePolicy(edges, nodes *bolt.Bucket, edge *ChannelEdgePolicy,
func putChanEdgePolicy(edges, nodes *bbolt.Bucket, edge *ChannelEdgePolicy,
from, to []byte) error {
var edgeKey [33 + 8]byte
@ -3248,7 +3248,7 @@ func putChanEdgePolicy(edges, nodes *bolt.Bucket, edge *ChannelEdgePolicy,
// putChanEdgePolicyUnknown marks the edge policy as unknown
// in the edges bucket.
func putChanEdgePolicyUnknown(edges *bolt.Bucket, channelID uint64,
func putChanEdgePolicyUnknown(edges *bbolt.Bucket, channelID uint64,
from []byte) error {
var edgeKey [33 + 8]byte
@ -3263,8 +3263,8 @@ func putChanEdgePolicyUnknown(edges *bolt.Bucket, channelID uint64,
return edges.Put(edgeKey[:], unknownPolicy)
}
func fetchChanEdgePolicy(edges *bolt.Bucket, chanID []byte,
nodePub []byte, nodes *bolt.Bucket) (*ChannelEdgePolicy, error) {
func fetchChanEdgePolicy(edges *bbolt.Bucket, chanID []byte,
nodePub []byte, nodes *bbolt.Bucket) (*ChannelEdgePolicy, error) {
var edgeKey [33 + 8]byte
copy(edgeKey[:], nodePub)
@ -3285,8 +3285,8 @@ func fetchChanEdgePolicy(edges *bolt.Bucket, chanID []byte,
return deserializeChanEdgePolicy(edgeReader, nodes)
}
func fetchChanEdgePolicies(edgeIndex *bolt.Bucket, edges *bolt.Bucket,
nodes *bolt.Bucket, chanID []byte,
func fetchChanEdgePolicies(edgeIndex *bbolt.Bucket, edges *bbolt.Bucket,
nodes *bbolt.Bucket, chanID []byte,
db *DB) (*ChannelEdgePolicy, *ChannelEdgePolicy, error) {
edgeInfo := edgeIndex.Get(chanID)
@ -3327,7 +3327,7 @@ func fetchChanEdgePolicies(edgeIndex *bolt.Bucket, edges *bolt.Bucket,
}
func deserializeChanEdgePolicy(r io.Reader,
nodes *bolt.Bucket) (*ChannelEdgePolicy, error) {
nodes *bbolt.Bucket) (*ChannelEdgePolicy, error) {
edge := &ChannelEdgePolicy{}

@ -837,7 +837,7 @@ func TestGraphTraversal(t *testing.T) {
// Iterate over each node as returned by the graph, if all nodes are
// reached, then the map created above should be empty.
err = graph.ForEachNode(nil, func(_ *bolt.Tx, node *LightningNode) error {
err = graph.ForEachNode(nil, func(_ *bbolt.Tx, node *LightningNode) error {
delete(nodeIndex, node.Alias)
return nil
})
@ -933,7 +933,7 @@ func TestGraphTraversal(t *testing.T) {
// Finally, we want to test the ability to iterate over all the
// outgoing channels for a particular node.
numNodeChans := 0
err = firstNode.ForEachChannel(nil, func(_ *bolt.Tx, _ *ChannelEdgeInfo,
err = firstNode.ForEachChannel(nil, func(_ *bbolt.Tx, _ *ChannelEdgeInfo,
outEdge, inEdge *ChannelEdgePolicy) error {
// All channels between first and second node should have fully
@ -1006,7 +1006,7 @@ func assertNumChans(t *testing.T, graph *ChannelGraph, n int) {
func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) {
numNodes := 0
err := graph.ForEachNode(nil, func(_ *bolt.Tx, _ *LightningNode) error {
err := graph.ForEachNode(nil, func(_ *bbolt.Tx, _ *LightningNode) error {
numNodes++
return nil
})
@ -2015,7 +2015,7 @@ func TestIncompleteChannelPolicies(t *testing.T) {
checkPolicies := func(node *LightningNode, expectedIn, expectedOut bool) {
calls := 0
node.ForEachChannel(nil, func(_ *bolt.Tx, _ *ChannelEdgeInfo,
node.ForEachChannel(nil, func(_ *bbolt.Tx, _ *ChannelEdgeInfo,
outEdge, inEdge *ChannelEdgePolicy) error {
if !expectedOut && outEdge != nil {
@ -2148,7 +2148,7 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) {
timestampSet[t] = struct{}{}
}
err := db.View(func(tx *bolt.Tx) error {
err := db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound

@ -185,7 +185,7 @@ func (d *DB) AddInvoice(newInvoice *Invoice) (uint64, error) {
}
var invoiceAddIndex uint64
err := d.Update(func(tx *bolt.Tx) error {
err := d.Update(func(tx *bbolt.Tx) error {
invoices, err := tx.CreateBucketIfNotExists(invoiceBucket)
if err != nil {
return err
@ -265,7 +265,7 @@ func (d *DB) InvoicesAddedSince(sinceAddIndex uint64) ([]Invoice, error) {
var startIndex [8]byte
byteOrder.PutUint64(startIndex[:], sinceAddIndex)
err := d.DB.View(func(tx *bolt.Tx) error {
err := d.DB.View(func(tx *bbolt.Tx) error {
invoices := tx.Bucket(invoiceBucket)
if invoices == nil {
return ErrNoInvoicesCreated
@ -320,7 +320,7 @@ func (d *DB) InvoicesAddedSince(sinceAddIndex uint64) ([]Invoice, error) {
// terms of the payment.
func (d *DB) LookupInvoice(paymentHash [32]byte) (Invoice, error) {
var invoice Invoice
err := d.View(func(tx *bolt.Tx) error {
err := d.View(func(tx *bbolt.Tx) error {
invoices := tx.Bucket(invoiceBucket)
if invoices == nil {
return ErrNoInvoicesCreated
@ -360,7 +360,7 @@ func (d *DB) LookupInvoice(paymentHash [32]byte) (Invoice, error) {
func (d *DB) FetchAllInvoices(pendingOnly bool) ([]Invoice, error) {
var invoices []Invoice
err := d.View(func(tx *bolt.Tx) error {
err := d.View(func(tx *bbolt.Tx) error {
invoiceB := tx.Bucket(invoiceBucket)
if invoiceB == nil {
return ErrNoInvoicesCreated
@ -449,7 +449,7 @@ func (d *DB) QueryInvoices(q InvoiceQuery) (InvoiceSlice, error) {
InvoiceQuery: q,
}
err := d.View(func(tx *bolt.Tx) error {
err := d.View(func(tx *bbolt.Tx) error {
// If the bucket wasn't found, then there aren't any invoices
// within the database yet, so we can simply exit.
invoices := tx.Bucket(invoiceBucket)
@ -463,7 +463,7 @@ func (d *DB) QueryInvoices(q InvoiceQuery) (InvoiceSlice, error) {
// keyForIndex is a helper closure that retrieves the invoice
// key for the given add index of an invoice.
keyForIndex := func(c *bolt.Cursor, index uint64) []byte {
keyForIndex := func(c *bbolt.Cursor, index uint64) []byte {
var keyIndex [8]byte
byteOrder.PutUint64(keyIndex[:], index)
_, invoiceKey := c.Seek(keyIndex[:])
@ -472,7 +472,7 @@ func (d *DB) QueryInvoices(q InvoiceQuery) (InvoiceSlice, error) {
// nextKey is a helper closure to determine what the next
// invoice key is when iterating over the invoice add index.
nextKey := func(c *bolt.Cursor) ([]byte, []byte) {
nextKey := func(c *bbolt.Cursor) ([]byte, []byte) {
if q.Reversed {
return c.Prev()
}
@ -573,7 +573,7 @@ func (d *DB) SettleInvoice(paymentHash [32]byte,
amtPaid lnwire.MilliSatoshi) (*Invoice, error) {
var settledInvoice *Invoice
err := d.Update(func(tx *bolt.Tx) error {
err := d.Update(func(tx *bbolt.Tx) error {
invoices, err := tx.CreateBucketIfNotExists(invoiceBucket)
if err != nil {
return err
@ -634,7 +634,7 @@ func (d *DB) InvoicesSettledSince(sinceSettleIndex uint64) ([]Invoice, error) {
var startIndex [8]byte
byteOrder.PutUint64(startIndex[:], sinceSettleIndex)
err := d.DB.View(func(tx *bolt.Tx) error {
err := d.DB.View(func(tx *bbolt.Tx) error {
invoices := tx.Bucket(invoiceBucket)
if invoices == nil {
return ErrNoInvoicesCreated
@ -676,7 +676,7 @@ func (d *DB) InvoicesSettledSince(sinceSettleIndex uint64) ([]Invoice, error) {
return settledInvoices, nil
}
func putInvoice(invoices, invoiceIndex, addIndex *bolt.Bucket,
func putInvoice(invoices, invoiceIndex, addIndex *bbolt.Bucket,
i *Invoice, invoiceNum uint32) (uint64, error) {
// Create the invoice key which is just the big-endian representation
@ -790,7 +790,7 @@ func serializeInvoice(w io.Writer, i *Invoice) error {
return nil
}
func fetchInvoice(invoiceNum []byte, invoices *bolt.Bucket) (Invoice, error) {
func fetchInvoice(invoiceNum []byte, invoices *bbolt.Bucket) (Invoice, error) {
invoiceBytes := invoices.Get(invoiceNum)
if invoiceBytes == nil {
return Invoice{}, ErrInvoiceNotFound
@ -862,7 +862,7 @@ func deserializeInvoice(r io.Reader) (Invoice, error) {
return invoice, nil
}
func settleInvoice(invoices, settleIndex *bolt.Bucket, invoiceNum []byte,
func settleInvoice(invoices, settleIndex *bbolt.Bucket, invoiceNum []byte,
amtPaid lnwire.MilliSatoshi) (*Invoice, error) {
invoice, err := fetchInvoice(invoiceNum, invoices)

@ -1,8 +1,6 @@
package channeldb
import (
"github.com/coreos/bbolt"
)
import "github.com/coreos/bbolt"
var (
// metaBucket stores all the meta information concerning the state of
@ -22,10 +20,10 @@ type Meta struct {
// FetchMeta fetches the meta data from boltdb and returns filled meta
// structure.
func (d *DB) FetchMeta(tx *bolt.Tx) (*Meta, error) {
func (d *DB) FetchMeta(tx *bbolt.Tx) (*Meta, error) {
meta := &Meta{}
err := d.View(func(tx *bolt.Tx) error {
err := d.View(func(tx *bbolt.Tx) error {
return fetchMeta(meta, tx)
})
if err != nil {
@ -38,7 +36,7 @@ func (d *DB) FetchMeta(tx *bolt.Tx) (*Meta, error) {
// fetchMeta is an internal helper function used in order to allow callers to
// re-use a database transaction. See the publicly exported FetchMeta method
// for more information.
func fetchMeta(meta *Meta, tx *bolt.Tx) error {
func fetchMeta(meta *Meta, tx *bbolt.Tx) error {
metaBucket := tx.Bucket(metaBucket)
if metaBucket == nil {
return ErrMetaNotFound
@ -56,7 +54,7 @@ func fetchMeta(meta *Meta, tx *bolt.Tx) error {
// PutMeta writes the passed instance of the database met-data struct to disk.
func (d *DB) PutMeta(meta *Meta) error {
return d.Update(func(tx *bolt.Tx) error {
return d.Update(func(tx *bbolt.Tx) error {
return putMeta(meta, tx)
})
}
@ -64,7 +62,7 @@ func (d *DB) PutMeta(meta *Meta) error {
// putMeta is an internal helper function used in order to allow callers to
// re-use a database transaction. See the publicly exported PutMeta method for
// more information.
func putMeta(meta *Meta, tx *bolt.Tx) error {
func putMeta(meta *Meta, tx *bbolt.Tx) error {
metaBucket, err := tx.CreateBucketIfNotExists(metaBucket)
if err != nil {
return err
@ -73,7 +71,7 @@ func putMeta(meta *Meta, tx *bolt.Tx) error {
return putDbVersion(metaBucket, meta)
}
func putDbVersion(metaBucket *bolt.Bucket, meta *Meta) error {
func putDbVersion(metaBucket *bbolt.Bucket, meta *Meta) error {
scratch := make([]byte, 4)
byteOrder.PutUint32(scratch, meta.DbVersionNumber)
return metaBucket.Put(dbVersionKey, scratch)

@ -108,11 +108,11 @@ func TestOrderOfMigrations(t *testing.T) {
versions := []version{
{0, nil},
{1, nil},
{2, func(tx *bolt.Tx) error {
{2, func(tx *bbolt.Tx) error {
appliedMigration = 2
return nil
}},
{3, func(tx *bolt.Tx) error {
{3, func(tx *bbolt.Tx) error {
appliedMigration = 3
return nil
}},
@ -184,7 +184,7 @@ func TestMigrationWithPanic(t *testing.T) {
beforeMigrationFunc := func(d *DB) {
// Insert data in database and in order then make sure that the
// key isn't changes in case of panic or fail.
d.Update(func(tx *bolt.Tx) error {
d.Update(func(tx *bbolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(bucketPrefix)
if err != nil {
return err
@ -197,7 +197,7 @@ func TestMigrationWithPanic(t *testing.T) {
// Create migration function which changes the initially created data and
// throw the panic, in this case we pretending that something goes.
migrationWithPanic := func(tx *bolt.Tx) error {
migrationWithPanic := func(tx *bbolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(bucketPrefix)
if err != nil {
return err
@ -218,7 +218,7 @@ func TestMigrationWithPanic(t *testing.T) {
t.Fatal("migration panicked but version is changed")
}
err = d.Update(func(tx *bolt.Tx) error {
err = d.Update(func(tx *bbolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(bucketPrefix)
if err != nil {
return err
@ -255,7 +255,7 @@ func TestMigrationWithFatal(t *testing.T) {
afterMigration := []byte("aftermigration")
beforeMigrationFunc := func(d *DB) {
d.Update(func(tx *bolt.Tx) error {
d.Update(func(tx *bbolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(bucketPrefix)
if err != nil {
return err
@ -269,7 +269,7 @@ func TestMigrationWithFatal(t *testing.T) {
// Create migration function which changes the initially created data and
// return the error, in this case we pretending that something goes
// wrong.
migrationWithFatal := func(tx *bolt.Tx) error {
migrationWithFatal := func(tx *bbolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(bucketPrefix)
if err != nil {
return err
@ -290,7 +290,7 @@ func TestMigrationWithFatal(t *testing.T) {
t.Fatal("migration failed but version is changed")
}
err = d.Update(func(tx *bolt.Tx) error {
err = d.Update(func(tx *bbolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(bucketPrefix)
if err != nil {
return err
@ -328,7 +328,7 @@ func TestMigrationWithoutErrors(t *testing.T) {
// Populate database with initial data.
beforeMigrationFunc := func(d *DB) {
d.Update(func(tx *bolt.Tx) error {
d.Update(func(tx *bbolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(bucketPrefix)
if err != nil {
return err
@ -340,7 +340,7 @@ func TestMigrationWithoutErrors(t *testing.T) {
}
// Create migration function which changes the initially created data.
migrationWithoutErrors := func(tx *bolt.Tx) error {
migrationWithoutErrors := func(tx *bbolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(bucketPrefix)
if err != nil {
return err
@ -362,7 +362,7 @@ func TestMigrationWithoutErrors(t *testing.T) {
"successfully applied migration")
}
err = d.Update(func(tx *bolt.Tx) error {
err = d.Update(func(tx *bbolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(bucketPrefix)
if err != nil {
return err
@ -406,7 +406,7 @@ func TestMigrationReversion(t *testing.T) {
// Update the database metadata to point to one more than the highest
// known version.
err = cdb.Update(func(tx *bolt.Tx) error {
err = cdb.Update(func(tx *bbolt.Tx) error {
newMeta := &Meta{
DbVersionNumber: getLatestDBVersion(dbVersions) + 1,
}

@ -14,7 +14,7 @@ import (
// (one for nodes and one for edges) to keep track of the last time a node or
// edge was updated on the network. These new indexes allow us to implement the
// new graph sync protocol added.
func migrateNodeAndEdgeUpdateIndex(tx *bolt.Tx) error {
func migrateNodeAndEdgeUpdateIndex(tx *bbolt.Tx) error {
// First, we'll populating the node portion of the new index. Before we
// can add new values to the index, we'll first create the new bucket
// where these items will be housed.
@ -119,7 +119,7 @@ func migrateNodeAndEdgeUpdateIndex(tx *bolt.Tx) error {
// invoices an index in the add and/or the settle index. Additionally, all
// existing invoices will have their bytes padded out in order to encode the
// add+settle index as well as the amount paid.
func migrateInvoiceTimeSeries(tx *bolt.Tx) error {
func migrateInvoiceTimeSeries(tx *bbolt.Tx) error {
invoices, err := tx.CreateBucketIfNotExists(invoiceBucket)
if err != nil {
return err
@ -238,7 +238,7 @@ func migrateInvoiceTimeSeries(tx *bolt.Tx) error {
// migrateInvoiceTimeSeries migration. As at the time of writing, the
// OutgoingPayment struct embeddeds an instance of the Invoice struct. As a
// result, we also need to migrate the internal invoice to the new format.
func migrateInvoiceTimeSeriesOutgoingPayments(tx *bolt.Tx) error {
func migrateInvoiceTimeSeriesOutgoingPayments(tx *bbolt.Tx) error {
payBucket := tx.Bucket(paymentBucket)
if payBucket == nil {
return nil
@ -307,7 +307,7 @@ func migrateInvoiceTimeSeriesOutgoingPayments(tx *bolt.Tx) error {
// bucket. It ensure that edges with unknown policies will also have an entry
// in the bucket. After the migration, there will be two edge entries for
// every channel, regardless of whether the policies are known.
func migrateEdgePolicies(tx *bolt.Tx) error {
func migrateEdgePolicies(tx *bbolt.Tx) error {
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return nil
@ -379,7 +379,7 @@ func migrateEdgePolicies(tx *bolt.Tx) error {
// paymentStatusesMigration is a database migration intended for adding payment
// statuses for each existing payment entity in bucket to be able control
// transitions of statuses and prevent cases such as double payment
func paymentStatusesMigration(tx *bolt.Tx) error {
func paymentStatusesMigration(tx *bbolt.Tx) error {
// Get the bucket dedicated to storing statuses of payments,
// where a key is payment hash, value is payment status.
paymentStatuses, err := tx.CreateBucketIfNotExists(paymentStatusBucket)
@ -466,7 +466,7 @@ func paymentStatusesMigration(tx *bolt.Tx) error {
// migration also fixes the case where the public keys within edge policies were
// being serialized with an extra byte, causing an even greater error when
// attempting to perform the offset calculation described earlier.
func migratePruneEdgeUpdateIndex(tx *bolt.Tx) error {
func migratePruneEdgeUpdateIndex(tx *bbolt.Tx) error {
// To begin the migration, we'll retrieve the update index bucket. If it
// does not exist, we have nothing left to do so we can simply exit.
edges := tx.Bucket(edgeBucket)
@ -577,7 +577,7 @@ func migratePruneEdgeUpdateIndex(tx *bolt.Tx) error {
// migrateOptionalChannelCloseSummaryFields migrates the serialized format of
// ChannelCloseSummary to a format where optional fields' presence is indicated
// with boolean markers.
func migrateOptionalChannelCloseSummaryFields(tx *bolt.Tx) error {
func migrateOptionalChannelCloseSummaryFields(tx *bbolt.Tx) error {
closedChanBucket := tx.Bucket(closedChannelBucket)
if closedChanBucket == nil {
return nil

@ -55,7 +55,7 @@ func TestPaymentStatusesMigration(t *testing.T) {
// locally-sourced payment should end up with an InFlight
// status, while the other should remain unchanged, which
// defaults to Grounded.
err = d.Update(func(tx *bolt.Tx) error {
err = d.Update(func(tx *bbolt.Tx) error {
circuits, err := tx.CreateBucketIfNotExists(
[]byte("circuit-adds"),
)
@ -382,7 +382,7 @@ func TestMigrateOptionalChannelCloseSummaryFields(t *testing.T) {
// Get the old serialization format for this test's
// close summary, and it to the closed channel bucket.
old := test.oldSerialization(test.closeSummary)
err = d.Update(func(tx *bolt.Tx) error {
err = d.Update(func(tx *bbolt.Tx) error {
closedChanBucket, err := tx.CreateBucketIfNotExists(
closedChannelBucket,
)
@ -418,7 +418,7 @@ func TestMigrateOptionalChannelCloseSummaryFields(t *testing.T) {
newSerialization := b.Bytes()
var dbSummary []byte
err = d.View(func(tx *bolt.Tx) error {
err = d.View(func(tx *bbolt.Tx) error {
closedChanBucket := tx.Bucket(closedChannelBucket)
if closedChanBucket == nil {
return errors.New("unable to find bucket")

@ -101,7 +101,7 @@ func (l *LinkNode) Sync() error {
// Finally update the database by storing the link node and updating
// any relevant indexes.
return l.db.Update(func(tx *bolt.Tx) error {
return l.db.Update(func(tx *bbolt.Tx) error {
nodeMetaBucket := tx.Bucket(nodeInfoBucket)
if nodeMetaBucket == nil {
return ErrLinkNodesNotFound
@ -114,7 +114,7 @@ func (l *LinkNode) Sync() error {
// putLinkNode serializes then writes the encoded version of the passed link
// node into the nodeMetaBucket. This function is provided in order to allow
// the ability to re-use a database transaction across many operations.
func putLinkNode(nodeMetaBucket *bolt.Bucket, l *LinkNode) error {
func putLinkNode(nodeMetaBucket *bbolt.Bucket, l *LinkNode) error {
// First serialize the LinkNode into its raw-bytes encoding.
var b bytes.Buffer
if err := serializeLinkNode(&b, l); err != nil {
@ -130,12 +130,12 @@ func putLinkNode(nodeMetaBucket *bolt.Bucket, l *LinkNode) error {
// DeleteLinkNode removes the link node with the given identity from the
// database.
func (db *DB) DeleteLinkNode(identity *btcec.PublicKey) error {
return db.Update(func(tx *bolt.Tx) error {
return db.Update(func(tx *bbolt.Tx) error {
return db.deleteLinkNode(tx, identity)
})
}
func (db *DB) deleteLinkNode(tx *bolt.Tx, identity *btcec.PublicKey) error {
func (db *DB) deleteLinkNode(tx *bbolt.Tx, identity *btcec.PublicKey) error {
nodeMetaBucket := tx.Bucket(nodeInfoBucket)
if nodeMetaBucket == nil {
return ErrLinkNodesNotFound
@ -154,7 +154,7 @@ func (db *DB) FetchLinkNode(identity *btcec.PublicKey) (*LinkNode, error) {
err error
)
err = db.View(func(tx *bolt.Tx) error {
err = db.View(func(tx *bbolt.Tx) error {
// First fetch the bucket for storing node metadata, bailing
// out early if it hasn't been created yet.
nodeMetaBucket := tx.Bucket(nodeInfoBucket)
@ -187,7 +187,7 @@ func (db *DB) FetchLinkNode(identity *btcec.PublicKey) (*LinkNode, error) {
// whom we have active channels with.
func (db *DB) FetchAllLinkNodes() ([]*LinkNode, error) {
var linkNodes []*LinkNode
err := db.View(func(tx *bolt.Tx) error {
err := db.View(func(tx *bbolt.Tx) error {
nodes, err := db.fetchAllLinkNodes(tx)
if err != nil {
return err
@ -205,7 +205,7 @@ func (db *DB) FetchAllLinkNodes() ([]*LinkNode, error) {
// fetchAllLinkNodes uses an existing database transaction to fetch all nodes
// with whom we have active channels with.
func (db *DB) fetchAllLinkNodes(tx *bolt.Tx) ([]*LinkNode, error) {
func (db *DB) fetchAllLinkNodes(tx *bbolt.Tx) ([]*LinkNode, error) {
nodeMetaBucket := tx.Bucket(nodeInfoBucket)
if nodeMetaBucket == nil {
return nil, ErrLinkNodesNotFound

@ -118,7 +118,7 @@ func (db *DB) AddPayment(payment *OutgoingPayment) error {
}
paymentBytes := b.Bytes()
return db.Batch(func(tx *bolt.Tx) error {
return db.Batch(func(tx *bbolt.Tx) error {
payments, err := tx.CreateBucketIfNotExists(paymentBucket)
if err != nil {
return err
@ -144,7 +144,7 @@ func (db *DB) AddPayment(payment *OutgoingPayment) error {
func (db *DB) FetchAllPayments() ([]*OutgoingPayment, error) {
var payments []*OutgoingPayment
err := db.View(func(tx *bolt.Tx) error {
err := db.View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(paymentBucket)
if bucket == nil {
return ErrNoPaymentsCreated
@ -176,9 +176,9 @@ func (db *DB) FetchAllPayments() ([]*OutgoingPayment, error) {
// DeleteAllPayments deletes all payments from DB.
func (db *DB) DeleteAllPayments() error {
return db.Update(func(tx *bolt.Tx) error {
return db.Update(func(tx *bbolt.Tx) error {
err := tx.DeleteBucket(paymentBucket)
if err != nil && err != bolt.ErrBucketNotFound {
if err != nil && err != bbolt.ErrBucketNotFound {
return err
}
@ -190,7 +190,7 @@ func (db *DB) DeleteAllPayments() error {
// UpdatePaymentStatus sets the payment status for outgoing/finished payments in
// local database.
func (db *DB) UpdatePaymentStatus(paymentHash [32]byte, status PaymentStatus) error {
return db.Batch(func(tx *bolt.Tx) error {
return db.Batch(func(tx *bbolt.Tx) error {
return UpdatePaymentStatusTx(tx, paymentHash, status)
})
}
@ -199,7 +199,7 @@ func (db *DB) UpdatePaymentStatus(paymentHash [32]byte, status PaymentStatus) er
// outgoing/finished payments in the local database. This method accepts a
// boltdb transaction such that the operation can be composed into other
// database transactions.
func UpdatePaymentStatusTx(tx *bolt.Tx,
func UpdatePaymentStatusTx(tx *bbolt.Tx,
paymentHash [32]byte, status PaymentStatus) error {
paymentStatuses, err := tx.CreateBucketIfNotExists(paymentStatusBucket)
@ -214,7 +214,7 @@ func UpdatePaymentStatusTx(tx *bolt.Tx,
// If status of the payment isn't found, it will default to "StatusGrounded".
func (db *DB) FetchPaymentStatus(paymentHash [32]byte) (PaymentStatus, error) {
var paymentStatus = StatusGrounded
err := db.View(func(tx *bolt.Tx) error {
err := db.View(func(tx *bbolt.Tx) error {
var err error
paymentStatus, err = FetchPaymentStatusTx(tx, paymentHash)
return err
@ -230,7 +230,7 @@ func (db *DB) FetchPaymentStatus(paymentHash [32]byte) (PaymentStatus, error) {
// outgoing payment. If status of the payment isn't found, it will default to
// "StatusGrounded". It accepts the boltdb transactions such that this method
// can be composed into other atomic operations.
func FetchPaymentStatusTx(tx *bolt.Tx, paymentHash [32]byte) (PaymentStatus, error) {
func FetchPaymentStatusTx(tx *bbolt.Tx, paymentHash [32]byte) (PaymentStatus, error) {
// The default status for all payments that aren't recorded in database.
var paymentStatus = StatusGrounded

@ -61,7 +61,7 @@ func (s *WaitingProofStore) Add(proof *WaitingProof) error {
s.mu.Lock()
defer s.mu.Unlock()
err := s.db.Update(func(tx *bolt.Tx) error {
err := s.db.Update(func(tx *bbolt.Tx) error {
var err error
var b bytes.Buffer
@ -100,7 +100,7 @@ func (s *WaitingProofStore) Remove(key WaitingProofKey) error {
return ErrWaitingProofNotFound
}
err := s.db.Update(func(tx *bolt.Tx) error {
err := s.db.Update(func(tx *bbolt.Tx) error {
// Get or create the top bucket.
bucket := tx.Bucket(waitingProofsBucketKey)
if bucket == nil {
@ -123,7 +123,7 @@ func (s *WaitingProofStore) Remove(key WaitingProofKey) error {
// ForAll iterates thought all waiting proofs and passing the waiting proof
// in the given callback.
func (s *WaitingProofStore) ForAll(cb func(*WaitingProof) error) error {
return s.db.View(func(tx *bolt.Tx) error {
return s.db.View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(waitingProofsBucketKey)
if bucket == nil {
return ErrWaitingProofNotFound
@ -158,7 +158,7 @@ func (s *WaitingProofStore) Get(key WaitingProofKey) (*WaitingProof, error) {
return nil, ErrWaitingProofNotFound
}
err := s.db.View(func(tx *bolt.Tx) error {
err := s.db.View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(waitingProofsBucketKey)
if bucket == nil {
return ErrWaitingProofNotFound

@ -76,7 +76,7 @@ func (d *DB) NewWitnessCache() *WitnessCache {
//
// TODO(roasbeef): fake closure to map instead a constructor?
func (w *WitnessCache) AddWitness(wType WitnessType, witness []byte) error {
return w.db.Batch(func(tx *bolt.Tx) error {
return w.db.Batch(func(tx *bbolt.Tx) error {
witnessBucket, err := tx.CreateBucketIfNotExists(witnessBucketKey)
if err != nil {
return err
@ -111,7 +111,7 @@ func (w *WitnessCache) AddWitness(wType WitnessType, witness []byte) error {
// will be returned.
func (w *WitnessCache) LookupWitness(wType WitnessType, witnessKey []byte) ([]byte, error) {
var witness []byte
err := w.db.View(func(tx *bolt.Tx) error {
err := w.db.View(func(tx *bbolt.Tx) error {
witnessBucket := tx.Bucket(witnessBucketKey)
if witnessBucket == nil {
return ErrNoWitnesses
@ -145,7 +145,7 @@ func (w *WitnessCache) LookupWitness(wType WitnessType, witnessKey []byte) ([]by
// DeleteWitness attempts to delete a particular witness from the database.
func (w *WitnessCache) DeleteWitness(wType WitnessType, witnessKey []byte) error {
return w.db.Batch(func(tx *bolt.Tx) error {
return w.db.Batch(func(tx *bbolt.Tx) error {
witnessBucket, err := tx.CreateBucketIfNotExists(witnessBucketKey)
if err != nil {
return err
@ -169,7 +169,7 @@ func (w *WitnessCache) DeleteWitness(wType WitnessType, witnessKey []byte) error
// DeleteWitnessClass attempts to delete an *entire* class of witnesses. After
// this function return with a non-nil error,
func (w *WitnessCache) DeleteWitnessClass(wType WitnessType) error {
return w.db.Batch(func(tx *bolt.Tx) error {
return w.db.Batch(func(tx *bbolt.Tx) error {
witnessBucket, err := tx.CreateBucketIfNotExists(witnessBucketKey)
if err != nil {
return err

@ -281,7 +281,7 @@ var (
// boltArbitratorLog is an implementation of the ArbitratorLog interface backed
// by a bolt DB instance.
type boltArbitratorLog struct {
db *bolt.DB
db *bbolt.DB
cfg ChannelArbitratorConfig
@ -290,7 +290,7 @@ type boltArbitratorLog struct {
// newBoltArbitratorLog returns a new instance of the boltArbitratorLog given
// an arbitrator config, and the items needed to create its log scope.
func newBoltArbitratorLog(db *bolt.DB, cfg ChannelArbitratorConfig,
func newBoltArbitratorLog(db *bbolt.DB, cfg ChannelArbitratorConfig,
chainHash chainhash.Hash, chanPoint wire.OutPoint) (*boltArbitratorLog, error) {
scope, err := newLogScope(chainHash, chanPoint)
@ -309,7 +309,7 @@ func newBoltArbitratorLog(db *bolt.DB, cfg ChannelArbitratorConfig,
// interface.
var _ ArbitratorLog = (*boltArbitratorLog)(nil)
func fetchContractReadBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error) {
func fetchContractReadBucket(tx *bbolt.Tx, scopeKey []byte) (*bbolt.Bucket, error) {
scopeBucket := tx.Bucket(scopeKey)
if scopeBucket == nil {
return nil, errScopeBucketNoExist
@ -323,7 +323,7 @@ func fetchContractReadBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error)
return contractBucket, nil
}
func fetchContractWriteBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error) {
func fetchContractWriteBucket(tx *bbolt.Tx, scopeKey []byte) (*bbolt.Bucket, error) {
scopeBucket, err := tx.CreateBucketIfNotExists(scopeKey)
if err != nil {
return nil, err
@ -341,7 +341,7 @@ func fetchContractWriteBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error
// writeResolver is a helper method that writes a contract resolver and stores
// it it within the passed contractBucket using its unique resolutionsKey key.
func (b *boltArbitratorLog) writeResolver(contractBucket *bolt.Bucket,
func (b *boltArbitratorLog) writeResolver(contractBucket *bbolt.Bucket,
res ContractResolver) error {
// First, we'll write to the buffer the type of this resolver. Using
@ -382,7 +382,7 @@ func (b *boltArbitratorLog) writeResolver(contractBucket *bolt.Bucket,
// NOTE: Part of the ContractResolver interface.
func (b *boltArbitratorLog) CurrentState() (ArbitratorState, error) {
var s ArbitratorState
err := b.db.View(func(tx *bolt.Tx) error {
err := b.db.View(func(tx *bbolt.Tx) error {
scopeBucket := tx.Bucket(b.scopeKey[:])
if scopeBucket == nil {
return errScopeBucketNoExist
@ -407,7 +407,7 @@ func (b *boltArbitratorLog) CurrentState() (ArbitratorState, error) {
//
// NOTE: Part of the ContractResolver interface.
func (b *boltArbitratorLog) CommitState(s ArbitratorState) error {
return b.db.Batch(func(tx *bolt.Tx) error {
return b.db.Batch(func(tx *bbolt.Tx) error {
scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:])
if err != nil {
return err
@ -427,7 +427,7 @@ func (b *boltArbitratorLog) FetchUnresolvedContracts() ([]ContractResolver, erro
Checkpoint: b.checkpointContract,
}
var contracts []ContractResolver
err := b.db.View(func(tx *bolt.Tx) error {
err := b.db.View(func(tx *bbolt.Tx) error {
contractBucket, err := fetchContractReadBucket(tx, b.scopeKey[:])
if err != nil {
return err
@ -518,7 +518,7 @@ func (b *boltArbitratorLog) FetchUnresolvedContracts() ([]ContractResolver, erro
//
// NOTE: Part of the ContractResolver interface.
func (b *boltArbitratorLog) InsertUnresolvedContracts(resolvers ...ContractResolver) error {
return b.db.Batch(func(tx *bolt.Tx) error {
return b.db.Batch(func(tx *bbolt.Tx) error {
contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:])
if err != nil {
return err
@ -541,7 +541,7 @@ func (b *boltArbitratorLog) InsertUnresolvedContracts(resolvers ...ContractResol
//
// NOTE: Part of the ContractResolver interface.
func (b *boltArbitratorLog) SwapContract(oldContract, newContract ContractResolver) error {
return b.db.Batch(func(tx *bolt.Tx) error {
return b.db.Batch(func(tx *bbolt.Tx) error {
contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:])
if err != nil {
return err
@ -561,7 +561,7 @@ func (b *boltArbitratorLog) SwapContract(oldContract, newContract ContractResolv
//
// NOTE: Part of the ContractResolver interface.
func (b *boltArbitratorLog) ResolveContract(res ContractResolver) error {
return b.db.Batch(func(tx *bolt.Tx) error {
return b.db.Batch(func(tx *bbolt.Tx) error {
contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:])
if err != nil {
return err
@ -579,7 +579,7 @@ func (b *boltArbitratorLog) ResolveContract(res ContractResolver) error {
//
// NOTE: Part of the ContractResolver interface.
func (b *boltArbitratorLog) LogContractResolutions(c *ContractResolutions) error {
return b.db.Batch(func(tx *bolt.Tx) error {
return b.db.Batch(func(tx *bbolt.Tx) error {
scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:])
if err != nil {
return err
@ -640,7 +640,7 @@ func (b *boltArbitratorLog) LogContractResolutions(c *ContractResolutions) error
// NOTE: Part of the ContractResolver interface.
func (b *boltArbitratorLog) FetchContractResolutions() (*ContractResolutions, error) {
c := &ContractResolutions{}
err := b.db.View(func(tx *bolt.Tx) error {
err := b.db.View(func(tx *bbolt.Tx) error {
scopeBucket := tx.Bucket(b.scopeKey[:])
if scopeBucket == nil {
return errScopeBucketNoExist
@ -726,7 +726,7 @@ func (b *boltArbitratorLog) FetchContractResolutions() (*ContractResolutions, er
//
// NOTE: Part of the ContractResolver interface.
func (b *boltArbitratorLog) LogChainActions(actions ChainActionMap) error {
return b.db.Batch(func(tx *bolt.Tx) error {
return b.db.Batch(func(tx *bbolt.Tx) error {
scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:])
if err != nil {
return err
@ -765,7 +765,7 @@ func (b *boltArbitratorLog) LogChainActions(actions ChainActionMap) error {
func (b *boltArbitratorLog) FetchChainActions() (ChainActionMap, error) {
actionsMap := make(ChainActionMap)
err := b.db.View(func(tx *bolt.Tx) error {
err := b.db.View(func(tx *bbolt.Tx) error {
scopeBucket := tx.Bucket(b.scopeKey[:])
if scopeBucket == nil {
return errScopeBucketNoExist
@ -807,7 +807,7 @@ func (b *boltArbitratorLog) FetchChainActions() (ChainActionMap, error) {
//
// NOTE: Part of the ContractResolver interface.
func (b *boltArbitratorLog) WipeHistory() error {
return b.db.Update(func(tx *bolt.Tx) error {
return b.db.Update(func(tx *bbolt.Tx) error {
scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:])
if err != nil {
return err
@ -870,7 +870,7 @@ func (b *boltArbitratorLog) WipeHistory() error {
// ContractResolver instances to checkpoint their state once they reach
// milestones during contract resolution.
func (b *boltArbitratorLog) checkpointContract(c ContractResolver) error {
return b.db.Batch(func(tx *bolt.Tx) error {
return b.db.Batch(func(tx *bbolt.Tx) error {
contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:])
if err != nil {
return err

@ -95,7 +95,7 @@ var (
}
)
func makeTestDB() (*bolt.DB, func(), error) {
func makeTestDB() (*bbolt.DB, func(), error) {
// First, create a temporary directory to be used for the duration of
// this test.
tempDirName, err := ioutil.TempDir("", "arblog")
@ -103,7 +103,7 @@ func makeTestDB() (*bolt.DB, func(), error) {
return nil, nil, err
}
db, err := bolt.Open(tempDirName+"/test.db", 0600, nil)
db, err := bbolt.Open(tempDirName+"/test.db", 0600, nil)
if err != nil {
return nil, nil, err
}

@ -826,7 +826,7 @@ func (d *AuthenticatedGossiper) resendAnnounceSignatures() error {
// TODO(halseth): database access should be abstracted
// behind interface.
var msgsResend []msgTuple
if err := d.cfg.DB.View(func(tx *bolt.Tx) error {
if err := d.cfg.DB.View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(messageStoreKey)
if bucket == nil {
return nil
@ -872,7 +872,7 @@ func (d *AuthenticatedGossiper) resendAnnounceSignatures() error {
deleteMsg := func(t msgTuple) error {
log.Debugf("Deleting message for chanID=%v from "+
"messageStore", t.msg.ChannelID)
if err := d.cfg.DB.Update(func(tx *bolt.Tx) error {
if err := d.cfg.DB.Update(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(messageStoreKey)
if bucket == nil {
return fmt.Errorf("bucket " +
@ -2429,7 +2429,7 @@ func (d *AuthenticatedGossiper) sendAnnSigReliably(
copy(key[:33], remotePeer.SerializeCompressed())
binary.BigEndian.PutUint64(key[33:], msg.ShortChannelID.ToUint64())
err := d.cfg.DB.Update(func(tx *bolt.Tx) error {
err := d.cfg.DB.Update(func(tx *bbolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(messageStoreKey)
if err != nil {
return err

@ -3028,7 +3028,7 @@ func copyPubKey(pub *btcec.PublicKey) *btcec.PublicKey {
// chanPoint to the channelOpeningStateBucket.
func (f *fundingManager) saveChannelOpeningState(chanPoint *wire.OutPoint,
state channelOpeningState, shortChanID *lnwire.ShortChannelID) error {
return f.cfg.Wallet.Cfg.Database.Update(func(tx *bolt.Tx) error {
return f.cfg.Wallet.Cfg.Database.Update(func(tx *bbolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists(channelOpeningStateBucket)
if err != nil {
@ -3058,7 +3058,7 @@ func (f *fundingManager) getChannelOpeningState(chanPoint *wire.OutPoint) (
var state channelOpeningState
var shortChanID lnwire.ShortChannelID
err := f.cfg.Wallet.Cfg.Database.View(func(tx *bolt.Tx) error {
err := f.cfg.Wallet.Cfg.Database.View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(channelOpeningStateBucket)
if bucket == nil {
@ -3090,7 +3090,7 @@ func (f *fundingManager) getChannelOpeningState(chanPoint *wire.OutPoint) (
// deleteChannelOpeningState removes any state for chanPoint from the database.
func (f *fundingManager) deleteChannelOpeningState(chanPoint *wire.OutPoint) error {
return f.cfg.Wallet.Cfg.Database.Update(func(tx *bolt.Tx) error {
return f.cfg.Wallet.Cfg.Database.Update(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(channelOpeningStateBucket)
if bucket == nil {
return fmt.Errorf("Bucket not found")

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

@ -2659,7 +2659,7 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver,
// node's chainstate to initial level, cleanly
// wipe buckets
if err := clearWalletStates(alice, bob); err !=
nil && err != bolt.ErrBucketNotFound {
nil && err != bbolt.ErrBucketNotFound {
t.Fatalf("unable to wipe wallet state: %v", err)
}
}

@ -6,6 +6,7 @@ import (
"os"
"path"
"github.com/coreos/bbolt"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
@ -14,8 +15,6 @@ import (
macaroon "gopkg.in/macaroon.v2"
"golang.org/x/net/context"
"github.com/coreos/bbolt"
)
var (
@ -50,8 +49,8 @@ func NewService(dir string, checks ...Checker) (*Service, error) {
// Open the database that we'll use to store the primary macaroon key,
// and all generated macaroons+caveats.
macaroonDB, err := bolt.Open(
path.Join(dir, DBFilename), 0600, bolt.DefaultOptions,
macaroonDB, err := bbolt.Open(
path.Join(dir, DBFilename), 0600, bbolt.DefaultOptions,
)
if err != nil {
return nil, err

@ -33,8 +33,8 @@ func setupTestRootKeyStorage(t *testing.T) string {
if err != nil {
t.Fatalf("Error creating temp dir: %v", err)
}
db, err := bolt.Open(path.Join(tempDir, "macaroons.db"), 0600,
bolt.DefaultOptions)
db, err := bbolt.Open(path.Join(tempDir, "macaroons.db"), 0600,
bbolt.DefaultOptions)
if err != nil {
t.Fatalf("Error opening store DB: %v", err)
}

@ -46,16 +46,16 @@ var (
// RootKeyStorage implements the bakery.RootKeyStorage interface.
type RootKeyStorage struct {
*bolt.DB
*bbolt.DB
encKey *snacl.SecretKey
}
// NewRootKeyStorage creates a RootKeyStorage instance.
// TODO(aakselrod): Add support for encryption of data with passphrase.
func NewRootKeyStorage(db *bolt.DB) (*RootKeyStorage, error) {
func NewRootKeyStorage(db *bbolt.DB) (*RootKeyStorage, error) {
// If the store's bucket doesn't exist, create it.
err := db.Update(func(tx *bolt.Tx) error {
err := db.Update(func(tx *bbolt.Tx) error {
_, err := tx.CreateBucketIfNotExists(rootKeyBucketName)
return err
})
@ -80,7 +80,7 @@ func (r *RootKeyStorage) CreateUnlock(password *[]byte) error {
return ErrPasswordRequired
}
return r.Update(func(tx *bolt.Tx) error {
return r.Update(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(rootKeyBucketName)
dbKey := bucket.Get(encryptedKeyID)
if len(dbKey) > 0 {
@ -124,7 +124,7 @@ func (r *RootKeyStorage) Get(_ context.Context, id []byte) ([]byte, error) {
return nil, ErrStoreLocked
}
var rootKey []byte
err := r.View(func(tx *bolt.Tx) error {
err := r.View(func(tx *bbolt.Tx) error {
dbKey := tx.Bucket(rootKeyBucketName).Get(id)
if len(dbKey) == 0 {
return fmt.Errorf("root key with id %s doesn't exist",
@ -156,7 +156,7 @@ func (r *RootKeyStorage) RootKey(_ context.Context) ([]byte, []byte, error) {
}
var rootKey []byte
id := defaultRootKeyID
err := r.Update(func(tx *bolt.Tx) error {
err := r.Update(func(tx *bbolt.Tx) error {
ns := tx.Bucket(rootKeyBucketName)
dbKey := ns.Get(id)

@ -21,8 +21,8 @@ func TestStore(t *testing.T) {
}
defer os.RemoveAll(tempDir)
db, err := bolt.Open(path.Join(tempDir, "weks.db"), 0600,
bolt.DefaultOptions)
db, err := bbolt.Open(path.Join(tempDir, "weks.db"), 0600,
bbolt.DefaultOptions)
if err != nil {
t.Fatalf("Error opening store DB: %v", err)
}
@ -75,8 +75,8 @@ func TestStore(t *testing.T) {
// Between here and the re-opening of the store, it's possible to get
// a double-close, but that's not such a big deal since the tests will
// fail anyway in that case.
db, err = bolt.Open(path.Join(tempDir, "weks.db"), 0600,
bolt.DefaultOptions)
db, err = bbolt.Open(path.Join(tempDir, "weks.db"), 0600,
bbolt.DefaultOptions)
if err != nil {
t.Fatalf("Error opening store DB: %v", err)
}

@ -307,7 +307,7 @@ func newNurseryStore(chainHash *chainhash.Hash,
// CSV-delayed outputs (commitment and incoming HTLC's), commitment output and
// a list of outgoing two-stage htlc outputs.
func (ns *nurseryStore) Incubate(kids []kidOutput, babies []babyOutput) error {
return ns.db.Update(func(tx *bolt.Tx) error {
return ns.db.Update(func(tx *bbolt.Tx) error {
// If we have any kid outputs to incubate, then we'll attempt
// to add each of them to the nursery store. Any duplicate
// outputs will be ignored.
@ -334,7 +334,7 @@ func (ns *nurseryStore) Incubate(kids []kidOutput, babies []babyOutput) error {
// kindergarten bucket. The now mature kidOutput contained in the babyOutput
// will be stored as it waits out the kidOutput's CSV delay.
func (ns *nurseryStore) CribToKinder(bby *babyOutput) error {
return ns.db.Update(func(tx *bolt.Tx) error {
return ns.db.Update(func(tx *bbolt.Tx) error {
// First, retrieve or create the channel bucket corresponding to
// the baby output's origin channel point.
@ -416,7 +416,7 @@ func (ns *nurseryStore) CribToKinder(bby *babyOutput) error {
// the kindergarten bucket. This transition should be executed after receiving
// confirmation of the preschool output's commitment transaction.
func (ns *nurseryStore) PreschoolToKinder(kid *kidOutput) error {
return ns.db.Update(func(tx *bolt.Tx) error {
return ns.db.Update(func(tx *bbolt.Tx) error {
// Create or retrieve the channel bucket corresponding to the
// kid output's origin channel point.
chanPoint := kid.OriginChanPoint()
@ -521,7 +521,7 @@ func (ns *nurseryStore) PreschoolToKinder(kid *kidOutput) error {
// kindergarten sweep txn. The height bucket will be opportunistically pruned
// from the height index as outputs are removed.
func (ns *nurseryStore) GraduateKinder(height uint32) error {
return ns.db.Update(func(tx *bolt.Tx) error {
return ns.db.Update(func(tx *bbolt.Tx) error {
// Since all kindergarten outputs at a particular height are
// swept in a single txn, we can now safely delete the finalized
@ -606,7 +606,7 @@ func (ns *nurseryStore) GraduateKinder(height uint32) error {
func (ns *nurseryStore) FinalizeKinder(height uint32,
finalTx *wire.MsgTx) error {
return ns.db.Update(func(tx *bolt.Tx) error {
return ns.db.Update(func(tx *bbolt.Tx) error {
return ns.finalizeKinder(tx, height, finalTx)
})
}
@ -615,7 +615,7 @@ func (ns *nurseryStore) FinalizeKinder(height uint32,
// graduated height.
func (ns *nurseryStore) GraduateHeight(height uint32) error {
return ns.db.Update(func(tx *bolt.Tx) error {
return ns.db.Update(func(tx *bbolt.Tx) error {
return ns.putLastGraduatedHeight(tx, height)
})
}
@ -632,7 +632,7 @@ func (ns *nurseryStore) FetchClass(
var finalTx *wire.MsgTx
var kids []kidOutput
var babies []babyOutput
if err := ns.db.View(func(tx *bolt.Tx) error {
if err := ns.db.View(func(tx *bbolt.Tx) error {
var err error
finalTx, err = ns.getFinalizedTxn(tx, height)
@ -693,7 +693,7 @@ func (ns *nurseryStore) FetchClass(
// preschool bucket.
func (ns *nurseryStore) FetchPreschools() ([]kidOutput, error) {
var kids []kidOutput
if err := ns.db.View(func(tx *bolt.Tx) error {
if err := ns.db.View(func(tx *bbolt.Tx) error {
// Retrieve the existing chain bucket for this nursery store.
chainBucket := tx.Bucket(ns.pfxChainKey)
@ -766,7 +766,7 @@ func (ns *nurseryStore) FetchPreschools() ([]kidOutput, error) {
// index at or below the provided upper bound.
func (ns *nurseryStore) HeightsBelowOrEqual(height uint32) ([]uint32, error) {
var activeHeights []uint32
err := ns.db.View(func(tx *bolt.Tx) error {
err := ns.db.View(func(tx *bbolt.Tx) error {
// Ensure that the chain bucket for this nursery store exists.
chainBucket := tx.Bucket(ns.pfxChainKey)
if chainBucket == nil {
@ -811,7 +811,7 @@ func (ns *nurseryStore) HeightsBelowOrEqual(height uint32) ([]uint32, error) {
func (ns *nurseryStore) ForChanOutputs(chanPoint *wire.OutPoint,
callback func([]byte, []byte) error) error {
return ns.db.View(func(tx *bolt.Tx) error {
return ns.db.View(func(tx *bbolt.Tx) error {
return ns.forChanOutputs(tx, chanPoint, callback)
})
}
@ -819,7 +819,7 @@ func (ns *nurseryStore) ForChanOutputs(chanPoint *wire.OutPoint,
// ListChannels returns all channels the nursery is currently tracking.
func (ns *nurseryStore) ListChannels() ([]wire.OutPoint, error) {
var activeChannels []wire.OutPoint
if err := ns.db.View(func(tx *bolt.Tx) error {
if err := ns.db.View(func(tx *bbolt.Tx) error {
// Retrieve the existing chain bucket for this nursery store.
chainBucket := tx.Bucket(ns.pfxChainKey)
if chainBucket == nil {
@ -853,7 +853,7 @@ func (ns *nurseryStore) ListChannels() ([]wire.OutPoint, error) {
// IsMatureChannel determines the whether or not all of the outputs in a
// particular channel bucket have been marked as graduated.
func (ns *nurseryStore) IsMatureChannel(chanPoint *wire.OutPoint) (bool, error) {
err := ns.db.View(func(tx *bolt.Tx) error {
err := ns.db.View(func(tx *bbolt.Tx) error {
// Iterate over the contents of the channel bucket, computing
// both total number of outputs, and those that have the grad
// prefix.
@ -882,7 +882,7 @@ var ErrImmatureChannel = errors.New("cannot remove immature channel, " +
// provided channel point.
// NOTE: The channel's entries in the height index are assumed to be removed.
func (ns *nurseryStore) RemoveChannel(chanPoint *wire.OutPoint) error {
return ns.db.Update(func(tx *bolt.Tx) error {
return ns.db.Update(func(tx *bbolt.Tx) error {
// Retrieve the existing chain bucket for this nursery store.
chainBucket := tx.Bucket(ns.pfxChainKey)
if chainBucket == nil {
@ -942,7 +942,7 @@ func (ns *nurseryStore) RemoveChannel(chanPoint *wire.OutPoint) error {
// store has finalized a kindergarten class.
func (ns *nurseryStore) LastFinalizedHeight() (uint32, error) {
var lastFinalizedHeight uint32
err := ns.db.View(func(tx *bolt.Tx) error {
err := ns.db.View(func(tx *bbolt.Tx) error {
var err error
lastFinalizedHeight, err = ns.getLastFinalizedHeight(tx)
return err
@ -955,7 +955,7 @@ func (ns *nurseryStore) LastFinalizedHeight() (uint32, error) {
// store has successfully graduated all outputs.
func (ns *nurseryStore) LastGraduatedHeight() (uint32, error) {
var lastGraduatedHeight uint32
err := ns.db.View(func(tx *bolt.Tx) error {
err := ns.db.View(func(tx *bbolt.Tx) error {
var err error
lastGraduatedHeight, err = ns.getLastGraduatedHeight(tx)
return err
@ -970,7 +970,7 @@ func (ns *nurseryStore) LastGraduatedHeight() (uint32, error) {
// its two-stage process of sweeping funds back to the user's wallet. These
// outputs are persisted in the nursery store in the crib state, and will be
// revisited after the first-stage output's CLTV has expired.
func (ns *nurseryStore) enterCrib(tx *bolt.Tx, baby *babyOutput) error {
func (ns *nurseryStore) enterCrib(tx *bbolt.Tx, baby *babyOutput) error {
// First, retrieve or create the channel bucket corresponding to the
// baby output's origin channel point.
chanPoint := baby.OriginChanPoint()
@ -1025,7 +1025,7 @@ func (ns *nurseryStore) enterCrib(tx *bolt.Tx, baby *babyOutput) error {
// through a single stage before sweeping. Outputs are stored in the preschool
// bucket until the commitment transaction has been confirmed, at which point
// they will be moved to the kindergarten bucket.
func (ns *nurseryStore) enterPreschool(tx *bolt.Tx, kid *kidOutput) error {
func (ns *nurseryStore) enterPreschool(tx *bbolt.Tx, kid *kidOutput) error {
// First, retrieve or create the channel bucket corresponding to the
// baby output's origin channel point.
chanPoint := kid.OriginChanPoint()
@ -1058,8 +1058,8 @@ func (ns *nurseryStore) enterPreschool(tx *bolt.Tx, kid *kidOutput) error {
// createChannelBucket creates or retrieves a channel bucket for the provided
// channel point.
func (ns *nurseryStore) createChannelBucket(tx *bolt.Tx,
chanPoint *wire.OutPoint) (*bolt.Bucket, error) {
func (ns *nurseryStore) createChannelBucket(tx *bbolt.Tx,
chanPoint *wire.OutPoint) (*bbolt.Bucket, error) {
// Ensure that the chain bucket for this nursery store exists.
chainBucket, err := tx.CreateBucketIfNotExists(ns.pfxChainKey)
@ -1089,8 +1089,8 @@ func (ns *nurseryStore) createChannelBucket(tx *bolt.Tx,
// getChannelBucket retrieves an existing channel bucket from the nursery store,
// using the given channel point. If the bucket does not exist, or any bucket
// along its path does not exist, a nil value is returned.
func (ns *nurseryStore) getChannelBucket(tx *bolt.Tx,
chanPoint *wire.OutPoint) *bolt.Bucket {
func (ns *nurseryStore) getChannelBucket(tx *bbolt.Tx,
chanPoint *wire.OutPoint) *bbolt.Bucket {
// Retrieve the existing chain bucket for this nursery store.
chainBucket := tx.Bucket(ns.pfxChainKey)
@ -1116,8 +1116,8 @@ func (ns *nurseryStore) getChannelBucket(tx *bolt.Tx,
// createHeightBucket creates or retrieves an existing bucket from the height
// index, corresponding to the provided height.
func (ns *nurseryStore) createHeightBucket(tx *bolt.Tx,
height uint32) (*bolt.Bucket, error) {
func (ns *nurseryStore) createHeightBucket(tx *bbolt.Tx,
height uint32) (*bbolt.Bucket, error) {
// Ensure that the chain bucket for this nursery store exists.
chainBucket, err := tx.CreateBucketIfNotExists(ns.pfxChainKey)
@ -1144,8 +1144,8 @@ func (ns *nurseryStore) createHeightBucket(tx *bolt.Tx,
// getHeightBucketPath retrieves an existing height bucket from the nursery
// store, using the provided block height. If the bucket does not exist, or any
// bucket along its path does not exist, a nil value is returned.
func (ns *nurseryStore) getHeightBucketPath(tx *bolt.Tx,
height uint32) (*bolt.Bucket, *bolt.Bucket, *bolt.Bucket) {
func (ns *nurseryStore) getHeightBucketPath(tx *bbolt.Tx,
height uint32) (*bbolt.Bucket, *bbolt.Bucket, *bbolt.Bucket) {
// Retrieve the existing chain bucket for this nursery store.
chainBucket := tx.Bucket(ns.pfxChainKey)
@ -1170,8 +1170,8 @@ func (ns *nurseryStore) getHeightBucketPath(tx *bolt.Tx,
// getHeightBucket retrieves an existing height bucket from the nursery store,
// using the provided block height. If the bucket does not exist, or any bucket
// along its path does not exist, a nil value is returned.
func (ns *nurseryStore) getHeightBucket(tx *bolt.Tx,
height uint32) *bolt.Bucket {
func (ns *nurseryStore) getHeightBucket(tx *bbolt.Tx,
height uint32) *bbolt.Bucket {
_, _, hghtBucket := ns.getHeightBucketPath(tx, height)
return hghtBucket
@ -1180,8 +1180,8 @@ func (ns *nurseryStore) getHeightBucket(tx *bolt.Tx,
// createHeightChanBucket creates or retrieves an existing height-channel bucket
// for the provided block height and channel point. This method will attempt to
// instantiate all buckets along the path if required.
func (ns *nurseryStore) createHeightChanBucket(tx *bolt.Tx,
height uint32, chanPoint *wire.OutPoint) (*bolt.Bucket, error) {
func (ns *nurseryStore) createHeightChanBucket(tx *bbolt.Tx,
height uint32, chanPoint *wire.OutPoint) (*bbolt.Bucket, error) {
// Ensure that the height bucket for this nursery store exists.
hghtBucket, err := ns.createHeightBucket(tx, height)
@ -1206,8 +1206,8 @@ func (ns *nurseryStore) createHeightChanBucket(tx *bolt.Tx,
// nursery store, using the provided block height and channel point. if the
// bucket does not exist, or any bucket along its path does not exist, a nil
// value is returned.
func (ns *nurseryStore) getHeightChanBucket(tx *bolt.Tx,
height uint32, chanPoint *wire.OutPoint) *bolt.Bucket {
func (ns *nurseryStore) getHeightChanBucket(tx *bbolt.Tx,
height uint32, chanPoint *wire.OutPoint) *bbolt.Bucket {
// Retrieve the existing height bucket from this nursery store.
hghtBucket := ns.getHeightBucket(tx, height)
@ -1233,7 +1233,7 @@ func (ns *nurseryStore) getHeightChanBucket(tx *bolt.Tx,
// enumerate crib and kindergarten outputs at a particular height. The callback
// is invoked with serialized bytes retrieved for each output of interest,
// allowing the caller to deserialize them into the appropriate type.
func (ns *nurseryStore) forEachHeightPrefix(tx *bolt.Tx, prefix []byte,
func (ns *nurseryStore) forEachHeightPrefix(tx *bbolt.Tx, prefix []byte,
height uint32, callback func([]byte) error) error {
// Start by retrieving the height bucket corresponding to the provided
@ -1321,7 +1321,7 @@ func (ns *nurseryStore) forEachHeightPrefix(tx *bolt.Tx, prefix []byte,
// provided callback. The callback accepts a key-value pair of byte slices
// corresponding to the prefixed-output key and the serialized output,
// respectively.
func (ns *nurseryStore) forChanOutputs(tx *bolt.Tx, chanPoint *wire.OutPoint,
func (ns *nurseryStore) forChanOutputs(tx *bbolt.Tx, chanPoint *wire.OutPoint,
callback func([]byte, []byte) error) error {
chanBucket := ns.getChannelBucket(tx, chanPoint)
@ -1334,7 +1334,7 @@ func (ns *nurseryStore) forChanOutputs(tx *bolt.Tx, chanPoint *wire.OutPoint,
// getLastFinalizedHeight is a helper method that retrieves the last height for
// which the database finalized its persistent state.
func (ns *nurseryStore) getLastFinalizedHeight(tx *bolt.Tx) (uint32, error) {
func (ns *nurseryStore) getLastFinalizedHeight(tx *bbolt.Tx) (uint32, error) {
// Retrieve the chain bucket associated with the given nursery store.
chainBucket := tx.Bucket(ns.pfxChainKey)
if chainBucket == nil {
@ -1362,7 +1362,7 @@ func (ns *nurseryStore) getLastFinalizedHeight(tx *bolt.Tx) (uint32, error) {
// finalized, and we skip the process of writing the txn. When the class is
// loaded, a nil value will be returned if no txn has been written to a
// finalized height bucket.
func (ns *nurseryStore) finalizeKinder(tx *bolt.Tx, height uint32,
func (ns *nurseryStore) finalizeKinder(tx *bbolt.Tx, height uint32,
finalTx *wire.MsgTx) error {
// TODO(conner) ensure height is greater that current finalized height.
@ -1409,7 +1409,7 @@ func (ns *nurseryStore) finalizeKinder(tx *bolt.Tx, height uint32,
// getFinalizedTxn retrieves the finalized kindergarten sweep txn at the given
// height, returning nil if one was not found.
func (ns *nurseryStore) getFinalizedTxn(tx *bolt.Tx,
func (ns *nurseryStore) getFinalizedTxn(tx *bbolt.Tx,
height uint32) (*wire.MsgTx, error) {
hghtBucket := ns.getHeightBucket(tx, height)
@ -1435,7 +1435,7 @@ func (ns *nurseryStore) getFinalizedTxn(tx *bolt.Tx,
// getLastGraduatedHeight is a helper method that retrieves the last height for
// which the database graduated all outputs successfully.
func (ns *nurseryStore) getLastGraduatedHeight(tx *bolt.Tx) (uint32, error) {
func (ns *nurseryStore) getLastGraduatedHeight(tx *bbolt.Tx) (uint32, error) {
// Retrieve the chain bucket associated with the given nursery store.
chainBucket := tx.Bucket(ns.pfxChainKey)
if chainBucket == nil {
@ -1455,7 +1455,7 @@ func (ns *nurseryStore) getLastGraduatedHeight(tx *bolt.Tx) (uint32, error) {
// pubLastGraduatedHeight is a helper method that writes the provided height under
// the last graduated height key.
func (ns *nurseryStore) putLastGraduatedHeight(tx *bolt.Tx, height uint32) error {
func (ns *nurseryStore) putLastGraduatedHeight(tx *bbolt.Tx, height uint32) error {
// Ensure that the chain bucket for this nursery store exists.
chainBucket, err := tx.CreateBucketIfNotExists(ns.pfxChainKey)
@ -1478,7 +1478,7 @@ var errBucketNotEmpty = errors.New("bucket is not empty, cannot be pruned")
// removeOutputFromHeight will delete the given output from the specified
// height-channel bucket, and attempt to prune the upstream directories if they
// are empty.
func (ns *nurseryStore) removeOutputFromHeight(tx *bolt.Tx, height uint32,
func (ns *nurseryStore) removeOutputFromHeight(tx *bbolt.Tx, height uint32,
chanPoint *wire.OutPoint, pfxKey []byte) error {
// Retrieve the height-channel bucket and delete the prefixed output.
@ -1530,7 +1530,7 @@ func (ns *nurseryStore) removeOutputFromHeight(tx *bolt.Tx, height uint32,
// all active outputs at this height have been removed from their respective
// height-channel buckets. The returned boolean value indicated whether or not
// this invocation successfully pruned the height bucket.
func (ns *nurseryStore) pruneHeight(tx *bolt.Tx, height uint32) (bool, error) {
func (ns *nurseryStore) pruneHeight(tx *bbolt.Tx, height uint32) (bool, error) {
// Fetch the existing height index and height bucket.
_, hghtIndex, hghtBucket := ns.getHeightBucketPath(tx, height)
if hghtBucket == nil {
@ -1576,7 +1576,7 @@ func (ns *nurseryStore) pruneHeight(tx *bolt.Tx, height uint32) (bool, error) {
// removeBucketIfEmpty attempts to delete a bucket specified by name from the
// provided parent bucket.
func removeBucketIfEmpty(parent *bolt.Bucket, bktName []byte) error {
func removeBucketIfEmpty(parent *bbolt.Bucket, bktName []byte) error {
// Attempt to fetch the named bucket from its parent.
bkt := parent.Bucket(bktName)
if bkt == nil {
@ -1594,7 +1594,7 @@ func removeBucketIfEmpty(parent *bolt.Bucket, bktName []byte) error {
// removeBucketIfExists safely deletes the named bucket by first checking
// that it exists in the parent bucket.
func removeBucketIfExists(parent *bolt.Bucket, bktName []byte) error {
func removeBucketIfExists(parent *bbolt.Bucket, bktName []byte) error {
// Attempt to fetch the named bucket from its parent.
bkt := parent.Bucket(bktName)
if bkt == nil {
@ -1607,7 +1607,7 @@ func removeBucketIfExists(parent *bolt.Bucket, bktName []byte) error {
// isBucketEmpty returns errBucketNotEmpty if the bucket has a non-zero number
// of children.
func isBucketEmpty(parent *bolt.Bucket) error {
func isBucketEmpty(parent *bbolt.Bucket) error {
return parent.ForEach(func(_, _ []byte) error {
return errBucketNotEmpty
})

@ -269,7 +269,7 @@ func generateBandwidthHints(sourceNode *channeldb.LightningNode,
// First, we'll collect the set of outbound edges from the target
// source node.
var localChans []*channeldb.ChannelEdgeInfo
err := sourceNode.ForEachChannel(nil, func(tx *bolt.Tx,
err := sourceNode.ForEachChannel(nil, func(tx *bbolt.Tx,
edgeInfo *channeldb.ChannelEdgeInfo,
_, _ *channeldb.ChannelEdgePolicy) error {

@ -457,7 +457,7 @@ func edgeWeight(lockedAmt lnwire.MilliSatoshi, fee lnwire.MilliSatoshi,
// destination node back to source. This is to properly accumulate fees
// that need to be paid along the path and accurately check the amount
// to forward at every node against the available bandwidth.
func findPath(tx *bolt.Tx, graph *channeldb.ChannelGraph,
func findPath(tx *bbolt.Tx, graph *channeldb.ChannelGraph,
additionalEdges map[Vertex][]*channeldb.ChannelEdgePolicy,
sourceNode *channeldb.LightningNode, target *btcec.PublicKey,
ignoredNodes map[Vertex]struct{}, ignoredEdges map[uint64]struct{},
@ -483,7 +483,7 @@ func findPath(tx *bolt.Tx, graph *channeldb.ChannelGraph,
// also returns the source node, so there is no need to add the source
// node explicitly.
distance := make(map[Vertex]nodeWithDist)
if err := graph.ForEachNode(tx, func(_ *bolt.Tx, node *channeldb.LightningNode) error {
if err := graph.ForEachNode(tx, func(_ *bbolt.Tx, node *channeldb.LightningNode) error {
// TODO(roasbeef): with larger graph can just use disk seeks
// with a visited map
distance[Vertex(node.PubKeyBytes)] = nodeWithDist{
@ -682,7 +682,7 @@ func findPath(tx *bolt.Tx, graph *channeldb.ChannelGraph,
// examine all the incoming edges (channels) from this node to
// further our graph traversal.
pivot := Vertex(bestNode.PubKeyBytes)
err := bestNode.ForEachChannel(tx, func(tx *bolt.Tx,
err := bestNode.ForEachChannel(tx, func(tx *bbolt.Tx,
edgeInfo *channeldb.ChannelEdgeInfo,
_, inEdge *channeldb.ChannelEdgePolicy) error {
@ -783,7 +783,7 @@ func findPath(tx *bolt.Tx, graph *channeldb.ChannelGraph,
// make our inner path finding algorithm aware of our k-shortest paths
// algorithm, rather than attempting to use an unmodified path finding
// algorithm in a block box manner.
func findPaths(tx *bolt.Tx, graph *channeldb.ChannelGraph,
func findPaths(tx *bbolt.Tx, graph *channeldb.ChannelGraph,
source *channeldb.LightningNode, target *btcec.PublicKey,
amt lnwire.MilliSatoshi, feeLimit lnwire.MilliSatoshi, numPaths uint32,
bandwidthHints map[uint64]lnwire.MilliSatoshi) ([][]*channeldb.ChannelEdgePolicy, error) {

@ -2185,7 +2185,7 @@ func (r *ChannelRouter) FetchLightningNode(node Vertex) (*channeldb.LightningNod
//
// NOTE: This method is part of the ChannelGraphSource interface.
func (r *ChannelRouter) ForEachNode(cb func(*channeldb.LightningNode) error) error {
return r.cfg.Graph.ForEachNode(nil, func(_ *bolt.Tx, n *channeldb.LightningNode) error {
return r.cfg.Graph.ForEachNode(nil, func(_ *bbolt.Tx, n *channeldb.LightningNode) error {
return cb(n)
})
}
@ -2197,7 +2197,7 @@ func (r *ChannelRouter) ForEachNode(cb func(*channeldb.LightningNode) error) err
func (r *ChannelRouter) ForAllOutgoingChannels(cb func(*channeldb.ChannelEdgeInfo,
*channeldb.ChannelEdgePolicy) error) error {
return r.selfNode.ForEachChannel(nil, func(_ *bolt.Tx, c *channeldb.ChannelEdgeInfo,
return r.selfNode.ForEachChannel(nil, func(_ *bbolt.Tx, c *channeldb.ChannelEdgeInfo,
e, _ *channeldb.ChannelEdgePolicy) error {
if e == nil {

@ -3436,7 +3436,7 @@ func (r *rpcServer) DescribeGraph(ctx context.Context,
// First iterate through all the known nodes (connected or unconnected
// within the graph), collating their current state into the RPC
// response.
err := graph.ForEachNode(nil, func(_ *bolt.Tx, node *channeldb.LightningNode) error {
err := graph.ForEachNode(nil, func(_ *bbolt.Tx, node *channeldb.LightningNode) error {
nodeAddrs := make([]*lnrpc.NodeAddress, 0)
for _, addr := range node.Addresses {
nodeAddr := &lnrpc.NodeAddress{
@ -3588,7 +3588,7 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context,
numChannels uint32
totalCapacity btcutil.Amount
)
if err := node.ForEachChannel(nil, func(_ *bolt.Tx, edge *channeldb.ChannelEdgeInfo,
if err := node.ForEachChannel(nil, func(_ *bbolt.Tx, edge *channeldb.ChannelEdgeInfo,
_, _ *channeldb.ChannelEdgePolicy) error {
numChannels++
@ -3873,7 +3873,7 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context,
// network, tallying up the total number of nodes, and also gathering
// each node so we can measure the graph diameter and degree stats
// below.
if err := graph.ForEachNode(nil, func(tx *bolt.Tx, node *channeldb.LightningNode) error {
if err := graph.ForEachNode(nil, func(tx *bbolt.Tx, node *channeldb.LightningNode) error {
// Increment the total number of nodes with each iteration.
numNodes++
@ -3883,7 +3883,7 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context,
// through the db transaction from the outer view so we can
// re-use it within this inner view.
var outDegree uint32
if err := node.ForEachChannel(tx, func(_ *bolt.Tx,
if err := node.ForEachChannel(tx, func(_ *bbolt.Tx,
edge *channeldb.ChannelEdgeInfo, _, _ *channeldb.ChannelEdgePolicy) error {
// Bump up the out degree for this node for each
@ -4254,7 +4254,7 @@ func (r *rpcServer) FeeReport(ctx context.Context,
}
var feeReports []*lnrpc.ChannelFeeReport
err = selfNode.ForEachChannel(nil, func(_ *bolt.Tx, chanInfo *channeldb.ChannelEdgeInfo,
err = selfNode.ForEachChannel(nil, func(_ *bbolt.Tx, chanInfo *channeldb.ChannelEdgeInfo,
edgePolicy, _ *channeldb.ChannelEdgePolicy) error {
// Self node should always have policies for its channels.

@ -1642,7 +1642,7 @@ func (s *server) establishPersistentConnections() error {
// TODO(roasbeef): instead iterate over link nodes and query graph for
// each of the nodes.
err = sourceNode.ForEachChannel(nil, func(
_ *bolt.Tx,
_ *bbolt.Tx,
_ *channeldb.ChannelEdgeInfo,
policy, _ *channeldb.ChannelEdgePolicy) error {