mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-29 14:11:21 +00:00
Save blocks on catch-up too.
This commit is contained in:
parent
0dac36aa5d
commit
d20251849e
@ -280,7 +280,7 @@ OUTER_LOOP:
|
||||
}
|
||||
|
||||
// If the peer is on a previous height, help catch up.
|
||||
if rs.Height > prs.Height {
|
||||
if 0 < prs.Height && prs.Height < rs.Height {
|
||||
log.Debug("Data catchup", "height", rs.Height, "peerHeight", prs.Height)
|
||||
if index, ok := prs.ProposalBlockBitArray.Not().PickRandom(); ok {
|
||||
// Ensure that the peer's PartSetHeaeder is correct
|
||||
|
@ -240,6 +240,7 @@ type ConsensusState struct {
|
||||
state *state.State // State until height-1.
|
||||
stagedBlock *Block // Cache last staged block.
|
||||
stagedState *state.State // Cache result of staged block.
|
||||
lastCommittedHeight uint // Last called saveCommitVoteBlock() on.
|
||||
}
|
||||
|
||||
func NewConsensusState(state *state.State, blockStore *BlockStore, mempoolReactor *mempool.MempoolReactor) *ConsensusState {
|
||||
@ -828,6 +829,8 @@ func (cs *ConsensusState) TryFinalizeCommit(height uint) bool {
|
||||
err := cs.stageBlock(cs.ProposalBlock, cs.ProposalBlockParts)
|
||||
if err == nil {
|
||||
log.Debug(Fmt("Finalizing commit of block: %v", cs.ProposalBlock))
|
||||
// We have the block, so save/stage/sign-commit-vote.
|
||||
cs.saveCommitVoteBlock(cs.ProposalBlock, cs.ProposalBlockParts)
|
||||
// Increment height.
|
||||
cs.updateToState(cs.stagedState)
|
||||
// cs.Step is now RoundStepNewHeight or RoundStepNewRound
|
||||
@ -1038,6 +1041,13 @@ func (cs *ConsensusState) signAddVote(type_ byte, hash []byte, header PartSetHea
|
||||
|
||||
func (cs *ConsensusState) saveCommitVoteBlock(block *Block, blockParts *PartSet) {
|
||||
|
||||
// Only run once per height.
|
||||
if cs.lastCommittedHeight >= block.Height {
|
||||
return
|
||||
} else {
|
||||
cs.lastCommittedHeight = block.Height
|
||||
}
|
||||
|
||||
// The proposal must be valid.
|
||||
if err := cs.stageBlock(block, blockParts); err != nil {
|
||||
// Prevent zombies.
|
||||
|
Loading…
x
Reference in New Issue
Block a user