mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 18:15:19 +00:00
47 lines
1.2 KiB
Go
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, app.CreateAppInit(),
|
|
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()
|
|
}
|