-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mint: issued and redeemed ecash for db
- Loading branch information
Showing
6 changed files
with
186 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
mint/storage/sqlite/migrations/000010_keyset_balance_view.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DROP VIEW total_issued; | ||
DROP VIEW total_redeemed; |
19 changes: 19 additions & 0 deletions
19
mint/storage/sqlite/migrations/000010_keyset_balance_view.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- drop previous balance views | ||
DROP VIEW minted_ecash; | ||
DROP VIEW melted_ecash; | ||
DROP VIEW balance; | ||
|
||
-- create new balance views by keyset | ||
CREATE VIEW IF NOT EXISTS total_issued AS | ||
SELECT keyset_id, COALESCE(amount, 0) AS balance FROM ( | ||
SELECT keyset_id, SUM(amount) AS amount | ||
FROM blind_signatures | ||
GROUP BY keyset_id | ||
); | ||
|
||
CREATE VIEW IF NOT EXISTS total_redeemed AS | ||
SELECT keyset_id, COALESCE(amount, 0) AS balance FROM ( | ||
SELECT keyset_id, SUM(amount) AS amount | ||
FROM proofs | ||
GROUP BY keyset_id | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters