0g-chain/cmd/kavad/main.go

46 lines
1.1 KiB
Go
Raw Normal View History

2018-05-25 13:46:33 +00:00
package main
import (
"encoding/json"
"os"
"github.com/spf13/cobra"
abci "github.com/tendermint/abci/types"
"github.com/tendermint/tmlibs/cli"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tmlibs/log"
"github.com/cosmos/cosmos-sdk/server"
2018-06-16 16:21:13 +00:00
"github.com/kava-labs/kava/internal/app"
2018-05-25 13:46:33 +00:00
)
func main() {
cdc := app.MakeCodec()
ctx := server.NewDefaultContext()
rootCmd := &cobra.Command{
2018-06-16 16:21:13 +00:00
Use: "kavad",
Short: "Kava Daemon",
2018-05-25 13:46:33 +00:00
PersistentPreRunE: server.PersistentPreRunEFn(ctx),
}
server.AddCommands(ctx, cdc, rootCmd, server.DefaultAppInit,
2018-06-16 16:21:13 +00:00
server.ConstructAppCreator(newApp, "kava"),
server.ConstructAppExporter(exportAppState, "kava"))
2018-05-25 13:46:33 +00:00
// prepare and add flags
2018-06-16 16:21:13 +00:00
rootDir := os.ExpandEnv("$HOME/.kavad")
executor := cli.PrepareBaseCmd(rootCmd, "KV", rootDir)
2018-05-25 13:46:33 +00:00
executor.Execute()
}
func newApp(logger log.Logger, db dbm.DB) abci.Application {
return app.NewBasecoinApp(logger, db)
}
func exportAppState(logger log.Logger, db dbm.DB) (json.RawMessage, error) {
bapp := app.NewBasecoinApp(logger, db)
return bapp.ExportAppStateJSON()
}