From 819af35962ac9990b89ca92b20104116eaaf0d8d Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Sat, 24 Nov 2018 18:10:59 -0800 Subject: [PATCH] Final fixes from review --- baseapp/baseapp.go | 5 +++-- types/context.go | 15 --------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index b2e07c5881..a83713d424 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -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) } diff --git a/types/context.go b/types/context.go index 905748d513..add88bfc33 100644 --- a/types/context.go +++ b/types/context.go @@ -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) }