*Update dist
This commit is contained in:
parent
76755b4644
commit
7d5f3719f9
|
@ -47,5 +47,8 @@ export default class DHTCache extends EventEmitter {
|
||||||
private _heartbeatCheck;
|
private _heartbeatCheck;
|
||||||
private _emitHeartbeat;
|
private _emitHeartbeat;
|
||||||
private _hello;
|
private _hello;
|
||||||
|
private _sendItemsToPeer;
|
||||||
|
private _createAddItemRequestMessage;
|
||||||
|
private _createAddItemRequest;
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=index.d.ts.map
|
//# sourceMappingURL=index.d.ts.map
|
|
@ -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;IAuC7C,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,CA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E,EAAE,MAAM;IAkGpD,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,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;IAmCtB,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,YAAY;IAgDpB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,WAAW;IA0BnB,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,cAAc;IA4BtB,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,4BAA4B;IAKpC,OAAO,CAAC,qBAAqB;CAS9B"}
|
|
@ -73,11 +73,7 @@ class DHTCache extends events_1.default {
|
||||||
this._ensureItem(item);
|
this._ensureItem(item);
|
||||||
this._addEntityConnection(this.id, item);
|
this._addEntityConnection(this.id, item);
|
||||||
const broadcast = () => {
|
const broadcast = () => {
|
||||||
this._broadcastMessage({
|
this._broadcastMessage(this._createAddItemRequest(item));
|
||||||
type: messages_js_1.Type.ADD_ITEM,
|
|
||||||
data: b4a_1.default.from(item, "hex"),
|
|
||||||
signature: this._signItem(item),
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
if (!this.bootstrapped) {
|
if (!this.bootstrapped) {
|
||||||
this.once("bootstrapped", broadcast);
|
this.once("bootstrapped", broadcast);
|
||||||
|
@ -142,6 +138,7 @@ class DHTCache extends events_1.default {
|
||||||
this.log.debug(`Relay peer connected: ${stringId}`);
|
this.log.debug(`Relay peer connected: ${stringId}`);
|
||||||
}
|
}
|
||||||
if (this.bootstrapped) {
|
if (this.bootstrapped) {
|
||||||
|
this._sendItemsToPeer(peer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.log.debug(`Broadcasting bootstrap request`);
|
this.log.debug(`Broadcasting bootstrap request`);
|
||||||
|
@ -229,6 +226,9 @@ class DHTCache extends events_1.default {
|
||||||
else if (type === messages_js_1.Type.BOOTSTRAP_RESPONSE) {
|
else if (type === messages_js_1.Type.BOOTSTRAP_RESPONSE) {
|
||||||
const { bootstrap } = decoded;
|
const { bootstrap } = decoded;
|
||||||
this._bootstrapFrom(bootstrap);
|
this._bootstrapFrom(bootstrap);
|
||||||
|
if (this.swarm._allConnections.has(id)) {
|
||||||
|
this._sendItemsToPeer(this.swarm._allConnections.get(id));
|
||||||
|
}
|
||||||
this.log.debug(`Bootstrap response received`);
|
this.log.debug(`Bootstrap response received`);
|
||||||
}
|
}
|
||||||
else if (type === messages_js_1.Type.HEARTBEAT) {
|
else if (type === messages_js_1.Type.HEARTBEAT) {
|
||||||
|
@ -438,5 +438,22 @@ class DHTCache extends events_1.default {
|
||||||
this.send(peer, b4a_1.default.from("hello"));
|
this.send(peer, b4a_1.default.from("hello"));
|
||||||
this.swarm.leavePeer(peer.remotePublicKey);
|
this.swarm.leavePeer(peer.remotePublicKey);
|
||||||
}
|
}
|
||||||
|
_sendItemsToPeer(peer) {
|
||||||
|
for (let item of this.cache) {
|
||||||
|
item = this._maybeHexify(item);
|
||||||
|
this.send(peer, this._createAddItemRequestMessage(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_createAddItemRequestMessage(item) {
|
||||||
|
item = this._maybeHexify(item);
|
||||||
|
return messages_js_1.Message.toBinary(messages_js_1.Message.create(this._createAddItemRequest(item)));
|
||||||
|
}
|
||||||
|
_createAddItemRequest(item) {
|
||||||
|
return {
|
||||||
|
type: messages_js_1.Type.ADD_ITEM,
|
||||||
|
data: b4a_1.default.from(item, "hex"),
|
||||||
|
signature: this._signItem(item),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.default = DHTCache;
|
exports.default = DHTCache;
|
||||||
|
|
Loading…
Reference in New Issue