2021-05-13 07:56:58 +08:00
|
|
|
package request_strategy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/anacrolix/torrent/types"
|
|
|
|
)
|
|
|
|
|
2021-05-14 11:06:12 +08:00
|
|
|
type ChunksIter func(func(types.ChunkSpec))
|
|
|
|
|
2021-05-13 07:56:58 +08:00
|
|
|
type Piece struct {
|
|
|
|
Request bool
|
|
|
|
Priority piecePriority
|
|
|
|
Partial bool
|
|
|
|
Availability int64
|
|
|
|
Length int64
|
|
|
|
NumPendingChunks int
|
2021-05-14 11:06:12 +08:00
|
|
|
IterPendingChunks ChunksIter
|
2021-05-13 07:56:58 +08:00
|
|
|
}
|
2021-05-13 18:56:12 +08:00
|
|
|
|
2021-05-14 11:06:12 +08:00
|
|
|
func (p Piece) iterPendingChunksWrapper(f func(ChunkSpec)) {
|
2021-05-13 18:56:12 +08:00
|
|
|
i := p.IterPendingChunks
|
|
|
|
if i != nil {
|
|
|
|
i(f)
|
|
|
|
}
|
|
|
|
}
|