// Sized puts require being able to stream from a statement executed on another connection.
// Without them, we buffer the entire read and then put that.
NoSizedPuts bool
- Capacity *int64
+ Capacity TorrentCapacity
}
func NewResourcePieces(p PieceProvider) ClientImpl {
s,
make([]sync.RWMutex, info.NumPieces()),
}
- return TorrentImpl{PieceWithHash: t.Piece, Close: t.Close}, nil
+ return TorrentImpl{
+ PieceWithHash: t.Piece,
+ Close: t.Close,
+ Capacity: s.opts.Capacity,
+ }, nil
}
func (s piecePerResourceTorrentImpl) Piece(p metainfo.Piece, pieceHash g.Option[[]byte]) PieceImpl {
if err != nil {
panic(err)
}
- var sharedCapacity *int64
+ var capFuncPtr storage.TorrentCapacity
if ps.SetCapacity {
- sharedCapacity = &ps.Capacity
fc.SetCapacity(ps.Capacity)
+ f := func() (cap int64, capped bool) {
+ return ps.Capacity, ps.SetCapacity
+ }
+ capFuncPtr = &f
}
+
return struct {
storage.ClientImpl
io.Closer
storage.NewResourcePiecesOpts(
fc.AsResourceProvider(),
storage.ResourcePiecesOpts{
- Capacity: sharedCapacity,
+ Capacity: capFuncPtr,
}),
io.NopCloser(nil),
}