-
Notifications
You must be signed in to change notification settings - Fork 220
chore(rpc): Fetch only block number for TransactionByBlockIDAndIndex #3296
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?
Changes from 2 commits
88d0596
38b8d72
0ccc7b7
529eaee
179ad67
69ed461
9094b97
499ee69
f59de0c
79ed446
008aa87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -550,12 +550,24 @@ func (h *Handler) TransactionByBlockIDAndIndex( | |||||||||||||||||||||||||||||
| return AdaptTransaction(pending.GetBlock().Transactions[txIndex]), nil | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| header, rpcErr := h.blockHeaderByID(blockID) | ||||||||||||||||||||||||||||||
| if rpcErr != nil { | ||||||||||||||||||||||||||||||
| return nil, rpcErr | ||||||||||||||||||||||||||||||
| var blockNumber uint64 | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| switch blockID.Type() { | ||||||||||||||||||||||||||||||
| case hash: | ||||||||||||||||||||||||||||||
| var err error | ||||||||||||||||||||||||||||||
| blockNumber, err = h.bcReader.BlockNumberByHash(blockID.Hash()) | ||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||
| return nil, rpccore.ErrBlockNotFound | ||||||||||||||||||||||||||||||
brbrr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| case number: | ||||||||||||||||||||||||||||||
| blockNumber = blockID.Number() | ||||||||||||||||||||||||||||||
| case l1Accepted, preConfirmed, latest: | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| case l1Accepted, preConfirmed, latest: | |
| case l1Accepted: | |
| header := h.L1Head() | |
| if header == nil { | |
| return nil, rpccore.ErrBlockNotFound | |
| } | |
| blockNumber = header.Number | |
| case latest: | |
| header := h.HeadsHeader() | |
| if header == nil { | |
| return nil, rpccore.ErrBlockNotFound | |
| } | |
| blockNumber = header.Number | |
| case preConfirmed: |
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.
l1Accepted should be like this, but use ChainHeight() for latest and PendingData() for preconfirmed.
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.
preConfirmed case is covered above the switch case. Also, it seems that we could follow the same logic for latest (assuming h.bcReader.Head() is better than following default code path)
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.
We're having 4 versions in v6, v7, v8 and v9, please also fix for the other versions.
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.
yup, I'll update other versions, once the v9 implementation is good enough :)
Uh oh!
There was an error while loading. Please reload this page.