diff --git a/src/index.ts b/src/index.ts index 0d790c8..2509959 100644 --- a/src/index.ts +++ b/src/index.ts @@ -319,11 +319,13 @@ export default class DHTCache extends EventEmitter { let bufId = b4a.from(toId as Uint8Array) as Buffer; - if (signature && crypto.verify(bufData, signature, id)) { - this._addEntityConnection(id, bufId as Buffer); - this._setEntity(bufId as Buffer, { heartbeat: Date.now() }); + if (!(signature && crypto.verify(bufData, signature, id))) { + return; } + this._addEntityConnection(id, bufId as Buffer); + this._setEntity(bufId as Buffer, { heartbeat: Date.now() }); + this.log.debug( `Bootstrap response received from ${bufId.toString("hex")}` );