lisk-sdk icon indicating copy to clipboard operation
lisk-sdk copied to clipboard

createInitGenesisStateContext & createFinalizeGenesisStateContext have duplicated body

Open sitetester opened this issue 2 years ago • 0 comments

Description

Currently both createInitGenesisStateContext & createFinalizeGenesisStateContext have a duplicated code block

return {
	eventQueue: childQueue,
	getAPIContext: () => new APIContext({ stateStore: this._stateStore, eventQueue: childQueue }),
	getStore: (moduleID: Buffer, storePrefix: number) =>
		this._stateStore.getStore(moduleID, storePrefix),
	header: this._header,
	logger: this._logger,
	assets: this._assets,
	setNextValidators: (
		precommitThreshold: bigint,
		certificateThreshold: bigint,
		validators: Validator[],
	) => {
		if (this._nextValidators) {
			throw new Error('Next validators can be set only once');
		}
		this._nextValidators = {
			precommitThreshold,
			certificateThreshold,
			validators: [...validators],
		};
	},
};

Motivation

Both methods should be updated to avoid duplication

Additional Information

framework/src/state_machine/genesis_block_context.ts

sitetester avatar Aug 12 '22 16:08 sitetester