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

horizon/actions: use action handlers on transaction-related endpoints #1069

Merged
merged 9 commits into from
May 8, 2019

Conversation

howardtw
Copy link
Contributor

@howardtw howardtw commented Apr 1, 2019

This PR brings the changes in #894 to two other transaction related endpoints.

This PR also generalizes our handlers and query params. Now we have two different query params for all the endpoints called showActionQueryParams and indexActionQueryParams. And we also have three different handlers called showActionHandler, streamShowActionHandler, and streamIndexActionHander.

This PR brings the changes in stellar#894 to
two other transaction related endpoints.
@howardtw howardtw requested a review from tomquisel April 1, 2019 22:04
@howardtw howardtw changed the title horizon/actions: use transaction handler on related endpoints horizon/actions: use action handlers on transaction-related endpoints Apr 2, 2019
@howardtw howardtw self-assigned this Apr 2, 2019
@howardtw howardtw requested a review from bartekn April 26, 2019 20:34
Copy link
Contributor

@bartekn bartekn left a comment

Choose a reason for hiding this comment

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

LGTM 👍 (but I haven't run the code).

return nil, errors.Wrap(err, "getting horizon db session")
}

return actions.TransactionPage(ctx, &history.Q{horizonSession}, qp.accountID, qp.ledgerID, qp.includeFailedTxs, qp.pagingParams)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking out loud (and also don't remember if we discussed this in previous PRs):

It looks like functions like getTransactionPage or streamTransactions are wrappers around actions.* methods that really just check if param is correct (interface{}...) and pass DB session. If these type checks were moved to actions we could remove all such functions. It requires some refactoring but maybe it's worth it.

There's an obvious problem of circular package dependency but maybe we can solve this by moving indexActionQueryParams and showActionQueryParams to actions package (?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking maybe we can have a general query structure for all endpoints, but it seems like we categorize them into show and index . And at this point, it doesn't make sense to combine them given that we validate them differently. Last but not least, I think it's better to keep the query processing in the web layer and let action package focus on processing the data from DB. It will become more clear what's better for us later when most of the endpoints are converted 😃

@howardtw howardtw merged commit a4bbd5d into stellar:master May 8, 2019
@howardtw howardtw deleted the transaction-ledger branch May 8, 2019 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants