/
main.go
72 lines (62 loc) · 1.62 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
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"encoding/json"
"github.com/MinterTeam/go-amino"
"github.com/MinterTeam/minter-go-node/cmd/utils"
"github.com/MinterTeam/minter-go-node/config"
"github.com/MinterTeam/minter-go-node/core/appdb"
"github.com/MinterTeam/minter-go-node/core/state"
"github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/types"
"time"
)
func main() {
err := common.EnsureDir(utils.GetMinterHome()+"/config", 0777)
if err != nil {
panic(err)
}
ldb, err := db.NewGoLevelDB("state", utils.GetMinterHome()+"/data")
if err != nil {
panic(err)
}
applicationDB := appdb.NewAppDB(config.GetConfig())
height := applicationDB.GetLastHeight()
currentState, err := state.New(height, ldb, false)
if err != nil {
panic(err)
}
cdc := amino.NewCodec()
jsonBytes, err := cdc.MarshalJSONIndent(currentState.Export(height), "", " ")
if err != nil {
panic(err)
}
appHash := [32]byte{}
// Compose Genesis
genesis := types.GenesisDoc{
GenesisTime: time.Date(2019, time.April, 2, 17, 0, 0, 0, time.UTC),
ChainID: "minter-test-network-35",
ConsensusParams: &types.ConsensusParams{
Block: types.BlockParams{
MaxBytes: 10000000,
MaxGas: 100000,
TimeIotaMs: 1000,
},
Evidence: types.EvidenceParams{
MaxAge: 1000,
},
Validator: types.ValidatorParams{
PubKeyTypes: []string{types.ABCIPubKeyTypeEd25519},
},
},
AppHash: appHash[:],
AppState: json.RawMessage(jsonBytes),
}
err = genesis.ValidateAndComplete()
if err != nil {
panic(err)
}
if err := genesis.SaveAs("genesis.json"); err != nil {
panic(err)
}
}