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-pubsub
Commits
5b0ec14e
Commit
5b0ec14e
authored
Dec 06, 2019
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't spawn a goroutine for scheduling connections
parent
efb09f29
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
gossipsub.go
gossipsub.go
+11
-10
No files found.
gossipsub.go
View file @
5b0ec14e
...
@@ -47,6 +47,9 @@ var (
...
@@ -47,6 +47,9 @@ var (
// number of active connection attempts for peers obtained through px
// number of active connection attempts for peers obtained through px
GossipSubConnectors
=
16
GossipSubConnectors
=
16
// maximum number of pending connections for peers attempted through px
GossipSubMaxPendingConnections
=
1024
// timeout for connection attempts
// timeout for connection attempts
GossipSubConnectionTimeout
=
30
*
time
.
Second
GossipSubConnectionTimeout
=
30
*
time
.
Second
)
)
...
@@ -61,7 +64,7 @@ func NewGossipSub(ctx context.Context, h host.Host, opts ...Option) (*PubSub, er
...
@@ -61,7 +64,7 @@ func NewGossipSub(ctx context.Context, h host.Host, opts ...Option) (*PubSub, er
gossip
:
make
(
map
[
peer
.
ID
][]
*
pb
.
ControlIHave
),
gossip
:
make
(
map
[
peer
.
ID
][]
*
pb
.
ControlIHave
),
control
:
make
(
map
[
peer
.
ID
]
*
pb
.
ControlMessage
),
control
:
make
(
map
[
peer
.
ID
]
*
pb
.
ControlMessage
),
backoff
:
make
(
map
[
string
]
map
[
peer
.
ID
]
time
.
Time
),
backoff
:
make
(
map
[
string
]
map
[
peer
.
ID
]
time
.
Time
),
connect
:
make
(
chan
connectInfo
,
GossipSubConnect
or
s
),
connect
:
make
(
chan
connectInfo
,
GossipSub
MaxPending
Connect
ion
s
),
mcache
:
NewMessageCache
(
GossipSubHistoryGossip
,
GossipSubHistoryLength
),
mcache
:
NewMessageCache
(
GossipSubHistoryGossip
,
GossipSubHistoryLength
),
}
}
return
NewPubSub
(
ctx
,
h
,
rt
,
opts
...
)
return
NewPubSub
(
ctx
,
h
,
rt
,
opts
...
)
...
@@ -325,16 +328,14 @@ func (gs *GossipSubRouter) pxConnect(peers []*pb.PeerInfo) {
...
@@ -325,16 +328,14 @@ func (gs *GossipSubRouter) pxConnect(peers []*pb.PeerInfo) {
return
return
}
}
// initiate connections, without blocking the event loop
for
_
,
ci
:=
range
toconnect
{
go
func
()
{
select
{
for
_
,
ci
:=
range
toconnect
{
case
gs
.
connect
<-
ci
:
select
{
default
:
case
gs
.
connect
<-
ci
:
log
.
Debugf
(
"ignoring peer connection attempt; too many pending connections"
)
case
<-
gs
.
p
.
ctx
.
Done
()
:
break
return
}
}
}
}
()
}
}
}
func
(
gs
*
GossipSubRouter
)
connector
()
{
func
(
gs
*
GossipSubRouter
)
connector
()
{
...
...
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