Skip to content

Commit

Permalink
use anyError
Browse files Browse the repository at this point in the history
  • Loading branch information
algorandskiy committed Jul 30, 2024
1 parent 6f3b9ba commit 375efad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/goal/p2pid.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ 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) {
anyError := false
datadir.OnDataDirs(func(dataDir string) {
exist := false
privKeyPath := path.Join(dataDir, p2p.DefaultPrivKeyPath)
Expand All @@ -47,11 +48,13 @@ 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)
anyError = true
return

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

View check run for this annotation

Codecov / codecov/patch

cmd/goal/p2pid.go#L48-L52

Added lines #L48 - L52 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)
anyError = true
return

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

View check run for this annotation

Codecov / codecov/patch

cmd/goal/p2pid.go#L54-L58

Added lines #L54 - L58 were not covered by tests
}

Expand All @@ -62,5 +65,8 @@ var p2pID = &cobra.Command{
fmt.Printf("Used existing key %s\n", privKeyPath)

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

View check run for this annotation

Codecov / codecov/patch

cmd/goal/p2pid.go#L61-L65

Added lines #L61 - L65 were not covered by tests
}
})
if anyError {
os.Exit(1)

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

View check run for this annotation

Codecov / codecov/patch

cmd/goal/p2pid.go#L68-L69

Added lines #L68 - L69 were not covered by tests
}
},
}

0 comments on commit 375efad

Please sign in to comment.