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
34138bb0
Commit
34138bb0
authored
Jan 31, 2019
by
Raúl Kripalani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make FD limits configurable by env prop.
parent
65dbfb6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
limiter.go
limiter.go
+9
-1
No files found.
limiter.go
View file @
34138bb0
...
...
@@ -2,6 +2,8 @@ package swarm
import
(
"context"
"os"
"strconv"
"sync"
"time"
...
...
@@ -59,7 +61,13 @@ type dialLimiter struct {
type
dialfunc
func
(
context
.
Context
,
peer
.
ID
,
ma
.
Multiaddr
)
(
transport
.
Conn
,
error
)
func
newDialLimiter
(
df
dialfunc
)
*
dialLimiter
{
return
newDialLimiterWithParams
(
df
,
ConcurrentFdDials
,
DefaultPerPeerRateLimit
)
fd
:=
ConcurrentFdDials
if
env
:=
os
.
Getenv
(
"LIBP2P_SWARM_FD_LIMIT"
);
env
!=
""
{
if
n
,
err
:=
strconv
.
ParseInt
(
env
,
10
,
32
);
err
==
nil
{
fd
=
int
(
n
)
}
}
return
newDialLimiterWithParams
(
df
,
fd
,
DefaultPerPeerRateLimit
)
}
func
newDialLimiterWithParams
(
df
dialfunc
,
fdLimit
,
perPeerLimit
int
)
*
dialLimiter
{
...
...
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