Skip to content

Commit 6537dbb

Browse files
committed
update
1 parent 75b6728 commit 6537dbb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

wasm/light-client-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ckb-light-client-js",
3-
"version": "1.0.2",
3+
"version": "1.0.4",
44
"main": "dist/index.js",
55
"license": "MIT",
66
"devDependencies": {

wasm/light-client-js/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class LightClient {
2020
private commandInvokeLock: Mutex
2121
private traceLogBuffer: SharedArrayBuffer
2222
private stopping: boolean = false;
23+
private started: boolean = false;
2324
private traceLogCallback: (value: TraceRecord) => void | null = null;
2425
/**
2526
* Construct a LightClient instance.
@@ -94,8 +95,12 @@ class LightClient {
9495
}
9596
console.log("Exiting trace log fetcher..");
9697
})();
98+
this.started = true;
9799
}
98100
private invokeLightClientCommand(name: string, args?: any[]): Promise<any> {
101+
if (!this.started) {
102+
throw new Error("ckb-light-client not started yet!");
103+
}
99104
// Why use lock here?
100105
// light-client-wasm provides synchronous APIs, means if we send a call request through postMessage, onmessage will be called only when the command call resolved.
101106
// We use lock here to avoid multiple call to postMessage before onmessage fired, to avoid mixed result of different calls
@@ -138,6 +143,7 @@ class LightClient {
138143
this.dbWorker.terminate();
139144
this.lightClientWorker.terminate();
140145
this.stopping = true;
146+
this.started = false;
141147
}
142148
/**
143149
* Returns the header with the highest block number in the canonical chain

0 commit comments

Comments
 (0)