update
This commit is contained in:
@@ -1,13 +1,36 @@
|
||||
import * as plugins from './bobcat.plugins';
|
||||
import { Bobcat } from './bobcat.classes.bobcat';
|
||||
import { Bobcat } from './bobcat.classes.bobcat';
|
||||
|
||||
/**
|
||||
*
|
||||
* a manager for managing multiple bobcats
|
||||
*/
|
||||
export class BobcatManager {
|
||||
public taskmanager = new plugins.taskbuffer.TaskManager();
|
||||
public bobcats: Bobcat[] = [];
|
||||
|
||||
public async addBobcat(networkAddressArg: string) {
|
||||
/**
|
||||
* a store for knowing what has happened retrospectively
|
||||
*/
|
||||
public actionStore: {
|
||||
actionName: string;
|
||||
actionPayload: string;
|
||||
}[] = [];
|
||||
|
||||
constructor() {
|
||||
this.taskmanager.addAndScheduleTask(new plugins.taskbuffer.Task({
|
||||
name: 'contMaintenance',
|
||||
taskFunction: async () => {
|
||||
this.actionStore.
|
||||
await this.runMaintenance();
|
||||
}
|
||||
}), '0 0 * * * *');
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a bobcat to the manager
|
||||
* @param networkAddressArg
|
||||
*/
|
||||
public async addBobcat (networkAddressArg: string) {
|
||||
const newBobcat = await Bobcat.createFromNetworkAddress(networkAddressArg);
|
||||
this.bobcats.push(newBobcat);
|
||||
console.log(`added ${newBobcat.latestMinerDetails.animal} at ${newBobcat.networkAddress}`);
|
||||
@@ -16,7 +39,7 @@ export class BobcatManager {
|
||||
/**
|
||||
* runs the maintenance on all managed bobcats
|
||||
*/
|
||||
public async runMaintenance() {
|
||||
public async runMaintenance () {
|
||||
console.log(`now running maintenance on ${this.bobcats.length} bobcats!`);
|
||||
console.log(`cooling down for 10 seconds`);
|
||||
await plugins.smartdelay.delayFor(10000);
|
||||
@@ -25,4 +48,18 @@ export class BobcatManager {
|
||||
await bobcat.runMaintenance();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* starts continuous maintenance of the bobcat miners
|
||||
*/
|
||||
public async startTaskmanager () {
|
||||
this.taskmanager.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* stops the taskmanager
|
||||
*/
|
||||
public async stopTaskmanager () {
|
||||
this.taskmanager.stop();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user