@spirobel/monero-wallet-api 0.4.0 → 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/io/atomicWrite.js +2 -1
- package/dist/io/logging.d.ts +40 -0
- package/dist/io/logging.js +172 -0
- package/dist/scanning-syncing/backgroundWorker.d.ts +1 -0
- package/dist/scanning-syncing/backgroundWorker.js +19 -7
- package/dist/scanning-syncing/blocksbuffer/blocksBufferFetchLoop.js +9 -7
- package/dist/scanning-syncing/blocksbuffer/blocksbufferCoordination.js +2 -1
- package/dist/scanning-syncing/scanSettings.d.ts +10 -0
- package/dist/scanning-syncing/scanSettings.js +9 -0
- package/dist/scanning-syncing/scanresult/scanCache.js +7 -3
- package/dist/scanning-syncing/scanresult/scanCoordination.js +63 -72
- package/dist/scanning-syncing/scanresult/scanResult.d.ts +1 -1
- package/dist/scanning-syncing/scanresult/scanResult.js +12 -3
- package/dist/scanning-syncing/worker-entrypoints/worker.js +1 -1
- package/dist/scanning-syncing/worker-mains/coordinator-main.js +3 -2
- package/dist/scanning-syncing/worker-mains/cpubound-main.js +24 -14
- package/dist/scanning-syncing/worker-mains/worker.js +11 -7
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { coordinatorMainMultithreaded } from "../scanresult/scanCoordination";
|
|
2
|
+
import { log } from "../../io/logging";
|
|
2
3
|
export async function coordinatorMainWorker(scan_settings_path, pathPrefix, cpuPorts) {
|
|
3
|
-
|
|
4
|
+
log("coordinatorMainWorker", "cpuPorts=" + cpuPorts?.length);
|
|
4
5
|
try {
|
|
5
6
|
const gen = coordinatorMainMultithreaded(scan_settings_path, pathPrefix, cpuPorts);
|
|
6
7
|
for await (const event of gen) {
|
|
7
|
-
|
|
8
|
+
log("coordinatorMainWorker", ["event:", event]);
|
|
8
9
|
if (event.type === "scan_ready") {
|
|
9
10
|
self.postMessage({
|
|
10
11
|
type: "SCAN_RESULT",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { sleep, ViewPair } from "../../api";
|
|
2
|
+
import { log } from "../../io/logging";
|
|
2
3
|
import {} from "../scanresult/scanLoop";
|
|
3
4
|
/**
|
|
4
5
|
* handle a single scan work item dispatched from the coordinator.
|
|
@@ -7,24 +8,24 @@ import {} from "../scanresult/scanLoop";
|
|
|
7
8
|
let callcounter = 0;
|
|
8
9
|
export async function handleCpuboundScan(msg, port) {
|
|
9
10
|
callcounter++;
|
|
10
|
-
|
|
11
|
+
log("handleCpuboundScan", "callcounter=" + callcounter);
|
|
11
12
|
if (!msg) {
|
|
12
|
-
|
|
13
|
+
log("handleCpuboundScan", "no content msg! ( ScanLoopInput = undefined )");
|
|
13
14
|
throw new Error("[cpubound] no content msg! ( ScanLoopInput = undefined )");
|
|
14
15
|
}
|
|
15
16
|
if (msg === "cancel") {
|
|
16
|
-
|
|
17
|
+
log("handleCpuboundScan", "cancel msg! ( ScanLoopInput = cancel )");
|
|
17
18
|
throw new Error("[cpubound] no content msg! ( ScanLoopInput = undefined )");
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
log("handleCpuboundScan", "got scan msg, walletConfig=" +
|
|
20
21
|
msg.walletConfig?.primary_address?.slice(0, 6));
|
|
21
22
|
const walletConfig = msg.walletConfig;
|
|
22
23
|
const item = msg;
|
|
23
24
|
if (!port) {
|
|
24
|
-
|
|
25
|
+
log("handleCpuboundScan", "no port!");
|
|
25
26
|
throw new Error("[cpubound] no port");
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
log("handleCpuboundScan", "primed, feeding workItem uuid=" +
|
|
28
29
|
(item && typeof item === "object"
|
|
29
30
|
? item.work_uuid?.slice(0, 8)
|
|
30
31
|
: "cancel"));
|
|
@@ -78,17 +79,26 @@ export async function handleCpuboundScan(msg, port) {
|
|
|
78
79
|
// the reconciliation workitembuffer -> blocksbuffer is done on every workitembuffer marked done at the end of the workbuffer (left end)
|
|
79
80
|
blockCount++;
|
|
80
81
|
if (blockCount % 10 === 0) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
log("handleCpuboundScan", [
|
|
83
|
+
"scanned " +
|
|
84
|
+
blockCount +
|
|
85
|
+
" " +
|
|
86
|
+
walletConfig.primary_address.slice(0, 6),
|
|
87
|
+
"@",
|
|
88
|
+
heighfrom,
|
|
89
|
+
"-",
|
|
90
|
+
heightto,
|
|
91
|
+
]);
|
|
85
92
|
}
|
|
86
93
|
await sleep(10); // make sure the loop is not tight
|
|
87
94
|
}
|
|
88
|
-
|
|
89
|
-
blockCount +
|
|
90
|
-
"
|
|
91
|
-
|
|
95
|
+
log("handleCpuboundScan", [
|
|
96
|
+
"scan done " + blockCount + " " + walletConfig.primary_address.slice(0, 6),
|
|
97
|
+
"@",
|
|
98
|
+
heighfrom,
|
|
99
|
+
"-",
|
|
100
|
+
heightto,
|
|
101
|
+
]);
|
|
92
102
|
return {
|
|
93
103
|
type: "Ready",
|
|
94
104
|
work_uuid: item.work_uuid,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { coordinatorMainWorker } from "./coordinator-main";
|
|
2
|
-
import {
|
|
2
|
+
import { handleCpuboundScanTry, sendFromCpuWorker } from "./cpubound-main";
|
|
3
|
+
import { log, setupLoggingPath } from "../../io/logging";
|
|
4
|
+
import { SCAN_SETTINGS_STORE_NAME_DEFAULT } from "../scanSettings";
|
|
3
5
|
self.onerror = (e) => self.postMessage({ type: "ERROR", payload: e });
|
|
4
6
|
self.addEventListener("unhandledrejection", (e) => self.postMessage({ type: "ERROR", payload: e.reason }));
|
|
5
7
|
let SCAN_SETTINGS_PATH;
|
|
@@ -8,13 +10,13 @@ let cpuPort;
|
|
|
8
10
|
export function CPU_PORT_HANDLER(pe) {
|
|
9
11
|
if (!cpuPort)
|
|
10
12
|
throw new Error("[cpubound] cpuPort is undefined in port.onmessage");
|
|
11
|
-
|
|
13
|
+
log("CPU_PORT_HANDLER", "new workitem msg received");
|
|
12
14
|
cpuPort.postMessage({
|
|
13
15
|
type: "WORKSTART",
|
|
14
16
|
work_uuid: pe.data.work_uuid,
|
|
15
17
|
});
|
|
16
18
|
handleCpuboundScanTry(pe.data, cpuPort).then((result) => {
|
|
17
|
-
|
|
19
|
+
log("CPU_PORT_HANDLER", "work finished, sending result");
|
|
18
20
|
if (!cpuPort)
|
|
19
21
|
throw new Error("[cpubound] cpuPort is undefined in port.onmessage");
|
|
20
22
|
cpuPort.onmessage = CPU_PORT_HANDLER;
|
|
@@ -23,19 +25,21 @@ export function CPU_PORT_HANDLER(pe) {
|
|
|
23
25
|
}
|
|
24
26
|
const handleMessage = async (e) => {
|
|
25
27
|
const msg = e.data;
|
|
26
|
-
|
|
28
|
+
log("handleMessage", ["msg received", msg]);
|
|
27
29
|
if (msg.type === "setup") {
|
|
28
|
-
|
|
30
|
+
const settingsPath = msg.scan_settings_path || SCAN_SETTINGS_STORE_NAME_DEFAULT;
|
|
31
|
+
SCAN_SETTINGS_PATH = settingsPath;
|
|
29
32
|
PATH_PREFIX = msg.pathPrefix;
|
|
33
|
+
await setupLoggingPath(settingsPath, msg.pathPrefix ?? "", msg.role, msg.cpu_worker_id);
|
|
30
34
|
if (msg.role === "cpubound") {
|
|
31
35
|
cpuPort = e.ports[0];
|
|
32
36
|
if (cpuPort) {
|
|
33
37
|
cpuPort.onmessage = CPU_PORT_HANDLER;
|
|
34
38
|
cpuPort.addEventListener("message", (e) => {
|
|
35
|
-
|
|
39
|
+
log("handleMessage", ["message received", e]);
|
|
36
40
|
});
|
|
37
41
|
cpuPort.addEventListener("messageerror", (e) => {
|
|
38
|
-
|
|
42
|
+
log("handleMessage", ["messageerror received", e]);
|
|
39
43
|
});
|
|
40
44
|
}
|
|
41
45
|
}
|