Browse Source

replace PB2TM.ConsensusParams with a call to params#Update (#3448)

Fixes #3444
pull/3461/head
Anton Kaliaev 5 years ago
committed by GitHub
parent
commit
1d4afb179b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 35 deletions
  1. +1
    -1
      consensus/replay.go
  2. +0
    -33
      types/protobuf.go
  3. +1
    -1
      types/protobuf_test.go

+ 1
- 1
consensus/replay.go View File

@ -324,7 +324,7 @@ func (h *Handshaker) ReplayBlocks(
}
if res.ConsensusParams != nil {
state.ConsensusParams = types.PB2TM.ConsensusParams(res.ConsensusParams, state.ConsensusParams.Block.TimeIotaMs)
state.ConsensusParams = state.ConsensusParams.Update(res.ConsensusParams)
}
sm.SaveState(h.stateDB, state)
}


+ 0
- 33
types/protobuf.go View File

@ -220,36 +220,3 @@ func (pb2tm) ValidatorUpdates(vals []abci.ValidatorUpdate) ([]*Validator, error)
}
return tmVals, nil
}
// BlockParams.TimeIotaMs is not exposed to the application. Therefore a caller
// must provide it.
func (pb2tm) ConsensusParams(csp *abci.ConsensusParams, blockTimeIotaMs int64) ConsensusParams {
params := ConsensusParams{
Block: BlockParams{},
Evidence: EvidenceParams{},
Validator: ValidatorParams{},
}
// we must defensively consider any structs may be nil
if csp.Block != nil {
params.Block = BlockParams{
MaxBytes: csp.Block.MaxBytes,
MaxGas: csp.Block.MaxGas,
TimeIotaMs: blockTimeIotaMs,
}
}
if csp.Evidence != nil {
params.Evidence = EvidenceParams{
MaxAge: csp.Evidence.MaxAge,
}
}
if csp.Validator != nil {
params.Validator = ValidatorParams{
PubKeyTypes: csp.Validator.PubKeyTypes,
}
}
return params
}

+ 1
- 1
types/protobuf_test.go View File

@ -64,7 +64,7 @@ func TestABCIValidators(t *testing.T) {
func TestABCIConsensusParams(t *testing.T) {
cp := DefaultConsensusParams()
abciCP := TM2PB.ConsensusParams(cp)
cp2 := PB2TM.ConsensusParams(abciCP, cp.Block.TimeIotaMs)
cp2 := cp.Update(abciCP)
assert.Equal(t, *cp, cp2)
}


Loading…
Cancel
Save