ax(node): rename dedup field to deduplicator in Transport struct
AX Principle 1: predictable names over short names. The abbreviated struct field `dedup` requires a reader to mentally expand it; the full name `deduplicator` is self-describing. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
8d9606c2d8
commit
6d77de500d
1 changed files with 5 additions and 5 deletions
|
|
@ -110,7 +110,7 @@ type Transport struct {
|
|||
node *NodeManager
|
||||
registry *PeerRegistry
|
||||
handler MessageHandler
|
||||
dedup *MessageDeduplicator // Message deduplication
|
||||
deduplicator *MessageDeduplicator // Message deduplication
|
||||
mutex sync.RWMutex
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
|
|
@ -180,7 +180,7 @@ func NewTransport(node *NodeManager, registry *PeerRegistry, config TransportCon
|
|||
node: node,
|
||||
registry: registry,
|
||||
conns: make(map[string]*PeerConnection),
|
||||
dedup: NewMessageDeduplicator(5 * time.Minute), // 5 minute TTL for dedup
|
||||
deduplicator: NewMessageDeduplicator(5 * time.Minute), // 5 minute TTL for dedup
|
||||
upgrader: websocket.Upgrader{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
|
|
@ -268,7 +268,7 @@ func (t *Transport) Start() error {
|
|||
case <-t.ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
t.dedup.Cleanup()
|
||||
t.deduplicator.Cleanup()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
@ -756,11 +756,11 @@ func (t *Transport) readLoop(pc *PeerConnection) {
|
|||
}
|
||||
|
||||
// Check for duplicate messages (prevents amplification attacks)
|
||||
if t.dedup.IsDuplicate(msg.ID) {
|
||||
if t.deduplicator.IsDuplicate(msg.ID) {
|
||||
logging.Debug("dropping duplicate message", logging.Fields{"msg_id": msg.ID, "peer_id": pc.Peer.ID})
|
||||
continue
|
||||
}
|
||||
t.dedup.Mark(msg.ID)
|
||||
t.deduplicator.Mark(msg.ID)
|
||||
|
||||
// Rate limit debug logs in hot path to reduce noise (log 1 in N messages)
|
||||
if debugLogCounter.Add(1)%debugLogInterval == 0 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue