Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
geoknee committed Nov 7, 2024
1 parent af0af7b commit 961b124
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,20 @@ async function main() {
console.log("⚒️ tx confirmed")


var log0: string
var log1: string
var aR: string
async function queryState() {
console.log("\nQuerying results...", period * counter++, "ms");

const log0 = await worker0.localResultLog()
log0 = await worker0.localResultLog()
console.log("worker0 (LOCAL) cached results have length:", log0.slice(2).length)

const log1 = await worker1.localResultLog()
log1 = await worker1.localResultLog()
console.log("worker1 (REMOTE) cached results have length:", log1.slice(2).length)

const aR = await interopPoW.allResults()
aR = await interopPoW.allResults()
console.log("InteropPoW.allResults has length:", aR.slice(2).length)

}
// wait for event
// event subscriptions are not supported, so we resort
Expand All @@ -150,12 +152,16 @@ async function main() {
let counter = 0;

async function runInterval() {
if (counter > 20 ||
aR && log0 && log1 && aR.slice(2).length == log0.slice(2).length + log1.slice(2).length) {
return
}
try {
const result = await queryState();
console.log(result);
await queryState();
} catch (error) {
console.error("Error:", error);
} finally {
counter++
setTimeout(runInterval, period); // Schedule the next run after completion
}
}
Expand Down

0 comments on commit 961b124

Please sign in to comment.