log neighbors when stabilizing
This commit is contained in:
parent
6316576823
commit
afd8755131
@ -175,6 +175,11 @@ func (p Peer) Values() (ID, netip.AddrPort) {
|
|||||||
return p.id, p.addr
|
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.
|
// Create creates a new Chord network using the given address as the initial node.
|
||||||
func Create(addr netip.AddrPort) (*Node, error) {
|
func Create(addr netip.AddrPort) (*Node, error) {
|
||||||
if !addr.IsValid() {
|
if !addr.IsValid() {
|
||||||
|
2
main.go
2
main.go
@ -183,6 +183,8 @@ func cliJoin(ctx context.Context, cmd *cli.Command) error {
|
|||||||
slog.ErrorContext(ctx, "stabilize", slog.Any("err", err))
|
slog.ErrorContext(ctx, "stabilize", slog.Any("err", err))
|
||||||
node.SuccessorFailed()
|
node.SuccessorFailed()
|
||||||
}
|
}
|
||||||
|
pred, succ := node.Neighbors(nil)
|
||||||
|
slog.InfoContext(ctx, "neighbors", slog.Any("predecessor", pred), slog.Any("successors", succ))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
|
Loading…
Reference in New Issue
Block a user