-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CLI tool to generate an identity file (#3167)
## Motivation Closes #3157 ## Changes Change the ensureIdentity to public EnsureIdentity, Add a CLI tool that calls EnsureIdentity ## DevOps Notes <!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases --> - [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources) - [x] This PR does not affect public APIs - [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.) - [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on)
- Loading branch information
Showing
6 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spacemeshos/go-spacemesh/p2p" | ||
) | ||
|
||
func main() { | ||
if len(os.Args) != 2 { | ||
fmt.Printf("Usage: %v <path/to/output_dir>\n", os.Args[0]) | ||
os.Exit(1) | ||
} | ||
|
||
dir := os.Args[1] | ||
_, err := p2p.EnsureIdentity(dir) | ||
if err != nil { | ||
fmt.Printf("failed generating identity: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
identityStr, err := p2p.PrettyIdentityInfoFromDir(dir) | ||
if err != nil { | ||
fmt.Printf("failed fetching identity from file: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
// Print ID | ||
fmt.Printf("%s\n", identityStr) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters