Skip to content

Commit

Permalink
wdb-txdb: Add pagination indexes.
Browse files Browse the repository at this point in the history
HSD: handshake-org#888
BCOIN: bcoin-org/bcoin#605

Co-authored-by: Braydon Fuller <courier@braydon.com>
  • Loading branch information
nodech and braydonf committed Mar 20, 2024
1 parent 63bc227 commit 3146818
Show file tree
Hide file tree
Showing 4 changed files with 619 additions and 78 deletions.
22 changes: 20 additions & 2 deletions lib/wallet/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ exports.wdb = {
* -------
* R -> wallet balance
* r[account] -> account balance
* I -> Latest Unconfirmed Index
*
* Coin
* ----
Expand All @@ -106,19 +107,26 @@ exports.wdb = {
* -----------
* t[tx-hash] -> extended tx
* T[account][tx-hash] -> dummy (tx by account)
* m[time][tx-hash] -> dummy (tx by time)
* M[account][time][tx-hash] -> dummy (tx by time + account)
* z[height][index] -> tx hash (tx by count)
* Z[account][height][index] -> tx hash (tx by count + account)
* y[hash] -> count (count for tx)
* x[hash] -> undo count (unconfirmed count for tx)
*
* Confirmed
* ---------
* b[height] -> block record
* h[height][tx-hash] -> dummy (tx by height)
* H[account][height][tx-hash] -> dummy (tx by height + account)
* g[time][height][index][hash] -> dummy (tx by time)
* G[account][time][height][index][hash] -> dummy (tx by time + account)
*
* Unconfirmed
* -----------
* p[hash] -> dummy (pending tx)
* P[account][tx-hash] -> dummy (pending tx by account)
* w[time][count][hash] -> dummy (tx by time)
* W[account][time][count][hash] -> dummy (tx by time + account)
* e[hash] -> undo time (unconfirmed time for tx)
*
* Names
* -----
Expand All @@ -136,6 +144,7 @@ exports.txdb = {
// Balance
R: bdb.key('R'),
r: bdb.key('r', ['uint32']),
I: bdb.key('I'),

// Coin
c: bdb.key('c', ['hash256', 'uint32']),
Expand All @@ -148,15 +157,24 @@ exports.txdb = {
T: bdb.key('T', ['uint32', 'hash256']),
m: bdb.key('m', ['uint32', 'hash256']),
M: bdb.key('M', ['uint32', 'uint32', 'hash256']),
z: bdb.key('z', ['uint32', 'uint32']),
Z: bdb.key('Z', ['uint32', 'uint32', 'uint32']),
y: bdb.key('y', ['hash256']),
x: bdb.key('u', ['hash256']),

// Confirmed
b: bdb.key('b', ['uint32']),
h: bdb.key('h', ['uint32', 'hash256']),
H: bdb.key('H', ['uint32', 'uint32', 'hash256']),
g: bdb.key('g', ['uint32', 'uint32', 'uint32', 'hash256']),
G: bdb.key('G', ['uint32', 'uint32', 'uint32', 'uint32', 'hash256']),

// Unconfirmed
p: bdb.key('p', ['hash256']),
P: bdb.key('P', ['uint32', 'hash256']),
w: bdb.key('w', ['uint32', 'uint32', 'hash256']),
W: bdb.key('W', ['uint32', 'uint32', 'uint32', 'hash256']),
e: bdb.key('e', ['hash256']),

// Names
A: bdb.key('A', ['hash256']),
Expand Down
Loading

0 comments on commit 3146818

Please sign in to comment.