Add CLI flag to print peer id from config (#34)

* Add CLI flag to print peer id from config

* Add printing peer id instructions to readme
This commit is contained in:
Agost Biro 2024-01-04 23:48:00 +01:00 committed by GitHub
parent 673b815ce8
commit bb71c38a39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -17,6 +17,14 @@ If you do not, or have already run the above, run:
GOEXPERIMENT=arenas go run ./... GOEXPERIMENT=arenas go run ./...
## Peer ID
In order to find the peer id of a running node, execute the following command from the `node/` folder:
GOEXPERIMENT=arenas go run ./... --peer-id
The peer id will be printed to stdout.
## EXPERIMENTAL gRPC/REST Support ## EXPERIMENTAL gRPC/REST Support
If you want to enable gRPC/REST, add the following entries to your config.yml: If you want to enable gRPC/REST, add the following entries to your config.yml:

View File

@ -38,11 +38,27 @@ var (
false, false,
"starts the node in database console mode", "starts the node in database console mode",
) )
peerId = flag.Bool(
"peer-id",
false,
"print the peer id to stdout from the config and exit",
)
) )
func main() { func main() {
flag.Parse() flag.Parse()
if *peerId {
config, err := config.LoadConfig(*configDirectory, "")
if err != nil {
panic(err)
}
printPeerID(config.P2P)
return
}
if *importPrivKey != "" { if *importPrivKey != "" {
config, err := config.LoadConfig(*configDirectory, *importPrivKey) config, err := config.LoadConfig(*configDirectory, *importPrivKey)
if err != nil { if err != nil {