*Refactor so if we emit heart beat we treat it like we added a peer then set the timestamp after, in case the peer is disconnected on one side or to handle unknown unknowns

This commit is contained in:
Derrick Hammer 2022-12-16 09:34:14 -05:00
parent fbbc2a2e71
commit 57d35e77fc
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 4 additions and 1 deletions

View File

@ -324,7 +324,10 @@ export default class DHTCache extends EventEmitter {
return; return;
} }
this._addEntityConnection(id, bufId as Buffer); this.addPeerHandler({
remotePublicKey: id,
});
this._setEntity(bufId as Buffer, { heartbeat: Date.now() }); this._setEntity(bufId as Buffer, { heartbeat: Date.now() });
this.log.debug(`Heartbeat received from ${bufId.toString("hex")}`); this.log.debug(`Heartbeat received from ${bufId.toString("hex")}`);