-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(jsonrpc): implement eth_getBlockReceipts #6379
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: release_v4.8.1
Are you sure you want to change the base?
feat(jsonrpc): implement eth_getBlockReceipts #6379
Conversation
…Receipt Constructor
framework/src/main/java/org/tron/core/services/jsonrpc/types/TransactionReceipt.java
Outdated
Show resolved
Hide resolved
long cumulativeGas = 0; | ||
long cumulativeLogCount = 0; | ||
|
||
for (int index = 0; index < infoList.getTransactionInfoCount(); index++) { |
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.
Suggest judging the size of the list as empty and then recycling it.
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.
Suggest judging the size of the list as empty and then recycling it.
Hi, If the list is empty, the loop condition index < 0
will skip the loop entirely and return null
TransactionInfo info = infoList.getTransactionInfo(index); | ||
ResourceReceipt resourceReceipt = info.getReceipt(); | ||
|
||
if (info.getId().equals(txId)) { |
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.
Need to check if info.getId()
is null.
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.
Need to check if
info.getId()
is null.
Thank you for your suggestion. Adding null checks can improve code robustness, but I believe TransactionInfo objects should contain valid IDs. A null ID typically indicates data corruption or a system error, which points to serious issues in java-tron. In most cases, this is an unnecessary check, and adding it in every loop will increase overhead.
throws JsonRpcInvalidParamsException, JsonRpcInternalException { | ||
Block block = wallet.getByJsonBlockId(blockNumOrTag); | ||
if (block == null) { | ||
return null; |
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.
Return null or empty list?
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.
To be consistent with ethereum eth_getBlockReceipts logic, return null for blocks that are not found.
long cumulativeGas = 0; | ||
long cumulativeLogCount = 0; | ||
|
||
for (int index = 0; index < transactionInfoList.getTransactionInfoCount(); index++) { |
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.
Need to check if the transactionInfoList
is empty. If it is empty, it can be returned directly without going down.
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.
Hi, If the transactionInfoList
is empty, the loop condition index < 0 will skip the loop entirely and return receipts which is empty ArrayList<>()
What does this PR do?
Implement eth_getBlockReceipts method, from #5910
Why are these changes required?
This PR has been tested by:
Follow up
Extra details