0g-chain/cmd/kvd/main.go
rhuairahrighairigh a2d4299b99 update sdk
2018-06-16 22:34:07 +01:00

47 lines
1.2 KiB
Go

package main
import (
"encoding/json"
"os"
"github.com/spf13/cobra"
abci "github.com/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/tendermint/tmlibs/cli"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tmlibs/log"
"github.com/cosmos/cosmos-sdk/server"
"github.com/kava-labs/kava/internal/app"
)
func main() {
cdc := app.MakeCodec()
ctx := server.NewDefaultContext()
rootCmd := &cobra.Command{
Use: "kvd",
Short: "Kava Daemon",
PersistentPreRunE: server.PersistentPreRunEFn(ctx),
}
server.AddCommands(ctx, cdc, rootCmd, server.DefaultAppInit,
server.ConstructAppCreator(newApp, "kava"),
server.ConstructAppExporter(exportAppStateAndTMValidators, "kava"))
// prepare and add flags
rootDir := os.ExpandEnv("$HOME/.kvd")
executor := cli.PrepareBaseCmd(rootCmd, "KV", rootDir)
executor.Execute()
}
func newApp(logger log.Logger, db dbm.DB) abci.Application {
return app.NewKavaApp(logger, db)
}
func exportAppStateAndTMValidators(logger log.Logger, db dbm.DB) (json.RawMessage, []tmtypes.GenesisValidator, error) {
bapp := app.NewKavaApp(logger, db)
return bapp.ExportAppStateAndValidators()
}