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AAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,EACpD,KAAK,EAAE,CAAC,EACR,EAAE,CAAC,EAAE,YAAY,CAAC,aAAa,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,EACnD,OAAO,CAAC,EAAE,GAAG,EACb,IAAI,CAAC,EAAE,OAAO,GACb,IAAI;IASP,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIrC,GAAG,IAAI,IAAI;IAUX,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,UAAU;CAInB;AAID,eAAO,MAAM,YAAY,+BAA4C,CAAC"}
|
|
@ -1,6 +1,7 @@
|
||||||
import { Client, factory } from "@lumeweb/libkernel-universal";
|
import { Client, factory } from "@lumeweb/libkernel-universal";
|
||||||
import { hexToBuf } from "@siaweb/libweb";
|
import { hexToBuf } from "@siaweb/libweb";
|
||||||
import backoff from "backoff";
|
// @ts-ignore
|
||||||
|
import Backoff from "backoff.js";
|
||||||
export class SwarmClient extends Client {
|
export class SwarmClient extends Client {
|
||||||
useDefaultSwarm;
|
useDefaultSwarm;
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -11,9 +12,9 @@ export class SwarmClient extends Client {
|
||||||
super();
|
super();
|
||||||
this.useDefaultSwarm = useDefaultDht;
|
this.useDefaultSwarm = useDefaultDht;
|
||||||
this._autoReconnect = autoReconnect;
|
this._autoReconnect = autoReconnect;
|
||||||
this._connectBackoff = backoff.fibonacci();
|
this._connectBackoff = new Backoff({
|
||||||
this._connectBackoff.on("ready", () => {
|
strategy: "fibo",
|
||||||
this.start();
|
maxAttempts: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
get swarm() {
|
get swarm() {
|
||||||
|
@ -41,18 +42,12 @@ export class SwarmClient extends Client {
|
||||||
this._ready = this.callModuleReturn("ready", { swarm: this.swarm });
|
this._ready = this.callModuleReturn("ready", { swarm: this.swarm });
|
||||||
await this._ready;
|
await this._ready;
|
||||||
this._ready = undefined;
|
this._ready = undefined;
|
||||||
this._connectBackoff.reset();
|
|
||||||
}
|
}
|
||||||
async start() {
|
async start() {
|
||||||
const backoff = () => setImmediate(() => this._connectBackoff.backoff());
|
this._connectBackoff.run(() => this.init());
|
||||||
try {
|
this._connectBackoff.on("retry", (error) => {
|
||||||
await this.init();
|
this.logErr(error);
|
||||||
}
|
});
|
||||||
catch (e) {
|
|
||||||
this.logErr(e);
|
|
||||||
backoff();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await this.ready();
|
await this.ready();
|
||||||
}
|
}
|
||||||
async _listen() {
|
async _listen() {
|
||||||
|
@ -60,7 +55,7 @@ export class SwarmClient extends Client {
|
||||||
this.emit("connection", await createSocket(socketId));
|
this.emit("connection", await createSocket(socketId));
|
||||||
});
|
});
|
||||||
await connect[1];
|
await connect[1];
|
||||||
this._connectBackoff.backoff();
|
this.start();
|
||||||
}
|
}
|
||||||
async addRelay(pubkey) {
|
async addRelay(pubkey) {
|
||||||
return this.callModuleReturn("addRelay", { pubkey, swarm: this.swarm });
|
return this.callModuleReturn("addRelay", { pubkey, swarm: this.swarm });
|
||||||
|
|
Loading…
Reference in New Issue