ax(node): replace prose constant comments with usage examples in message.go
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:
parent
871dc781f1
commit
ea9eb19e5b
1 changed files with 5 additions and 7 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue