forked from bnb-chain/bnc-cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.go
52 lines (45 loc) · 1.26 KB
/
helpers.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
package baseapp
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/abci/server"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/tmhash"
cmn "github.com/tendermint/tendermint/libs/common"
)
// nolint - Mostly for testing
func (app *BaseApp) Check(tx sdk.Tx) (result sdk.Result) {
txHash := cmn.HexBytes(tmhash.Sum(nil)).String()
return app.RunTx(sdk.RunTxModeCheck, nil, tx, txHash)
}
// nolint - full tx execution
func (app *BaseApp) Simulate(tx sdk.Tx) (result sdk.Result) {
txHash := cmn.HexBytes(tmhash.Sum(nil)).String()
return app.RunTx(sdk.RunTxModeSimulate, nil, tx, txHash)
}
// nolint
func (app *BaseApp) Deliver(tx sdk.Tx) (result sdk.Result) {
txHash := cmn.HexBytes(tmhash.Sum(nil)).String()
return app.RunTx(sdk.RunTxModeDeliver, nil, tx, txHash)
}
// RunForever - BasecoinApp execution and cleanup
func RunForever(app abci.Application) {
// Start the ABCI server
srv, err := server.NewServer("0.0.0.0:26658", "socket", app)
if err != nil {
cmn.Exit(err.Error())
return
}
err = srv.Start()
if err != nil {
cmn.Exit(err.Error())
return
}
// Wait forever
cmn.TrapSignal(func() {
// Cleanup
err := srv.Stop()
if err != nil {
cmn.Exit(err.Error())
}
})
}