Skip to content

Commit 6e613cf

Browse files
sorinfjl
authored andcommitted
cmd/geth: add support for geth attach --testnet (#15597)
1 parent afb8154 commit 6e613cf

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎cmd/geth/consolecmd.go‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"os"
2222
"os/signal"
23+
"path/filepath"
2324
"strings"
2425

2526
"github.com/ethereum/go-ethereum/cmd/utils"
@@ -114,8 +115,15 @@ func localConsole(ctx *cli.Context) error {
114115
func remoteConsole(ctx *cli.Context) error {
115116
// Attach to a remotely running geth instance and start the JavaScript console
116117
endpoint := ctx.Args().First()
117-
if endpoint == "" && ctx.GlobalIsSet(utils.DataDirFlag.Name) {
118-
endpoint = fmt.Sprintf("%s/geth.ipc", ctx.GlobalString(utils.DataDirFlag.Name))
118+
if endpoint == "" {
119+
path := node.DefaultDataDir()
120+
if ctx.GlobalIsSet(utils.DataDirFlag.Name) {
121+
path = ctx.GlobalString(utils.DataDirFlag.Name)
122+
}
123+
if path != "" && ctx.GlobalBool(utils.TestnetFlag.Name) {
124+
path = filepath.Join(path, "testnet")
125+
}
126+
endpoint = fmt.Sprintf("%s/geth.ipc", path)
119127
}
120128
client, err := dialRPC(endpoint)
121129
if err != nil {

0 commit comments

Comments
 (0)