6 log "github.com/sirupsen/logrus"
7 "github.com/spf13/cobra"
9 "github.com/bytom/node"
12 var runNodeCmd = &cobra.Command{
14 Short: "Run the bytomd",
19 runNodeCmd.Flags().String("prof_laddr", config.ProfListenAddress, "Use http to profile bytomd programs")
20 runNodeCmd.Flags().Bool("mining", config.Mining, "Enable mining")
22 runNodeCmd.Flags().Bool("auth.disable", config.Auth.Disable, "Disable rpc access authenticate")
24 runNodeCmd.Flags().Bool("wallet.disable", config.Wallet.Disable, "Disable wallet")
25 runNodeCmd.Flags().Bool("vault_mode", config.VaultMode, "Run in the offline enviroment")
26 runNodeCmd.Flags().Bool("web.closed", config.Web.Closed, "Lanch web browser or not")
27 runNodeCmd.Flags().String("chain_id", config.ChainID, "Select network type")
30 runNodeCmd.Flags().String("p2p.laddr", config.P2P.ListenAddress, "Node listen address. (0.0.0.0:0 means any interface, any port)")
31 runNodeCmd.Flags().String("p2p.seeds", config.P2P.Seeds, "Comma delimited host:port seed nodes")
32 runNodeCmd.Flags().Bool("p2p.skip_upnp", config.P2P.SkipUPNP, "Skip UPNP configuration")
33 runNodeCmd.Flags().Bool("p2p.pex", config.P2P.PexReactor, "Enable Peer-Exchange ")
34 runNodeCmd.Flags().Int("p2p.max_num_peers", config.P2P.MaxNumPeers, "Set max num peers")
35 runNodeCmd.Flags().Int("p2p.handshake_timeout", config.P2P.HandshakeTimeout, "Set handshake timeout")
36 runNodeCmd.Flags().Int("p2p.dial_timeout", config.P2P.DialTimeout, "Set dial timeout")
38 RootCmd.AddCommand(runNodeCmd)
41 func runNode(cmd *cobra.Command, args []string) error {
42 // Create & start node
43 n := node.NewNode(config)
44 if _, err := n.Start(); err != nil {
45 return fmt.Errorf("Failed to start node: %v", err)
47 log.WithField("nodeInfo", n.SyncManager().Switch().NodeInfo()).Info("Started node")
50 // Trap signal, run forever.