p2p: fix docstrings
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Sep 6, 2018 at 11:15 UTC
80b89405edf1054f17244520d619ef7e82cf26c8
2 files changed
+8
-6
p2p/listener.go
+2
@@ -24,6 +24,8 @@ type Listener interface {
24
Close() error
25
}
26
27
+// Listeners manages a group of Listener implementations,
28
+// checking for conflicts and optionally dispatching connections
29
type Listeners struct {
30
sync.RWMutex
31
p2p/stream.go
+6
-6
@@ -12,7 +12,7 @@ import (
12
protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol"
13
)
14
15
-const CMGR_TAG = "stream-fwd"
15
+const cmgrTag = "stream-fwd"
16
17
// Stream holds information on active incoming and outgoing p2p streams.
18
type Stream struct {
@@ -30,7 +30,7 @@ type Stream struct {
30
Registry *StreamRegistry
31
}
32
33
-// close closes stream endpoints and deregisters it
33
+// close stream endpoints and deregister it
34
func (s *Stream) close() error {
35
s.Registry.Close(s)
36
return nil
@@ -78,7 +78,7 @@ func (r *StreamRegistry) Register(streamInfo *Stream) {
78
r.Lock()
79
defer r.Unlock()
80
81
- r.ConnManager.TagPeer(streamInfo.peer, CMGR_TAG, 20)
81
+ r.ConnManager.TagPeer(streamInfo.peer, cmgrTag, 20)
82
r.conns[streamInfo.peer]++
83
84
streamInfo.id = r.nextID
@@ -99,13 +99,13 @@ func (r *StreamRegistry) Deregister(streamID uint64) {
99
r.conns[p]--
100
if r.conns[p] < 1 {
101
delete(r.conns, p)
102
- r.ConnManager.UntagPeer(p, CMGR_TAG)
102
+ r.ConnManager.UntagPeer(p, cmgrTag)
103
}
104
105
delete(r.Streams, streamID)
106
}
107
108
-// close closes stream endpoints and deregisters it
108
+// Close stream endpoints and deregister it
109
func (r *StreamRegistry) Close(s *Stream) error {
110
s.Local.Close()
111
s.Remote.Close()
@@ -113,7 +113,7 @@ func (r *StreamRegistry) Close(s *Stream) error {
113
return nil
114
}
115
116
-// reset closes stream endpoints and deregisters it
116
+// Reset closes stream endpoints and deregisters it
117
func (r *StreamRegistry) Reset(s *Stream) error {
118
s.Local.Close()
119
s.Remote.Reset()