bobcat/ts/bobcat.classes.bobcat.ts

45 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-02-24 19:16:21 +00:00
import * as plugins from './bobcat.plugins';
/**
* maps to an individual bobcat miner
*/
export class Bobcat {
2022-02-25 19:36:44 +00:00
// STATIC
public static async createFromNetworkAddress(networkAddressArg: string) {
const newBobcat = new Bobcat(networkAddressArg);
await newBobcat.gatherMinerDetails();
return newBobcat;
}
// INSTANCE
public networkAddress: string;
2022-02-25 19:57:46 +00:00
constructor(networkAddressArg: string) {
this.networkAddress = networkAddressArg;
2022-02-25 19:36:44 +00:00
}
/**
* 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`);
}
2022-02-24 19:16:21 +00:00
}