Skip to content
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

Add getTransactions endpoint #136

Merged
merged 65 commits into from
May 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
c00ddae
Add cursor for getTransactions
aditya1702 Apr 12, 2024
2467dbe
Add validation of pagination and range
aditya1702 Apr 12, 2024
6aa348d
implement getTransactions handler - 1
aditya1702 Apr 15, 2024
7928c78
Add getLedgers
aditya1702 Apr 15, 2024
355b1e2
Read a single ledger instead of getting all ledgers
aditya1702 Apr 15, 2024
11baf9e
Add ParseCursor method for tx cursor
aditya1702 Apr 15, 2024
81eceff
Cursor changes - 1
aditya1702 Apr 15, 2024
83918f2
Cursor changes - 2
aditya1702 Apr 16, 2024
3d7f7d3
Cursor changes - 3
aditya1702 Apr 16, 2024
f509457
revert go-mod changes
aditya1702 Apr 16, 2024
f813d01
Use reader.Seek()
aditya1702 Apr 16, 2024
0e8b9da
Use reader.Seek() - 2
aditya1702 Apr 16, 2024
5156b9e
Add config-options for tx pagination limits
aditya1702 Apr 16, 2024
e4b34e5
Merge branch 'main' into get-transactions
aditya1702 Apr 16, 2024
35da2a5
Fix failing cursor test
aditya1702 Apr 16, 2024
35ed84d
Go mod changes
aditya1702 Apr 16, 2024
fce765b
Go mod changes - 2
aditya1702 Apr 16, 2024
60055da
Add unittests - 1
aditya1702 Apr 17, 2024
90f6b5b
Update go.mod and go.sum
aditya1702 Apr 17, 2024
36205ce
Merge branch 'main' into get-transactions
aditya1702 Apr 17, 2024
ba254f0
Add integration tests
aditya1702 Apr 18, 2024
18dbbd1
Merge branch 'main' into get-transactions
aditya1702 Apr 18, 2024
cb3eae9
Update go.mod and go.sum
aditya1702 Apr 18, 2024
a75205c
Add ledgerSeq to error string
aditya1702 Apr 18, 2024
65d2ab8
Add docstrings
aditya1702 Apr 18, 2024
dae0624
Change transactions limits
aditya1702 Apr 18, 2024
f1a0a87
add defensive check for error other than EOF
aditya1702 Apr 18, 2024
364ee92
add defensive check for error other than EOF - 2
aditya1702 Apr 18, 2024
aeb0a84
Change ledger sequence to uint32
aditya1702 Apr 18, 2024
2c5b2a4
Add comments/docstrings
aditya1702 Apr 18, 2024
95ce052
Include only cursor in response
aditya1702 Apr 18, 2024
c27d20c
Use toid instead of new cursor
aditya1702 Apr 22, 2024
6837f79
Revert cursor changes
aditya1702 Apr 22, 2024
9239dff
Merge branch 'main' into get-transactions
aditya1702 Apr 23, 2024
0f098fb
Return cursor as string in result
aditya1702 Apr 29, 2024
5f273a7
Merge branch 'main' into get-transactions
aditya1702 Apr 29, 2024
c9ddee4
Refactor reader.Seek error handling
aditya1702 Apr 29, 2024
d426361
Merge remote-tracking branch 'origin/get-transactions' into get-trans…
aditya1702 Apr 29, 2024
1c44f63
Small refactoring
aditya1702 Apr 30, 2024
850f208
Remove startLedger check
aditya1702 May 3, 2024
c45d333
Merge branch 'refs/heads/main' into get-transactions
aditya1702 May 3, 2024
be21a95
Remove endLedger
aditya1702 May 3, 2024
bd81a39
Merge branch 'refs/heads/database-backend' into get-transactions
aditya1702 May 3, 2024
088dff0
Import fix
aditya1702 May 3, 2024
74e2941
Fix failing tests
aditya1702 May 3, 2024
ca6c4ca
Refactor to use new transaction db
aditya1702 May 3, 2024
6d415dd
Refactor mocks
aditya1702 May 3, 2024
acaae61
Refactor unittests for using the new db changes
aditya1702 May 6, 2024
af41b32
Refactor integration test
aditya1702 May 6, 2024
90afd1e
Add config vars for max requests and request duration
aditya1702 May 6, 2024
31c80f7
Fix failing test
aditya1702 May 6, 2024
0a00590
Use transactionInfo struct instead of db.Transactions
aditya1702 May 8, 2024
0b19b17
Start indexing from 1 instead of 0 for toid
aditya1702 May 8, 2024
f85bdfb
Operation index from 1
aditya1702 May 9, 2024
4442348
Add lines to make sure structs implement interfaces
aditya1702 May 9, 2024
2d66084
Remove omitempty
aditya1702 May 9, 2024
f08dc00
rename test func
aditya1702 May 9, 2024
bc6cbba
make txInfo struct public and convert string cursor to int
aditya1702 May 10, 2024
68e45d5
Use sendSuccessfulTransaction helper func
aditya1702 May 10, 2024
21da905
Convert cursor to string in request
aditya1702 May 10, 2024
7e1a471
Change jrpc response codes
aditya1702 May 10, 2024
c63f8e1
Change ledger close meta code to invalid-params
aditya1702 May 13, 2024
a6a77b9
Revert back to InvalidParams error for reader.Read()
aditya1702 May 13, 2024
7509c6e
Refactor if-else statement
aditya1702 May 13, 2024
d4f9b54
Refactor if-else statement - 2
aditya1702 May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions cmd/soroban-rpc/internal/methods/get_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ LedgerLoop:
for ledgerSeq := start.LedgerSequence; ledgerSeq <= int32(ledgerRange.LastLedger.Sequence); ledgerSeq++ {
// Get ledger close meta from db
ledger, found, err := h.ledgerReader.GetLedger(ctx, uint32(ledgerSeq))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a thought for the future: we should probably do something more like getLedgers() and then process ledgers in batches so that we don't have to have one SQL query for each iteration (while still respecting limit, of course, but a little extra memory is worth saving queries).

We can include this as part of (or after, at the very least) the getLedgers work in #111.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shaptic Yeah I agree. We should do the batch processing as its more efficient.

if (err != nil) || (!found) {
code := jrpc2.InternalError
if err == nil {
err = errors.Errorf("ledger close meta not found: %d", ledgerSeq)
code = jrpc2.InvalidParams
if !found {
aditya1702 marked this conversation as resolved.
Show resolved Hide resolved
return GetTransactionsResponse{}, &jrpc2.Error{
Code: jrpc2.InvalidParams,
Message: errors.Errorf("ledger close meta not found: %d", ledgerSeq).Error(),
}
} else if err != nil {
return GetTransactionsResponse{}, &jrpc2.Error{
Code: code,
Code: jrpc2.InternalError,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why internal now? if it's not in the DB then their request is out of bounds

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment for all of the below error changes imo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shaptic Yeah you are correct. I refactored this code again to use InvalidParams for "ledger close meta not found" or for any other db related error, use the InternalError code.

However, for these 3 errors:

InternalError would make more sense dont you think? Since they are generated due to some internal parsing issues?

Message: err.Error(),
}
}
Expand Down