Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
0bf3065f
Unverified
Commit
0bf3065f
authored
Oct 02, 2018
by
Viktor Trón
Committed by
GitHub
Oct 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17771 from ethersphere/cmd-config-errors
swarm: handle errors in cmdLineOverride and envVarsOverride
parents
83116a34
bf37241e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
13 deletions
+30
-13
config.go
cmd/swarm/config.go
+30
-13
No files found.
cmd/swarm/config.go
View file @
0bf3065f
...
@@ -176,8 +176,12 @@ func cmdLineOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Con
...
@@ -176,8 +176,12 @@ func cmdLineOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Con
}
}
if
networkid
:=
ctx
.
GlobalString
(
SwarmNetworkIdFlag
.
Name
);
networkid
!=
""
{
if
networkid
:=
ctx
.
GlobalString
(
SwarmNetworkIdFlag
.
Name
);
networkid
!=
""
{
if
id
,
_
:=
strconv
.
Atoi
(
networkid
);
id
!=
0
{
id
,
err
:=
strconv
.
ParseUint
(
networkid
,
10
,
64
)
currentConfig
.
NetworkID
=
uint64
(
id
)
if
err
!=
nil
{
utils
.
Fatalf
(
"invalid cli flag %s: %v"
,
SwarmNetworkIdFlag
.
Name
,
err
)
}
if
id
!=
0
{
currentConfig
.
NetworkID
=
id
}
}
}
}
...
@@ -270,8 +274,12 @@ func envVarsOverride(currentConfig *bzzapi.Config) (config *bzzapi.Config) {
...
@@ -270,8 +274,12 @@ func envVarsOverride(currentConfig *bzzapi.Config) (config *bzzapi.Config) {
}
}
if
networkid
:=
os
.
Getenv
(
SWARM_ENV_NETWORK_ID
);
networkid
!=
""
{
if
networkid
:=
os
.
Getenv
(
SWARM_ENV_NETWORK_ID
);
networkid
!=
""
{
if
id
,
_
:=
strconv
.
Atoi
(
networkid
);
id
!=
0
{
id
,
err
:=
strconv
.
ParseUint
(
networkid
,
10
,
64
)
currentConfig
.
NetworkID
=
uint64
(
id
)
if
err
!=
nil
{
utils
.
Fatalf
(
"invalid environment variable %s: %v"
,
SWARM_ENV_NETWORK_ID
,
err
)
}
if
id
!=
0
{
currentConfig
.
NetworkID
=
id
}
}
}
}
...
@@ -289,27 +297,34 @@ func envVarsOverride(currentConfig *bzzapi.Config) (config *bzzapi.Config) {
...
@@ -289,27 +297,34 @@ func envVarsOverride(currentConfig *bzzapi.Config) (config *bzzapi.Config) {
}
}
if
swapenable
:=
os
.
Getenv
(
SWARM_ENV_SWAP_ENABLE
);
swapenable
!=
""
{
if
swapenable
:=
os
.
Getenv
(
SWARM_ENV_SWAP_ENABLE
);
swapenable
!=
""
{
if
swap
,
err
:=
strconv
.
ParseBool
(
swapenable
);
err
!=
nil
{
swap
,
err
:=
strconv
.
ParseBool
(
swapenable
)
currentConfig
.
SwapEnabled
=
swap
if
err
!=
nil
{
utils
.
Fatalf
(
"invalid environment variable %s: %v"
,
SWARM_ENV_SWAP_ENABLE
,
err
)
}
}
currentConfig
.
SwapEnabled
=
swap
}
}
if
syncdisable
:=
os
.
Getenv
(
SWARM_ENV_SYNC_DISABLE
);
syncdisable
!=
""
{
if
syncdisable
:=
os
.
Getenv
(
SWARM_ENV_SYNC_DISABLE
);
syncdisable
!=
""
{
if
sync
,
err
:=
strconv
.
ParseBool
(
syncdisable
);
err
!=
nil
{
sync
,
err
:=
strconv
.
ParseBool
(
syncdisable
)
currentConfig
.
SyncEnabled
=
!
sync
if
err
!=
nil
{
utils
.
Fatalf
(
"invalid environment variable %s: %v"
,
SWARM_ENV_SYNC_DISABLE
,
err
)
}
}
currentConfig
.
SyncEnabled
=
!
sync
}
}
if
v
:=
os
.
Getenv
(
SWARM_ENV_DELIVERY_SKIP_CHECK
);
v
!=
""
{
if
v
:=
os
.
Getenv
(
SWARM_ENV_DELIVERY_SKIP_CHECK
);
v
!=
""
{
if
skipCheck
,
err
:=
strconv
.
ParseBool
(
v
);
err
!=
nil
{
skipCheck
,
err
:=
strconv
.
ParseBool
(
v
)
if
err
!=
nil
{
currentConfig
.
DeliverySkipCheck
=
skipCheck
currentConfig
.
DeliverySkipCheck
=
skipCheck
}
}
}
}
if
v
:=
os
.
Getenv
(
SWARM_ENV_SYNC_UPDATE_DELAY
);
v
!=
""
{
if
v
:=
os
.
Getenv
(
SWARM_ENV_SYNC_UPDATE_DELAY
);
v
!=
""
{
if
d
,
err
:=
time
.
ParseDuration
(
v
);
err
!=
nil
{
d
,
err
:=
time
.
ParseDuration
(
v
)
currentConfig
.
SyncUpdateDelay
=
d
if
err
!=
nil
{
utils
.
Fatalf
(
"invalid environment variable %s: %v"
,
SWARM_ENV_SYNC_UPDATE_DELAY
,
err
)
}
}
currentConfig
.
SyncUpdateDelay
=
d
}
}
if
max
:=
os
.
Getenv
(
SWARM_ENV_MAX_STREAM_PEER_SERVERS
);
max
!=
""
{
if
max
:=
os
.
Getenv
(
SWARM_ENV_MAX_STREAM_PEER_SERVERS
);
max
!=
""
{
...
@@ -321,9 +336,11 @@ func envVarsOverride(currentConfig *bzzapi.Config) (config *bzzapi.Config) {
...
@@ -321,9 +336,11 @@ func envVarsOverride(currentConfig *bzzapi.Config) (config *bzzapi.Config) {
}
}
if
lne
:=
os
.
Getenv
(
SWARM_ENV_LIGHT_NODE_ENABLE
);
lne
!=
""
{
if
lne
:=
os
.
Getenv
(
SWARM_ENV_LIGHT_NODE_ENABLE
);
lne
!=
""
{
if
lightnode
,
err
:=
strconv
.
ParseBool
(
lne
);
err
!=
nil
{
lightnode
,
err
:=
strconv
.
ParseBool
(
lne
)
currentConfig
.
LightNodeEnabled
=
lightnode
if
err
!=
nil
{
utils
.
Fatalf
(
"invalid environment variable %s: %v"
,
SWARM_ENV_LIGHT_NODE_ENABLE
,
err
)
}
}
currentConfig
.
LightNodeEnabled
=
lightnode
}
}
if
swapapi
:=
os
.
Getenv
(
SWARM_ENV_SWAP_API
);
swapapi
!=
""
{
if
swapapi
:=
os
.
Getenv
(
SWARM_ENV_SWAP_API
);
swapapi
!=
""
{
...
...
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