1 //go:build !noboltdb && !wasm
2 // +build !noboltdb,!wasm
11 "github.com/anacrolix/missinggo/expect"
14 "github.com/anacrolix/torrent/metainfo"
18 // Chosen to match the usual chunk size in a torrent client. This way, most chunk writes are to
19 // exactly one full item in bbolt DB.
23 type boltClient struct {
27 type boltTorrent struct {
32 func NewBoltDB(filePath string) ClientImplCloser {
33 db, err := bbolt.Open(filepath.Join(filePath, "bolt.db"), 0o600, &bbolt.Options{
38 return &boltClient{db}
41 func (me *boltClient) Close() error {
45 func (me *boltClient) OpenTorrent(_ *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error) {
46 t := &boltTorrent{me, infoHash}
53 func (me *boltTorrent) Piece(p metainfo.Piece) PieceImpl {
59 copy(ret.key[:], me.ih[:])
60 binary.BigEndian.PutUint32(ret.key[20:], uint32(p.Index()))
64 func (boltTorrent) Close() error { return nil }