8 "github.com/anacrolix/missinggo/expect"
9 "github.com/anacrolix/torrent/metainfo"
10 "github.com/boltdb/bolt"
14 // Chosen to match the usual chunk size in a torrent client. This way,
15 // most chunk writes are to exactly one full item in bolt DB.
19 type boltDBClient struct {
23 type boltDBTorrent struct {
28 func NewBoltDB(filePath string) ClientImpl {
29 db, err := bolt.Open(filepath.Join(filePath, "bolt.db"), 0600, &bolt.Options{
34 return &boltDBClient{db}
37 func (me *boltDBClient) Close() error {
41 func (me *boltDBClient) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error) {
42 return &boltDBTorrent{me, infoHash}, nil
45 func (me *boltDBTorrent) Piece(p metainfo.Piece) PieceImpl {
51 copy(ret.key[:], me.ih[:])
52 binary.BigEndian.PutUint32(ret.key[20:], uint32(p.Index()))
56 func (boltDBTorrent) Close() error { return nil }