-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3072 from OriginTrail/v6/prerelease/mainnet
OriginTrail Mainnet Release v6.2.2
- Loading branch information
Showing
14 changed files
with
363 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/commands/protocols/common/epoch-check/epoch-check-command.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import Command from '../../../command.js'; | ||
import { ERROR_TYPE } from '../../../../constants/constants.js'; | ||
|
||
class EpochCheckCommand extends Command { | ||
constructor(ctx) { | ||
super(ctx); | ||
this.commandExecutor = ctx.commandExecutor; | ||
this.blockchainModuleManager = ctx.blockchainModuleManager; | ||
|
||
this.errorType = ERROR_TYPE.COMMIT_PROOF.EPOCH_CHECK_ERROR; | ||
} | ||
|
||
calculateCommandPeriod() { | ||
const devEnvironment = | ||
process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test'; | ||
|
||
return devEnvironment ? 30_000 : 120_000; | ||
} | ||
|
||
async execute() { | ||
const operationId = this.operationIdService.generateId(); | ||
|
||
this.logger.info( | ||
`Epoch check: Starting epoch check command for operation id: ${operationId}`, | ||
); | ||
|
||
await this.commandExecutor.delete('blockchainEpochCheckCommand'); | ||
|
||
await Promise.all( | ||
this.blockchainModuleManager.getImplementationNames().map(async (blockchain) => { | ||
const commandData = { | ||
blockchain, | ||
operationId, | ||
}; | ||
return this.commandExecutor.add({ | ||
name: 'blockchainEpochCheckCommand', | ||
data: commandData, | ||
period: this.calculateCommandPeriod(), | ||
}); | ||
}), | ||
); | ||
|
||
return Command.empty(); | ||
} | ||
|
||
/** | ||
* Recover system from failure | ||
* @param command | ||
* @param error | ||
*/ | ||
async recover(command) { | ||
this.logger.warn(`Failed to execute ${command.name}. Error: ${command.message}`); | ||
|
||
return Command.repeat(); | ||
} | ||
|
||
/** | ||
* Builds default epochCheckCommand | ||
* @param map | ||
* @returns {{add, data: *, delay: *, deadline: *}} | ||
*/ | ||
default(map) { | ||
const command = { | ||
name: 'epochCheckCommand', | ||
data: {}, | ||
transactional: false, | ||
period: this.calculateCommandPeriod(), | ||
}; | ||
Object.assign(command, map); | ||
return command; | ||
} | ||
} | ||
|
||
export default EpochCheckCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.