mirror of https://codeberg.org/pzp/pzp-net.git
fix scheduler start()
This commit is contained in:
parent
809d3e774b
commit
5b79b9566b
|
@ -22,6 +22,8 @@ class Scheduler {
|
|||
#peer
|
||||
/** @type {Connections} */
|
||||
#connections
|
||||
/** @type {boolean} */
|
||||
#closed
|
||||
|
||||
/**
|
||||
* @param {Peer} peer
|
||||
|
@ -30,15 +32,18 @@ class Scheduler {
|
|||
constructor(peer, connections) {
|
||||
this.#peer = peer
|
||||
this.#connections = connections
|
||||
this.#closed = true
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Multiaddr} multiaddr
|
||||
*/
|
||||
async #scheduleWithHub(multiaddr) {
|
||||
/** @type {[Error, null] | [null, any]} */
|
||||
const [err, hubRPC] = await run(this.#connections.connect)(multiaddr)
|
||||
if (err) {
|
||||
/**@type {any}*/
|
||||
let hubRPC
|
||||
try {
|
||||
hubRPC = await this.#connections.connect(multiaddr)
|
||||
} catch (err) {
|
||||
debug('Failed to connect to hub at "%s" because %o', multiaddr, err)
|
||||
return
|
||||
}
|
||||
|
@ -73,13 +78,13 @@ class Scheduler {
|
|||
}
|
||||
|
||||
start() {
|
||||
if (!this.closed) return
|
||||
this.closed = false
|
||||
|
||||
if (!this.#closed) return
|
||||
this.#closed = false
|
||||
this.#setupHubDiscovery();
|
||||
}
|
||||
|
||||
stop() {
|
||||
this.#closed = true
|
||||
// FIXME: implement
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue