Skip to content

Commit

Permalink
space PR sends out over the whole epoch duration
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Jun 10, 2024
1 parent d845cc2 commit 04facb9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mixing/mixclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const (
maxJitter = timeoutDuration / 10
msgJitter = 15 * time.Millisecond
peerJitter = maxJitter - msgJitter
extraPRJitter = 30 * time.Second
)

// expiredPRErr indicates that a dicemix session failed to complete due to the
Expand Down Expand Up @@ -532,13 +531,14 @@ func (p *peer) msgJitter() time.Duration {
func (c *Client) prDelay(ctx context.Context, p *peer) error {
now := time.Now().UTC()
epoch := now.Truncate(c.epoch).Add(c.epoch)
sendBefore := epoch.Add(-timeoutDuration - maxJitter - extraPRJitter)
sendBefore := epoch.Add(-timeoutDuration - maxJitter)
sendAfter := epoch.Add(timeoutDuration)
var wait time.Duration
if now.After(sendBefore) {
wait = sendAfter.Sub(now)
sendBefore = sendBefore.Add(c.epoch)
}
wait += p.msgJitter() + uniform.Duration(cryptorand.Reader, extraPRJitter)
wait += p.msgJitter() + uniform.Duration(cryptorand.Reader, time.Until(sendBefore))
timer := time.NewTimer(wait)
select {
case <-ctx.Done():
Expand Down

0 comments on commit 04facb9

Please sign in to comment.