Skip to content

Commit

Permalink
Add variable names n and m
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Jul 30, 2023
1 parent 2b0437d commit 5cb419b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,23 @@ if (import.meta.main) {
const cache = new BeaconCache(fastestNodeClient, 200 /* 10 min of beacons */);
const abortController = new AbortController();
for await (const beacon of watch(fastestNodeClient, abortController)) {
cache.add(beacon.round, beacon.signature);
const n = beacon.round; // n is the round we just received and process now
const m = n + 1; // m := n+1 refers to the next round in this current loop

cache.add(n, beacon.signature);

setTimeout(() => {
// This is called 100ms after publishing time (might be some ms later)
// From here we have ~300ms until the beacon comes in which should be
// enough for the query to finish. In case the query is not yet done,
// we can wait for the promise to be resolved.
// console.log(`Now : ${new Date().toISOString()}\nPublish time: ${new Date(timeOfRound(round)).toISOString()}`);
const round = beacon.round + 1;
const promise = queryIsIncentivized(client, config.contract, [round], botAddress).then(
const promise = queryIsIncentivized(client, config.contract, [m], botAddress).then(
(incentivized) => !!incentivized[0],
(_err) => false,
);
incentivizedRounds.set(round, promise);
}, publishedIn(beacon.round + 1) + 100);
incentivizedRounds.set(m, promise);
}, publishedIn(m) + 100);

const didSubmit = await loop({
client,
Expand Down

0 comments on commit 5cb419b

Please sign in to comment.