Skip to content

Commit

Permalink
Final fixes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
jaekwon committed Nov 25, 2018
1 parent 5792e1d commit 819af35
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
5 changes: 3 additions & 2 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"runtime/debug"
"strings"

"github.com/gogo/protobuf/proto"
"github.com/pkg/errors"

abci "github.com/tendermint/tendermint/abci/types"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
15 changes: 0 additions & 15 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ const (
contextKeyMultiStore contextKey = iota
contextKeyBlockHeader
contextKeyBlockHeight
contextKeyConsensusParams
contextKeyChainID
contextKeyIsCheckTx
contextKeyTxBytes
Expand All @@ -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) }
Expand Down Expand Up @@ -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) }
Expand Down

0 comments on commit 819af35

Please sign in to comment.