]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Some peerImpl observations v1.20.0
authorMatt Joiner <anacrolix@gmail.com>
Mon, 4 Jan 2021 04:51:23 +0000 (15:51 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 4 Jan 2021 04:51:23 +0000 (15:51 +1100)
peer-impl.go
peerconn.go
webseed-peer.go

index 10a6d249f74bb9dbd7faf455f2cd15ee262135f5..81ec26ef25389ebd814f39fdef0a2cd813247633 100644 (file)
@@ -14,7 +14,7 @@ type peerImpl interface {
        // Return true if there's room for more activity.
        request(request) bool
        connectionFlags() string
-       _close()
+       onClose()
        _postCancel(request)
        onGotInfo(*metainfo.Info)
        drop()
index e333d21372b036d334e2769b429b904b55b638c8..28f7d005f9b6cce20c12eaea38a86668fd35ae12 100644 (file)
@@ -201,7 +201,7 @@ func (cn *peer) cumInterest() time.Duration {
        return ret
 }
 
-func (cn *PeerConn) peerHasAllPieces() (all bool, known bool) {
+func (cn *peer) peerHasAllPieces() (all bool, known bool) {
        if cn.peerSentHaveAll {
                return true, true
        }
@@ -349,10 +349,10 @@ func (cn *peer) close() {
        }
        cn.discardPieceInclination()
        cn._pieceRequestOrder.Clear()
-       cn.peerImpl._close()
+       cn.peerImpl.onClose()
 }
 
-func (cn *PeerConn) _close() {
+func (cn *PeerConn) onClose() {
        if cn.pex.IsEnabled() {
                cn.pex.Close()
        }
index 4ed323725d655f5c55156a41eb43ec7e0168bbfa..5b0cb824ad88eb2ec9076478be1a5454737b46fe 100644 (file)
@@ -61,14 +61,15 @@ func (ws *webseedPeer) connectionFlags() string {
        return "WS"
 }
 
-// TODO: This is called when banning peers. Perhaps we want to be able to ban webseeds too.
+// TODO: This is called when banning peers. Perhaps we want to be able to ban webseeds too. We could
+// return bool if this is even possible, and if it isn't, skip to the next drop candidate.
 func (ws *webseedPeer) drop() {}
 
 func (ws *webseedPeer) updateRequests() {
        ws.peer.doRequestState()
 }
 
-func (ws *webseedPeer) _close() {}
+func (ws *webseedPeer) onClose() {}
 
 func (ws *webseedPeer) requestResultHandler(r request, webseedRequest webseed.Request) {
        result := <-webseedRequest.Result