UNPKG

lisk-framework

Version:

Lisk blockchain application platform

50 lines 2.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConsensusEndpoint = void 0; const lisk_chain_1 = require("@liskhq/lisk-chain"); const lisk_cryptography_1 = require("@liskhq/lisk-cryptography"); class ConsensusEndpoint { constructor(args) { this._bftMethod = args.bftMethod; this._blockchainDB = args.blockchainDB; } async getBFTParameters(ctx) { const stateStore = new lisk_chain_1.StateStore(this._blockchainDB); const { certificateThreshold, precommitThreshold, prevoteThreshold, validators, validatorsHash, } = await this._bftMethod.getBFTParameters(stateStore, ctx.params.height); const validatorsJSON = validators.map(v => ({ address: lisk_cryptography_1.address.getLisk32AddressFromAddress(v.address), bftWeight: v.bftWeight.toString(), blsKey: v.blsKey.toString('hex'), })); return { validators: validatorsJSON, certificateThreshold: certificateThreshold.toString(), precommitThreshold: precommitThreshold.toString(), prevoteThreshold: prevoteThreshold.toString(), validatorsHash: validatorsHash.toString('hex'), }; } async getBFTParametersActiveValidators(ctx) { const stateStore = new lisk_chain_1.StateStore(this._blockchainDB); const { certificateThreshold, precommitThreshold, prevoteThreshold, validators, validatorsHash, } = await this._bftMethod.getBFTParametersActiveValidators(stateStore, ctx.params.height); const validatorsJSON = validators.map(v => ({ address: lisk_cryptography_1.address.getLisk32AddressFromAddress(v.address), bftWeight: v.bftWeight.toString(), blsKey: v.blsKey.toString('hex'), })); return { validators: validatorsJSON, certificateThreshold: certificateThreshold.toString(), precommitThreshold: precommitThreshold.toString(), prevoteThreshold: prevoteThreshold.toString(), validatorsHash: validatorsHash.toString('hex'), }; } async getBFTHeights(_ctx) { const stateStore = new lisk_chain_1.StateStore(this._blockchainDB); const result = await this._bftMethod.getBFTHeights(stateStore); return result; } } exports.ConsensusEndpoint = ConsensusEndpoint; //# sourceMappingURL=consensus.js.map