@@ -27,10 +27,10 @@ import (
27
27
"strings"
28
28
"unicode"
29
29
30
+ "github.com/ethereum/go-ethereum/common"
30
31
cli "gopkg.in/urfave/cli.v1"
31
32
32
33
"github.com/ethereum/go-ethereum/cmd/utils"
33
- "github.com/ethereum/go-ethereum/common"
34
34
"github.com/ethereum/go-ethereum/log"
35
35
"github.com/ethereum/go-ethereum/node"
36
36
"github.com/naoina/toml"
@@ -59,33 +59,35 @@ var (
59
59
60
60
//constants for environment variables
61
61
const (
62
- SwarmEnvChequebookAddr = "SWARM_CHEQUEBOOK_ADDR"
63
- SwarmEnvAccount = "SWARM_ACCOUNT"
64
- SwarmEnvBzzKeyHex = "SWARM_BZZ_KEY_HEX"
65
- SwarmEnvListenAddr = "SWARM_LISTEN_ADDR"
66
- SwarmEnvPort = "SWARM_PORT"
67
- SwarmEnvNetworkID = "SWARM_NETWORK_ID"
68
- SwarmEnvSwapEnable = "SWARM_SWAP_ENABLE"
69
- SwarmEnvSwapBackendURL = "SWARM_SWAP_BACKEND_URL"
70
- SwarmEnvSyncDisable = "SWARM_SYNC_DISABLE"
71
- SwarmEnvSyncUpdateDelay = "SWARM_ENV_SYNC_UPDATE_DELAY"
72
- SwarmEnvMaxStreamPeerServers = "SWARM_ENV_MAX_STREAM_PEER_SERVERS"
73
- SwarmEnvLightNodeEnable = "SWARM_LIGHT_NODE_ENABLE"
74
- SwarmEnvDeliverySkipCheck = "SWARM_DELIVERY_SKIP_CHECK"
75
- SwarmEnvENSAPI = "SWARM_ENS_API"
76
- SwarmEnvENSAddr = "SWARM_ENS_ADDR"
77
- SwarmEnvCORS = "SWARM_CORS"
78
- SwarmEnvBootnodes = "SWARM_BOOTNODES"
79
- SwarmEnvPSSEnable = "SWARM_PSS_ENABLE"
80
- SwarmEnvStorePath = "SWARM_STORE_PATH"
81
- SwarmEnvStoreCapacity = "SWARM_STORE_CAPACITY"
82
- SwarmEnvStoreCacheCapacity = "SWARM_STORE_CACHE_CAPACITY"
83
- SwarmEnvBootnodeMode = "SWARM_BOOTNODE_MODE"
84
- SwarmEnvNATInterface = "SWARM_NAT_INTERFACE"
85
- SwarmAccessPassword = "SWARM_ACCESS_PASSWORD"
86
- SwarmAutoDefaultPath = "SWARM_AUTO_DEFAULTPATH"
87
- SwarmGlobalstoreAPI = "SWARM_GLOBALSTORE_API"
88
- GethEnvDataDir = "GETH_DATADIR"
62
+ SwarmEnvChequebookAddr = "SWARM_CHEQUEBOOK_ADDR"
63
+ SwarmEnvAccount = "SWARM_ACCOUNT"
64
+ SwarmEnvBzzKeyHex = "SWARM_BZZ_KEY_HEX"
65
+ SwarmEnvListenAddr = "SWARM_LISTEN_ADDR"
66
+ SwarmEnvPort = "SWARM_PORT"
67
+ SwarmEnvNetworkID = "SWARM_NETWORK_ID"
68
+ SwarmEnvSwapEnable = "SWARM_SWAP_ENABLE"
69
+ SwarmEnvSwapBackendURL = "SWARM_SWAP_BACKEND_URL"
70
+ SwarmEnvSwapPaymentThreshold = "SWARM_SWAP_PAYMENT_THRESHOLD"
71
+ SwarmEnvSwapDisconnectThreshold = "SWARM_SWAP_DISCONNECT_THRESHOLD"
72
+ SwarmEnvSyncDisable = "SWARM_SYNC_DISABLE"
73
+ SwarmEnvSyncUpdateDelay = "SWARM_ENV_SYNC_UPDATE_DELAY"
74
+ SwarmEnvMaxStreamPeerServers = "SWARM_ENV_MAX_STREAM_PEER_SERVERS"
75
+ SwarmEnvLightNodeEnable = "SWARM_LIGHT_NODE_ENABLE"
76
+ SwarmEnvDeliverySkipCheck = "SWARM_DELIVERY_SKIP_CHECK"
77
+ SwarmEnvENSAPI = "SWARM_ENS_API"
78
+ SwarmEnvENSAddr = "SWARM_ENS_ADDR"
79
+ SwarmEnvCORS = "SWARM_CORS"
80
+ SwarmEnvBootnodes = "SWARM_BOOTNODES"
81
+ SwarmEnvPSSEnable = "SWARM_PSS_ENABLE"
82
+ SwarmEnvStorePath = "SWARM_STORE_PATH"
83
+ SwarmEnvStoreCapacity = "SWARM_STORE_CAPACITY"
84
+ SwarmEnvStoreCacheCapacity = "SWARM_STORE_CACHE_CAPACITY"
85
+ SwarmEnvBootnodeMode = "SWARM_BOOTNODE_MODE"
86
+ SwarmEnvNATInterface = "SWARM_NAT_INTERFACE"
87
+ SwarmAccessPassword = "SWARM_ACCESS_PASSWORD"
88
+ SwarmAutoDefaultPath = "SWARM_AUTO_DEFAULTPATH"
89
+ SwarmGlobalstoreAPI = "SWARM_GLOBALSTORE_API"
90
+ GethEnvDataDir = "GETH_DATADIR"
89
91
)
90
92
91
93
// These settings ensure that TOML keys use the same names as Go struct fields.
@@ -176,11 +178,9 @@ func flagsOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Confi
176
178
if keyid := ctx .GlobalString (SwarmAccountFlag .Name ); keyid != "" {
177
179
currentConfig .BzzAccount = keyid
178
180
}
179
-
180
- if chbookaddr := ctx .GlobalString (ChequebookAddrFlag .Name ); chbookaddr != "" {
181
+ if chbookaddr := ctx .GlobalString (SwarmSwapChequebookAddrFlag .Name ); chbookaddr != "" {
181
182
currentConfig .Contract = common .HexToAddress (chbookaddr )
182
183
}
183
-
184
184
if networkid := ctx .GlobalString (SwarmNetworkIdFlag .Name ); networkid != "" {
185
185
id , err := strconv .ParseUint (networkid , 10 , 64 )
186
186
if err != nil {
@@ -190,50 +190,44 @@ func flagsOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Confi
190
190
currentConfig .NetworkID = id
191
191
}
192
192
}
193
-
194
193
if ctx .GlobalIsSet (utils .DataDirFlag .Name ) {
195
194
if datadir := ctx .GlobalString (utils .DataDirFlag .Name ); datadir != "" {
196
195
currentConfig .Path = expandPath (datadir )
197
196
}
198
197
}
199
-
200
198
bzzport := ctx .GlobalString (SwarmPortFlag .Name )
201
199
if len (bzzport ) > 0 {
202
200
currentConfig .Port = bzzport
203
201
}
204
-
205
202
if bzzaddr := ctx .GlobalString (SwarmListenAddrFlag .Name ); bzzaddr != "" {
206
203
currentConfig .ListenAddr = bzzaddr
207
204
}
208
-
209
205
if ctx .GlobalIsSet (SwarmSwapEnabledFlag .Name ) {
210
206
currentConfig .SwapEnabled = true
211
207
}
212
-
208
+ if swapBackendURL := ctx .GlobalString (SwarmSwapBackendURLFlag .Name ); swapBackendURL != "" {
209
+ currentConfig .SwapBackendURL = swapBackendURL
210
+ }
211
+ if paymentThreshold := ctx .GlobalUint64 (SwarmSwapPaymentThresholdFlag .Name ); paymentThreshold != 0 {
212
+ currentConfig .SwapPaymentThreshold = paymentThreshold
213
+ }
214
+ if disconnectThreshold := ctx .GlobalUint64 (SwarmSwapDisconnectThresholdFlag .Name ); disconnectThreshold != 0 {
215
+ currentConfig .SwapDisconnectThreshold = disconnectThreshold
216
+ }
213
217
if ctx .GlobalIsSet (SwarmSyncDisabledFlag .Name ) {
214
218
currentConfig .SyncEnabled = false
215
219
}
216
-
217
220
if d := ctx .GlobalDuration (SwarmSyncUpdateDelay .Name ); d > 0 {
218
221
currentConfig .SyncUpdateDelay = d
219
222
}
220
-
221
223
// any value including 0 is acceptable
222
224
currentConfig .MaxStreamPeerServers = ctx .GlobalInt (SwarmMaxStreamPeerServersFlag .Name )
223
-
224
225
if ctx .GlobalIsSet (SwarmLightNodeEnabled .Name ) {
225
226
currentConfig .LightNodeEnabled = true
226
227
}
227
-
228
228
if ctx .GlobalIsSet (SwarmDeliverySkipCheckFlag .Name ) {
229
229
currentConfig .DeliverySkipCheck = true
230
230
}
231
-
232
- currentConfig .SwapBackendURL = ctx .GlobalString (SwarmSwapBackendURLFlag .Name )
233
- if currentConfig .SwapEnabled && currentConfig .SwapBackendURL == "" {
234
- utils .Fatalf (SwarmErrSwapSetNoBackendURL )
235
- }
236
-
237
231
if ctx .GlobalIsSet (EnsAPIFlag .Name ) {
238
232
ensAPIs := ctx .GlobalStringSlice (EnsAPIFlag .Name )
239
233
// preserve backward compatibility to disable ENS with --ens-api=""
@@ -243,40 +237,30 @@ func flagsOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Confi
243
237
for i := range ensAPIs {
244
238
ensAPIs [i ] = expandPath (ensAPIs [i ])
245
239
}
246
-
247
240
currentConfig .EnsAPIs = ensAPIs
248
241
}
249
-
250
242
if cors := ctx .GlobalString (CorsStringFlag .Name ); cors != "" {
251
243
currentConfig .Cors = cors
252
244
}
253
-
254
245
if storePath := ctx .GlobalString (SwarmStorePath .Name ); storePath != "" {
255
246
currentConfig .ChunkDbPath = storePath
256
247
}
257
-
258
248
if storeCapacity := ctx .GlobalUint64 (SwarmStoreCapacity .Name ); storeCapacity != 0 {
259
249
currentConfig .DbCapacity = storeCapacity
260
250
}
261
-
262
251
if ctx .GlobalIsSet (SwarmStoreCacheCapacity .Name ) {
263
252
currentConfig .CacheCapacity = ctx .GlobalUint (SwarmStoreCacheCapacity .Name )
264
253
}
265
-
266
254
if ctx .GlobalIsSet (SwarmBootnodeModeFlag .Name ) {
267
255
currentConfig .BootnodeMode = ctx .GlobalBool (SwarmBootnodeModeFlag .Name )
268
256
}
269
-
270
257
if ctx .GlobalIsSet (SwarmDisableAutoConnectFlag .Name ) {
271
258
currentConfig .DisableAutoConnect = ctx .GlobalBool (SwarmDisableAutoConnectFlag .Name )
272
259
}
273
-
274
260
if ctx .GlobalIsSet (SwarmGlobalStoreAPIFlag .Name ) {
275
261
currentConfig .GlobalStoreAPI = ctx .GlobalString (SwarmGlobalStoreAPIFlag .Name )
276
262
}
277
-
278
263
return currentConfig
279
-
280
264
}
281
265
282
266
// dumpConfig is the dumpconfig command.
0 commit comments