Skip to content
Snippets Groups Projects
Commit 14850d46 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] #1089 Add a semaphore on block computation

parent 3ade9547
No related branches found
No related tags found
No related merge requests found
......@@ -156,11 +156,15 @@ export class PermanentProver {
// The generation
(async () => {
try {
let unsignedBlock = null, trial2 = 0
await this.server.BlockchainService.pushFIFO('generatingNextBlock', async () => {
const current = await this.server.dal.getCurrentBlockOrNull();
const selfPubkey = this.server.keyPair.publicKey;
const trial2 = await this.server.getBcContext().getIssuerPersonalizedDifficulty(selfPubkey);
trial2 = await this.server.getBcContext().getIssuerPersonalizedDifficulty(selfPubkey);
this.checkTrialIsNotTooHigh(trial2, current, selfPubkey);
this.lastComputedBlock = await this.generator.makeNextBlock(null, trial2);
unsignedBlock = await this.generator.nextBlock()
})
this.lastComputedBlock = await this.prover.prove(unsignedBlock, trial2, null)
try {
const obj = parsers.parseBlock.syncWrite(dos2unix(this.lastComputedBlock.getRawSigned()));
await this.server.writeBlock(obj)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment