Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6956 from LiskHQ/6953-add-default-value
Browse files Browse the repository at this point in the history
Update all modules to have default config - Closes #6953
  • Loading branch information
shuse2 authored Dec 2, 2021
2 parents 3b88bfb + 58f9db9 commit 610b986
Show file tree
Hide file tree
Showing 70 changed files with 295 additions and 9,132 deletions.
4 changes: 4 additions & 0 deletions framework/src/modules/bft/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ export const STORE_PREFIX_BFT_PARAMETERS = 0x0000;
export const STORE_PREFIX_BFT_VOTES = 0x8000;
export const EMPTY_KEY = Buffer.alloc(0);
export const MAX_UINT32 = 2 ** 32 - 1;

export const defaultConfig = {
batchSize: 103,
};
7 changes: 5 additions & 2 deletions framework/src/modules/bft/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
* Removal or modification of this copyright notice is prohibited.
*/
import { LiskValidationError, validator } from '@liskhq/lisk-validator';
import { objects } from '@liskhq/lisk-utils';
import { BaseModule, ModuleInitArgs } from '../base_module';
import { BFTAPI } from './api';
import { BFTEndpoint } from './endpoint';
import {
defaultConfig,
EMPTY_KEY,
MODULE_ID_BFT,
STORE_PREFIX_BFT_PARAMETERS,
Expand Down Expand Up @@ -45,11 +47,12 @@ export class BFTModule extends BaseModule {
// eslint-disable-next-line @typescript-eslint/require-await
public async init(args: ModuleInitArgs): Promise<void> {
const { moduleConfig } = args;
const errors = validator.validate(bftModuleConfig, moduleConfig);
const config = objects.mergeDeep({}, defaultConfig, moduleConfig);
const errors = validator.validate(bftModuleConfig, config);
if (errors.length) {
throw new LiskValidationError(errors);
}
this._batchSize = moduleConfig.batchSize as number;
this._batchSize = config.batchSize as number;
this.api.init(this._batchSize);
this._maxLengthBlockBFTInfos = 3 * this._batchSize;
}
Expand Down
42 changes: 0 additions & 42 deletions framework/src/modules/dpos/constants.ts

This file was deleted.

80 changes: 0 additions & 80 deletions framework/src/modules/dpos/data_access.ts

This file was deleted.

Loading

0 comments on commit 610b986

Please sign in to comment.