*Refactor so every call to addPeerHandler, we only add if it's not there, vs aborting completely if in connectedTo. This will ensure we stay alive via heartbeats even in edge cases
This commit is contained in:
parent
dd21b0fa30
commit
225537fc39
|
@ -178,11 +178,11 @@ export default class DHTCache extends EventEmitter {
|
|||
protected addPeerHandler(peer: any) {
|
||||
const id = peer.remotePublicKey;
|
||||
const stringId = id.toString("hex");
|
||||
if (this.connectedTo.has(stringId)) {
|
||||
return;
|
||||
} // Already know we're connected here
|
||||
|
||||
if (!this.connectedTo.has(stringId)) {
|
||||
this.connectedTo.add(stringId);
|
||||
}
|
||||
|
||||
if (!this._hasSeenEntity(id)) {
|
||||
this._ensurePeer(id);
|
||||
this._addEntityConnection(this.id, id);
|
||||
this.emit("peer-add", id);
|
||||
|
@ -197,6 +197,7 @@ export default class DHTCache extends EventEmitter {
|
|||
this._emitHeartbeat(peer);
|
||||
|
||||
this.log.debug(`Relay peer connected: ${stringId}`);
|
||||
}
|
||||
|
||||
if (this.bootstrapped) {
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue