Skip to content

Commit

Permalink
Merge pull request #109 from saul-jb/fix/heads-exchange-validation
Browse files Browse the repository at this point in the history
fix: prevent heads exchange hanging
  • Loading branch information
tabcat authored Dec 6, 2023
2 parents ab04f97 + 61f253a commit 7dfa4dd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/utils/heads-exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,15 @@ export class HeadsExchange {

const localHash = await hashHeads(this.heads)
const remoteHash = CID.decode(message.hash)
const match = localHash.equals(remoteHash)

return {
match: localHash.equals(remoteHash)
if (this.verifyPromise == null) {
this.verifyPromise = new DeferredPromise(resolve => { resolve(match) })
} else {
this.verifyPromise?.resolve(match)
}

return { match }
}

private handleVerifyResponse (message: Message): void {
Expand Down

0 comments on commit 7dfa4dd

Please sign in to comment.