UNPKG

lisk-framework

Version:

Lisk blockchain application platform

43 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Endpoint = void 0; const lisk_codec_1 = require("@liskhq/lisk-codec"); const schema_1 = require("./schema"); class Endpoint { init(args) { this._p2p = args.p2p; } getConnectedPeers() { const peers = this._p2p.getConnectedPeers(); return peers.map(peer => { var _a, _b; const parsedPeer = { ...peer, chainID: (_b = (_a = peer.chainID) === null || _a === void 0 ? void 0 : _a.toString('hex')) !== null && _b !== void 0 ? _b : '', }; if (parsedPeer.options) { parsedPeer.options = lisk_codec_1.codec.toJSON(schema_1.customNodeInfoSchema, parsedPeer.options); } return parsedPeer; }); } getDisconnectedPeers() { const peers = this._p2p.getDisconnectedPeers(); return peers.map(peer => { var _a, _b; const parsedPeer = { ...peer, chainID: (_b = (_a = peer.chainID) === null || _a === void 0 ? void 0 : _a.toString('hex')) !== null && _b !== void 0 ? _b : '', }; if (parsedPeer.options) { parsedPeer.options = lisk_codec_1.codec.toJSON(schema_1.customNodeInfoSchema, parsedPeer.options); } return parsedPeer; }); } getStats() { return this._p2p.getNetworkStats(); } } exports.Endpoint = Endpoint; //# sourceMappingURL=endpoint.js.map