github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/baseapp/baseapp_mode_simulate.go (about)

     1  package baseapp
     2  
     3  import (
     4  	"fmt"
     5  
     6  	sdkerrors "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/errors"
     7  	tmtypes "github.com/fibonacci-chain/fbc/libs/tendermint/types"
     8  )
     9  
    10  func (m *modeHandlerSimulate) handleStartHeight(info *runTxInfo, height int64) error {
    11  	app := m.app
    12  	startHeight := tmtypes.GetStartBlockHeight()
    13  
    14  	var err error
    15  	lastHeight := app.LastBlockHeight()
    16  	if height == 0 {
    17  		height = lastHeight
    18  	}
    19  	if height <= startHeight {
    20  		err = sdkerrors.Wrap(sdkerrors.ErrInvalidRequest,
    21  			fmt.Sprintf("height(%d) should be greater than start block height(%d)", height, startHeight))
    22  	} else if height > startHeight && height <= lastHeight {
    23  		info.ctx, err = app.getContextForSimTx(info.txBytes, height)
    24  	} else {
    25  		err = sdkerrors.Wrap(sdkerrors.ErrInvalidRequest,
    26  			fmt.Sprintf("height(%d) should be less than or equal to latest block height(%d)", height, lastHeight))
    27  	}
    28  	if info.overridesBytes != nil {
    29  		info.ctx.SetOverrideBytes(info.overridesBytes)
    30  	}
    31  	return err
    32  }