Skip to content

Commit

Permalink
express block duration in slots, not ms
Browse files Browse the repository at this point in the history
gotta go fast brrr (and not fuck up the timeline in the process)
  • Loading branch information
lemmon-714 authored Sep 20, 2024
1 parent 9d45156 commit a0328a5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/blaze-emulator/src/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -176,15 +176,15 @@ 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) {
clearInterval(this.eventLoop);
}
this.eventLoop = setInterval(() => {
this.stepForwardBlock();
}, 20000);
}, 20 * this.clock.slotLength);
}

/**
Expand Down

0 comments on commit a0328a5

Please sign in to comment.