log neighbors when stabilizing

This commit is contained in:
Branden J Brown 2025-03-14 12:22:23 -04:00
parent 6316576823
commit afd8755131
2 changed files with 7 additions and 0 deletions

View File

@ -175,6 +175,11 @@ func (p Peer) Values() (ID, netip.AddrPort) {
return p.id, p.addr
}
// String formats the peer's address for debugging.
func (p Peer) String() string {
return p.addr.String()
}
// Create creates a new Chord network using the given address as the initial node.
func Create(addr netip.AddrPort) (*Node, error) {
if !addr.IsValid() {

View File

@ -183,6 +183,8 @@ func cliJoin(ctx context.Context, cmd *cli.Command) error {
slog.ErrorContext(ctx, "stabilize", slog.Any("err", err))
node.SuccessorFailed()
}
pred, succ := node.Neighbors(nil)
slog.InfoContext(ctx, "neighbors", slog.Any("predecessor", pred), slog.Any("successors", succ))
}
}()
<-ctx.Done()