UNPKG

@ellcrys/spell

Version:

The official JavaScript library for Ellcrys

159 lines 7.72 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var namespace_1 = __importDefault(require("./namespace")); /** * Miner handles mining operations * on a node. * * @export * @class Miner * @extends {Namespace} */ var Miner = /** @class */ (function (_super) { __extends(Miner, _super); /** * Creates an instance of Miner. * @param {RPCClient} client * @memberof Miner */ function Miner(client) { var _this = _super.call(this) || this; _this.client = client; return _this; } /** * Start the miner on the node * * @returns {Promise<Boolean>} * @memberof Miner */ Miner.prototype.start = function () { var _this = this; return new Promise(function (resolve, reject) { _this.client .call("miner_start", null) .then(function (res) { return resolve(res); }) .catch(function (err) { return reject(err); }); }); }; /** * Stop the miner on the node * * @returns {Promise<Boolean>} * @memberof Miner */ Miner.prototype.stop = function () { var _this = this; return new Promise(function (resolve, reject) { _this.client .call("miner_stop", null) .then(function (res) { return resolve(res); }) .catch(function (err) { return reject(err); }); }); }; /** * Check whether the miner has is running * * @returns {Promise<Boolean>} * @memberof Miner */ Miner.prototype.isMining = function () { var _this = this; return new Promise(function (resolve, reject) { _this.client .call("miner_isMining", null) .then(function (res) { return resolve(res); }) .catch(function (err) { return reject(err); }); }); }; /** * Get the hashrate of the miner * * @returns {Promise<number>} * @memberof Miner */ Miner.prototype.getHashrate = function () { var _this = this; return new Promise(function (resolve, reject) { _this.client .call("miner_getHashrate", null) .then(function (res) { return resolve(res); }) .catch(function (err) { return reject(err); }); }); }; /** * Get the number of miner threads * * @returns {Promise<number>} * @memberof Miner */ Miner.prototype.numThreads = function () { var _this = this; return new Promise(function (resolve, reject) { _this.client .call("miner_numThreads", null) .then(function (res) { return resolve(res); }) .catch(function (err) { return reject(err); }); }); }; /** * Set the number of miner threads * to run. * * @param {number} num * @returns {Promise<number>} * @memberof Miner */ Miner.prototype.setThreads = function (num) { var _this = this; return new Promise(function (resolve, reject) { _this.client .call("miner_setThreads", num) .then(function (res) { return resolve(res); }) .catch(function (err) { return reject(err); }); }); }; return Miner; }(namespace_1.default)); exports.default = Miner; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWluZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL25hbWVzcGFjZXMvbWluZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBSUEsMERBQW9DO0FBRXBDOzs7Ozs7O0dBT0c7QUFDSDtJQUFtQyx5QkFBUztJQUMzQzs7OztPQUlHO0lBQ0gsZUFBWSxNQUFpQjtRQUE3QixZQUNDLGlCQUFPLFNBRVA7UUFEQSxLQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQzs7SUFDdEIsQ0FBQztJQUVEOzs7OztPQUtHO0lBQ0kscUJBQUssR0FBWjtRQUFBLGlCQVdDO1FBVkEsT0FBTyxJQUFJLE9BQU8sQ0FBQyxVQUFDLE9BQU8sRUFBRSxNQUFNO1lBQ2xDLEtBQUksQ0FBQyxNQUFNO2lCQUNULElBQUksQ0FBQyxhQUFhLEVBQUUsSUFBSSxDQUFDO2lCQUN6QixJQUFJLENBQUMsVUFBQyxHQUFHO2dCQUNULE9BQU8sT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO1lBQ3JCLENBQUMsQ0FBQztpQkFDRCxLQUFLLENBQUMsVUFBQyxHQUFHO2dCQUNWLE9BQU8sTUFBTSxDQ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