/
main.go
60 lines (49 loc) · 1.76 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"encoding/json"
"io"
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/server"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/cli"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/AdityaSripal/plasma-mvp-sidechain/app"
"github.com/AdityaSripal/plasma-mvp-sidechain/client/plasmad/cmd"
)
func main() {
cdc := app.MakeCodec()
ctx := server.NewDefaultContext()
rootCmd := &cobra.Command{
Use: "plasmad",
Short: "Plasma Daemon (server)",
PersistentPreRunE: PersistentPreRunEFn(ctx),
}
rootCmd.AddCommand(cmd.InitCmd(ctx, cdc, app.PlasmaAppInit()))
server.AddCommands(ctx, cdc, rootCmd, app.PlasmaAppInit(),
newApp,
exportAppState)
// prepare and add flags
rootDir := os.ExpandEnv("$HOME/.plasmad")
executor := cli.PrepareBaseCmd(rootCmd, "PC", rootDir)
executor.Execute()
}
func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application {
key_file := viper.GetString("ethereum_privkey_file")
isValidator := viper.GetBool("is_validator")
rootchain := viper.GetString("ethereum_rootchain")
nodeURL := viper.GetString("ethereum_nodeurl")
key_file = viper.GetString(cli.HomeFlag) + "/config/" + key_file
finality := viper.GetString("ethereum_finality")
return app.NewChildChain(logger, db, traceStore,
app.SetEthConfig(isValidator, key_file, rootchain, nodeURL, finality),
)
}
// non-functional
func exportAppState(logger log.Logger, db dbm.DB, traceStore io.Writer) (json.RawMessage, []tmtypes.GenesisValidator, error) {
papp := app.NewChildChain(logger, db, traceStore)
return papp.ExportAppStateJSON()
}