2018-05-25 13:46:33 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
|
|
abci "github.com/tendermint/abci/types"
|
2018-06-16 21:34:07 +00:00
|
|
|
tmtypes "github.com/tendermint/tendermint/types"
|
2018-05-25 13:46:33 +00:00
|
|
|
"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 21:34:07 +00:00
|
|
|
Use: "kvd",
|
2018-06-16 16:21:13 +00:00
|
|
|
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"),
|
2018-06-16 21:34:07 +00:00
|
|
|
server.ConstructAppExporter(exportAppStateAndTMValidators, "kava"))
|
2018-05-25 13:46:33 +00:00
|
|
|
|
|
|
|
// prepare and add flags
|
2018-06-16 21:34:07 +00:00
|
|
|
rootDir := os.ExpandEnv("$HOME/.kvd")
|
2018-06-16 16:21:13 +00:00
|
|
|
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 {
|
2018-06-16 21:34:07 +00:00
|
|
|
return app.NewKavaApp(logger, db)
|
2018-05-25 13:46:33 +00:00
|
|
|
}
|
|
|
|
|
2018-06-16 21:34:07 +00:00
|
|
|
func exportAppStateAndTMValidators(logger log.Logger, db dbm.DB) (json.RawMessage, []tmtypes.GenesisValidator, error) {
|
|
|
|
bapp := app.NewKavaApp(logger, db)
|
|
|
|
return bapp.ExportAppStateAndValidators()
|
2018-05-25 13:46:33 +00:00
|
|
|
}
|