Assert that a request isn't cancelled before requesting it again
This commit is contained in:
parent
a671c06b94
commit
47ef8d9c2d
|
@ -570,6 +570,9 @@ type messageWriter func(pp.Message) bool
|
|||
// when we want to go fast.
|
||||
func (cn *Peer) shouldRequest(r RequestIndex) error {
|
||||
pi := pieceIndex(r / cn.t.chunksPerRegularPiece())
|
||||
if cn.requestState.Cancelled.Contains(r) {
|
||||
return errors.New("request is cancelled and waiting acknowledgement")
|
||||
}
|
||||
if !cn.peerHasPiece(pi) {
|
||||
return errors.New("requesting piece peer doesn't have")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue