@lelantos-org/sdk / wallet / NoteCache
Class: NoteCache โ
Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:28
Where a sync writes what it finds.
Deliberately not a NoteStore: a store hands back a fresh NotesFile on every load(), so a sync that owned one would be mutating a second copy of state the wallet already holds in NoteCache โ and whichever of the two saved last would erase the other's writes. The sink is the live file, so exactly one NotesFile exists per wallet. NoteCache implements it.
Implements โ
Constructors โ
Constructor โ
new NoteCache(store, initial): NoteCache;Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:45
Parameters โ
| Parameter | Type |
|---|---|
store | NoteStore |
initial | NotesFile |
Returns โ
NoteCache
Properties โ
store โ
readonly store: NoteStore;Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:29
Accessors โ
file โ
Get Signature โ
get file(): NotesFile;Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:47
The live notes file. Read for the resume cursor; never replaced.
Returns โ
The live notes file. Read for the resume cursor; never replaced.
Implementation of โ
notes โ
Get Signature โ
get notes(): readonly StoredNote[];Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:48
Returns โ
readonly StoredNote[]
Methods โ
addHits() โ
addHits(hits): object;Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:66
Append scan hits to the live file. Synchronous, so it cannot interleave with a queued write; persistence is deferred to checkpoint so a sync still batches its store writes.
Parameters โ
| Parameter | Type |
|---|---|
hits | ScanHit[] |
Returns โ
object
added โ
added: StoredNote[];skipped โ
skipped: number;Implementation of โ
checkpoint() โ
checkpoint(cursor): Promise<void>;Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:71
Persist the current notes together with the sync resume cursor.
Parameters โ
| Parameter | Type |
|---|---|
cursor | number |
Returns โ
Promise<void>
Implementation of โ
compact() โ
compact(): Promise<{
removed: number;
}>;Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:58
Drop notes flagged spent: true. Returns removed count.
Returns โ
Promise<{ removed: number; }>
markPendingSpend() โ
markPendingSpend(ids): Promise<void>;Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:78
Reserve every note whose id is in ids against a spend of unknown outcome, then persist. See StoredNote.pendingSpendAt.
Parameters โ
| Parameter | Type |
|---|---|
ids | Iterable<string> |
Returns โ
Promise<void>
markSpent() โ
markSpent(ids): Promise<void>;Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:73
Flip spent for every note whose id is in ids, then persist.
Parameters โ
| Parameter | Type |
|---|---|
ids | Iterable<string> |
Returns โ
Promise<void>
open() โ
static open(store): Promise<NoteCache>;Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:46
Parameters โ
| Parameter | Type |
|---|---|
store | NoteStore |
Returns โ
Promise<NoteCache>
reconcile() โ
reconcile(rules): Promise<void>;Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:88
Apply spent-set reconciliation. spent(note) returns true when the note's nullifier was observed on-chain; release(note) returns true when its reservation no longer stands for anything โ either that same observation, or expiry.
Both in one pass, so a sync writes the notes file once and cannot leave a note marked spent while it still carries a reservation.
Parameters โ
| Parameter | Type |
|---|---|
rules | { release: (note) => boolean; spent: (note) => boolean; } |
rules.release | (note) => boolean |
rules.spent | (note) => boolean |
Returns โ
Promise<void>
refresh() โ
refresh(): Promise<void>;Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:56
Replace the in-memory snapshot with the store's current state.
For external mutation only. A sync does not need it: syncWallet writes through this cache via NoteSink, so the snapshot is already current when it returns.
Returns โ
Promise<void>