"github.com/anacrolix/multiless"
"github.com/anacrolix/sync"
"github.com/davecgh/go-spew/spew"
+ "github.com/google/go-cmp/cmp"
"github.com/pion/datachannel"
"github.com/anacrolix/torrent/bencode"
}
torrent.Add("deleted connections", 1)
c.deleteAllRequests()
- if t.numActivePeers() == 0 && t.haveInfo() {
- t.assertNoPendingRequests()
- }
+ t.assertPendingRequests()
return
}
return
}
-func (t *Torrent) assertNoPendingRequests() {
- t.pendingRequests.AssertEmpty()
+func (t *Torrent) assertPendingRequests() {
+ var actual pendingRequests
+ if t.haveInfo() {
+ actual.m = make([]int, t.numRequests())
+ }
+ t.iterPeers(func(p *Peer) {
+ p.actualRequestState.Requests.Iterate(func(x uint32) bool {
+ actual.Inc(x)
+ return true
+ })
+ })
+ diff := cmp.Diff(actual.m, t.pendingRequests.m)
+ if diff != "" {
+ panic(diff)
+ }
}
func (t *Torrent) dropConnection(c *PeerConn) {