fix: code review — dead code, security, logic flaws#103
Conversation
- Remove dead `image` and `ticker` fields from Indexer struct - Fix WebSocket message relay: clients are now receive-only - Fix RWMutex lock upgrade race in handleMessages - Fix handleRollBackward: delete orphaned blocks + recompute nonce - Fix cmdStake context cancel leak (defer koiosCancel) - Deduplicate cmdLeaderlog into computeAndReplyLeaderlog helper - Fix misplaced truncHash/formatNumber doc comments - Add DeleteBlocksAfterSlot to Store interface + both implementations
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe pull request refactors the leaderlog command handler by extracting computation logic into a helper function, adds block deletion capability to the storage layer, enhances rollback handling with block cleanup and epoch nonce recomputation, and redesigns WebSocket broadcasting as a dedicated receive-only pattern. Additionally, unused fields are removed from the Indexer struct, and operation timeouts are increased. Changes
Sequence DiagramsequenceDiagram
participant WS as WebSocket Handler
participant BC as Broadcaster Loop
participant Clients as Connected Clients
participant Ch as Broadcast Channel
WS->>WS: Accept client connection
WS->>Clients: Add to clients set
WS->>WS: Launch receive loop (discard messages)
Note over BC: Dedicated broadcaster goroutine
BC->>Ch: Wait for BlockEvent
Ch-->>BC: BlockEvent received
BC->>Clients: Iterate all clients
BC->>Clients: Send event to each client
alt Broadcast Success
Clients-->>BC: Message sent ✓
else Broadcast Fails
BC->>BC: Mark client as failed
BC->>Clients: Remove from set (batched)
end
BC->>Ch: Wait for next event
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Test plan
Summary by CodeRabbit
New Features
Improvements