From ed43a12f276a40a45e291c459b9121d010731858 Mon Sep 17 00:00:00 2001 From: Inkvi Date: Tue, 12 Mar 2024 14:11:55 -0700 Subject: [PATCH] Search in a set should be done differently --- app/api/cache/route.ts | 2 +- app/api/packets/route.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/cache/route.ts b/app/api/cache/route.ts index 87553bd..6569d81 100644 --- a/app/api/cache/route.ts +++ b/app/api/cache/route.ts @@ -30,7 +30,7 @@ export async function GET(request: NextRequest) { // Set cache concurrently await Promise.all([ cache.set('allChannels', channels, -1), - // cache.set('allPackets', packets, -1), + cache.set('allPackets', packets, -1), ]); console.log(`Fetched packets and channels in ${Date.now() - start}ms`); diff --git a/app/api/packets/route.ts b/app/api/packets/route.ts index a6e2fc6..0cad638 100644 --- a/app/api/packets/route.ts +++ b/app/api/packets/route.ts @@ -65,7 +65,7 @@ export async function getPackets() { let channel; try { - console.log(`Getting channel for port ${portId} and channel ${srcChannelId}`); + console.log(`Getting channel for port ${portId} and channel ${srcChannelId} and sequence ${sequence}`); channel = await tmClient.ibc.channel.channel(portId, srcChannelId); } catch (e) { console.log('Skipping packet for channel: ', srcChannelId); @@ -201,7 +201,7 @@ export async function getPackets() { } const key = `${channel.channel.counterparty.portId}-${channel.channel.counterparty.channelId}-${sequence}`; - if (key in unprocessedPacketKeys) { + if (unprocessedPacketKeys.has(key)) { packets[key].state = PacketStates.WRITE_ACK; unprocessedPacketKeys.delete(key); } @@ -249,7 +249,7 @@ export async function getPackets() { return; } - if (key in unprocessedPacketKeys) { + if (unprocessedPacketKeys.has(key)) { packets[key].state = PacketStates.RECV; unprocessedPacketKeys.delete(key); }