Compare commits
3 Commits
dd21b0fa30
...
ef4a6f60e9
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | ef4a6f60e9 | |
Derrick Hammer | a3c61e2b66 | |
Derrick Hammer | 225537fc39 |
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAYlC,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAc1C,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,YAAY;IAChD,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;IACrB,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,WAAW,CAAW;IAC9B,OAAO,CAAC,iBAAiB,CAAS;IAElC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC;IAC1B,OAAO,CAAC,GAAG,CAAa;gBAGtB,KAAK,EAAE,GAAG,EACV,EACE,EAA4B,EAC5B,iBAAsB,EACtB,GAAG,IAAI,EACR,GAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAO;IAsC7C,OAAO,CAAC,MAAM,CAAc;IAE5B,IAAW,KAAK,IAAI,MAAM,EAAE,CAE3B;IAED,IAAW,QAAQ,IAAI,MAAM,EAAE,CAU9B;IAEM,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;IAOlE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAsBpC,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,iBAAiB;IAIlB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;IA2BjD,OAAO,CAAC,OAAO,CAAc;IAE7B,IAAW,MAAM,I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/B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,cAAc;IAwBtB,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,YAAY;IA8CpB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,WAAW;IA0BnB,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,cAAc;CA2BvB"}
|
|
@ -126,20 +126,21 @@ class DHTCache extends events_1.default {
|
|||
addPeerHandler(peer) {
|
||||
const id = peer.remotePublicKey;
|
||||
const stringId = id.toString("hex");
|
||||
if (this.connectedTo.has(stringId)) {
|
||||
return;
|
||||
} // Already know we're connected here
|
||||
this.connectedTo.add(stringId);
|
||||
this._ensurePeer(id);
|
||||
this._addEntityConnection(this.id, id);
|
||||
this.emit("peer-add", id);
|
||||
this._recalculate();
|
||||
this._broadcastMessage({
|
||||
type: messages_js_1.Type.CONNECTED,
|
||||
id,
|
||||
});
|
||||
this._emitHeartbeat(peer);
|
||||
this.log.debug(`Relay peer connected: ${stringId}`);
|
||||
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);
|
||||
this._recalculate();
|
||||
this._broadcastMessage({
|
||||
type: messages_js_1.Type.CONNECTED,
|
||||
id,
|
||||
});
|
||||
this._emitHeartbeat(peer);
|
||||
this.log.debug(`Relay peer connected: ${stringId}`);
|
||||
}
|
||||
if (this.bootstrapped) {
|
||||
return;
|
||||
}
|
||||
|
|
33
src/index.ts
33
src/index.ts
|
@ -178,25 +178,26 @@ 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);
|
||||
}
|
||||
|
||||
this.connectedTo.add(stringId);
|
||||
this._ensurePeer(id);
|
||||
this._addEntityConnection(this.id, id);
|
||||
this.emit("peer-add", id);
|
||||
if (!this._hasSeenEntity(id)) {
|
||||
this._ensurePeer(id);
|
||||
this._addEntityConnection(this.id, id);
|
||||
this.emit("peer-add", id);
|
||||
|
||||
this._recalculate();
|
||||
this._recalculate();
|
||||
|
||||
this._broadcastMessage({
|
||||
type: Type.CONNECTED,
|
||||
id,
|
||||
});
|
||||
this._broadcastMessage({
|
||||
type: Type.CONNECTED,
|
||||
id,
|
||||
});
|
||||
|
||||
this._emitHeartbeat(peer);
|
||||
this._emitHeartbeat(peer);
|
||||
|
||||
this.log.debug(`Relay peer connected: ${stringId}`);
|
||||
this.log.debug(`Relay peer connected: ${stringId}`);
|
||||
}
|
||||
|
||||
if (this.bootstrapped) {
|
||||
return;
|
||||
|
@ -383,8 +384,8 @@ export default class DHTCache extends EventEmitter {
|
|||
origin.toString("hex"),
|
||||
destination.toString("hex")
|
||||
);
|
||||
} catch (e: any) {
|
||||
if (e.name !== "JSNetworkXError") throw e;
|
||||
} catch (e) {
|
||||
if ((e as Error).name !== "JSNetworkXError") throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue