fix: getBlockWithTx* fetch block header and txns separately#3322
fix: getBlockWithTx* fetch block header and txns separately#3322
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors block fetching to separate header and transaction retrieval as part of fixing issue #3261. The change aims to optimize performance by allowing header and transaction data to be fetched independently rather than always fetching the entire block.
Key changes:
- Added new
blockTxnsByNumberhelper method andTransactionsByBlockNumberblockchain reader method to fetch transactions separately - Refactored
BlockWithTxHashesandBlockWithTxsto callblockHeaderByIDandblockTxnsByNumberseparately instead ofblockByID - Updated
blockStatussignature to accept block number directly instead of the full block
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| rpc/v9/helpers.go | Added new blockTxnsByNumber helper to fetch transactions by block number |
| rpc/v9/block.go | Refactored BlockWithTxHashes and BlockWithTxs to use separate header and transaction fetches; updated blockStatus to accept block number |
| blockchain/blockchain.go | Added new TransactionsByBlockNumber method to Reader interface and implementation |
| mocks/mock_blockchain.go | Added mock implementation for TransactionsByBlockNumber method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (49.31%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #3322 +/- ##
==========================================
- Coverage 75.98% 75.26% -0.73%
==========================================
Files 377 377
Lines 34614 34772 +158
==========================================
- Hits 26301 26170 -131
- Misses 6466 6531 +65
- Partials 1847 2071 +224 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Yaroslav Kukharuk <[email protected]>
fixes #3261