Compare commits
No commits in common. "bdf0cb705ce90a1119e6ad08b83a85668958e331" and "14a71cffd9f841cd90e66ad5e3fe1f87bc843c9e" have entirely different histories.
bdf0cb705c
...
14a71cffd9
|
@ -9,7 +9,6 @@ export declare class SwarmClient extends Client {
|
|||
private _autoReconnect;
|
||||
private _connectBackoff;
|
||||
private _ready?;
|
||||
private _connectionListener?;
|
||||
private _topics;
|
||||
private _sockets;
|
||||
get dht(): {
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAW,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAU,QAAQ,EAAY,MAAM,gBAAgB,CAAC;AAG5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAKlD,qBAAa,WAAY,SAAQ,MAAM;IACrC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,EAAE,CAAa;IACvB,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,eAAe,CAAM;IAE7B,OAAO,CAAC,MAAM,CAAC,CAAgB;IAC/B,OAAO,CAAC,mBAAmB,CAAC,CAG1B;IAEF,OAAO,CAAC,OAAO,CAA0C;IACzD,OAAO,CAAC,QAAQ,CAAkD;IAElE,IAAI,GAAG;;MAON;gBAEW,aAAa,UAAO,EAAE,aAAa,UAAQ;IAcvD,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAEY,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAa5D,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC;IAGzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAMd,OAAO;IA2BR,QAAQ,CAAC,MAAM,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AAM;IAChC,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,YAAY,CAAqC;gBAE7C,EAAE,EAAE,MAAM;IAKtB,OAAO,CAAC,gBAAgB,CAAC,CAAa;IAEtC,IAAI,eAAe,IAAI,UAAU,CAEhC;IAED,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC,IAAI,SAAS,IAAI,UAAU,CAE1B;IAEK,KAAK;IAOX,EAAE,CAAC,CAAC,SAAS,YAAY,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,EACnD,KAAK,EAAE,CAAC,EACR,EAAE,EAAE,YAAY,CAAC,aAAa,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,EAClD,OAAO,CAAC,EAAE,GAAG,GACZ,IAAI;IAiBP,GAAG,CAAC,CAAC,SAAS,YAAY,CAAC,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"}
|
|
@ -9,7 +9,6 @@ export class SwarmClient extends Client {
|
|||
_autoReconnect;
|
||||
_connectBackoff;
|
||||
_ready;
|
||||
_connectionListener;
|
||||
_topics = new Set();
|
||||
_sockets = new Map();
|
||||
get dht() {
|
||||
|
@ -28,9 +27,6 @@ export class SwarmClient extends Client {
|
|||
strategy: "fibo",
|
||||
maxAttempts: Number.MAX_SAFE_INTEGER,
|
||||
});
|
||||
this._connectBackoff.on("retry", (error) => {
|
||||
this.logErr(error);
|
||||
});
|
||||
}
|
||||
get swarm() {
|
||||
return this.useDefaultSwarm ? undefined : this.id;
|
||||
|
@ -63,11 +59,13 @@ export class SwarmClient extends Client {
|
|||
}
|
||||
async start() {
|
||||
await this._connectBackoff.run(() => this.init());
|
||||
this._connectBackoff.on("retry", (error) => {
|
||||
this.logErr(error);
|
||||
});
|
||||
await this.ready();
|
||||
}
|
||||
async _listen() {
|
||||
if (!this._connectionListener) {
|
||||
this._connectionListener = this.connectModule("listenConnections", { swarm: this.swarm }, async (socketId) => {
|
||||
const connect = this.connectModule("listenConnections", { swarm: this.swarm }, async (socketId) => {
|
||||
const socket = this._sockets.get(socketId) ?? (await createSocket(socketId));
|
||||
socket.on("close", () => {
|
||||
this._sockets.delete(socketId);
|
||||
|
@ -77,9 +75,7 @@ export class SwarmClient extends Client {
|
|||
}
|
||||
this.emit("connection", socket);
|
||||
});
|
||||
}
|
||||
await this._connectionListener[1];
|
||||
this._connectionListener = undefined;
|
||||
await connect[1];
|
||||
this.start();
|
||||
}
|
||||
async addRelay(pubkey) {
|
||||
|
|
19
src/index.ts
19
src/index.ts
|
@ -15,10 +15,6 @@ export class SwarmClient extends Client {
|
|||
private _connectBackoff: any;
|
||||
|
||||
private _ready?: Promise<void>;
|
||||
private _connectionListener?: [
|
||||
sendUpdate: DataFn,
|
||||
response: Promise<ErrTuple>
|
||||
];
|
||||
|
||||
private _topics: Set<Uint8Array> = new Set<Uint8Array>();
|
||||
private _sockets: Map<number, Socket> = new Map<number, Socket>();
|
||||
|
@ -40,10 +36,6 @@ export class SwarmClient extends Client {
|
|||
strategy: "fibo",
|
||||
maxAttempts: Number.MAX_SAFE_INTEGER,
|
||||
});
|
||||
|
||||
this._connectBackoff.on("retry", (error: any) => {
|
||||
this.logErr(error);
|
||||
});
|
||||
}
|
||||
|
||||
get swarm(): number | undefined {
|
||||
|
@ -87,12 +79,15 @@ export class SwarmClient extends Client {
|
|||
async start(): Promise<void> {
|
||||
await this._connectBackoff.run(() => this.init());
|
||||
|
||||
this._connectBackoff.on("retry", (error: any) => {
|
||||
this.logErr(error);
|
||||
});
|
||||
|
||||
await this.ready();
|
||||
}
|
||||
|
||||
private async _listen() {
|
||||
if (!this._connectionListener) {
|
||||
this._connectionListener = this.connectModule(
|
||||
const connect = this.connectModule(
|
||||
"listenConnections",
|
||||
{ swarm: this.swarm },
|
||||
async (socketId: any) => {
|
||||
|
@ -110,10 +105,8 @@ export class SwarmClient extends Client {
|
|||
this.emit("connection", socket);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
await this._connectionListener[1];
|
||||
this._connectionListener = undefined;
|
||||
await connect[1];
|
||||
this.start();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue