Add disabled code for limiting wasted chunks

This commit is contained in:
Matt Joiner 2021-10-25 21:37:25 +11:00
parent e7426133e2
commit 344ada8b7c
2 changed files with 4 additions and 0 deletions

View File

@ -1335,6 +1335,7 @@ func (c *Peer) receiveChunk(msg *pp.Message) error {
// Do we actually want this chunk?
if t.haveChunk(ppReq) {
//panic(fmt.Sprintf("%+v", ppReq))
chunksReceived.Add("wasted", 1)
c.allStats(add(1, func(cs *ConnStats) *Count { return &cs.ChunksReadWasted }))
return nil

View File

@ -215,6 +215,9 @@ func (p *Peer) getDesiredRequestState() (desired requestState) {
allowedFast := p.peerAllowedFast.ContainsInt(pieceIndex)
rsp.IterPendingChunks.Iter(func(ci request_strategy.ChunkIndex) {
r := p.t.pieceRequestIndexOffset(pieceIndex) + ci
//if p.t.pendingRequests.Get(r) != 0 && !p.actualRequestState.Requests.Contains(r) {
// return
//}
if !allowedFast {
// We must signal interest to request this
desired.Interested = true