提交 80b89405 作者: Łukasz Magiera

p2p: fix docstrings

License: MIT
Signed-off-by: 's avatarŁukasz Magiera <magik6k@gmail.com>
上级 05bc3bd9
...@@ -24,6 +24,8 @@ type Listener interface { ...@@ -24,6 +24,8 @@ type Listener interface {
Close() error Close() error
} }
// Listeners manages a group of Listener implementations,
// checking for conflicts and optionally dispatching connections
type Listeners struct { type Listeners struct {
sync.RWMutex sync.RWMutex
......
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol"
) )
const CMGR_TAG = "stream-fwd" const cmgrTag = "stream-fwd"
// Stream holds information on active incoming and outgoing p2p streams. // Stream holds information on active incoming and outgoing p2p streams.
type Stream struct { type Stream struct {
...@@ -30,7 +30,7 @@ type Stream struct { ...@@ -30,7 +30,7 @@ type Stream struct {
Registry *StreamRegistry Registry *StreamRegistry
} }
// close closes stream endpoints and deregisters it // close stream endpoints and deregister it
func (s *Stream) close() error { func (s *Stream) close() error {
s.Registry.Close(s) s.Registry.Close(s)
return nil return nil
...@@ -78,7 +78,7 @@ func (r *StreamRegistry) Register(streamInfo *Stream) { ...@@ -78,7 +78,7 @@ func (r *StreamRegistry) Register(streamInfo *Stream) {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
r.ConnManager.TagPeer(streamInfo.peer, CMGR_TAG, 20) r.ConnManager.TagPeer(streamInfo.peer, cmgrTag, 20)
r.conns[streamInfo.peer]++ r.conns[streamInfo.peer]++
streamInfo.id = r.nextID streamInfo.id = r.nextID
...@@ -99,13 +99,13 @@ func (r *StreamRegistry) Deregister(streamID uint64) { ...@@ -99,13 +99,13 @@ func (r *StreamRegistry) Deregister(streamID uint64) {
r.conns[p]-- r.conns[p]--
if r.conns[p] < 1 { if r.conns[p] < 1 {
delete(r.conns, p) delete(r.conns, p)
r.ConnManager.UntagPeer(p, CMGR_TAG) r.ConnManager.UntagPeer(p, cmgrTag)
} }
delete(r.Streams, streamID) delete(r.Streams, streamID)
} }
// close closes stream endpoints and deregisters it // Close stream endpoints and deregister it
func (r *StreamRegistry) Close(s *Stream) error { func (r *StreamRegistry) Close(s *Stream) error {
s.Local.Close() s.Local.Close()
s.Remote.Close() s.Remote.Close()
...@@ -113,7 +113,7 @@ func (r *StreamRegistry) Close(s *Stream) error { ...@@ -113,7 +113,7 @@ func (r *StreamRegistry) Close(s *Stream) error {
return nil return nil
} }
// reset closes stream endpoints and deregisters it // Reset closes stream endpoints and deregisters it
func (r *StreamRegistry) Reset(s *Stream) error { func (r *StreamRegistry) Reset(s *Stream) error {
s.Local.Close() s.Local.Close()
s.Remote.Reset() s.Remote.Reset()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论