Skip to content

Commit

Permalink
fix: increase redstone rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsower committed Jul 22, 2024
1 parent 907d5c6 commit 5534e7e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/RedstoneServiceV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ export class RedstoneServiceV3 {
// Also, when forking anvil->anvil (when running on testnets) block.timestamp can be in future because min ts for block is 1 seconds,
// and scripts can take dozens of blocks (hundreds for faucet). So we take min value;
const nowMs = new Date().getTime();
const anvilTsS = 10 * Math.floor(Number(block.timestamp) / 10);
const fromNowTsS = 10 * Math.floor(nowMs / 10_000 - 1);
const redstoneIntervalS = 60;
const anvilTsS =
redstoneIntervalS *
Math.floor(Number(block.timestamp) / redstoneIntervalS);
const fromNowTsS =
redstoneIntervalS * Math.floor(nowMs / (redstoneIntervalS * 1000) - 1);
this.#optimisticTimestamp = Math.min(anvilTsS, fromNowTsS);
const deltaS = Math.floor(nowMs / 1000) - this.#optimisticTimestamp;
this.logger.info(
Expand Down

0 comments on commit 5534e7e

Please sign in to comment.