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

accounts: Credit and debit accounts DB additions prep #973

Conversation

ViktorTigerstrom
Copy link
Contributor

Part of #648

Based on #954

This PR adds DB preparation required in order to support functionality which allows crediting or debiting an account's balance by a given amount, rather than the current update method, which sets the balance to a specific value.

ellemouton and others added 6 commits January 31, 2025 08:54
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.
In preparation for the upcoming credit/debit accounts feature, rename
the store `IncreaseAccountBalance` method to `CreditAccount` to better
reflect its purpose.
To support decreasing an existing off-chain account’s balance by a
specified amount in the database, we'll first implement the
functionality in the db stores. This commit introduces the
`DebitAccount` function in the kvdb store.
This commit introduces the `DebitAccount` function in the sqlc store, to
support decreasing the balance of an existing off-chain account by a
specified amount for sql backends.

We'll also add testing of the store functionality, as both stores now
support the `DebitAccount` operation.
This commit adds a separate `CreditAccount` query to the sql db, to
incentivize not setting the balance directly, but rather instead
increase and decrease the balance by a specific amount.

We also update the sql store to use the new query in the `CreditAccount`
method.
@ViktorTigerstrom
Copy link
Contributor Author

Closing this in favour of #981 & #982.

@ellemouton, please include the functionality of e10ae03 in #954, if #981 is merged prior to #954.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog This PR is does not require a release notes entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants