Skip to content

@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 โ€‹

ts
new NoteCache(store, initial): NoteCache;

Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:45

Parameters โ€‹

ParameterType
storeNoteStore
initialNotesFile

Returns โ€‹

NoteCache

Properties โ€‹

store โ€‹

ts
readonly store: NoteStore;

Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:29

Accessors โ€‹

file โ€‹

Get Signature โ€‹

ts
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 โ€‹

NotesFile

The live notes file. Read for the resume cursor; never replaced.

Implementation of โ€‹

NoteSink.file


notes โ€‹

Get Signature โ€‹

ts
get notes(): readonly StoredNote[];

Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:48

Returns โ€‹

readonly StoredNote[]

Methods โ€‹

addHits() โ€‹

ts
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 โ€‹

ParameterType
hitsScanHit[]

Returns โ€‹

object

added โ€‹
ts
added: StoredNote[];
skipped โ€‹
ts
skipped: number;

Implementation of โ€‹

NoteSink.addHits


checkpoint() โ€‹

ts
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 โ€‹

ParameterType
cursornumber

Returns โ€‹

Promise<void>

Implementation of โ€‹

NoteSink.checkpoint


compact() โ€‹

ts
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() โ€‹

ts
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 โ€‹

ParameterType
idsIterable<string>

Returns โ€‹

Promise<void>


markSpent() โ€‹

ts
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 โ€‹

ParameterType
idsIterable<string>

Returns โ€‹

Promise<void>


open() โ€‹

ts
static open(store): Promise<NoteCache>;

Defined in: @lelantos-org/sdk/dist/wallet/note-cache.d.ts:46

Parameters โ€‹

ParameterType
storeNoteStore

Returns โ€‹

Promise<NoteCache>


reconcile() โ€‹

ts
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 โ€‹

ParameterType
rules{ release: (note) => boolean; spent: (note) => boolean; }
rules.release(note) => boolean
rules.spent(note) => boolean

Returns โ€‹

Promise<void>


refresh() โ€‹

ts
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>

Lelantosno cookies ๐Ÿช ยท no tracking ๐Ÿ‘๏ธ ยท no accounts ๐Ÿ‘คwalletexplorer4536080GitHub