ax(node): replace prose comments with usage examples in transport and identity
AX Principle 2: comments must show HOW with real values, not restate what the function name already says. Five prose descriptions replaced with concrete call-site examples. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
dc9d7d5041
commit
83a4d9d07d
2 changed files with 5 additions and 5 deletions
|
|
@ -275,7 +275,7 @@ func (manager *NodeManager) loadIdentity() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Delete removes the node identity and keys from disk.
|
||||
// if err := manager.Delete(); err != nil { return err } // removes key and config from disk; clears in-memory state
|
||||
func (manager *NodeManager) Delete() error {
|
||||
manager.mutex.Lock()
|
||||
defer manager.mutex.Unlock()
|
||||
|
|
|
|||
|
|
@ -607,7 +607,7 @@ func (t *Transport) handleWSUpgrade(w http.ResponseWriter, r *http.Request) {
|
|||
go t.keepalive(pc)
|
||||
}
|
||||
|
||||
// performHandshake initiates handshake with a peer.
|
||||
// if err := t.performHandshake(pc); err != nil { conn.Close(); return nil, err }
|
||||
func (t *Transport) performHandshake(pc *PeerConnection) error {
|
||||
// Set handshake timeout
|
||||
handshakeTimeout := 10 * time.Second
|
||||
|
|
@ -712,7 +712,7 @@ func (t *Transport) performHandshake(pc *PeerConnection) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// readLoop reads messages from a peer connection.
|
||||
// go t.readLoop(pc) // started by Connect and handleWSUpgrade after handshake
|
||||
func (t *Transport) readLoop(pc *PeerConnection) {
|
||||
defer t.waitGroup.Done()
|
||||
defer t.removeConnection(pc)
|
||||
|
|
@ -781,7 +781,7 @@ func (t *Transport) readLoop(pc *PeerConnection) {
|
|||
}
|
||||
}
|
||||
|
||||
// keepalive sends periodic pings.
|
||||
// go t.keepalive(pc) // started by Connect and handleWSUpgrade; pings every t.config.PingInterval
|
||||
func (t *Transport) keepalive(pc *PeerConnection) {
|
||||
defer t.waitGroup.Done()
|
||||
|
||||
|
|
@ -816,7 +816,7 @@ func (t *Transport) keepalive(pc *PeerConnection) {
|
|||
}
|
||||
}
|
||||
|
||||
// removeConnection removes and cleans up a connection.
|
||||
// t.removeConnection(pc) // called from readLoop on error and keepalive on timeout
|
||||
func (t *Transport) removeConnection(pc *PeerConnection) {
|
||||
t.mutex.Lock()
|
||||
delete(t.conns, pc.Peer.ID)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue