Compare commits
No commits in common. "866c91c0c6dd51244fbed5fa4c01a0d3b4838ae9" and "0ff1a24de216c0f9938a1768f7e484644a1ce49a" have entirely different histories.
866c91c0c6
...
0ff1a24de2
|
@ -15,17 +15,19 @@ export default class DHTOnlineBase extends EventEmitter {
|
||||||
get online(): string[];
|
get online(): string[];
|
||||||
broadcast(data: any, ttl?: number): void;
|
broadcast(data: any, ttl?: number): void;
|
||||||
getPeerData(id: Buffer | string): any;
|
getPeerData(id: Buffer | string): any;
|
||||||
setData(data: any): void;
|
protected setData(data: any): void;
|
||||||
private _broadcastData;
|
private _broadcastData;
|
||||||
protected onAddPeer(id: Buffer): void;
|
protected onAddPeer(id: Buffer): void;
|
||||||
protected onRemovePeer(id: Buffer): void;
|
protected onRemovePeer(id: Buffer): void;
|
||||||
protected onGetBroadcast(message: Buffer, id: Buffer): void;
|
protected onGetBroadcast(message: Buffer, id: Buffer): void;
|
||||||
private _hasSeenPeer;
|
private _hasSeenPeer;
|
||||||
private _setPeer;
|
private _setPeer;
|
||||||
|
private _removePeer;
|
||||||
private _ensurePeer;
|
private _ensurePeer;
|
||||||
private _addPeerConnection;
|
private _addPeerConnection;
|
||||||
private _removePeerConnection;
|
private _removePeerConnection;
|
||||||
private _bootstrapFrom;
|
private _bootstrapFrom;
|
||||||
|
private _getPeerConnectedTo;
|
||||||
private _getBootstrapInfo;
|
private _getBootstrapInfo;
|
||||||
private _recalculate;
|
private _recalculate;
|
||||||
private _maybeHexify;
|
private _maybeHexify;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"dhtOnlineBase.d.ts","sourceRoot":"","sources":["../src/dhtOnlineBase.ts"],"names":[],"mappings":";;AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAYlC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,YAAY;IACrD,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,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5D,OAAO,CAAC,OAAO,CAAW;IAE1B,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAED,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM;IAIjC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAI/B,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG;IAQ3B,OAAO,CAAC,cAAc;IAgBtB,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM;IAqC9B,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM;IAiBjC,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IA6CpD,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,cAAc;IA4BtB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,YAAY;CAOrB"}
|
|
@ -135,6 +135,9 @@ class DHTOnlineBase extends events_1.default {
|
||||||
_setPeer(id, data) {
|
_setPeer(id, data) {
|
||||||
this.graph.addNode(this._maybeHexify(id), data);
|
this.graph.addNode(this._maybeHexify(id), data);
|
||||||
}
|
}
|
||||||
|
_removePeer(id) {
|
||||||
|
this.graph.removeNode(this._maybeHexify(id));
|
||||||
|
}
|
||||||
_ensurePeer(id) {
|
_ensurePeer(id) {
|
||||||
id = this._maybeHexify(id);
|
id = this._maybeHexify(id);
|
||||||
if (!this._hasSeenPeer(id)) {
|
if (!this._hasSeenPeer(id)) {
|
||||||
|
@ -182,6 +185,9 @@ class DHTOnlineBase extends events_1.default {
|
||||||
this.emit("bootstrapped");
|
this.emit("bootstrapped");
|
||||||
this._recalculate();
|
this._recalculate();
|
||||||
}
|
}
|
||||||
|
_getPeerConnectedTo(id) {
|
||||||
|
return this.graph.successors(id);
|
||||||
|
}
|
||||||
_getBootstrapInfo() {
|
_getBootstrapInfo() {
|
||||||
const state = {};
|
const state = {};
|
||||||
for (const [id, rawData] of this.graph.nodes(true)) {
|
for (const [id, rawData] of this.graph.nodes(true)) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ export default class DHTOnlineBase extends EventEmitter {
|
||||||
return this.graph.node.get(this._maybeHexify(id));
|
return this.graph.node.get(this._maybeHexify(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public setData(data: any) {
|
protected setData(data: any) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
|
||||||
this._setPeer(this.id, data);
|
this._setPeer(this.id, data);
|
||||||
|
@ -175,6 +175,11 @@ export default class DHTOnlineBase extends EventEmitter {
|
||||||
private _setPeer(id: Buffer | string, data: any) {
|
private _setPeer(id: Buffer | string, data: any) {
|
||||||
this.graph.addNode(this._maybeHexify(id), data);
|
this.graph.addNode(this._maybeHexify(id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _removePeer(id: Buffer | string) {
|
||||||
|
this.graph.removeNode(this._maybeHexify(id));
|
||||||
|
}
|
||||||
|
|
||||||
private _ensurePeer(id: Buffer | string) {
|
private _ensurePeer(id: Buffer | string) {
|
||||||
id = this._maybeHexify(id);
|
id = this._maybeHexify(id);
|
||||||
if (!this._hasSeenPeer(id)) {
|
if (!this._hasSeenPeer(id)) {
|
||||||
|
@ -234,6 +239,11 @@ export default class DHTOnlineBase extends EventEmitter {
|
||||||
|
|
||||||
this._recalculate();
|
this._recalculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _getPeerConnectedTo(id: string) {
|
||||||
|
return this.graph.successors(id);
|
||||||
|
}
|
||||||
|
|
||||||
private _getBootstrapInfo() {
|
private _getBootstrapInfo() {
|
||||||
const state: Bootstrap = {};
|
const state: Bootstrap = {};
|
||||||
for (const [id, rawData] of this.graph.nodes(true)) {
|
for (const [id, rawData] of this.graph.nodes(true)) {
|
||||||
|
|
Loading…
Reference in New Issue