Closed m-Peter closed 2 months ago
The pull request introduces changes to the BlockChainAPI
methods, focusing on transaction and block data retrieval. It replaces direct calls to GetTransactionByHash
with a new method, prepareTransactionResponse
, enhancing code structure. The prepareBlockResponse
method has also been simplified by removing the context parameter. These modifications aim to improve code readability and maintainability by centralizing transaction handling and reducing redundancy.
File | Change Summary |
---|---|
api/api.go | - Added prepareTransactionResponse method. - Modified prepareBlockResponse to remove context parameter. |
Objective | Addressed | Explanation |
---|---|---|
Block endpoints with many transactions fail with rate limit error (#547) | ✅ |
prepareBlockResponse
method, directly related to the changes made in this PR.🐰 In the blockchain's dance, we tidy up,
With methods refined, we fill the cup.
Transactions flow, no more a mess,
Simplified calls, we surely impress!
Hopping along, our code shines bright,
A clearer path, oh what a delight! 🌟
api/api.go (4)
Line range hint `278-288`: **LGTM!** The changes to `GetTransactionByBlockHashAndIndex` look good. Extracting the transaction retrieval and response preparation logic into `b.prepareTransactionResponse` improves code readability and maintainability. --- Line range hint `326-332`: **LGTM!** The changes to `GetTransactionByBlockNumberAndIndex` look good. Extracting the transaction retrieval and response preparation logic into `b.prepareTransactionResponse` improves code readability and maintainability. --- Line range hint `935-950`: **LGTM!** The changes to `fetchBlockTransactions` look good. Using `b.prepareTransactionResponse` to prepare each transaction response improves code readability and maintainability. --- `953-967`: **LGTM!** The new `prepareTransactionResponse` function looks good. Extracting the transaction retrieval and response preparation logic into a separate function reduces code duplication and improves readability.
Closes: https://github.com/onflow/flow-evm-gateway/issues/547
Description
To avoid this, instead of re-using the
eth_getTransactionByHash
method directly, we extract its logic to a helper function, avoiding the possibility of rate-limit errors for blocks with many transactions.For contributor use:
master
branchFiles changed
in the Github PR explorerSummary by CodeRabbit
New Features
Improvements
These changes enhance the overall efficiency and maintainability of the blockchain API, leading to a smoother user experience.