mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
cmd/blsync: use default JWT secret path when datadir is specified
Implements the TODO to automatically use jwtsecret file from the specified datadir when --blsync.jwtsecret is not explicitly provided. This matches the behavior of the main geth command and improves UX by reducing required command line arguments.
This commit is contained in:
parent
ef6e92e51d
commit
6b64a1b994
1 changed files with 14 additions and 3 deletions
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/beacon/blsync"
|
"github.com/ethereum/go-ethereum/beacon/blsync"
|
||||||
|
|
@ -51,6 +52,7 @@ func main() {
|
||||||
utils.HoodiFlag,
|
utils.HoodiFlag,
|
||||||
utils.BlsyncApiFlag,
|
utils.BlsyncApiFlag,
|
||||||
utils.BlsyncJWTSecretFlag,
|
utils.BlsyncJWTSecretFlag,
|
||||||
|
utils.DataDirFlag,
|
||||||
},
|
},
|
||||||
debug.Flags,
|
debug.Flags,
|
||||||
)
|
)
|
||||||
|
|
@ -87,11 +89,20 @@ func makeRPCClient(ctx *cli.Context) *rpc.Client {
|
||||||
log.Warn("No engine API target specified, performing a dry run")
|
log.Warn("No engine API target specified, performing a dry run")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !ctx.IsSet(utils.BlsyncJWTSecretFlag.Name) {
|
|
||||||
utils.Fatalf("JWT secret parameter missing") //TODO use default if datadir is specified
|
engineApiUrl := ctx.String(utils.BlsyncApiFlag.Name)
|
||||||
|
var jwtFileName string
|
||||||
|
|
||||||
|
if ctx.IsSet(utils.BlsyncJWTSecretFlag.Name) {
|
||||||
|
jwtFileName = ctx.String(utils.BlsyncJWTSecretFlag.Name)
|
||||||
|
} else if ctx.IsSet(utils.DataDirFlag.Name) {
|
||||||
|
// Use default JWT secret path in the specified datadir
|
||||||
|
datadir := ctx.String(utils.DataDirFlag.Name)
|
||||||
|
jwtFileName = filepath.Join(datadir, "jwtsecret")
|
||||||
|
} else {
|
||||||
|
utils.Fatalf("JWT secret parameter missing and no datadir specified. Use --blsync.jwtsecret or --datadir")
|
||||||
}
|
}
|
||||||
|
|
||||||
engineApiUrl, jwtFileName := ctx.String(utils.BlsyncApiFlag.Name), ctx.String(utils.BlsyncJWTSecretFlag.Name)
|
|
||||||
var jwtSecret [32]byte
|
var jwtSecret [32]byte
|
||||||
if jwt, err := node.ObtainJWTSecret(jwtFileName); err == nil {
|
if jwt, err := node.ObtainJWTSecret(jwtFileName); err == nil {
|
||||||
copy(jwtSecret[:], jwt)
|
copy(jwtSecret[:], jwt)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue