fix(core): update
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import * as plugins from './bobcat.plugins';
|
||||
import * as interfaces from './interfaces';
|
||||
|
||||
/**
|
||||
* maps to an individual bobcat miner
|
||||
@@ -8,11 +9,14 @@ export class Bobcat {
|
||||
public static async createFromNetworkAddress(networkAddressArg: string) {
|
||||
const newBobcat = new Bobcat(networkAddressArg);
|
||||
await newBobcat.gatherMinerDetails();
|
||||
await newBobcat.checkMinerStatus();
|
||||
return newBobcat;
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
public networkAddress: string;
|
||||
public latestStatus: interfaces.IMinerStatus;
|
||||
public latestMinerDetails: interfaces.IMinerDetailsResponse
|
||||
|
||||
constructor(networkAddressArg: string) {
|
||||
this.networkAddress = networkAddressArg;
|
||||
@@ -23,23 +27,18 @@ export class Bobcat {
|
||||
*/
|
||||
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;
|
||||
const body: interfaces.IMinerStatus = response.body;
|
||||
this.latestStatus = body;
|
||||
return this.latestStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* gathers the miner details
|
||||
*/
|
||||
public async gatherMinerDetails() {
|
||||
const response: {
|
||||
|
||||
} = plugins.smartrequest.getJson(`http://${this.networkAddress}/miner.json`);
|
||||
|
||||
const response = await plugins.smartrequest.getJson(`http://${this.networkAddress}/miner.json`);
|
||||
const body: interfaces.IMinerDetailsResponse = response.body;
|
||||
this.latestMinerDetails = body;
|
||||
return this.latestMinerDetails;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user