Skip to content

Commit

Permalink
fix: findPeerWithStoreKey
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Sep 19, 2024
1 parent f85c8e1 commit dc4238e
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/DigNetwork/DigNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,29 +180,23 @@ export class DigNetwork {

console.log(peerIp, storeResponse.headers);

if (
storeResponse.success &&
storeResponse.headers?.["x-has-rootHash"] === "true"
) {
if (!key) return peerIp;
if (storeResponse.headers?.["x-has-roothash"] === "true") {
console.log(
`Found Peer at ${peerIp} for storeId: ${storeId}, root hash ${rootHash}`
);

if (!key) {
return peerIp;
}

const keyResponse = await digPeer.contentServer.headKey(key);
if (
keyResponse.success &&
keyResponse.headers?.["x-key-exists"] === "true"
) {
if (keyResponse.headers?.["x-key-exists"] === "true") {
return peerIp;
}
}

peerBlackList.push(peerIp);
} catch (error) {
console.error(
"Error while sampling the epoch or contacting peer:",
error
);
break;
}
} catch {}
}

return null;
Expand Down

0 comments on commit dc4238e

Please sign in to comment.