Skip to content

Commit

Permalink
chore: fixed finalization time
Browse files Browse the repository at this point in the history
  • Loading branch information
merklefruit committed Jun 9, 2024
1 parent 7fa843d commit 067b668
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions bolt-web-demo/frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ export default function Home() {
newSocket.on("new-event", (event: Event) => {
console.info("Event from server:", event);

if (event.type === EventType.NEW_SLOT) {
const slot = Number(event.message);
if (slot === preconfSlot + 64) {
setPreconfFinalized(true);
setFinalizationTimerActive(false);
dispatchEvent({
message: `Preconfirmed transaction finalized at slot ${slot}`,
timestamp: new Date().toISOString(),
});
}
}

// If the event has a special type, handle it differently
switch (event.type) {
case EventType.BEACON_CLIENT_URL_FOUND:
Expand Down Expand Up @@ -89,18 +101,6 @@ export default function Home() {
timestamp: new Date().toISOString(),
});
}

if (event.type === EventType.NEW_SLOT) {
const slot = Number(event.message);
if (slot === preconfSlot + 64) {
setPreconfFinalized(true);
setFinalizationTimerActive(false);
dispatchEvent({
message: `Preconfirmed transaction finalized at slot ${slot}`,
timestamp: new Date().toISOString(),
});
}
}
});

return () => {
Expand All @@ -127,8 +127,8 @@ export default function Home() {

if (inclusionTimerActive) {
interval = setInterval(() => {
setInclusionTime((prev) => prev + 2);
}, 2);
setInclusionTime((prev) => prev + 10);
}, 10);
} else {
clearInterval(interval);
}
Expand All @@ -141,8 +141,8 @@ export default function Home() {

if (finalizationTimerActive) {
interval = setInterval(() => {
setFinalizationTime((prev) => prev + 2);
}, 2);
setFinalizationTime((prev) => prev + 30);
}, 30);
} else {
clearInterval(interval);
}
Expand Down

0 comments on commit 067b668

Please sign in to comment.