diff options
| author | Paul Buetow <paul@buetow.org> | 2023-06-13 00:59:15 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-06-13 00:59:15 +0300 |
| commit | 93b32777632eb79393e4f6fe0b752665c8e511ff (patch) | |
| tree | db6e7b7f0fc003d3fd816eaf769bb66eb9f46dd3 | |
| parent | a04fa17d3719e5435c35a599cf566630a08108a8 (diff) | |
lower vote expiry, send every expiry interval to partners my move anyway
| -rw-r--r-- | Taskfile.yml | 3 | ||||
| -rw-r--r-- | internal/quorum/quorum.go | 14 | ||||
| -rw-r--r-- | internal/vote/vote.go | 2 |
3 files changed, 10 insertions, 9 deletions
diff --git a/Taskfile.yml b/Taskfile.yml index 886e8b6..3d16722 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -4,6 +4,9 @@ tasks: build: cmds: - go build -o gorum cmd/gorum/main.go + race: + cmds: + - go build -race -o gorum cmd/gorum/main.go test: cmds: - go clean -testcache diff --git a/internal/quorum/quorum.go b/internal/quorum/quorum.go index e3f0eeb..52cf6ee 100644 --- a/internal/quorum/quorum.go +++ b/internal/quorum/quorum.go @@ -42,14 +42,12 @@ func (quo Quorum) Start(ctx context.Context) <-chan vote.Vote { for { select { case <-time.After(vote.Expiry): - if newVote, changed := quo.makeMyVote(); changed { - quo.score() - ch <- newVote - } - case vote := <-quo.voteCh: - quo.vote(vote) - if newVote, changed := quo.makeMyVote(); changed { - ch <- newVote + myVote, _ := quo.makeMyVote() + ch <- myVote + case v := <-quo.voteCh: + quo.vote(v) + if myVote, changed := quo.makeMyVote(); changed { + ch <- myVote } quo.score() case <-ctx.Done(): diff --git a/internal/vote/vote.go b/internal/vote/vote.go index 8ad5a37..91775d0 100644 --- a/internal/vote/vote.go +++ b/internal/vote/vote.go @@ -6,7 +6,7 @@ import ( "time" ) -const Expiry = 20 * time.Second +const Expiry = 10 * time.Second type Vote struct { FromID string |
