This repository has been archived by the owner on Feb 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
76 lines (62 loc) · 1.92 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
73
74
75
76
package main
import (
"fmt"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/krhubert/cosmos-test/serviceapp"
"github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
)
func main() {
// create new default config
cfg := config.DefaultConfig()
cfg.SetRoot("s1")
// cfg.P2P.Seeds = "57e1d834e500ac497cc30c884ebb85a0879ca295@localhost:26656"
// cfg.RPC.ListenAddress = "tcp://0.0.0.0:36657"
// cfg.P2P.ListenAddress = "tcp://0.0.0.0:36656"
// create new json logger
// logger := log.NewTMJSONLogger(log.NewSyncWriter(os.Stdout))
logger := log.NewNopLogger()
// create database for app
db := db.NewMemDB()
// create simple app
sapp, err := NewSimApp(logger, db)
if err != nil {
panic(err)
}
// generate node PrivKey
nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile())
if err != nil {
panic(err)
}
node, err := node.NewNode(cfg,
privval.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()),
nodeKey,
proxy.NewLocalClientCreator(sapp),
node.DefaultGenesisDocProviderFunc(cfg),
node.DefaultDBProvider,
node.DefaultMetricsProvider(cfg.Instrumentation),
logger,
)
if err != nil {
panic(err)
}
if err := node.Start(); err != nil {
panic(err)
}
fmt.Println("LET DO THIS")
time.Sleep(1 * time.Second)
sapp.Deliver(tx{serviceapp.NewMsgSetService([]byte("test"), []byte("service"))})
// ctx := sapp.NewContext(false, abci.Header{Height: sapp.LastBlockHeight()})
// sapp.saKeeper.SetService(ctx, []byte("test"), []byte("my service"))
// fmt.Println(sapp.saKeeper.GetService(ctx, []byte("test")))
select {}
}
type tx []sdk.Msg
func (t tx) GetMsgs() []sdk.Msg { return t }
func (t tx) ValidateBasic() sdk.Error { return nil }