Skip to content

Commit

Permalink
next receives Deadline-type timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
yossigi committed Aug 16, 2023
1 parent 0a3fbea commit bb94590
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions agreement/demux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package agreement
import (
"context"
"fmt"
"time"

"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/logging"
Expand Down Expand Up @@ -190,7 +189,7 @@ func (d *demux) verifyBundle(ctx context.Context, m message, r round, p period,
// next blocks until it observes an external input event of interest for the state machine.
//
// If ok is false, there are no more events so the agreement service should quit.
func (d *demux) next(s *Service, deadline Deadline, fastDeadline time.Duration, currentRound round) (e externalEvent, ok bool) {
func (d *demux) next(s *Service, deadline Deadline, fastDeadline Deadline, currentRound round) (e externalEvent, ok bool) {
defer func() {
if !ok {
return
Expand Down Expand Up @@ -251,7 +250,7 @@ func (d *demux) next(s *Service, deadline Deadline, fastDeadline time.Duration,

ledgerNextRoundCh := s.Ledger.Wait(nextRound)
deadlineCh := s.Clock.TimeoutAt(deadline.Duration, deadline.Type)
fastDeadlineCh := s.Clock.TimeoutAt(fastDeadline, TimeoutFastRecovery)
fastDeadlineCh := s.Clock.TimeoutAt(fastDeadline.Duration, fastDeadline.Type)

d.UpdateEventsQueue(eventQueueDemux, 0)
d.monitor.dec(demuxCoserviceType)
Expand Down
2 changes: 1 addition & 1 deletion agreement/demux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ func (t *demuxTester) TestUsecase(testcase demuxTestUsecase) bool {
close(s.quit)
}

e, ok := dmx.next(s, Deadline{Duration: time.Second, Type: TimeoutDeadline}, fastTimeoutChTime, 300)
e, ok := dmx.next(s, Deadline{Duration: time.Second, Type: TimeoutDeadline}, Deadline{Duration: fastTimeoutChTime, Type: TimeoutFastRecovery}, 300)

if !assert.Equal(t, testcase.ok, ok) {
return false
Expand Down
6 changes: 3 additions & 3 deletions agreement/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package agreement
//go:generate dbgen -i agree.sql -p agreement -n agree -o agreeInstall.go -h ../scripts/LICENSE_HEADER
import (
"context"
"time"

"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/logging"
Expand Down Expand Up @@ -81,7 +80,7 @@ type parameters Parameters
// externalDemuxSignals used to syncronize the external signals that goes to the demux with the main loop.
type externalDemuxSignals struct {
Deadline Deadline
FastRecoveryDeadline time.Duration
FastRecoveryDeadline Deadline
CurrentRound round
}

Expand Down Expand Up @@ -242,7 +241,8 @@ func (s *Service) mainLoop(input <-chan externalEvent, output chan<- []action, r

for {
output <- a
ready <- externalDemuxSignals{Deadline: status.Deadline, FastRecoveryDeadline: status.FastRecoveryDeadline, CurrentRound: status.Round}
fastRecoveryDeadline := Deadline{Duration: status.FastRecoveryDeadline, Type: TimeoutFastRecovery}
ready <- externalDemuxSignals{Deadline: status.Deadline, FastRecoveryDeadline: fastRecoveryDeadline, CurrentRound: status.Round}
e, ok := <-input
if !ok {
break
Expand Down

0 comments on commit bb94590

Please sign in to comment.