From f227eaee37a4cc7901b9133aeff456b4f5fe9d59 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Fri, 25 Feb 2022 21:33:24 +0100 Subject: [PATCH] fix(core): update --- ts/bobcat.classes.bobcat.ts | 15 +++++++++++++-- ts/bobcat.classes.bobcatmanager.ts | 10 ++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ts/bobcat.classes.bobcat.ts b/ts/bobcat.classes.bobcat.ts index a4caba9..0b2340e 100644 --- a/ts/bobcat.classes.bobcat.ts +++ b/ts/bobcat.classes.bobcat.ts @@ -8,8 +8,8 @@ export class Bobcat { // STATIC public static async createFromNetworkAddress(networkAddressArg: string) { const newBobcat = new Bobcat(networkAddressArg); - await newBobcat.gatherMinerDetails(); - await newBobcat.checkMinerStatus(); + await newBobcat.checkMinerStatus().catch(); + await newBobcat.gatherMinerDetails().catch(); return newBobcat; } @@ -41,4 +41,15 @@ export class Bobcat { this.latestMinerDetails = body; return this.latestMinerDetails; } + + /** + * runs maintenance on the bobcat + */ + public async runMaintenance() { + await this.checkMinerStatus(); + await this.gatherMinerDetails(); + if (this.latestStatus.status !== 'Synced') { + console.log(`Miner ${this.latestMinerDetails.animal} is not synced. Restarting now!`); + } + } } \ No newline at end of file diff --git a/ts/bobcat.classes.bobcatmanager.ts b/ts/bobcat.classes.bobcatmanager.ts index 40156a9..d9e16c5 100644 --- a/ts/bobcat.classes.bobcatmanager.ts +++ b/ts/bobcat.classes.bobcatmanager.ts @@ -11,4 +11,14 @@ export class BobcatManager { const newBobcat = await Bobcat.createFromNetworkAddress(networkAddressArg); this.bobcats.push(newBobcat); } + + /** + * runs the maintenance on all managed bobcats + */ + public async runMaintenance() { + console.log(`now running maintenance on ${this.bobcats.length} bobcats!`); + for (const bobcat of this.bobcats) { + await bobcat.runMaintenance(); + } + }; } \ No newline at end of file