4 request_strategy "github.com/anacrolix/torrent/request-strategy"
7 func (t *Torrent) updatePieceRequestOrder(pieceIndex int) {
11 t.cl.pieceRequestOrder[t.clientPieceRequestOrderKey()].Update(
12 t.pieceRequestOrderKey(pieceIndex),
13 t.requestStrategyPieceOrderState(pieceIndex))
16 func (t *Torrent) clientPieceRequestOrderKey() interface{} {
17 if t.storage.Capacity == nil {
20 return t.storage.Capacity
23 func (t *Torrent) deletePieceRequestOrder() {
27 cpro := t.cl.pieceRequestOrder
28 key := t.clientPieceRequestOrderKey()
30 for i := 0; i < t.numPieces(); i++ {
31 pro.Delete(t.pieceRequestOrderKey(i))
38 func (t *Torrent) initPieceRequestOrder() {
42 if t.cl.pieceRequestOrder == nil {
43 t.cl.pieceRequestOrder = make(map[interface{}]*request_strategy.PieceRequestOrder)
45 key := t.clientPieceRequestOrderKey()
46 cpro := t.cl.pieceRequestOrder
48 cpro[key] = request_strategy.NewPieceOrder(request_strategy.NewAjwernerBtree(), t.numPieces())
52 func (t *Torrent) addRequestOrderPiece(i int) {
56 t.cl.pieceRequestOrder[t.clientPieceRequestOrderKey()].Add(
57 t.pieceRequestOrderKey(i),
58 t.requestStrategyPieceOrderState(i))
61 func (t *Torrent) getPieceRequestOrder() *request_strategy.PieceRequestOrder {
62 return t.cl.pieceRequestOrder[t.clientPieceRequestOrderKey()]