Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

use system.health to get isSyncing status #270

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ export class Client {
return this.api.rpc.system.syncState();
}

public async isSyncing(): Promise<boolean> {
const { isSyncing } = await this.api.rpc.system.health();
return isSyncing.isTrue;
}

public async startNode(path: string, nodeName: string): Promise<void> {
await tauri.invoke("start_node", { path, nodeName })
if (!this.firstLoad) {
Expand Down
4 changes: 3 additions & 1 deletion src/pages/PlottingProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,15 @@ export default defineComponent({
await this.$client.startSubscription();
util.infoLogger("PLOTTING PROGRESS | block subscription started")
this.syncState = (await this.$client.getSyncState()).toJSON() as unknown as SyncState;
let isSyncing = await this.$client.isSyncing();

do {
await new Promise((resolve) => setTimeout(resolve, 3000))
this.syncState = (await this.$client.getSyncState()).toJSON() as unknown as SyncState;
this.plottingData.status = `Syncing ${this.syncState.currentBlock} of ${this.syncState.highestBlock} blocks`
this.plottingData.finishedGB = (this.syncState.currentBlock * this.plottingData.allocatedGB) / this.syncState.highestBlock;
} while (this.syncState.currentBlock < this.syncState.highestBlock)
isSyncing = await this.$client.isSyncing();
} while (isSyncing);
},
startTimers() {
farmerTimer = window.setInterval(() => {
Expand Down