-
Notifications
You must be signed in to change notification settings - Fork 182
/
app_abci.go
58 lines (42 loc) · 1.69 KB
/
app_abci.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
package app
import (
appconfig "github.com/okex/exchain/app/config"
abci "github.com/okex/exchain/libs/tendermint/abci/types"
"github.com/okex/exchain/libs/tendermint/trace"
"github.com/okex/exchain/x/common/analyzer"
"github.com/okex/exchain/x/evm"
)
// BeginBlock implements the Application interface
func (app *OKExChainApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeginBlock) {
analyzer.OnAppBeginBlockEnter(app.LastBlockHeight() + 1)
// dump app.LastBlockHeight()-1 info for reactor sync mode
trace.GetElapsedInfo().Dump(app.Logger())
return app.BaseApp.BeginBlock(req)
}
func (app *OKExChainApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliverTx) {
analyzer.OnAppDeliverTxEnter()
resp := app.BaseApp.DeliverTx(req)
if appconfig.GetOecConfig().GetEnableDynamicGp() {
tx, err := evm.TxDecoder(app.Codec())(req.Tx)
if err == nil {
//optimize get tx gas price can not get value from verifySign method
app.blockGasPrice = append(app.blockGasPrice, tx.GetGasPrice())
}
}
return resp
}
// EndBlock implements the Application interface
func (app *OKExChainApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBlock) {
return app.BaseApp.EndBlock(req)
}
// Commit implements the Application interface
func (app *OKExChainApp) Commit(req abci.RequestCommit) abci.ResponseCommit {
defer analyzer.OnCommitDone()
res := app.BaseApp.Commit(req)
// we call watch#Commit here ,because
// 1. this round commit a valid block
// 2. before commit the block,State#updateToState hasent not called yet,so the proposalBlockPart is not nil which means we wont
// call the prerun during commit step(edge case)
app.EvmKeeper.Watcher.Commit()
return res
}