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 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)
|
log.Debug("Data catchup", "height", rs.Height, "peerHeight", prs.Height)
|
||||||
if index, ok := prs.ProposalBlockBitArray.Not().PickRandom(); ok {
|
if index, ok := prs.ProposalBlockBitArray.Not().PickRandom(); ok {
|
||||||
// Ensure that the peer's PartSetHeaeder is correct
|
// Ensure that the peer's PartSetHeaeder is correct
|
||||||
|
@ -237,9 +237,10 @@ type ConsensusState struct {
|
|||||||
|
|
||||||
mtx sync.Mutex
|
mtx sync.Mutex
|
||||||
RoundState
|
RoundState
|
||||||
state *state.State // State until height-1.
|
state *state.State // State until height-1.
|
||||||
stagedBlock *Block // Cache last staged block.
|
stagedBlock *Block // Cache last staged block.
|
||||||
stagedState *state.State // Cache result of 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 {
|
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)
|
err := cs.stageBlock(cs.ProposalBlock, cs.ProposalBlockParts)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Debug(Fmt("Finalizing commit of block: %v", cs.ProposalBlock))
|
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.
|
// Increment height.
|
||||||
cs.updateToState(cs.stagedState)
|
cs.updateToState(cs.stagedState)
|
||||||
// cs.Step is now RoundStepNewHeight or RoundStepNewRound
|
// 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) {
|
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.
|
// The proposal must be valid.
|
||||||
if err := cs.stageBlock(block, blockParts); err != nil {
|
if err := cs.stageBlock(block, blockParts); err != nil {
|
||||||
// Prevent zombies.
|
// Prevent zombies.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user