UNPKG

lisk-framework

Version:

Lisk blockchain application platform

83 lines 3.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GenesisBlockContext = void 0; const method_context_1 = require("./method_context"); const constants_1 = require("./constants"); class GenesisBlockContext { constructor(params) { this._logger = params.logger; this._stateStore = params.stateStore; this._eventQueue = params.eventQueue; this._header = params.header; this._assets = params.assets; this._chainID = params.chainID; this._contextStore = new Map(); } createInitGenesisStateContext() { const childQueue = this._eventQueue.getChildQueue(constants_1.EVENT_INDEX_INIT_GENESIS_STATE); return { eventQueue: childQueue, getMethodContext: () => new method_context_1.MethodContext({ stateStore: this._stateStore, eventQueue: childQueue, contextStore: this._contextStore, }), getStore: (moduleID, storePrefix) => this._stateStore.getStore(moduleID, storePrefix), stateStore: this._stateStore, header: this._header, logger: this._logger, assets: this._assets, chainID: this._chainID, setNextValidators: (precommitThreshold, certificateThreshold, validators) => { if (this._nextValidators) { throw new Error('Next validators can be set only once'); } this._nextValidators = { precommitThreshold, certificateThreshold, validators: [...validators], }; }, }; } createFinalizeGenesisStateContext() { const childQueue = this._eventQueue.getChildQueue(constants_1.EVENT_INDEX_FINALIZE_GENESIS_STATE); return { eventQueue: childQueue, getMethodContext: () => new method_context_1.MethodContext({ stateStore: this._stateStore, eventQueue: childQueue, contextStore: this._contextStore, }), getStore: (moduleID, storePrefix) => this._stateStore.getStore(moduleID, storePrefix), stateStore: this._stateStore, header: this._header, logger: this._logger, assets: this._assets, chainID: this._chainID, setNextValidators: (precommitThreshold, certificateThreshold, validators) => { if (this._nextValidators) { throw new Error('Next validators can be set only once'); } this._nextValidators = { precommitThreshold, certificateThreshold, validators: [...validators], }; }, }; } get eventQueue() { return this._eventQueue; } get nextValidators() { var _a; return ((_a = this._nextValidators) !== null && _a !== void 0 ? _a : { certificateThreshold: BigInt(0), precommitThreshold: BigInt(0), validators: [], }); } } exports.GenesisBlockContext = GenesisBlockContext; //# sourceMappingURL=genesis_block_context.js.map