Skip to content

Commit

Permalink
properly support multuple data dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
algorandskiy committed Jul 30, 2024
1 parent dc8b3e0 commit 6f3b9ba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/goal/p2pid.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ var p2pID = &cobra.Command{
Long: "Generate a new p2p private key (saved to " + p2p.DefaultPrivKeyPath + ") and print out peerID to stdout",
Args: validateNoPosArgsFn,
Run: func(cmd *cobra.Command, args []string) {
exist := false
datadir.OnDataDirs(func(dataDir string) {
exist := false
privKeyPath := path.Join(dataDir, p2p.DefaultPrivKeyPath)
if util.FileExists(privKeyPath) {
exist = true

Check warning on line 44 in cmd/goal/p2pid.go

View check run for this annotation

Codecov / codecov/patch

cmd/goal/p2pid.go#L39-L44

Added lines #L39 - L44 were not covered by tests
Expand All @@ -47,12 +47,12 @@ var p2pID = &cobra.Command{
peerKey, err := p2p.GetPrivKey(config.Local{P2PPersistPeerID: true}, dataDir)
if err != nil {
fmt.Fprintf(os.Stderr, "Error obtaining private key: %v\n", err)
os.Exit(1)
return

Check warning on line 50 in cmd/goal/p2pid.go

View check run for this annotation

Codecov / codecov/patch

cmd/goal/p2pid.go#L47-L50

Added lines #L47 - L50 were not covered by tests
}
peerID, err := peer.IDFromPublicKey(peerKey.GetPublic())
if err != nil {
fmt.Fprintf(os.Stderr, "Error obtaining peerID from a key: %v\n", err)
os.Exit(1)
return

Check warning on line 55 in cmd/goal/p2pid.go

View check run for this annotation

Codecov / codecov/patch

cmd/goal/p2pid.go#L52-L55

Added lines #L52 - L55 were not covered by tests
}

fmt.Printf("PeerID: %s\n", peerID.String())
Expand Down

0 comments on commit 6f3b9ba

Please sign in to comment.