-
Notifications
You must be signed in to change notification settings - Fork 221
fix: getBlockWithTx* fetch block header and txns separately #3322
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
base: main
Are you sure you want to change the base?
Conversation
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.
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 Additional details and impacted files@@ Coverage Diff @@
## main #3322 +/- ##
==========================================
+ Coverage 76.20% 76.26% +0.05%
==========================================
Files 346 346
Lines 32713 32816 +103
==========================================
+ Hits 24930 25027 +97
+ Misses 5993 5987 -6
- Partials 1790 1802 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fixes #3261