Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
80b89405
Commit
80b89405
authored
Sep 06, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: fix docstrings
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
05bc3bd9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
p2p/listener.go
p2p/listener.go
+2
-0
p2p/stream.go
p2p/stream.go
+6
-6
No files found.
p2p/listener.go
View file @
80b89405
...
...
@@ -24,6 +24,8 @@ type Listener interface {
Close
()
error
}
// Listeners manages a group of Listener implementations,
// checking for conflicts and optionally dispatching connections
type
Listeners
struct
{
sync
.
RWMutex
...
...
p2p/stream.go
View file @
80b89405
...
...
@@ -12,7 +12,7 @@ import (
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.
type
Stream
struct
{
...
...
@@ -30,7 +30,7 @@ type Stream struct {
Registry
*
StreamRegistry
}
// close
closes
stream endpoints and deregister
s
it
// close stream endpoints and deregister it
func
(
s
*
Stream
)
close
()
error
{
s
.
Registry
.
Close
(
s
)
return
nil
...
...
@@ -78,7 +78,7 @@ func (r *StreamRegistry) Register(streamInfo *Stream) {
r
.
Lock
()
defer
r
.
Unlock
()
r
.
ConnManager
.
TagPeer
(
streamInfo
.
peer
,
CMGR_TAG
,
20
)
r
.
ConnManager
.
TagPeer
(
streamInfo
.
peer
,
cmgrTag
,
20
)
r
.
conns
[
streamInfo
.
peer
]
++
streamInfo
.
id
=
r
.
nextID
...
...
@@ -99,13 +99,13 @@ func (r *StreamRegistry) Deregister(streamID uint64) {
r
.
conns
[
p
]
--
if
r
.
conns
[
p
]
<
1
{
delete
(
r
.
conns
,
p
)
r
.
ConnManager
.
UntagPeer
(
p
,
CMGR_TAG
)
r
.
ConnManager
.
UntagPeer
(
p
,
cmgrTag
)
}
delete
(
r
.
Streams
,
streamID
)
}
//
c
lose
closes
stream endpoints and deregister
s
it
//
C
lose stream endpoints and deregister it
func
(
r
*
StreamRegistry
)
Close
(
s
*
Stream
)
error
{
s
.
Local
.
Close
()
s
.
Remote
.
Close
()
...
...
@@ -113,7 +113,7 @@ func (r *StreamRegistry) Close(s *Stream) error {
return
nil
}
//
r
eset closes stream endpoints and deregisters it
//
R
eset closes stream endpoints and deregisters it
func
(
r
*
StreamRegistry
)
Reset
(
s
*
Stream
)
error
{
s
.
Local
.
Close
()
s
.
Remote
.
Reset
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment