Compare commits

...

2 Commits

Author SHA1 Message Date
Derrick Hammer 08dee10521
*Update dist 2022-11-16 01:33:52 -05:00
Derrick Hammer ee4c552fb4
*Export FLOOD_SYMBOL 2022-11-16 01:33:26 -05:00
4 changed files with 11 additions and 7 deletions

1
dist/index.d.ts vendored
View File

@ -1,6 +1,7 @@
/// <reference types="node" />
/// <reference types="node" />
import EventEmitter from "events";
export declare const FLOOD_SYMBOL: unique symbol;
export default class DHTFlood extends EventEmitter {
private id;
private ttl;

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;AAoBlC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,YAAY;IAChD,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,KAAK,CAAM;gBAEP,EACV,OAAkB,EAClB,GAAS,EACT,aAAiB,EACjB,EAA2B,EAC3B,KAAY,GACb;;;;;;KAAK;IAkBN,OAAO,CAAC,aAAa;IAiCrB,OAAO,CAAC,SAAS;IA6CjB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,SAAW;IAenC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,SAAW;CAY1C"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAkBlC,eAAO,MAAM,YAAY,eAAuB,CAAC;AAEjD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,YAAY;IAChD,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,KAAK,CAAM;gBAEP,EACV,OAAkB,EAClB,GAAS,EACT,aAAiB,EACjB,EAA2B,EAC3B,KAAY,GACb;;;;;;KAAK;IAkBN,OAAO,CAAC,aAAa;IAkCrB,OAAO,CAAC,SAAS;IA6CjB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,SAAW;IAenC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,SAAW;CAY1C"}

10
dist/index.js vendored
View File

@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FLOOD_SYMBOL = void 0;
const events_1 = __importDefault(require("events"));
const crypto_1 = __importDefault(require("crypto"));
// @ts-ignore
@ -18,7 +19,7 @@ const debug = (0, debug_1.default)("dht-flood");
const LRU_SIZE = 255;
const TTL = 255;
const PROTOCOL = "lumeweb.flood";
const FLOOD_SYMBOL = Symbol.for(PROTOCOL);
exports.FLOOD_SYMBOL = Symbol.for(PROTOCOL);
class DHTFlood extends events_1.default {
id;
ttl;
@ -51,8 +52,9 @@ class DHTFlood extends events_1.default {
return debug("Got message that was already seen", originId, messageNumber);
this.lru.set(key, true);
this.emit("message", data, originId, messageNumber);
if (ttl <= 0)
if (ttl <= 0) {
return debug("Got message at end of TTL", originId, messageNumber, ttl);
}
messenger.send({
originId,
messageNumber,
@ -74,9 +76,9 @@ class DHTFlood extends events_1.default {
self.emit("peer-remove", peer);
},
});
peer[FLOOD_SYMBOL] = chan;
peer[exports.FLOOD_SYMBOL] = chan;
}
chan = peer[FLOOD_SYMBOL];
chan = peer[exports.FLOOD_SYMBOL];
if (!chan) {
throw new Error("could not find channel");
}

View File

@ -16,7 +16,7 @@ const LRU_SIZE = 255;
const TTL = 255;
const PROTOCOL = "lumeweb.flood";
const FLOOD_SYMBOL = Symbol.for(PROTOCOL);
export const FLOOD_SYMBOL = Symbol.for(PROTOCOL);
export default class DHTFlood extends EventEmitter {
private id: Buffer;
@ -71,8 +71,9 @@ export default class DHTFlood extends EventEmitter {
this.emit("message", data, originId, messageNumber);
if (ttl <= 0)
if (ttl <= 0) {
return debug("Got message at end of TTL", originId, messageNumber, ttl);
}
messenger.send({
originId,