fix wrong field access in LoadConsensusParams

Closes #1766
This commit is contained in:
Anton Kaliaev 2018-07-04 15:34:13 +04:00
parent bff68abe04
commit e565e348d5
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
1 changed files with 6 additions and 5 deletions

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/types"
) )
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -175,7 +175,7 @@ func LoadValidators(db dbm.DB, height int64) (*types.ValidatorSet, error) {
if valInfo.ValidatorSet == nil { if valInfo.ValidatorSet == nil {
valInfo2 := loadValidatorsInfo(db, valInfo.LastHeightChanged) valInfo2 := loadValidatorsInfo(db, valInfo.LastHeightChanged)
if valInfo2 == nil { if valInfo2 == nil {
cmn.PanicSanity(fmt.Sprintf(`Couldn't find validators at height %d as panic(fmt.Sprintf(`Couldn't find validators at height %d as
last changed from height %d`, valInfo.LastHeightChanged, height)) last changed from height %d`, valInfo.LastHeightChanged, height))
} }
valInfo = valInfo2 valInfo = valInfo2
@ -239,11 +239,12 @@ func LoadConsensusParams(db dbm.DB, height int64) (types.ConsensusParams, error)
} }
if paramsInfo.ConsensusParams == empty { if paramsInfo.ConsensusParams == empty {
paramsInfo = loadConsensusParamsInfo(db, paramsInfo.LastHeightChanged) paramsInfo2 := loadConsensusParamsInfo(db, paramsInfo.LastHeightChanged)
if paramsInfo == nil { if paramsInfo2 == nil {
cmn.PanicSanity(fmt.Sprintf(`Couldn't find consensus params at height %d as panic(fmt.Sprintf(`Couldn't find consensus params at height %d as
last changed from height %d`, paramsInfo.LastHeightChanged, height)) last changed from height %d`, paramsInfo.LastHeightChanged, height))
} }
paramsInfo = paramsInfo2
} }
return paramsInfo.ConsensusParams, nil return paramsInfo.ConsensusParams, nil