}
tr.Stop("write chunk")
}()
+ if c.peerTouchedPieces == nil {
+ c.peerTouchedPieces = make(map[int]struct{})
+ }
+ c.peerTouchedPieces[int(req.Index)] = struct{}{}
// log.Println("got chunk", req)
piece.Event.Broadcast()
} else {
log.Printf("%s: piece %d failed hash", t, piece)
pieceHashedNotCorrect.Add(1)
+ var touched []*connection
+ for _, c := range t.Conns {
+ if _, ok := c.peerTouchedPieces[int(piece)]; ok {
+ touched = append(touched, c)
+ }
+ }
+ log.Printf("dropping %d conns that touched piece", len(touched))
+ for _, c := range touched {
+ me.dropConnection(t, c)
+ }
}
}
p.EverHashed = true
// related messages yet.
PeerPieces []bool
peerHasAll bool
+ // Pieces we've accepted chunks for from the peer.
+ peerTouchedPieces map[int]struct{}
PeerMaxRequests int // Maximum pending requests the peer allows.
PeerExtensionIDs map[string]byte
eventAgeString(cn.completedHandshake),
eventAgeString(cn.lastUsefulChunkReceived))
fmt.Fprintf(w,
- " %s completed, good chunks: %d/%d-%d reqq: %d-%d, flags: %s\n",
+ " %s completed, %d pieces touched, good chunks: %d/%d-%d reqq: %d-%d, flags: %s\n",
cn.completedString(t),
+ len(cn.peerTouchedPieces),
cn.UsefulChunksReceived,
cn.UnwantedChunksReceived+cn.UsefulChunksReceived,
cn.chunksSent,