-
Notifications
You must be signed in to change notification settings - Fork 222
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 all commits
deec1de
8289c52
6b0ec72
f14e771
0d86b26
e4c2509
f759f36
249163e
85c4b99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -537,7 +537,10 @@ func (h *Handler) TransactionByBlockIDAndIndex( | |
| return nil, rpccore.ErrInvalidTxIndex | ||
| } | ||
|
|
||
| if blockID.IsPreConfirmed() { | ||
| var blockNumber uint64 | ||
| var err error | ||
| switch blockID.Type() { | ||
| case preConfirmed: | ||
| pending, err := h.PendingData() | ||
| if err != nil { | ||
| return nil, rpccore.ErrBlockNotFound | ||
|
|
@@ -548,14 +551,32 @@ func (h *Handler) TransactionByBlockIDAndIndex( | |
| } | ||
|
|
||
| return AdaptTransaction(pending.GetBlock().Transactions[txIndex]), nil | ||
| case latest: | ||
| header, err := h.bcReader.HeadsHeader() | ||
| if err != nil { | ||
| return nil, rpccore.ErrBlockNotFound | ||
| } | ||
| blockNumber = header.Number | ||
| case hash: | ||
| blockNumber, err = h.bcReader.BlockNumberByHash(blockID.Hash()) | ||
| case number: | ||
| blockNumber = blockID.Number() | ||
| case l1Accepted: | ||
| var l1Head core.L1Head | ||
| l1Head, err = h.bcReader.L1Head() | ||
| if err != nil { | ||
| break | ||
| } | ||
| blockNumber = l1Head.BlockNumber | ||
| default: | ||
| panic("unknown block type id") | ||
| } | ||
|
|
||
| header, rpcErr := h.blockHeaderByID(blockID) | ||
| if rpcErr != nil { | ||
| return nil, rpcErr | ||
| if err != nil { | ||
| return nil, rpccore.ErrBlockNotFound | ||
| } | ||
|
|
||
| txn, err := h.bcReader.TransactionByBlockNumberAndIndex(header.Number, uint64(txIndex)) | ||
| txn, err := h.bcReader.TransactionByBlockNumberAndIndex(blockNumber, uint64(txIndex)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need v8, v9 and v10 only please |
||
| if err != nil { | ||
| return nil, rpccore.ErrInvalidTxIndex | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.