fix(core): update

This commit is contained in:
2022-02-25 20:36:44 +01:00
parent babcb832f3
commit e5fe74d2d2
6 changed files with 294 additions and 142 deletions

View File

@ -4,5 +4,41 @@ import * as plugins from './bobcat.plugins';
* maps to an individual bobcat miner
*/
export class Bobcat {
// STATIC
public static async createFromNetworkAddress(networkAddressArg: string) {
const newBobcat = new Bobcat(networkAddressArg);
await newBobcat.gatherMinerDetails();
return newBobcat;
}
// INSTANCE
public networkAddress: string;
constructor(networkAddress: string) {
}
/**
* checks the status of the miner
*/
public async checkMinerStatus() {
const response = await plugins.smartrequest.getJson(`http://${this.networkAddress}/status.json`);
const body: {
"status": string,
"gap": string,
"miner_height": string,
"blockchain_height": string,
"epoch": "rpc"
} = response.body;
return response;
}
/**
* gathers the miner details
*/
public async gatherMinerDetails() {
const response: {
} = plugins.smartrequest.getJson(`http://${this.networkAddress}/miner.json`);
}
}

View File

@ -1,8 +1,14 @@
import * as plugins from './bobcat.plugins';
import { Bobcat } from './bobcat.classes.bobcat';
/**
*
*/
export class BobcatManager {
public bobcats: Bobcat[] = [];
public async addBobcat(networkAddressArg: string) {
const newBobcat = await Bobcat.createFromNetworkAddress(networkAddressArg);
this.bobcats.push(newBobcat);
}
}

View File

@ -1,5 +1,7 @@
import * as smartnetwork from '@pushrocks/smartnetwork';
import * as smartrequest from '@pushrocks/smartrequest';
export {
smartnetwork,
smartrequest
}