ax(node): replace prose constant comments with usage examples in message.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

AX Principle 2: comments show usage, not prose descriptions. The
ProtocolVersion/MinProtocolVersion block comment and SupportedProtocolVersions
doc comment restated what the names already say; replaced with concrete
call-site examples.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 16:48:39 +01:00
parent 871dc781f1
commit ea9eb19e5b
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -7,16 +7,14 @@ import (
"github.com/google/uuid"
)
// Protocol version constants
// if payload.Version != ProtocolVersion { return errVersionMismatch }
// if payload.Version < MinProtocolVersion { return errUnsupportedVersion }
const (
// ProtocolVersion is the current protocol version
ProtocolVersion = "1.0"
// MinProtocolVersion is the minimum supported version
ProtocolVersion = "1.0"
MinProtocolVersion = "1.0"
)
// SupportedProtocolVersions lists all protocol versions this node supports.
// Used for version negotiation during handshake.
// if !IsProtocolVersionSupported(peer.Version) { return errUnsupportedVersion }
var SupportedProtocolVersions = []string{"1.0"}
// if node.IsProtocolVersionSupported(peerVersion) { proceed() }
@ -93,7 +91,7 @@ func NewMessage(msgType MessageType, from, to string, payload interface{}) (*Mes
}, nil
}
// resp, err := msg.Reply(MsgPong, PongPayload{SentAt: ping.SentAt, ReceivedAt: time.Now().UnixMilli()})
// response, err := msg.Reply(MsgPong, PongPayload{SentAt: ping.SentAt, ReceivedAt: time.Now().UnixMilli()})
// if err != nil { return nil, err }
func (message *Message) Reply(msgType MessageType, payload interface{}) (*Message, error) {
reply, err := NewMessage(msgType, message.To, message.From, payload)