*Update dist

This commit is contained in:
Derrick Hammer 2022-12-16 13:56:06 -05:00
parent 35d6d7153e
commit dd21b0fa30
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
4 changed files with 10 additions and 19 deletions

1
dist/index.d.ts vendored
View File

@ -1,5 +1,4 @@
/// <reference types="node" />
/// <reference types="node" />
import EventEmitter from "events";
import DHTFlood from "@lumeweb/dht-flood";
export default class DHTCache extends EventEmitter {

2
dist/index.d.ts.map vendored
View File

@ -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,e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AC,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"}

22
dist/index.js vendored
View File

@ -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,
})) {

4
dist/messages.js vendored
View File

@ -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) {