psibase
psibase copied to clipboard
Tokens service: GraphQL - Combined userCredits and userDebits queries
This is a nice to have; we're not planning immediate pagination support for Pending Transactions in the UI at the moment. But if/when we do want to paginate, we won't be able to do so with the current UI, which combines the userCredits and userDebits queries into one table.
Proposal
Table 1: Shared Balance Table
Almost identical to today's shared-balance table
| Column | Type | Description |
|---|---|---|
shared_bal_id |
u64 | <-- NEW! |
creditor |
accountnumber | |
debitor |
accountnumber | |
token_id |
TID (u32) | |
balance |
quantity |
Indexes:
- Primary key =
shared_bal_id
Table 2: User Pending Summary
Add two records for every shared balance record
- One for the creditor
- One for the debitor
| Column | Type |
|---|---|
user |
string |
token_id |
TID (u32) |
shared_bal_id |
u64 |
Indexes:
- Primary key =
{ User, token_id, shared_bal_id }
Notes:
- I think that other indexes for Shared Balance Table can be removed
- Enables efficient searches on:
- All pending transactions that involve a user (across all tokens, either creditor or debitor)
- All pending transactions that involve a user for a particular token (either creditor or debitor)