Compare commits
No commits in common. "08dee10521e48b95a3c1c071b566a8e26f34eda0" and "c72f45393ca99d9125a57cf22605933f36c3ddb3" have entirely different histories.
08dee10521
...
c72f45393c
|
@ -1,7 +1,6 @@
|
||||||
/// <reference types="node" />
|
/// <reference types="node" />
|
||||||
/// <reference types="node" />
|
/// <reference types="node" />
|
||||||
import EventEmitter from "events";
|
import EventEmitter from "events";
|
||||||
export declare const FLOOD_SYMBOL: unique symbol;
|
|
||||||
export default class DHTFlood extends EventEmitter {
|
export default class DHTFlood extends EventEmitter {
|
||||||
private id;
|
private id;
|
||||||
private ttl;
|
private ttl;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"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"}
|
{"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"}
|
|
@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.FLOOD_SYMBOL = void 0;
|
|
||||||
const events_1 = __importDefault(require("events"));
|
const events_1 = __importDefault(require("events"));
|
||||||
const crypto_1 = __importDefault(require("crypto"));
|
const crypto_1 = __importDefault(require("crypto"));
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -19,7 +18,7 @@ const debug = (0, debug_1.default)("dht-flood");
|
||||||
const LRU_SIZE = 255;
|
const LRU_SIZE = 255;
|
||||||
const TTL = 255;
|
const TTL = 255;
|
||||||
const PROTOCOL = "lumeweb.flood";
|
const PROTOCOL = "lumeweb.flood";
|
||||||
exports.FLOOD_SYMBOL = Symbol.for(PROTOCOL);
|
const FLOOD_SYMBOL = Symbol.for(PROTOCOL);
|
||||||
class DHTFlood extends events_1.default {
|
class DHTFlood extends events_1.default {
|
||||||
id;
|
id;
|
||||||
ttl;
|
ttl;
|
||||||
|
@ -52,9 +51,8 @@ class DHTFlood extends events_1.default {
|
||||||
return debug("Got message that was already seen", originId, messageNumber);
|
return debug("Got message that was already seen", originId, messageNumber);
|
||||||
this.lru.set(key, true);
|
this.lru.set(key, true);
|
||||||
this.emit("message", data, originId, messageNumber);
|
this.emit("message", data, originId, messageNumber);
|
||||||
if (ttl <= 0) {
|
if (ttl <= 0)
|
||||||
return debug("Got message at end of TTL", originId, messageNumber, ttl);
|
return debug("Got message at end of TTL", originId, messageNumber, ttl);
|
||||||
}
|
|
||||||
messenger.send({
|
messenger.send({
|
||||||
originId,
|
originId,
|
||||||
messageNumber,
|
messageNumber,
|
||||||
|
@ -76,9 +74,9 @@ class DHTFlood extends events_1.default {
|
||||||
self.emit("peer-remove", peer);
|
self.emit("peer-remove", peer);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
peer[exports.FLOOD_SYMBOL] = chan;
|
peer[FLOOD_SYMBOL] = chan;
|
||||||
}
|
}
|
||||||
chan = peer[exports.FLOOD_SYMBOL];
|
chan = peer[FLOOD_SYMBOL];
|
||||||
if (!chan) {
|
if (!chan) {
|
||||||
throw new Error("could not find channel");
|
throw new Error("could not find channel");
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ const LRU_SIZE = 255;
|
||||||
const TTL = 255;
|
const TTL = 255;
|
||||||
const PROTOCOL = "lumeweb.flood";
|
const PROTOCOL = "lumeweb.flood";
|
||||||
|
|
||||||
export const FLOOD_SYMBOL = Symbol.for(PROTOCOL);
|
const FLOOD_SYMBOL = Symbol.for(PROTOCOL);
|
||||||
|
|
||||||
export default class DHTFlood extends EventEmitter {
|
export default class DHTFlood extends EventEmitter {
|
||||||
private id: Buffer;
|
private id: Buffer;
|
||||||
|
@ -71,9 +71,8 @@ export default class DHTFlood extends EventEmitter {
|
||||||
|
|
||||||
this.emit("message", data, originId, messageNumber);
|
this.emit("message", data, originId, messageNumber);
|
||||||
|
|
||||||
if (ttl <= 0) {
|
if (ttl <= 0)
|
||||||
return debug("Got message at end of TTL", originId, messageNumber, ttl);
|
return debug("Got message at end of TTL", originId, messageNumber, ttl);
|
||||||
}
|
|
||||||
|
|
||||||
messenger.send({
|
messenger.send({
|
||||||
originId,
|
originId,
|
||||||
|
|
Loading…
Reference in New Issue