8 "github.com/anacrolix/missinggo/expect"
11 "github.com/anacrolix/torrent/metainfo"
15 // Chosen to match the usual chunk size in a torrent client. This way,
16 // most chunk writes are to exactly one full item in bbolt DB.
20 type boltDBClient struct {
24 type boltDBTorrent struct {
29 func NewBoltDB(filePath string) ClientImplCloser {
30 db, err := bbolt.Open(filepath.Join(filePath, "bolt.db"), 0600, &bbolt.Options{
35 return &boltDBClient{db}
38 func (me *boltDBClient) Close() error {
42 func (me *boltDBClient) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error) {
43 return &boltDBTorrent{me, infoHash}, nil
46 func (me *boltDBTorrent) Piece(p metainfo.Piece) PieceImpl {
52 copy(ret.key[:], me.ih[:])
53 binary.BigEndian.PutUint32(ret.key[20:], uint32(p.Index()))
57 func (boltDBTorrent) Close() error { return nil }