Compare commits

...

2 Commits

Author SHA1 Message Date
Branden J Brown
730bb45db4 fix path parameter in notify 2025-03-13 22:15:25 -04:00
Branden J Brown
8e73402c58 wrap stabilization errors 2025-03-13 22:10:28 -04:00
2 changed files with 6 additions and 3 deletions

View File

@ -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.

View File

@ -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 {