check predecessor before stabilizing

This commit is contained in:
Branden J Brown 2025-03-14 10:01:00 -04:00
parent 4c79714fcd
commit 6316576823

View File

@ -55,6 +55,7 @@ func (n *Node) Router() http.Handler {
// Check performs checks that implement the Chord protocol.
// It must be called periodically while the node is alive.
func (n *Node) Check(ctx context.Context) error {
chord.CheckPredecessor(ctx, n.client, n.self)
if err := chord.Stabilize(ctx, n.client, n.self); err != nil {
return fmt.Errorf("failed to stabilize: %w", err)
}
@ -62,7 +63,6 @@ func (n *Node) Check(ctx context.Context) error {
// if err := chord.FixFingers(ctx, n.client, n.self); err != nil {
// return fmt.Errorf("failed to fix fingers: %w", err)
// }
chord.CheckPredecessor(ctx, n.client, n.self)
return nil
}