You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
639 B

package cmd
import (
"go-dht/config"
"go-dht/node"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var NodeCommands = []cli.Command{
{
Name: "start",
Usage: "start the node",
Action: cmdStart,
},
}
func cmdStart(c *cli.Context) error {
if err := config.MustRead(c); err != nil {
return err
}
var n node.Node
var err error
if config.C.ID != "" {
n, err = node.LoadNode(config.C.ID)
if err != nil {
return err
}
log.Info("Node loaded with ID: ", n.ID())
} else {
n, err = node.NewNode()
if err != nil {
return err
}
log.Info("New node created with ID: ", n.ID())
}
return nil
}