@spirobel/monero-wallet-api 0.3.18 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +5 -2
- package/dist/api.js +5 -1
- package/dist/io/atomicWrite.js +3 -1
- package/dist/io/indexedDB.js +7 -2
- package/dist/io/logging.d.ts +40 -0
- package/dist/io/logging.js +172 -0
- package/dist/keypairs-seeds/keypairs.d.ts +21 -0
- package/dist/keypairs-seeds/keypairs.js +21 -0
- package/dist/node-interaction/binaryEndpoints.d.ts +31 -2
- package/dist/node-interaction/binaryEndpoints.js +61 -43
- package/dist/node-interaction/jsonEndpoints.d.ts +257 -130
- package/dist/node-interaction/jsonEndpoints.js +159 -119
- package/dist/node-interaction/nodeUrl.d.ts +21 -6
- package/dist/node-interaction/nodeUrl.js +50 -8
- package/dist/scanning-syncing/backgroundWorker.d.ts +10 -6
- package/dist/scanning-syncing/backgroundWorker.js +88 -39
- package/dist/scanning-syncing/blocksbuffer/blocksBufferFetchLoop.d.ts +44 -0
- package/dist/scanning-syncing/blocksbuffer/blocksBufferFetchLoop.js +355 -0
- package/dist/scanning-syncing/blocksbuffer/blocksbufferCoordination.d.ts +15 -0
- package/dist/scanning-syncing/blocksbuffer/blocksbufferCoordination.js +28 -0
- package/dist/scanning-syncing/{scanresult → blocksbuffer}/getBlocksbinBuffer.d.ts +5 -5
- package/dist/scanning-syncing/{scanresult → blocksbuffer}/getBlocksbinBuffer.js +7 -5
- package/dist/scanning-syncing/connectionStatus.d.ts +33 -9
- package/dist/scanning-syncing/connectionStatus.js +89 -19
- package/dist/scanning-syncing/scanSettings.d.ts +21 -0
- package/dist/scanning-syncing/scanSettings.js +29 -0
- package/dist/scanning-syncing/scanresult/reorg.d.ts +0 -11
- package/dist/scanning-syncing/scanresult/reorg.js +39 -16
- package/dist/scanning-syncing/scanresult/scanCache.d.ts +16 -2
- package/dist/scanning-syncing/scanresult/scanCache.js +65 -5
- package/dist/scanning-syncing/scanresult/scanCacheOpened.d.ts +18 -0
- package/dist/scanning-syncing/scanresult/scanCacheOpened.js +56 -11
- package/dist/scanning-syncing/scanresult/scanCoordination.d.ts +127 -0
- package/dist/scanning-syncing/scanresult/scanCoordination.js +602 -0
- package/dist/scanning-syncing/scanresult/scanLoop.d.ts +20 -0
- package/dist/scanning-syncing/scanresult/scanLoop.js +116 -0
- package/dist/scanning-syncing/scanresult/scanResult.d.ts +24 -3
- package/dist/scanning-syncing/scanresult/scanResult.js +159 -97
- package/dist/scanning-syncing/worker-entrypoints/worker.js +1 -1
- package/dist/scanning-syncing/worker-mains/coordinator-main.d.ts +1 -0
- package/dist/scanning-syncing/worker-mains/coordinator-main.js +24 -0
- package/dist/scanning-syncing/worker-mains/cpubound-main.d.ts +5 -0
- package/dist/scanning-syncing/worker-mains/cpubound-main.js +122 -0
- package/dist/scanning-syncing/worker-mains/worker.d.ts +1 -1
- package/dist/scanning-syncing/worker-mains/worker.js +62 -6
- package/dist/viewpair/ViewPair.d.ts +30 -7
- package/dist/viewpair/ViewPair.js +56 -118
- package/dist/wasm-processing/wasmFile.js +1 -1
- package/package.json +22 -24
- package/dist/io/extension.d.ts +0 -18
- package/dist/io/extension.js +0 -11
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type GetBlocksBinBufferItem, type BlocksBufferLoopResult, type BlocksBufferIteratorResult, type ProcessScanResult, type BlockInfo } from "../../api";
|
|
2
|
+
import { type ScanLoopYield } from "./scanLoop";
|
|
3
|
+
import { type WorkItem } from "./scanLoop";
|
|
4
|
+
import { type ScanSettings } from "../scanSettings";
|
|
5
|
+
import { type CacheRange, type ScanCache } from "./scanCache";
|
|
6
|
+
export type WalletConfig = {
|
|
7
|
+
primary_address: string;
|
|
8
|
+
secret_view_key: string;
|
|
9
|
+
secret_spend_key?: string;
|
|
10
|
+
subaddress_index: number;
|
|
11
|
+
};
|
|
12
|
+
export type WalletConfigPlusCache = {
|
|
13
|
+
primary_address: string;
|
|
14
|
+
secret_view_key: string;
|
|
15
|
+
secret_spend_key?: string;
|
|
16
|
+
subaddress_index: number;
|
|
17
|
+
cache: ScanCache;
|
|
18
|
+
};
|
|
19
|
+
export type WorkToBeDone = {
|
|
20
|
+
start_height: number;
|
|
21
|
+
wallet_configs: WalletConfigPlusCache[];
|
|
22
|
+
anchor_range: CacheRange;
|
|
23
|
+
scan_settings: ScanSettings;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* this depends only on ScanSettings.json start_height and wallet caches scanned_ranges
|
|
27
|
+
* side effect: will init wallet cache file if it does not exist
|
|
28
|
+
* side effect: will merge scan ranges + add subaddreses to existing cache files
|
|
29
|
+
* @param scan_settings_path
|
|
30
|
+
*/
|
|
31
|
+
export declare function findWorkToBeDone(scan_settings_path?: string, pathPrefix?: string): Promise<WorkToBeDone | false>;
|
|
32
|
+
export declare function workToBeDoneForBatch(cache: ScanCache, batch_meta_infos: BlockInfo[]): "skip" | {
|
|
33
|
+
from: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* called when the blocks buffer generator yields "blocks_buffer_changed".
|
|
37
|
+
* adds new work items for blocks buffer items not yet referenced.
|
|
38
|
+
* per wallet
|
|
39
|
+
*/
|
|
40
|
+
export declare function makeWorkItemsFromBlocksBuffer(blocksBuffer: GetBlocksBinBufferItem[], workItemBuffer: WorkItem[], walletConfig: WalletConfigPlusCache, from?: number, to?: number): void;
|
|
41
|
+
export declare function makeWorkItemsForAllWallets(wallet_configs: WalletConfigPlusCache[], blocksBuffer: GetBlocksBinBufferItem[], workBuffer: WorkItem[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* called when a work item at the left end of the work buffer is done.
|
|
44
|
+
* shifts done items off the left, and removes their batch from the
|
|
45
|
+
* blocks buffer if no remaining work items reference it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function reconcileWorkItemDone(blocksBuffer: GetBlocksBinBufferItem[], workItemBuffer: WorkItem[]): void;
|
|
48
|
+
/**
|
|
49
|
+
* one round of the select race. takes two primed promises (blocks, scan),
|
|
50
|
+
* races them, returns winner info. the loser stays in flight.
|
|
51
|
+
*/
|
|
52
|
+
export declare function raceStep(blocksPromise: Promise<IteratorResult<BlocksBufferLoopResult>>, scanPromise: Promise<IteratorResult<ScanLoopYield, void>>): Promise<{
|
|
53
|
+
src: "blocks" | "scan";
|
|
54
|
+
value: IteratorResult<BlocksBufferLoopResult> | IteratorResult<ScanLoopYield, void>;
|
|
55
|
+
done: boolean;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* handle a yield from the blocks buffer fetch loop.
|
|
59
|
+
*/
|
|
60
|
+
export declare function handleBlocksYield(value: BlocksBufferLoopResult, scanSettingsPath?: string): Promise<{
|
|
61
|
+
isBlocksBufferChanged: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* process a scan result for a completed work item.
|
|
65
|
+
* updates the cache, writes to disk, marks work item done, reconciles.
|
|
66
|
+
*/
|
|
67
|
+
export declare function processScanResultForWorkItem(value: ScanLoopYield, workBuffer: WorkItem[], blocksBuffer: GetBlocksBinBufferItem[], pathPrefix: string, secret_spend_key?: string): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* process a scan result for a completed work item.
|
|
70
|
+
* updates the cache, writes to disk, marks work item done, reconciles blockbuffer with this.
|
|
71
|
+
*/
|
|
72
|
+
export declare function processWorkItem(item: WorkItem, workBuffer: WorkItem[], blocksBuffer: GetBlocksBinBufferItem[], pathPrefix: string, secret_spend_key?: string): Promise<ProcessScanResult>;
|
|
73
|
+
export type CoordinatorEvent = {
|
|
74
|
+
type: "blocks_buffer_changed";
|
|
75
|
+
} | {
|
|
76
|
+
type: "connection_status";
|
|
77
|
+
status: any;
|
|
78
|
+
} | {
|
|
79
|
+
type: "scan_ready";
|
|
80
|
+
address: string;
|
|
81
|
+
result: ScanLoopYield;
|
|
82
|
+
newCache: ScanCache;
|
|
83
|
+
changed_outputs: {
|
|
84
|
+
output: any;
|
|
85
|
+
change_reason: string;
|
|
86
|
+
}[];
|
|
87
|
+
} | {
|
|
88
|
+
type: "all_idle";
|
|
89
|
+
} | {
|
|
90
|
+
type: "error";
|
|
91
|
+
error: Error;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* coordinator main: async generator that drives the full scan cycle.
|
|
95
|
+
* takes only scanSettingsPath, derives everything else internally.
|
|
96
|
+
* yields events for some of the underlying generator events,
|
|
97
|
+
* look at CoordinatorEvent, processing not decoupled from cpu bound scan work,
|
|
98
|
+
* as this single threaded, there is no point
|
|
99
|
+
*/
|
|
100
|
+
export declare function coordinatorMain(scanSettingsPath?: string, pathPrefix?: string): AsyncGenerator<CoordinatorEvent>;
|
|
101
|
+
export declare function setupCoordinator(scanSettingsPath?: string, pathPrefix?: string): Promise<false | {
|
|
102
|
+
blocksGenerator: AsyncGenerator<BlocksBufferLoopResult, any, any>;
|
|
103
|
+
workBuffer: WorkItem[];
|
|
104
|
+
blocksBuffer: GetBlocksBinBufferItem[];
|
|
105
|
+
work_to_be_done: WorkToBeDone;
|
|
106
|
+
}>;
|
|
107
|
+
export type WalletSyncInfo = {
|
|
108
|
+
walletConfig: WalletConfig;
|
|
109
|
+
work_buffer: WorkItem[];
|
|
110
|
+
};
|
|
111
|
+
export type PortStatus = {
|
|
112
|
+
port: MessagePort;
|
|
113
|
+
promise: Promise<ScanLoopYield> | null;
|
|
114
|
+
};
|
|
115
|
+
export type BlocksBufferRacer = {
|
|
116
|
+
src: "blocks";
|
|
117
|
+
value: BlocksBufferIteratorResult;
|
|
118
|
+
};
|
|
119
|
+
export type ScanLoopRacer = ScanLoopYield;
|
|
120
|
+
export type Racers = BlocksBufferRacer | ScanLoopRacer;
|
|
121
|
+
/**
|
|
122
|
+
* coordinator main (multithreaded): dispatches scan work to CPU workers
|
|
123
|
+
* via MessagePorts, processes results in order per wallet.
|
|
124
|
+
* falls back to single-threaded coordinator if no cpuPorts provided.
|
|
125
|
+
*/
|
|
126
|
+
export declare function coordinatorMainMultithreaded(scanSettingsPath?: string, pathPrefix?: string, cpuPorts?: MessagePort[]): AsyncGenerator<CoordinatorEvent>;
|
|
127
|
+
export declare function scheduleWorkOnCpuPorts(ports: PortStatus[], work_buffer: WorkItem[]): Promise<void>;
|