Documentation
¶
Index ¶
- func GetRequestablePieces(input Input, pro *PieceRequestOrder, requestPiece RequestPieceFunc) bool
- func NewAjwernerBtree() *ajwernerBtree
- func NewTidwallBtree() *tidwallBtree
- type Btree
- type ChunkIndex
- type ChunkSpec
- type Input
- type PeerRequestState
- type PeerRequests
- type Piece
- type PieceRequestOrder
- func (me *PieceRequestOrder) Add(key PieceRequestOrderKey, state PieceRequestOrderState) (old g.Option[PieceRequestOrderState])
- func (me *PieceRequestOrder) Delete(key PieceRequestOrderKey) (deleted bool)
- func (me *PieceRequestOrder) Get(key PieceRequestOrderKey) (ret g.Option[PieceRequestOrderState])
- func (me *PieceRequestOrder) Iter(yield func(PieceRequestOrderItem) bool)
- func (me *PieceRequestOrder) Len() int
- func (me *PieceRequestOrder) Update(key PieceRequestOrderKey, state PieceRequestOrderState) (changed bool)
- type PieceRequestOrderItem
- type PieceRequestOrderKey
- type PieceRequestOrderPathHint
- type PieceRequestOrderState
- type Request
- type RequestIndex
- type RequestPieceFunc
- type Torrent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRequestablePieces ¶
func GetRequestablePieces( input Input, pro *PieceRequestOrder, requestPiece RequestPieceFunc, ) bool
Calls f with requestable pieces in order. Returns false if iteration should stop.
func NewAjwernerBtree ¶
func NewAjwernerBtree() *ajwernerBtree
func NewTidwallBtree ¶
func NewTidwallBtree() *tidwallBtree
Types ¶
type Btree ¶
type Btree interface {
Delete(PieceRequestOrderItem)
Add(PieceRequestOrderItem)
// This is an iterator. Go can't guarantee to not allocate if you return an iterator.
Scan(func(PieceRequestOrderItem) bool)
Contains(PieceRequestOrderItem) bool
}
type ChunkIndex ¶
type ChunkIndex = RequestIndex
type Input ¶
type Input interface {
Torrent(metainfo.Hash) Torrent
// Storage capacity, shared among all Torrents with the same storage.TorrentCapacity pointer in
// their storage.Torrent references.
Capacity() (cap int64, capped bool)
// Across all the Torrents. This might be partitioned by storage capacity key now.
MaxUnverifiedBytes() int64
}
type PeerRequestState ¶
type PeerRequestState struct {
Interested bool
Requests PeerRequests
// Cancelled and waiting response
Cancelled typedRoaring.Bitmap[RequestIndex]
}
type PeerRequests ¶
type PeerRequests interface {
// Can be more efficient than GetCardinality.
IsEmpty() bool
// See roaring.Bitmap.GetCardinality.
GetCardinality() uint64
Contains(RequestIndex) bool
// Should not adjust iteration order if item already exists, although I don't think that usage
// exists.
Add(RequestIndex)
// See roaring.Bitmap.Rank.
Rank(RequestIndex) uint64
// Must yield in order items were added.
Iterate(func(RequestIndex) bool) (all bool)
// Must yield in order items were added.
Iterator() iter.Seq[RequestIndex]
// See roaring.Bitmap.CheckedRemove.
CheckedRemove(RequestIndex) bool
// Iterate a snapshot of the values. It is safe to mutate the underlying data structure.
IterateSnapshot(func(RequestIndex) bool)
}
A set of request indices iterable by order added.
type Piece ¶
type Piece interface {
// Whether requests should be made for this piece. This would be false for cases like the piece
// is currently being hashed, or already complete.
Request() bool
// Whether the piece should be counted towards the unverified bytes limit. The intention is to
// prevent pieces being starved from the opportunity to move to the completed state. Pieces that
// are in an overhead state like being hashed, queued, or having metadata modified are here. If
// we didn't count them we could race ahead downloading and leave lots of pieces stuck in an
// intermediate state.
CountUnverified() bool
}
type PieceRequestOrder ¶
type PieceRequestOrder struct {
// contains filtered or unexported fields
}
func NewPieceOrder ¶
func NewPieceOrder(btree Btree, cap int) *PieceRequestOrder
func (*PieceRequestOrder) Add ¶
func (me *PieceRequestOrder) Add( key PieceRequestOrderKey, state PieceRequestOrderState, ) (old g.Option[PieceRequestOrderState])
Returns the old state if the key was already present. The Update method needs to look at it.
func (*PieceRequestOrder) Delete ¶
func (me *PieceRequestOrder) Delete(key PieceRequestOrderKey) (deleted bool)
func (*PieceRequestOrder) Get ¶
func (me *PieceRequestOrder) Get(key PieceRequestOrderKey) (ret g.Option[PieceRequestOrderState])
func (*PieceRequestOrder) Iter ¶
func (me *PieceRequestOrder) Iter(yield func(PieceRequestOrderItem) bool)
func (*PieceRequestOrder) Len ¶
func (me *PieceRequestOrder) Len() int
func (*PieceRequestOrder) Update ¶
func (me *PieceRequestOrder) Update( key PieceRequestOrderKey, state PieceRequestOrderState, ) (changed bool)
type PieceRequestOrderItem ¶
type PieceRequestOrderItem struct {
Key PieceRequestOrderKey
State PieceRequestOrderState
}
func (*PieceRequestOrderItem) Less ¶
func (me *PieceRequestOrderItem) Less(otherConcrete *PieceRequestOrderItem) bool
type PieceRequestOrderKey ¶
type PieceRequestOrderState ¶
type RequestIndex ¶
type RequestIndex uint32
type RequestPieceFunc ¶
type RequestPieceFunc func(ih metainfo.Hash, pieceIndex int, orderState PieceRequestOrderState) bool
This did return true if the piece should be considered against the unverified bytes limit. But that would cause thrashing on completion: The order should be stable. This is now a 3-tuple iterator.
Click to show internal directories.
Click to hide internal directories.