torrent-piece-request-order.go | 8 +++++--- diff --git a/torrent-piece-request-order.go b/torrent-piece-request-order.go index 17206679e86919c8fa79a77326e927d8e9a7496f..10623da0b5d83594c396a14a11a2599123b44151 100644 --- a/torrent-piece-request-order.go +++ b/torrent-piece-request-order.go @@ -8,9 +8,11 @@ func (t *Torrent) updatePieceRequestOrder(pieceIndex int) { if t.storage == nil { return } - t.cl.pieceRequestOrder[t.clientPieceRequestOrderKey()].Update( - t.pieceRequestOrderKey(pieceIndex), - t.requestStrategyPieceOrderState(pieceIndex)) + if ro, ok := t.cl.pieceRequestOrder[t.clientPieceRequestOrderKey()]; ok { + ro.Update( + t.pieceRequestOrderKey(pieceIndex), + t.requestStrategyPieceOrderState(pieceIndex)) + } } func (t *Torrent) clientPieceRequestOrderKey() interface{} {