-
Notifications
You must be signed in to change notification settings - Fork 18
/
main.go
71 lines (58 loc) · 2.14 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
package main
import (
"encoding/json"
"io"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/server"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"
"github.com/lino-network/lino/app"
"github.com/lino-network/lino/types"
)
// generate Lino application
func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application {
app := app.NewLinoBlockchain(
logger,
db,
traceStore,
// XXX(yumin): previously we use
// "syncable": PruneSyncable = NewPruningOptions(100, 10000)
// which means every (10000 * block_time) seconds, a state is kept.
// If block_time is around 3 seconds, then every ~8.33 hours, a state
// is kept. When height is 4M, there are about 400 copies in db. Even if
// it's an immutable iavl, an early state may be just a full copy of the state, as
// it may be totally different from current and following kepted states.
// Plus state-sync is not supported for now, we set it to 400000 here.
baseapp.SetPruning(storetypes.NewPruningOptions(100, 400000)),
)
return app
}
func main() {
cobra.EnableCommandSorting = false
types.ConfigAndSealCosmosSDKAddress()
cdc := app.MakeCodec()
ctx := server.NewDefaultContext()
rootCmd := &cobra.Command{
Use: "lino",
Short: "Lino Blockchain (server)",
PersistentPreRunE: server.PersistentPreRunEFn(ctx),
}
rootCmd.AddCommand(app.VersionCmd())
rootCmd.AddCommand(app.InitCmd(ctx, cdc))
server.AddCommands(ctx, cdc, rootCmd, newApp, exportAppStateAndTMValidators)
executor := cli.PrepareBaseCmd(rootCmd, "BC", app.DefaultNodeHome)
err := executor.Execute()
if err != nil {
panic(err)
}
}
func exportAppStateAndTMValidators(logger log.Logger, db dbm.DB, traceStore io.Writer,
_ int64, _ bool, _ []string) (json.RawMessage, []tmtypes.GenesisValidator, error) {
lb := app.NewLinoBlockchain(logger, db, traceStore)
return lb.ExportAppStateAndValidators()
}