fix scheduler start()

This commit is contained in:
Andre Staltz 2024-02-06 15:35:11 +02:00
parent 809d3e774b
commit 5b79b9566b
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 11 additions and 6 deletions

View File

@ -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
}
}