Skip to content

Commit

Permalink
refactored retry
Browse files Browse the repository at this point in the history
  • Loading branch information
ivcosla committed May 20, 2019
1 parent 6efde16 commit bebafeb
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions pkg/messaging-discovery/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,26 @@ func (c *httpClient) UpdateEntry(ctx context.Context, sk cipher.SecKey, e *Entry

for {
err = c.SetEntry(ctx, e)
if err == nil {
return nil
}
if err != ErrValidationWrongSequence {
e.Sequence--
return err
}
rE, entryErr := c.Entry(ctx, e.Static)
if entryErr != nil {
return err
}
if rE.Timestamp > e.Timestamp { // If there is a more up to date entry drop update
e.Sequence = rE.Sequence
return nil
}
e.Sequence = rE.Sequence + 1
err := e.Sign(sk)
if err != nil {
if err != ErrValidationWrongSequence {
e.Sequence--
return err
}
rE, entryErr := c.Entry(ctx, e.Static)
if entryErr != nil {
return err
}
if rE.Timestamp > e.Timestamp { // If there is a more up to date entry drop update
e.Sequence = rE.Sequence
return nil
}
e.Sequence = rE.Sequence + 1
err := e.Sign(sk)
if err != nil {
return err
}
continue
return err
}
return nil
}
}

Expand Down

0 comments on commit bebafeb

Please sign in to comment.