aboutsummaryrefslogtreecommitdiff
path: root/lib/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/wallet')
-rw-r--r--lib/wallet/cryptoApi.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/wallet/cryptoApi.ts b/lib/wallet/cryptoApi.ts
index 62f51f450..4b4a2e5dd 100644
--- a/lib/wallet/cryptoApi.ts
+++ b/lib/wallet/cryptoApi.ts
@@ -88,6 +88,9 @@ export class CryptoApi {
let {resolve, workerIndex} = this.rpcRegistry[id];
delete this.rpcRegistry[id];
let ws = this.workers[workerIndex];
+ if (!ws.busy) {
+ throw Error("assertion failed");
+ }
ws.busy = false;
this.numBusy--;
resolve(msg.data.result);
@@ -105,6 +108,7 @@ export class CryptoApi {
ws.w.postMessage(msg);
ws.busy = true;
this.numBusy++;
+ return;
}
}
};
@@ -146,20 +150,24 @@ export class CryptoApi {
});
}
+ console.log(`${this.numBusy} of ${this.workers.length} workers are busy`);
+ console.log(this.workers);
+
for (let i = 0; i < this.workers.length; i++) {
let ws = this.workers[i];
if (ws.busy) {
continue;
}
+ ws.busy = true;
+ this.numBusy++;
+
return new Promise<T>((resolve, reject) => {
let msg: any = {
operation, args,
id: this.registerRpcId(resolve, reject, i),
};
ws.w.postMessage(msg);
- ws.busy = true;
- this.numBusy++;
});
}