From 2ea04e9083b31b6d84ba420487ee6226d29b28c8 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 24 Mar 2020 12:54:57 +1100 Subject: [PATCH] Use default bbolt package alias --- storage/boltPieceCompletion.go | 10 +++++----- storage/bolt_piece.go | 8 ++++---- storage/boltdb.go | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/storage/boltPieceCompletion.go b/storage/boltPieceCompletion.go index 2ad0b4b8..36fc6c1f 100644 --- a/storage/boltPieceCompletion.go +++ b/storage/boltPieceCompletion.go @@ -6,7 +6,7 @@ import ( "path/filepath" "time" - bolt "go.etcd.io/bbolt" + "go.etcd.io/bbolt" "github.com/anacrolix/torrent/metainfo" ) @@ -21,7 +21,7 @@ var ( ) type boltPieceCompletion struct { - db *bolt.DB + db *bbolt.DB } var _ PieceCompletion = (*boltPieceCompletion)(nil) @@ -29,7 +29,7 @@ var _ PieceCompletion = (*boltPieceCompletion)(nil) func NewBoltPieceCompletion(dir string) (ret PieceCompletion, err error) { os.MkdirAll(dir, 0770) p := filepath.Join(dir, ".torrent.bolt.db") - db, err := bolt.Open(p, 0660, &bolt.Options{ + db, err := bbolt.Open(p, 0660, &bbolt.Options{ Timeout: time.Second, }) if err != nil { @@ -41,7 +41,7 @@ func NewBoltPieceCompletion(dir string) (ret PieceCompletion, err error) { } func (me boltPieceCompletion) Get(pk metainfo.PieceKey) (cn Completion, err error) { - err = me.db.View(func(tx *bolt.Tx) error { + err = me.db.View(func(tx *bbolt.Tx) error { cb := tx.Bucket(completionBucketKey) if cb == nil { return nil @@ -67,7 +67,7 @@ func (me boltPieceCompletion) Get(pk metainfo.PieceKey) (cn Completion, err erro } func (me boltPieceCompletion) Set(pk metainfo.PieceKey, b bool) error { - return me.db.Update(func(tx *bolt.Tx) error { + return me.db.Update(func(tx *bbolt.Tx) error { c, err := tx.CreateBucketIfNotExists(completionBucketKey) if err != nil { return err diff --git a/storage/bolt_piece.go b/storage/bolt_piece.go index 6fa5271d..a932bea4 100644 --- a/storage/bolt_piece.go +++ b/storage/bolt_piece.go @@ -5,13 +5,13 @@ import ( "io" "github.com/anacrolix/missinggo/x" - bolt "go.etcd.io/bbolt" + "go.etcd.io/bbolt" "github.com/anacrolix/torrent/metainfo" ) type boltDBPiece struct { - db *bolt.DB + db *bbolt.DB p metainfo.Piece ih metainfo.Hash key [24]byte @@ -44,7 +44,7 @@ func (me *boltDBPiece) MarkNotComplete() error { return me.pc().Set(me.pk(), false) } func (me *boltDBPiece) ReadAt(b []byte, off int64) (n int, err error) { - err = me.db.View(func(tx *bolt.Tx) error { + err = me.db.View(func(tx *bbolt.Tx) error { db := tx.Bucket(dataBucketKey) if db == nil { return io.EOF @@ -76,7 +76,7 @@ func (me *boltDBPiece) chunkKey(index int) (ret [26]byte) { } func (me *boltDBPiece) WriteAt(b []byte, off int64) (n int, err error) { - err = me.db.Update(func(tx *bolt.Tx) error { + err = me.db.Update(func(tx *bbolt.Tx) error { db, err := tx.CreateBucketIfNotExists(dataBucketKey) if err != nil { return err diff --git a/storage/boltdb.go b/storage/boltdb.go index 015e3d90..f95d2a60 100644 --- a/storage/boltdb.go +++ b/storage/boltdb.go @@ -6,19 +6,19 @@ import ( "time" "github.com/anacrolix/missinggo/expect" - bolt "go.etcd.io/bbolt" + "go.etcd.io/bbolt" "github.com/anacrolix/torrent/metainfo" ) const ( // Chosen to match the usual chunk size in a torrent client. This way, - // most chunk writes are to exactly one full item in bolt DB. + // most chunk writes are to exactly one full item in bbolt DB. chunkSize = 1 << 14 ) type boltDBClient struct { - db *bolt.DB + db *bbolt.DB } type boltDBTorrent struct { @@ -27,7 +27,7 @@ type boltDBTorrent struct { } func NewBoltDB(filePath string) ClientImplCloser { - db, err := bolt.Open(filepath.Join(filePath, "bolt.db"), 0600, &bolt.Options{ + db, err := bbolt.Open(filepath.Join(filePath, "bolt.db"), 0600, &bbolt.Options{ Timeout: time.Second, }) expect.Nil(err) -- 2.44.0