Final fixes from review
This commit is contained in:
parent
5792e1d5c4
commit
819af35962
|
@ -6,6 +6,7 @@ import (
|
|||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
@ -183,7 +184,7 @@ func (app *BaseApp) initFromMainStore(mainKey *sdk.KVStoreKey) error {
|
|||
consensusParamsBz := mainStore.Get(mainConsensusParamsKey)
|
||||
if consensusParamsBz != nil {
|
||||
var consensusParams = &abci.ConsensusParams{}
|
||||
err := codec.Cdc.UnmarshalBinaryLengthPrefixed(consensusParamsBz, consensusParams)
|
||||
err := proto.Unmarshal(consensusParamsBz, consensusParams)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -248,7 +249,7 @@ func (app *BaseApp) setConsensusParams(consensusParams *abci.ConsensusParams) {
|
|||
|
||||
// setConsensusParams stores the consensus params to the main store.
|
||||
func (app *BaseApp) storeConsensusParams(consensusParams *abci.ConsensusParams) {
|
||||
consensusParamsBz, err := codec.Cdc.MarshalBinaryLengthPrefixed(consensusParams)
|
||||
consensusParamsBz, err := proto.Marshal(consensusParams)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -133,7 +133,6 @@ const (
|
|||
contextKeyMultiStore contextKey = iota
|
||||
contextKeyBlockHeader
|
||||
contextKeyBlockHeight
|
||||
contextKeyConsensusParams
|
||||
contextKeyChainID
|
||||
contextKeyIsCheckTx
|
||||
contextKeyTxBytes
|
||||
|
@ -152,10 +151,6 @@ func (c Context) BlockHeader() abci.Header { return c.Value(contextKeyBlockHeade
|
|||
|
||||
func (c Context) BlockHeight() int64 { return c.Value(contextKeyBlockHeight).(int64) }
|
||||
|
||||
func (c Context) ConsensusParams() abci.ConsensusParams {
|
||||
return c.Value(contextKeyConsensusParams).(abci.ConsensusParams)
|
||||
}
|
||||
|
||||
func (c Context) ChainID() string { return c.Value(contextKeyChainID).(string) }
|
||||
|
||||
func (c Context) TxBytes() []byte { return c.Value(contextKeyTxBytes).([]byte) }
|
||||
|
@ -201,16 +196,6 @@ func (c Context) WithBlockHeight(height int64) Context {
|
|||
return c.withValue(contextKeyBlockHeight, height).withValue(contextKeyBlockHeader, newHeader)
|
||||
}
|
||||
|
||||
func (c Context) WithConsensusParams(params *abci.ConsensusParams) Context {
|
||||
if params == nil {
|
||||
return c
|
||||
}
|
||||
|
||||
// TODO: Do we need to handle invalid MaxGas values?
|
||||
return c.withValue(contextKeyConsensusParams, params).
|
||||
WithGasMeter(NewGasMeter(uint64(params.BlockSize.MaxGas)))
|
||||
}
|
||||
|
||||
func (c Context) WithChainID(chainID string) Context { return c.withValue(contextKeyChainID, chainID) }
|
||||
|
||||
func (c Context) WithTxBytes(txBytes []byte) Context { return c.withValue(contextKeyTxBytes, txBytes) }
|
||||
|
|
Loading…
Reference in New Issue