From: Matt Joiner Date: Mon, 4 Jan 2021 04:51:23 +0000 (+1100) Subject: Some peerImpl observations X-Git-Tag: v1.20.0^0 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=133cc17c0090a87c74866c3dd7e36979c3accf70;p=btrtrc.git Some peerImpl observations --- diff --git a/peer-impl.go b/peer-impl.go index 10a6d249..81ec26ef 100644 --- a/peer-impl.go +++ b/peer-impl.go @@ -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() diff --git a/peerconn.go b/peerconn.go index e333d213..28f7d005 100644 --- a/peerconn.go +++ b/peerconn.go @@ -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() } diff --git a/webseed-peer.go b/webseed-peer.go index 4ed32372..5b0cb824 100644 --- a/webseed-peer.go +++ b/webseed-peer.go @@ -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