Skip to content

Commit b58c43a

Browse files
committed
fix: restore legacy mode detection in resolveNodeMode
1 parent e386677 commit b58c43a

2 files changed

Lines changed: 34 additions & 29 deletions

File tree

.github/workflows/beekeeper.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ env:
1919
SETUP_CONTRACT_IMAGE: "ethersphere/bee-localchain"
2020
SETUP_CONTRACT_IMAGE_TAG: "0.9.4"
2121
BEELOCAL_BRANCH: "main"
22-
BEEKEEPER_BRANCH: "master"
22+
BEEKEEPER_BRANCH: "refactor/node-mode-config"
2323
BEEKEEPER_METRICS_ENABLED: false
2424
REACHABILITY_OVERRIDE_PUBLIC: true
2525
BATCHFACTOR_OVERRIDE_PUBLIC: 2

cmd/bee/cmd/start.go

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -342,46 +342,51 @@ func buildBeeNode(ctx context.Context, c *command, cmd *cobra.Command, logger lo
342342
}
343343

344344
// resolveNodeMode determines the effective node mode from config.
345-
// --node-mode takes precedence; the deprecated --full-node flag is honoured as a fallback.
346-
// It also validates that the required options for each mode are present.
345+
// --node-mode takes precedence and triggers strict per-mode validation.
346+
// The deprecated --full-node flag is honoured as a fallback.
347+
// When neither is set, mode is inferred from blockchain-rpc-endpoint presence
348+
// (legacy behaviour) without strict validation, for backward compatibility.
347349
func (c *command) resolveNodeMode(logger log.Logger) (node.NodeMode, error) {
348350
rpcEndpoint := c.config.GetString(configKeyBlockchainRpcEndpoint)
349351
swapEnable := c.config.GetBool(optionNameSwapEnable)
350352

351-
// Resolve the mode: explicit node-mode wins, then legacy full-node, then default ultra-light.
352-
var mode node.NodeMode
353353
if c.config.IsSet(optionNameNodeMode) {
354-
mode = node.NodeMode(c.config.GetString(optionNameNodeMode))
354+
// Explicit node-mode: validate strictly.
355+
mode := node.NodeMode(c.config.GetString(optionNameNodeMode))
355356
if !mode.IsValid() {
356357
return "", fmt.Errorf("invalid node-mode %q: must be one of full, light, ultra-light", mode)
357358
}
358-
} else if c.config.GetBool(optionNameFullNode) {
359-
logger.Warning("--full-node is deprecated, use --node-mode=full instead")
360-
mode = node.FullMode
361-
} else {
362-
mode = node.UltraLightMode
359+
switch mode {
360+
case node.FullMode:
361+
if rpcEndpoint == "" {
362+
return "", errors.New("full node requires blockchain-rpc-endpoint to be set")
363+
}
364+
if !swapEnable {
365+
return "", errors.New("full node requires swap-enable to be true")
366+
}
367+
case node.LightMode:
368+
if rpcEndpoint == "" {
369+
return "", errors.New("light node requires blockchain-rpc-endpoint to be set")
370+
}
371+
case node.UltraLightMode:
372+
if swapEnable {
373+
return "", errors.New("ultra-light node cannot have swap-enable set to true")
374+
}
375+
}
376+
return mode, nil
363377
}
364378

365-
// Validate mode-specific requirements.
366-
switch mode {
367-
case node.FullMode:
368-
if rpcEndpoint == "" {
369-
return "", errors.New("full node requires blockchain-rpc-endpoint to be set")
370-
}
371-
if !swapEnable {
372-
return "", errors.New("full node requires swap-enable to be true")
373-
}
374-
case node.LightMode:
375-
if rpcEndpoint == "" {
376-
return "", errors.New("light node requires blockchain-rpc-endpoint to be set")
377-
}
378-
case node.UltraLightMode:
379-
if swapEnable {
380-
return "", errors.New("ultra-light node cannot have swap-enable set to true")
381-
}
379+
// Legacy path: node-mode not set, fall back to deprecated flags / old detection.
380+
if c.config.GetBool(optionNameFullNode) {
381+
logger.Warning("--full-node is deprecated, use --node-mode=full instead")
382+
return node.FullMode, nil
382383
}
383384

384-
return mode, nil
385+
// Infer light vs ultra-light from RPC endpoint presence (original behaviour).
386+
if rpcEndpoint != "" {
387+
return node.LightMode, nil
388+
}
389+
return node.UltraLightMode, nil
385390
}
386391

387392
type program struct {

0 commit comments

Comments
 (0)