peer.go | 8 ++++---- peerconn.go | 14 +++++++------- diff --git a/peer.go b/peer.go index c4b4fb9e0e95faff1c6493d984c94fd8d6442543..608ccb12144c6ed86d87dfd2abbc4ed22cea803a 100644 --- a/peer.go +++ b/peer.go @@ -244,11 +244,11 @@ } return float64(num) / cn.totalExpectingTime().Seconds() } -func (cn *Peer) DownloadRate() float64 { - cn.locker().RLock() - defer cn.locker().RUnlock() +func (p *Peer) DownloadRate() float64 { + p.locker().RLock() + defer p.locker().RUnlock() - return cn.downloadRate() + return p.downloadRate() } func (cn *Peer) iterContiguousPieceRequests(f func(piece pieceIndex, count int)) { diff --git a/peerconn.go b/peerconn.go index 0dd99cef1f86216d35c50c8641d06aa4711c46c0..ee47dd1b2505e6cf56a3e837962cedb91cce4df1 100644 --- a/peerconn.go +++ b/peerconn.go @@ -1097,16 +1097,16 @@ } return pexEvent{t, addr, f, nil}, nil } -func (c *PeerConn) String() string { - return fmt.Sprintf("%T %p [id=%+q, exts=%v, v=%q]", c, c, c.PeerID, c.PeerExtensionBytes, c.PeerClientName.Load()) +func (pc *PeerConn) String() string { + return fmt.Sprintf("%T %p [id=%+q, exts=%v, v=%q]", pc, pc, pc.PeerID, pc.PeerExtensionBytes, pc.PeerClientName.Load()) } // Returns the pieces the peer could have based on their claims. If we don't know how many pieces -// are in the torrent, it could be a very large range the peer has sent HaveAll. -func (cn *PeerConn) PeerPieces() *roaring.Bitmap { - cn.locker().RLock() - defer cn.locker().RUnlock() - return cn.newPeerPieces() +// are in the torrent, it could be a very large range if the peer has sent HaveAll. +func (pc *PeerConn) PeerPieces() *roaring.Bitmap { + pc.locker().RLock() + defer pc.locker().RUnlock() + return pc.newPeerPieces() } func (pc *PeerConn) remoteIsTransmission() bool {