"path/filepath"
"time"
- bolt "go.etcd.io/bbolt"
+ "go.etcd.io/bbolt"
"github.com/anacrolix/torrent/metainfo"
)
)
type boltPieceCompletion struct {
- db *bolt.DB
+ db *bbolt.DB
}
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 {
}
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
}
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
"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
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
}
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
"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 {
}
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)