From a0328a5c5986c54c1d686d4c5f604aaff05ca1fe Mon Sep 17 00:00:00 2001 From: "Chris M. Hiatt" <69039074+lemmon-714@users.noreply.github.com> Date: Fri, 20 Sep 2024 12:59:10 +0200 Subject: [PATCH] express block duration in slots, not ms gotta go fast brrr (and not fuck up the timeline in the process) --- packages/blaze-emulator/src/emulator.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/blaze-emulator/src/emulator.ts b/packages/blaze-emulator/src/emulator.ts index b75c190..bcaab3f 100644 --- a/packages/blaze-emulator/src/emulator.ts +++ b/packages/blaze-emulator/src/emulator.ts @@ -155,9 +155,9 @@ export class Emulator { stepForwardBlock(): void { this.clock.block++; - const blockMs = 20_000; + const blockMs = 20 * this.clock.slotLength; this.clock.time += blockMs; - this.clock.slot += Math.floor(blockMs / this.clock.slotLength); + this.clock.slot += 20; Object.values(this.#mempool).forEach(({ inputs, outputs }) => { inputs.forEach(this.removeUtxo); @@ -176,7 +176,7 @@ export class Emulator { /** * Starts the event loop for the ledger. * If the event loop is already running, it is cleared and restarted. - * The event loop calls the stepForwardBlock method every 20 seconds. + * The event loop calls the stepForwardBlock method every 20 slots. */ startEventLoop() { if (this.eventLoop) { @@ -184,7 +184,7 @@ export class Emulator { } this.eventLoop = setInterval(() => { this.stepForwardBlock(); - }, 20000); + }, 20 * this.clock.slotLength); } /**