Skip to content

Commit

Permalink
don't convert the keys
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr authored Oct 7, 2024
1 parent a3e0be2 commit 9b4fc5a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1473,27 +1473,28 @@ 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) {
return [-1, buf];
}
}


function toContext(code, buf) {
if (code == "Graphsync") {
try {
Expand Down

0 comments on commit 9b4fc5a

Please sign in to comment.