Compare commits
No commits in common. "21f7f2e67d41cbd0df2f637670d87fe9c827fc8a" and "175d66c99497f9537e8a0d7f0ad522e79a0aa37c" have entirely different histories.
21f7f2e67d
...
175d66c994
|
@ -8,14 +8,12 @@ export default class DHTFlood extends EventEmitter {
|
|||
private messageNumber;
|
||||
private lru;
|
||||
private swarm;
|
||||
private protocol;
|
||||
constructor({ lruSize, ttl, messageNumber, id, swarm, protocol, }?: {
|
||||
constructor({ lruSize, ttl, messageNumber, id, swarm, }?: {
|
||||
lruSize?: number | undefined;
|
||||
ttl?: number | undefined;
|
||||
messageNumber?: number | undefined;
|
||||
id?: Buffer | undefined;
|
||||
swarm?: null | undefined;
|
||||
protocol?: string | undefined;
|
||||
});
|
||||
private handleMessage;
|
||||
private setupPeer;
|
||||
|
|
|
@ -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;IACnB,OAAO,CAAC,QAAQ,CAAS;gBAEb,EACV,OAAkB,EAClB,GAAS,EACT,aAAiB,EACjB,EAA2B,EAC3B,KAAY,EACZ,QAAmB,GACpB;;;;;;;KAAK;IAmBN,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;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"}
|
|
@ -26,21 +26,19 @@ class DHTFlood extends events_1.default {
|
|||
messageNumber;
|
||||
lru;
|
||||
swarm;
|
||||
protocol;
|
||||
constructor({ lruSize = LRU_SIZE, ttl = TTL, messageNumber = 0, id = crypto_1.default.randomBytes(32), swarm = null, protocol = PROTOCOL, } = {}) {
|
||||
constructor({ lruSize = LRU_SIZE, ttl = TTL, messageNumber = 0, id = crypto_1.default.randomBytes(32), swarm = null, } = {}) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.ttl = ttl;
|
||||
this.messageNumber = messageNumber;
|
||||
this.lru = new lru_1.default(lruSize);
|
||||
this.protocol = protocol;
|
||||
if (!swarm) {
|
||||
throw new Error("swarm is required");
|
||||
}
|
||||
this.swarm = swarm;
|
||||
this.swarm.on("connection", (peer) => {
|
||||
const mux = protomux_1.default.from(peer);
|
||||
mux.pair({ protocol: this.protocol }, () => this.setupPeer(peer));
|
||||
mux.pair({ protocol: PROTOCOL }, () => this.setupPeer(peer));
|
||||
});
|
||||
}
|
||||
handleMessage({ originId, messageNumber, ttl, data }, messenger) {
|
||||
|
@ -70,7 +68,7 @@ class DHTFlood extends events_1.default {
|
|||
const self = this;
|
||||
if (!mux.opened({ protocol: PROTOCOL })) {
|
||||
chan = mux.createChannel({
|
||||
protocol: this.protocol,
|
||||
protocol: PROTOCOL,
|
||||
async onopen() {
|
||||
self.emit("peer-open", peer);
|
||||
},
|
||||
|
|
|
@ -24,7 +24,6 @@ export default class DHTFlood extends EventEmitter {
|
|||
private messageNumber: number;
|
||||
private lru: LRU;
|
||||
private swarm: any;
|
||||
private protocol: string;
|
||||
|
||||
constructor({
|
||||
lruSize = LRU_SIZE,
|
||||
|
@ -32,7 +31,6 @@ export default class DHTFlood extends EventEmitter {
|
|||
messageNumber = 0,
|
||||
id = crypto.randomBytes(32),
|
||||
swarm = null,
|
||||
protocol = PROTOCOL,
|
||||
} = {}) {
|
||||
super();
|
||||
|
||||
|
@ -40,7 +38,6 @@ export default class DHTFlood extends EventEmitter {
|
|||
this.ttl = ttl;
|
||||
this.messageNumber = messageNumber;
|
||||
this.lru = new LRU(lruSize);
|
||||
this.protocol = protocol;
|
||||
if (!swarm) {
|
||||
throw new Error("swarm is required");
|
||||
}
|
||||
|
@ -48,7 +45,7 @@ export default class DHTFlood extends EventEmitter {
|
|||
|
||||
this.swarm.on("connection", (peer: any) => {
|
||||
const mux = Protomux.from(peer);
|
||||
mux.pair({ protocol: this.protocol }, () => this.setupPeer(peer));
|
||||
mux.pair({ protocol: PROTOCOL }, () => this.setupPeer(peer));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -94,7 +91,7 @@ export default class DHTFlood extends EventEmitter {
|
|||
|
||||
if (!mux.opened({ protocol: PROTOCOL })) {
|
||||
chan = mux.createChannel({
|
||||
protocol: this.protocol,
|
||||
protocol: PROTOCOL,
|
||||
async onopen() {
|
||||
self.emit("peer-open", peer);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue