diff --git a/dist/index.d.ts b/dist/index.d.ts
index 12b5c95..3bfa3db 100644
--- a/dist/index.d.ts
+++ b/dist/index.d.ts
@@ -1,5 +1,4 @@
///
-///
import EventEmitter from "events";
import DHTFlood from "@lumeweb/dht-flood";
export default class DHTCache extends EventEmitter {
diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map
index 95f26b1..720185b 100644
--- a/dist/index.d.ts.map
+++ b/dist/index.d.ts.map
@@ -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,OAA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,WAAW;IAInB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,uBAAuB;IAa/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"}
\ No newline at end of file
diff --git a/dist/index.js b/dist/index.js
index fd608a0..937a100 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -18,15 +18,7 @@ const EntityType = {
};
const DISCONNECT_SMOOTH = 500;
class DHTCache extends events_1.default {
- swarm;
- id;
- bootstrapped;
- graph;
- connectedTo;
- heartBeatInterval;
- flood;
- log;
- constructor(swarm, { id = swarm.keyPair.publicKey, heartBeatInterval = 15, ...opts } = {}) {
+ constructor(swarm, { id = swarm.keyPair.publicKey, heartBeatInterval = 60, ...opts } = {}) {
super();
if (!id)
throw new TypeError("Must provide id for self");
@@ -39,7 +31,7 @@ class DHTCache extends events_1.default {
this._online = new Set([this._maybeHexify(this.id)]);
this.swarm = swarm;
this.flood = new dht_flood_1.default({ id, swarm, ...opts });
- this.log = (0, loglevel_1.getLogger)("dht-cache");
+ this.log = loglevel_1.getLogger("dht-cache");
this.flood.on("peer-open", (peer) => this.addPeerHandler(peer));
this.flood.on("peer-remove", (peer) => this.removePeerHandler(peer));
this.flood.on("message", (message, id) => this.onGetBroadcast(message, id));
@@ -56,7 +48,6 @@ class DHTCache extends events_1.default {
setInterval(() => this._heartbeatCheck(), 5 * 1000);
setInterval(() => this._emitHeartbeat(), this.heartBeatInterval * 1000);
}
- _cache;
get cache() {
return [...this._cache].sort();
}
@@ -123,7 +114,6 @@ class DHTCache extends events_1.default {
}
return true;
}
- _online;
get online() {
return this._online;
}
@@ -243,10 +233,12 @@ class DHTCache extends events_1.default {
else if (type === messages_js_1.Type.HEARTBEAT) {
const { id: toId, signature, data: bufData } = decoded;
let bufId = b4a_1.default.from(toId);
- if (!(signature && hypercore_crypto_1.default.verify(bufData, signature, id))) {
+ if (!(signature && hypercore_crypto_1.default.verify(bufData, signature, bufId))) {
return;
}
- this._addEntityConnection(id, bufId);
+ this.addPeerHandler({
+ remotePublicKey: bufId,
+ });
this._setEntity(bufId, { heartbeat: Date.now() });
this.log.debug(`Heartbeat received from ${bufId.toString("hex")}`);
}
@@ -335,7 +327,7 @@ class DHTCache extends events_1.default {
if (item?.type !== EntityType.PUBKEY) {
continue;
}
- if ((0, jsnetworkx_1.hasPath)(this.graph, {
+ if (jsnetworkx_1.hasPath(this.graph, {
source: this._maybeHexify(this.id),
target: id,
})) {
diff --git a/dist/messages.js b/dist/messages.js
index 1284cee..8720168 100644
--- a/dist/messages.js
+++ b/dist/messages.js
@@ -59,7 +59,7 @@ class Message$Type extends runtime_5.MessageType {
const message = { type: 0, bootstrap: {} };
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
- (0, runtime_3.reflectionMergePartial)(this, message, value);
+ runtime_3.reflectionMergePartial(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
@@ -150,7 +150,7 @@ class State$Type extends runtime_5.MessageType {
const message = { connectedTo: [] };
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
- (0, runtime_3.reflectionMergePartial)(this, message, value);
+ runtime_3.reflectionMergePartial(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {