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
p2p
go-p2p-swarm
Commits
6357e7c3
Unverified
Commit
6357e7c3
authored
Mar 29, 2021
by
Steven Allen
Committed by
GitHub
Mar 29, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #247 from libp2p/fix/64bit-ids
fix: use 64bit stream/conn IDs
parents
3d932ed9
62e792f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
swarm.go
swarm.go
+4
-4
swarm_conn.go
swarm_conn.go
+2
-2
swarm_stream.go
swarm_stream.go
+1
-1
No files found.
swarm.go
View file @
6357e7c3
...
@@ -48,6 +48,9 @@ var ErrDialTimeout = errors.New("dial timed out")
...
@@ -48,6 +48,9 @@ var ErrDialTimeout = errors.New("dial timed out")
// communication. The Chan sends/receives Messages, which note the
// communication. The Chan sends/receives Messages, which note the
// destination or source Peer.
// destination or source Peer.
type
Swarm
struct
{
type
Swarm
struct
{
nextConnID
uint64
// guarded by atomic
nextStreamID
uint64
// guarded by atomic
// Close refcount. This allows us to fully wait for the swarm to be torn
// Close refcount. This allows us to fully wait for the swarm to be torn
// down before continuing.
// down before continuing.
refs
sync
.
WaitGroup
refs
sync
.
WaitGroup
...
@@ -55,9 +58,6 @@ type Swarm struct {
...
@@ -55,9 +58,6 @@ type Swarm struct {
local
peer
.
ID
local
peer
.
ID
peers
peerstore
.
Peerstore
peers
peerstore
.
Peerstore
nextConnID
uint32
// guarded by atomic
nextStreamID
uint32
// guarded by atomic
conns
struct
{
conns
struct
{
sync
.
RWMutex
sync
.
RWMutex
m
map
[
peer
.
ID
][]
*
Conn
m
map
[
peer
.
ID
][]
*
Conn
...
@@ -235,7 +235,7 @@ func (s *Swarm) addConn(tc transport.CapableConn, dir network.Direction) (*Conn,
...
@@ -235,7 +235,7 @@ func (s *Swarm) addConn(tc transport.CapableConn, dir network.Direction) (*Conn,
conn
:
tc
,
conn
:
tc
,
swarm
:
s
,
swarm
:
s
,
stat
:
stat
,
stat
:
stat
,
id
:
atomic
.
AddUint
32
(
&
s
.
nextConnID
,
1
),
id
:
atomic
.
AddUint
64
(
&
s
.
nextConnID
,
1
),
}
}
// we ONLY check upgraded connections here so we can send them a Disconnect message.
// we ONLY check upgraded connections here so we can send them a Disconnect message.
...
...
swarm_conn.go
View file @
6357e7c3
...
@@ -25,7 +25,7 @@ var ErrConnClosed = errors.New("connection closed")
...
@@ -25,7 +25,7 @@ var ErrConnClosed = errors.New("connection closed")
// Conn is the connection type used by swarm. In general, you won't use this
// Conn is the connection type used by swarm. In general, you won't use this
// type directly.
// type directly.
type
Conn
struct
{
type
Conn
struct
{
id
uint
32
id
uint
64
conn
transport
.
CapableConn
conn
transport
.
CapableConn
swarm
*
Swarm
swarm
*
Swarm
...
@@ -209,7 +209,7 @@ func (c *Conn) addStream(ts mux.MuxedStream, dir network.Direction) (*Stream, er
...
@@ -209,7 +209,7 @@ func (c *Conn) addStream(ts mux.MuxedStream, dir network.Direction) (*Stream, er
stream
:
ts
,
stream
:
ts
,
conn
:
c
,
conn
:
c
,
stat
:
stat
,
stat
:
stat
,
id
:
atomic
.
AddUint
32
(
&
c
.
swarm
.
nextStreamID
,
1
),
id
:
atomic
.
AddUint
64
(
&
c
.
swarm
.
nextStreamID
,
1
),
}
}
c
.
streams
.
m
[
s
]
=
struct
{}{}
c
.
streams
.
m
[
s
]
=
struct
{}{}
...
...
swarm_stream.go
View file @
6357e7c3
...
@@ -17,7 +17,7 @@ var _ network.Stream = &Stream{}
...
@@ -17,7 +17,7 @@ var _ network.Stream = &Stream{}
// Stream is the stream type used by swarm. In general, you won't use this type
// Stream is the stream type used by swarm. In general, you won't use this type
// directly.
// directly.
type
Stream
struct
{
type
Stream
struct
{
id
uint
32
id
uint
64
stream
mux
.
MuxedStream
stream
mux
.
MuxedStream
conn
*
Conn
conn
*
Conn
...
...
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