diff --git a/chord/topology.go b/chord/topology.go index 5ec7407..409f684 100644 --- a/chord/topology.go +++ b/chord/topology.go @@ -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() { diff --git a/main.go b/main.go index 2e4b965..8ec909b 100644 --- a/main.go +++ b/main.go @@ -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()