From 9b4fc5af758b0a2ac019c9b511f7ffda50112a08 Mon Sep 17 00:00:00 2001 From: LexLuthr <88259624+LexLuthr@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:11:54 +0400 Subject: [PATCH] don't convert the keys --- pages/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pages/index.js b/pages/index.js index 863496a..d58d2fc 100755 --- a/pages/index.js +++ b/pages/index.js @@ -1473,20 +1473,20 @@ function popProtocol(buf) { let [code, Vlen] = readVarint(buf, 0); buf = buf.slice(Vlen); - // Map of protocol codes to protocol names + // Map of protocol codes to protocol names (using decimal keys) const protocolMap = { 2304: "Bitswap", // 0x0900 2320: "Graphsync", // 0x0910 2336: "HTTP", // 0x0920 }; - // Convert code to hexadecimal for mapping - const hexCode = code.toString(16).toLowerCase(); - const protocolName = protocolMap[`0x${hexCode}`]; + const protocolName = protocolMap[code]; if (protocolName) { return [protocolName, buf]; } else { + // Optionally, handle unknown codes + console.warn(`Unknown protocol code: ${code}`); return [code, buf]; } } catch (e) { @@ -1494,6 +1494,7 @@ function popProtocol(buf) { } } + function toContext(code, buf) { if (code == "Graphsync") { try {