-
Notifications
You must be signed in to change notification settings - Fork 180
/
baseapp_mode_simulate.go
35 lines (31 loc) · 1.05 KB
/
baseapp_mode_simulate.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
package baseapp
import (
"fmt"
sdkerrors "github.com/okex/exchain/libs/cosmos-sdk/types/errors"
tmtypes "github.com/okex/exchain/libs/tendermint/types"
)
func (m *modeHandlerSimulate) handleStartHeight(info *runTxInfo, height int64) error {
app := m.app
startHeight := tmtypes.GetStartBlockHeight()
var err error
lastHeight := app.LastBlockHeight()
if height == 0 {
height = lastHeight
}
if height <= startHeight {
err = sdkerrors.Wrap(sdkerrors.ErrInvalidRequest,
fmt.Sprintf("height(%d) should be greater than start block height(%d)", height, startHeight))
} else if height > startHeight && height <= lastHeight {
info.ctx, err = app.getContextForSimTx(info.txBytes, height)
if m.mode == runTxModeSimulate && info.mempoolSimulate {
info.ctx.SetMempoolSimulate(true)
}
} else {
err = sdkerrors.Wrap(sdkerrors.ErrInvalidRequest,
fmt.Sprintf("height(%d) should be less than or equal to latest block height(%d)", height, lastHeight))
}
if info.overridesBytes != nil {
info.ctx.SetOverrideBytes(info.overridesBytes)
}
return err
}