Skip to content

Commit

Permalink
follower: Use Buffered syncNow channel to correctly trigger sync in p…
Browse files Browse the repository at this point in the history
…rivate networks (#5516)
  • Loading branch information
algochoi committed Jun 29, 2023
1 parent 11a180f commit 06fedda
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions catchup/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func MakeService(log logging.Logger, config config.Local, net network.GossipNode
s.parallelBlocks = config.CatchupParallelBlocks
s.deadlineTimeout = agreement.DeadlineTimeout()
s.blockValidationPool = blockValidationPool
s.syncNow = make(chan struct{})
s.syncNow = make(chan struct{}, 1)

return s
}
Expand Down Expand Up @@ -159,11 +159,11 @@ func (s *Service) IsSynchronizing() (synchronizing bool, initialSync bool) {

// triggerSync attempts to wake up the sync loop.
func (s *Service) triggerSync() {
if syncing, initial := s.IsSynchronizing(); !syncing && !initial {
select {
case s.syncNow <- struct{}{}:
default:
}
// Prevents deadlock if periodic sync isn't running
// when catchup is setting the sync round.
select {
case s.syncNow <- struct{}{}:
default:
}
}

Expand Down

0 comments on commit 06fedda

Please sign in to comment.