Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consensus: restructure peer catchup sleep #8651

Merged
merged 1 commit into from
May 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions internal/consensus/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,22 +544,25 @@ func (r *Reactor) gossipDataForCatchup(rs *cstypes.RoundState, prs *cstypes.Peer

func (r *Reactor) gossipDataRoutine(ps *PeerState) {
logger := r.Logger.With("peer", ps.peerID)
timer := time.NewTimer(r.state.config.PeerGossipSleepDuration)
defer timer.Stop()

OUTER_LOOP:
for {
if !r.IsRunning() {
return
}

timer.Reset(r.state.config.PeerGossipSleepDuration)

select {
case <-r.closeCh:
return
case <-ps.closer.Done():
// The peer is marked for removal via a PeerUpdate as the doneCh was
// explicitly closed to signal we should exit.
return

default:
case <-timer.C:
}

rs := r.getRoundState()
Expand Down Expand Up @@ -605,7 +608,6 @@ OUTER_LOOP:
"blockstoreBase", blockStoreBase,
"blockstoreHeight", r.state.blockStore.Height(),
)
time.Sleep(r.state.config.PeerGossipSleepDuration)
} else {
ps.InitProposalBlockParts(blockMeta.BlockID.PartSetHeader)
}
Expand All @@ -621,7 +623,6 @@ OUTER_LOOP:

// if height and round don't match, sleep
if (rs.Height != prs.Height) || (rs.Round != prs.Round) {
time.Sleep(r.state.config.PeerGossipSleepDuration)
continue OUTER_LOOP
}

Expand Down Expand Up @@ -676,12 +677,8 @@ OUTER_LOOP:
}:
}
}

continue OUTER_LOOP
}

// nothing to do -- sleep
time.Sleep(r.state.config.PeerGossipSleepDuration)
continue OUTER_LOOP
}
}
Expand Down