-
Notifications
You must be signed in to change notification settings - Fork 6
fix(peergov): initial peers and guard against nil #1060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
📝 WalkthroughWalkthroughA new Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes The changes are straightforward and minimal:
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 1 file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
peergov/peergov.go (1)
87-97: Nil-guard when pruning topology-sourced peers prevents panicsThe
tmpPeer == nilcheck correctly protects thetmpPeer.Sourceaccess and matches the existing defensive pattern elsewhere (GetPeers,startOutboundConnections,peerIndexBy*). Behaviorally, silently skipping nils is safe; if nil entries are not expected under normal operation, you might optionally add a debug-level log here to aid future diagnostics, but it’s not required for correctness.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
peergov/peergov.go(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: wolf31o2
Repo: blinklabs-io/dingo PR: 1036
File: peergov/peergov.go:78-105
Timestamp: 2025-11-22T22:57:02.415Z
Learning: In the blinklabs-io/dingo repository, metric names in peergov/peergov.go (specifically cardano_node_metrics_peerSelection_ActivePeers, cardano_node_metrics_peerSelection_EstablishedPeers, and cardano_node_metrics_peerSelection_KnownPeers) use PascalCase to match the Haskell node implementation for ecosystem tooling compatibility between the Haskell node, Amaru, and Dingo.
🧬 Code graph analysis (1)
peergov/peergov.go (1)
peergov/peer.go (1)
Peer(36-43)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: nilaway
- GitHub Check: lint
- GitHub Check: go-test (1.24.x, macos-latest)
- GitHub Check: go-test (1.24.x, ubuntu-latest)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
peergov/peergov.go (1)
51-59: Explicit peers slice initialization is safe and clearInitializing
peersto an empty slice is consistent with how it’s used elsewhere (len checks, range, appends) and avoids any surprises for callers that might rely on a non-nil slice. No issues from a correctness or concurrency standpoint given the existing mutex usage around mutations.
Summary by cubic
Initialize the peers slice in NewPeerGovernor and skip nil entries in LoadTopologyConfig. This prevents nil-pointer panics during topology cleanup and ensures a predictable empty state.
Written for commit b9770b0. Summary will update automatically on new commits.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.