Use intermediate t in Peer.getDesiredRequestState
This commit is contained in:
parent
9eb80abc29
commit
4eb6a49f27
|
@ -184,22 +184,23 @@ type desiredRequestState struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Peer) getDesiredRequestState() (desired desiredRequestState) {
|
func (p *Peer) getDesiredRequestState() (desired desiredRequestState) {
|
||||||
if !p.t.haveInfo() {
|
t := p.t
|
||||||
|
if !t.haveInfo() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if p.t.closed.IsSet() {
|
if t.closed.IsSet() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
input := p.t.getRequestStrategyInput()
|
input := t.getRequestStrategyInput()
|
||||||
requestHeap := desiredPeerRequests{
|
requestHeap := desiredPeerRequests{
|
||||||
peer: p,
|
peer: p,
|
||||||
pieceStates: make(map[pieceIndex]request_strategy.PieceRequestOrderState),
|
pieceStates: make(map[pieceIndex]request_strategy.PieceRequestOrderState),
|
||||||
}
|
}
|
||||||
request_strategy.GetRequestablePieces(
|
request_strategy.GetRequestablePieces(
|
||||||
input,
|
input,
|
||||||
p.t.getPieceRequestOrder(),
|
t.getPieceRequestOrder(),
|
||||||
func(ih InfoHash, pieceIndex int, pieceExtra request_strategy.PieceRequestOrderState) {
|
func(ih InfoHash, pieceIndex int, pieceExtra request_strategy.PieceRequestOrderState) {
|
||||||
if ih != p.t.infoHash {
|
if ih != t.infoHash {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !p.peerHasPiece(pieceIndex) {
|
if !p.peerHasPiece(pieceIndex) {
|
||||||
|
@ -231,7 +232,7 @@ func (p *Peer) getDesiredRequestState() (desired desiredRequestState) {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
p.t.assertPendingRequests()
|
t.assertPendingRequests()
|
||||||
desired.Requests = requestHeap
|
desired.Requests = requestHeap
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue