-
Notifications
You must be signed in to change notification settings - Fork 26
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
Changes from 1 commit
c00ddae
2467dbe
6aa348d
7928c78
355b1e2
11baf9e
81eceff
83918f2
3d7f7d3
f509457
f813d01
0e8b9da
5156b9e
e4b34e5
35da2a5
35ed84d
fce765b
60055da
90f6b5b
36205ce
ba254f0
18dbbd1
cb3eae9
a75205c
65d2ab8
dae0624
f1a0a87
364ee92
aeb0a84
2c5b2a4
95ce052
c27d20c
6837f79
9239dff
0f098fb
5f273a7
c9ddee4
d426361
1c44f63
850f208
c45d333
be21a95
bd81a39
088dff0
74e2941
ca6c4ca
6d415dd
acaae61
af41b32
90afd1e
31c80f7
0a00590
0b19b17
f85bdfb
4442348
2d66084
f08dc00
bc6cbba
68e45d5
21da905
7e1a471
c63f8e1
a6a77b9
7509c6e
d4f9b54
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 |
---|---|---|
|
@@ -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)) | ||
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, | ||
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. why internal now? if it's not in the DB then their request is out of bounds 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. same comment for all of the below error changes imo 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. @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(), | ||
} | ||
} | ||
|
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.
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 respectinglimit
, 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.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.
@Shaptic Yeah I agree. We should do the batch processing as its more efficient.