UNPKG

lisk-framework

Version:

Lisk blockchain application platform

65 lines 2.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SystemEndpoint = void 0; const lisk_chain_1 = require("@liskhq/lisk-chain"); const metrics_1 = require("../metrics/metrics"); class SystemEndpoint { constructor(args) { this._abi = args.abi; this._chain = args.chain; this._consensus = args.consensus; this._generator = args.generator; this._config = args.config; this._genesisHeight = args.genesisHeight; } async getNodeInfo(_context) { return { version: this._config.system.version, networkVersion: this._config.network.version, chainID: this._chain.chainID.toString('hex'), lastBlockID: this._chain.lastBlock.header.id.toString('hex'), height: this._chain.lastBlock.header.height, finalizedHeight: this._consensus.finalizedHeight(), syncing: this._consensus.syncing(), unconfirmedTransactions: this._generator.getPooledTransactions().length, genesisHeight: this._genesisHeight, genesis: { ...this._config.genesis, }, network: { version: this._config.network.version, port: this._config.network.port, host: this._config.network.host, seedPeers: this._config.network.seedPeers, blacklistedIPs: this._config.network.blacklistedIPs, fixedPeers: this._config.network.fixedPeers, whitelistedPeers: this._config.network.whitelistedPeers, }, }; } async getMetadata(_ctx) { const { data } = await this._abi.getMetadata({}); return JSON.parse(data.toString()); } async getSchema(_ctx) { return { block: lisk_chain_1.blockSchema, header: lisk_chain_1.blockHeaderSchema, asset: lisk_chain_1.blockAssetSchema, transaction: lisk_chain_1.transactionSchema, event: lisk_chain_1.eventSchema, standardEvent: lisk_chain_1.standardEventDataSchema, }; } async getMetricsReport(ctx) { if (!metrics_1.defaultMetrics.enabled()) { throw new Error('metrics is not enabled'); } if (ctx.params && ctx.params.inString === true) { return metrics_1.defaultMetrics.report(); } return metrics_1.defaultMetrics.report(true); } } exports.SystemEndpoint = SystemEndpoint; //# sourceMappingURL=system.js.map