+++ /dev/null
-package commands
-
-import (
- "os"
-
- "github.com/spf13/cobra"
-
- "github.com/node_p2p/types"
- cmn "github.com/tendermint/tmlibs/common"
-)
-
-var initFilesCmd = &cobra.Command{
- Use: "init",
- Short: "Initialize node_p2p",
- Run: initFiles,
-}
-
-func init() {
- RootCmd.AddCommand(initFilesCmd)
-}
-
-func initFiles(cmd *cobra.Command, args []string) {
- privValFile := config.PrivValidatorFile()
- if _, err := os.Stat(privValFile); os.IsNotExist(err) {
- privValidator := types.GenPrivValidator()
- privValidator.SetFile(privValFile)
- privValidator.Save()
-
- genFile := config.GenesisFile()
-
- if _, err := os.Stat(genFile); os.IsNotExist(err) {
- genDoc := types.GenesisDoc{
- ChainID: cmn.Fmt("chain0"),
- }
- genDoc.Validators = []types.GenesisValidator{types.GenesisValidator{
- PubKey: privValidator.PubKey,
- Amount: 10,
- }}
-
- genDoc.SaveAs(genFile)
- }
-
- logger.Info("Initialized tendermint", "genesis", config.GenesisFile(), "priv_validator", config.PrivValidatorFile())
- } else {
- logger.Info("Already initialized", "priv_validator", config.PrivValidatorFile())
- }
-}
"os"
"github.com/spf13/cobra"
- "github.com/spf13/viper"
- tmflags "github.com/node_p2p/node_p2p/commands/flags"
- cfg "github.com/node_p2p/config"
+// tmflags "github.com/blockchain/cmd/blockchain/commands/flags"
"github.com/tendermint/tmlibs/log"
)
var (
- config = cfg.DefaultConfig()
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "main")
)
func init() {
- RootCmd.PersistentFlags().String("log_level", config.LogLevel, "Log level")
+ RootCmd.PersistentFlags().String("log_level", "*:info", "Log level")
}
var RootCmd = &cobra.Command{
- Use: "node_p2p",
- Short: "node_p2p in Go",
+ Use: "blockchain",
+ Short: "blockchain in Go",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
- err := viper.Unmarshal(config)
+ /*logger, err := tmflags.ParseLogLevel("*:info", logger)
if err != nil {
return err
- }
- config.SetRoot(config.RootDir)
- cfg.EnsureRoot(config.RootDir)
- logger, err = tmflags.ParseLogLevel(config.LogLevel, logger)
- if err != nil {
- return err
- }
+ }*/
return nil
},
}
+++ /dev/null
-package commands
-
-import (
- "fmt"
- "io/ioutil"
- "time"
-
- "github.com/spf13/cobra"
-
- "github.com/node_p2p/node"
- "github.com/node_p2p/types"
- cmn "github.com/tendermint/tmlibs/common"
-)
-
-var runNodeCmd = &cobra.Command{
- Use: "node_p2p",
- Short: "Run the p2p node",
- RunE: runNode,
-}
-
-func init() {
- // p2p flags
- runNodeCmd.Flags().String("p2p.laddr", config.P2P.ListenAddress, "Node listen address. (0.0.0.0:0 means any interface, any port)")
- runNodeCmd.Flags().String("p2p.seeds", config.P2P.Seeds, "Comma delimited host:port seed nodes")
- runNodeCmd.Flags().Bool("p2p.skip_upnp", config.P2P.SkipUPNP, "Skip UPNP configuration")
- runNodeCmd.Flags().Bool("p2p.pex", config.P2P.PexReactor, "Enable Peer-Exchange (dev feature)")
-
- RootCmd.AddCommand(runNodeCmd)
-}
-
-func runNode(cmd *cobra.Command, args []string) error {
-
- // Wait until the genesis doc becomes available
- // This is for Mintnet compatibility.
- // TODO: If Mintnet gets deprecated or genesis_file is
- // always available, remove.
- genDocFile := config.GenesisFile()
- if !cmn.FileExists(genDocFile) {
- logger.Info(cmn.Fmt("Waiting for genesis file %v...", genDocFile))
- for {
- time.Sleep(time.Second)
- if !cmn.FileExists(genDocFile) {
- continue
- }
- jsonBlob, err := ioutil.ReadFile(genDocFile)
- if err != nil {
- return fmt.Errorf("Couldn't read GenesisDoc file: %v", err)
- }
- genDoc, err := types.GenesisDocFromJSON(jsonBlob)
- if err != nil {
- return fmt.Errorf("Error reading GenesisDoc: %v", err)
- }
- if genDoc.ChainID == "" {
- return fmt.Errorf("Genesis doc %v must include non-empty chain_id", genDocFile)
- }
- config.ChainID = genDoc.ChainID
- }
- }
-
- // Create & start node
- n := node.NewNodeDefault(config, logger.With("module", "node_p2p"))
- if _, err := n.Start(); err != nil {
- return fmt.Errorf("Failed to start node: %v", err)
- } else {
- logger.Info("Started node", "nodeInfo", n.Switch().NodeInfo())
- }
-
- // Trap signal, run forever.
- n.RunForever()
-
- return nil
-}
"github.com/spf13/cobra"
- "github.com/node_p2p/version"
+ "github.com/blockchain/version"
)
var versionCmd = &cobra.Command{
import (
"os"
- "github.com/node_p2p/node_p2p/commands"
+ "github.com/blockchain/cmd/blockchain/commands"
"github.com/tendermint/tmlibs/cli"
)
func main() {
- cmd := cli.PrepareBaseCmd(commands.RootCmd, "TM", os.ExpandEnv("./.node"))
+ cmd := cli.PrepareBaseCmd(commands.RootCmd, "TM", os.ExpandEnv("./.blockchain"))
cmd.Execute()
}
--- /dev/null
+package version
+
+const Maj = "0"
+const Min = "1"
+const Fix = "0"
+
+var (
+ // The full version string
+ Version = "0.1.0"
+
+ // GitCommit is set with --ldflags "-X main.gitCommit=$(git rev-parse HEAD)"
+ GitCommit string
+)
+
+func init() {
+ if GitCommit != "" {
+ Version += "-" + GitCommit[:8]
+ }
+}