Skip to content

Commit

Permalink
cons printer
Browse files Browse the repository at this point in the history
  • Loading branch information
mh0lt committed Jul 3, 2024
1 parent f2ec7ac commit e4fb54c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,7 @@ func (t *Torrent) deletePeerConn(c *PeerConn, lock bool) (ret bool) {
}
_, ret = t.conns[c]
delete(t.conns, c)
fmt.Println("-CON", t.numActivePeers(false), c.String())
// Avoid adding a drop event more than once. Probably we should track whether we've generated
// the drop event against the PexConnState instead.
if ret {
Expand Down Expand Up @@ -3454,7 +3455,6 @@ func (t *Torrent) requestingPeer(r RequestIndex, lock bool) *Peer {
}

func (t *Torrent) addConnWithAllPieces(p *Peer, lock bool) {
fmt.Println("+CWAP", p.String())
if lock {
t.mu.Lock()
defer t.mu.Unlock()
Expand All @@ -3464,17 +3464,18 @@ func (t *Torrent) addConnWithAllPieces(p *Peer, lock bool) {
t.connsWithAllPieces = make(map[*Peer]struct{}, t.maxEstablishedConns)
}
t.connsWithAllPieces[p] = struct{}{}
fmt.Println("+CWAP", len(t.connsWithAllPieces), t.numActivePeers(false), p.String())
}

func (t *Torrent) deleteConnWithAllPieces(p *Peer, lock bool) bool {
fmt.Println("-CWAP", p.String())
if lock {
t.mu.Lock()
defer t.mu.Unlock()
}

_, ok := t.connsWithAllPieces[p]
delete(t.connsWithAllPieces, p)
fmt.Println("-CWAP", len(t.connsWithAllPieces), t.numActivePeers(false), p.String())
return ok
}

Expand Down

0 comments on commit e4fb54c

Please sign in to comment.