mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-22 09:21:32 +00:00
This example shows how a user of the tendermint library can build their own node and supply it with its own commands. It includes two todos in order to make it easier for library users to use tendermint.
32 lines
571 B
Go
32 lines
571 B
Go
package commands
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/tendermint/tendermint/p2p/upnp"
|
|
)
|
|
|
|
var ProbeUpnpCmd = &cobra.Command{
|
|
Use: "probe_upnp",
|
|
Short: "Test UPnP functionality",
|
|
RunE: probeUpnp,
|
|
}
|
|
|
|
func probeUpnp(cmd *cobra.Command, args []string) error {
|
|
capabilities, err := upnp.Probe(logger)
|
|
if err != nil {
|
|
fmt.Println("Probe failed: %v", err)
|
|
} else {
|
|
fmt.Println("Probe success!")
|
|
jsonBytes, err := json.Marshal(capabilities)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(string(jsonBytes))
|
|
}
|
|
return nil
|
|
}
|