45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
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(networkAddressArg: string) {
|
|
this.networkAddress = networkAddressArg;
|
|
}
|
|
|
|
/**
|
|
* 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`);
|
|
|
|
}
|
|
} |