Compare commits
2 Commits
7a04a22f76
...
730bb45db4
Author | SHA1 | Date | |
---|---|---|---|
![]() |
730bb45db4 | ||
![]() |
8e73402c58 |
@ -88,14 +88,17 @@ func Stabilize(ctx context.Context, cl Client, n *Node) error {
|
||||
pred, _, err := cl.Neighbors(ctx, n.Successor())
|
||||
if err != nil {
|
||||
// TODO(zeph): replication
|
||||
return err
|
||||
return fmt.Errorf("acquiring successor neighbors for stabilization: %w", err)
|
||||
}
|
||||
if pred.IsValid() && contains(n.self.id, n.Successor().id, pred.id) && pred.id != n.Successor().id {
|
||||
// Shift in the new successor.
|
||||
copy(n.succ[1:], n.succ)
|
||||
n.succ[0] = pred
|
||||
}
|
||||
return cl.Notify(ctx, n, n.Successor())
|
||||
if err := cl.Notify(ctx, n, n.Successor()); err != nil {
|
||||
return fmt.Errorf("notifying successor: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Notify informs n that p considers n to be p's successor.
|
||||
|
@ -80,7 +80,7 @@ func (cl *Client) Notify(ctx context.Context, n *chord.Node, s chord.Peer) error
|
||||
Scheme: "http",
|
||||
Host: addr.String(),
|
||||
Path: path.Join("/", cl.APIBase, "pred"),
|
||||
RawQuery: url.Values{"s": {self.String()}}.Encode(),
|
||||
RawQuery: url.Values{"p": {self.String()}}.Encode(),
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", url.String(), nil)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user