Clear time separation for loss before gain

This commit is contained in:
Ian Gulliver
2023-06-04 13:59:06 -07:00
parent 7c3e760759
commit ed7ce91819
3 changed files with 43 additions and 18 deletions

View File

@@ -52,7 +52,7 @@ func NewVoter(url string, signingKey string, candidate *Candidate) *Voter {
vote: vote{
VoterID: uniuri.New(),
},
period: 5 * time.Second,
period: maxVotePeriod,
}
go v.loop()
@@ -82,8 +82,7 @@ func (v *Voter) poll() bool {
t2 := &time.Timer{}
if v.vote.NumPollsSinceChange <= 10 {
// mean: 100ms, max: 200ms
t2 = time.NewTimer(randDurationN(100 * time.Millisecond))
t2 = time.NewTimer(randDurationN(maxFastVotePeriod))
defer t2.Stop()
}