From 1ff90ba170a5a658a8d94aaa58d19be311c1aa23 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 08:47:20 +0100 Subject: [PATCH] ax(node): replace prose comments with usage examples on PeerRegistry auth methods SetAuthMode, GetAuthMode, AllowPublicKey, and RevokePublicKey all had comments that restated the function signature rather than showing concrete usage. Replaced with call-site examples per AX Principle 2. Co-Authored-By: Charon --- pkg/node/peer.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/node/peer.go b/pkg/node/peer.go index 9fde5f5..3254fe2 100644 --- a/pkg/node/peer.go +++ b/pkg/node/peer.go @@ -153,7 +153,8 @@ func NewPeerRegistryWithPath(peersPath string) (*PeerRegistry, error) { return pr, nil } -// SetAuthMode sets the authentication mode for peer connections. +// registry.SetAuthMode(PeerAuthAllowlist) // require pre-registration +// registry.SetAuthMode(PeerAuthOpen) // allow any peer (default) func (r *PeerRegistry) SetAuthMode(mode PeerAuthMode) { r.allowedPublicKeyMutex.Lock() defer r.allowedPublicKeyMutex.Unlock() @@ -161,14 +162,14 @@ func (r *PeerRegistry) SetAuthMode(mode PeerAuthMode) { logging.Info("peer auth mode changed", logging.Fields{"mode": mode}) } -// GetAuthMode returns the current authentication mode. +// if registry.GetAuthMode() == PeerAuthAllowlist { /* enforce allowlist */ } func (r *PeerRegistry) GetAuthMode() PeerAuthMode { r.allowedPublicKeyMutex.RLock() defer r.allowedPublicKeyMutex.RUnlock() return r.authMode } -// AllowPublicKey adds a public key to the allowlist. +// registry.AllowPublicKey(peer.PublicKey) // permit this key without pre-registration func (r *PeerRegistry) AllowPublicKey(publicKey string) { r.allowedPublicKeyMutex.Lock() defer r.allowedPublicKeyMutex.Unlock() @@ -176,7 +177,7 @@ func (r *PeerRegistry) AllowPublicKey(publicKey string) { logging.Debug("public key added to allowlist", logging.Fields{"key": safeKeyPrefix(publicKey)}) } -// RevokePublicKey removes a public key from the allowlist. +// registry.RevokePublicKey(peer.PublicKey) // block this key on next connect attempt func (r *PeerRegistry) RevokePublicKey(publicKey string) { r.allowedPublicKeyMutex.Lock() defer r.allowedPublicKeyMutex.Unlock()