Skip to content

Conversation

@ordishs
Copy link
Collaborator

@ordishs ordishs commented Nov 21, 2025

Summary

  • Rename peerClient to legacyP2PClient for clarity across RPC and daemon services
  • Change InjectPeerForTesting to use *chainhash.Hash instead of string for type safety
  • Refactor handleGetpeerinfo with concurrent peer fetching using WaitGroup for improved performance
  • Simplify InjectPeerForTesting implementation using peerRegistry.Put
  • Use t.Context() instead of context.Background() for better test lifecycle management
  • Adjust p2p notification logging levels (Block=Info, others=Debug)

Test plan

  • Run existing unit tests
  • Run e2e daemon tests
  • Verify RPC getpeerinfo works correctly with concurrent peer fetching
  • Verify peer injection tests pass with new Hash type

oskarszoon and others added 4 commits November 20, 2025 10:18
- Rename peerClient to legacyP2PClient for clarity across RPC and daemon
- Change InjectPeerForTesting to use *chainhash.Hash instead of string
- Refactor handleGetpeerinfo with concurrent peer fetching using WaitGroup
- Simplify InjectPeerForTesting using peerRegistry.Put
- Use test context for better lifecycle management
- Adjust p2p notification logging levels (Block=Info, others=Debug)
@github-actions
Copy link
Contributor

github-actions bot commented Nov 21, 2025

🤖 Claude Code Review

Status: Complete


Current Review:
No issues found. All previously identified problems have been resolved:

  • Channel deadlock in handleGetpeerinfo - fixed by checking client existence before reading channels
  • Busy-wait in WaitForBlockhash - fixed by using require.Eventually
  • Missing newline in test output - fixed

History:

  • ✅ Fixed: Critical channel deadlock when either legacyP2PClient or p2pClient was nil (services/rpc/handlers.go:1148, 1189)
  • ✅ Fixed: Busy-wait loop replaced with require.Eventually for cleaner timeout handling (daemon/test_daemon.go:1304)
  • ✅ Fixed: Missing newline in test Printf statement (test/e2e/daemon/ready/multi_node_inject_test.go:60)

@ordishs ordishs requested a review from sugh01 November 21, 2025 17:06
@ordishs ordishs enabled auto-merge (squash) November 21, 2025 17:07
- Fix critical channel deadlock in handleGetpeerinfo when clients are nil
- Replace busy-wait with ticker in WaitForBlockhash test helper
- Change t.Errorf to t.Fatalf to properly halt tests on timeout
- Add missing newline in multi_node_inject_test.go Printf statement
Changed getPeersFunc to getPeerRegistryFunc in test mocks to match
the actual method being called by handleGetpeerinfo after the channel
deadlock fix.
Add defensive check in periodicEvaluation to use default 30s interval
if SyncCoordinatorPeriodicEvaluationInterval is zero or negative,
preventing time.NewTicker panic.
@ordishs ordishs merged commit 5fb0df4 into bsv-blockchain:main Nov 27, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants