-
Notifications
You must be signed in to change notification settings - Fork 100
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
[sql-7] accounts: add SQL implementation of the accounts store #954
base: master
Are you sure you want to change the base?
Conversation
f326bdb
to
87fa366
Compare
87fa366
to
a018629
Compare
27c7272
to
9207179
Compare
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.
Generally looks great 🚀🔥! Just a few minor comments.
if opts.errIfAlreadyPending && | ||
currStatus != lnrpc.Payment_FAILED { | ||
|
||
return fmt.Errorf("payment with hash %s is "+ | ||
"already in flight or succeeded "+ | ||
"(status %v)", hash, currStatus) | ||
} |
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.
Should probably have commented this in kvdb PR, but this will return an error if the currStatus
is lnrpc.Payment_UNKOWN
, which seems a bit incorrect?
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.
as discussed offline, seems like a parallel issue right?
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.
I've rechecked this, and the current behavior is correct—it should return an error if currStatus != lnrpc.Payment_FAILED
. In other words, it should also error on lnrpc.Payment_UNKNOWN
.
I believe the confusion comes from the doc comments, which state that this only fails if the payment is "in-flight or succeeded." However, we actually treat lnrpc.Payment_UNKNOWN
as "in-flight" as well, which I think would be clearer if the docs mentioned that.
I can update the doc comments in a separate PR after this is merged if you'd like.
In this commit, we add the SQLStore type which implements the accounts.Store interface. To demonstrate that it works as expected, we also plug this implementation into all the account unit tests to show that they pass against the sqlite and postgres backends. One can use `make unit pkg=accounts tags=test_db_postgres` or `make unit pkg=accounts tags=test_db_sqlite` to test locally. Note that 2 small timestamp related changes are made to the unit tests. This is to compensate for timestamp precision in postgres.
9207179
to
21c0677
Compare
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.
LGTM 🚀!
Part of #917
In this commit, we add the SQLStore type which implements the
accounts.Store interface. To demonstrate that it works as expected, we
also plug this implementation into all the account unit tests to show
that they pass against the sqlite and postgres backends.
One can use
make unit pkg=accounts tags=test_db_postgres
ormake unit pkg=accounts tags=test_db_sqlite
to test locally.