mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
types: refactor PB2TM.ConsensusParams to take BlockTimeIota as an arg (#3442)
See https://github.com/tendermint/tendermint/pull/3403/files#r266208947 In #3403 we unexposed BlockTimeIota from the ABCI, but it's still part of the ConsensusParams struct, so we have to remember to add it back after calling PB2TM.ConsensusParams. Instead, PB2TM.ConsensusParams should take it as an argument Fixes #3432
This commit is contained in:
parent
7457133307
commit
4162ebe8b5
@ -324,12 +324,7 @@ func (h *Handshaker) ReplayBlocks(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if res.ConsensusParams != nil {
|
if res.ConsensusParams != nil {
|
||||||
// Preserve TimeIotaMs since it's not exposed to the application.
|
state.ConsensusParams = types.PB2TM.ConsensusParams(res.ConsensusParams, state.ConsensusParams.Block.TimeIotaMs)
|
||||||
timeIotaMs := state.ConsensusParams.Block.TimeIotaMs
|
|
||||||
{
|
|
||||||
state.ConsensusParams = types.PB2TM.ConsensusParams(res.ConsensusParams)
|
|
||||||
}
|
|
||||||
state.ConsensusParams.Block.TimeIotaMs = timeIotaMs
|
|
||||||
}
|
}
|
||||||
sm.SaveState(h.stateDB, state)
|
sm.SaveState(h.stateDB, state)
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,9 @@ func (pb2tm) ValidatorUpdates(vals []abci.ValidatorUpdate) ([]*Validator, error)
|
|||||||
return tmVals, nil
|
return tmVals, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pb2tm) ConsensusParams(csp *abci.ConsensusParams) ConsensusParams {
|
// 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{
|
params := ConsensusParams{
|
||||||
Block: BlockParams{},
|
Block: BlockParams{},
|
||||||
Evidence: EvidenceParams{},
|
Evidence: EvidenceParams{},
|
||||||
@ -233,6 +235,7 @@ func (pb2tm) ConsensusParams(csp *abci.ConsensusParams) ConsensusParams {
|
|||||||
params.Block = BlockParams{
|
params.Block = BlockParams{
|
||||||
MaxBytes: csp.Block.MaxBytes,
|
MaxBytes: csp.Block.MaxBytes,
|
||||||
MaxGas: csp.Block.MaxGas,
|
MaxGas: csp.Block.MaxGas,
|
||||||
|
TimeIotaMs: blockTimeIotaMs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,9 +64,7 @@ func TestABCIValidators(t *testing.T) {
|
|||||||
func TestABCIConsensusParams(t *testing.T) {
|
func TestABCIConsensusParams(t *testing.T) {
|
||||||
cp := DefaultConsensusParams()
|
cp := DefaultConsensusParams()
|
||||||
abciCP := TM2PB.ConsensusParams(cp)
|
abciCP := TM2PB.ConsensusParams(cp)
|
||||||
cp2 := PB2TM.ConsensusParams(abciCP)
|
cp2 := PB2TM.ConsensusParams(abciCP, cp.Block.TimeIotaMs)
|
||||||
// TimeIotaMs is not exposed to the application.
|
|
||||||
cp2.Block.TimeIotaMs = cp.Block.TimeIotaMs
|
|
||||||
|
|
||||||
assert.Equal(t, *cp, cp2)
|
assert.Equal(t, *cp, cp2)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user