Pulled most of gaiad into server, with rough implementation

This commit is contained in:
Ethan Frey
2018-03-01 02:30:13 +00:00
committed by rigelrozanski
parent a99d913982
commit 438d18e059
5 changed files with 155 additions and 58 deletions
+14 -8
View File
@@ -9,15 +9,10 @@ import (
"github.com/tendermint/tmlibs/cli"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/version"
)
const (
flagTo = "to"
flagAmount = "amount"
flagFee = "fee"
)
// gaiadCmd is the entry point for this binary
var (
gaiadCmd = &cobra.Command{
@@ -26,16 +21,27 @@ var (
}
)
// TODO: move into server
var (
initNodeCmd = &cobra.Command{
Use: "init <flags???>",
Short: "Initialize full node",
RunE: todoNotImplemented,
}
)
func todoNotImplemented(_ *cobra.Command, _ []string) error {
return errors.New("TODO: Command not yet implemented")
}
func main() {
// TODO: set this to something real
var node baseapp.BaseApp
var app *baseapp.BaseApp
AddNodeCommands(gaiadCmd, node)
gaiadCmd.AddCommand(
initNodeCmd,
server.StartNodeCmd(app),
server.UnsafeResetAllCmd(app.Logger),
version.VersionCmd,
)
-47
View File
@@ -1,47 +0,0 @@
package main
import (
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/baseapp"
)
const (
flagWithTendermint = "with-tendermint"
)
var (
initNodeCmd = &cobra.Command{
Use: "init <flags???>",
Short: "Initialize full node",
RunE: todoNotImplemented,
}
resetNodeCmd = &cobra.Command{
Use: "unsafe_reset_all",
Short: "Reset full node data (danger, must resync)",
RunE: todoNotImplemented,
}
)
// AddNodeCommands registers all commands to interact
// with a local full-node as subcommands of the argument.
//
// Accept an application it should start
func AddNodeCommands(cmd *cobra.Command, node baseapp.BaseApp) {
cmd.AddCommand(
initNodeCmd,
startNodeCmd(node),
resetNodeCmd,
)
}
func startNodeCmd(node baseapp.BaseApp) *cobra.Command {
cmd := &cobra.Command{
Use: "start",
Short: "Run the full node",
RunE: todoNotImplemented,
}
cmd.Flags().Bool(flagWithTendermint, true, "run abci app embedded in-process with tendermint")
return cmd
}