diff --git a/app/lib/blockchain/DuniterBlockchain.ts b/app/lib/blockchain/DuniterBlockchain.ts index a8f651f2172dba6c9f328f5c9bace6145626e39d..1341b1fdd0fa6fb2ceef1c3dbaf4b94bf64cc91a 100644 --- a/app/lib/blockchain/DuniterBlockchain.ts +++ b/app/lib/blockchain/DuniterBlockchain.ts @@ -227,7 +227,7 @@ export class DuniterBlockchain extends MiscIndexedBlockchain { } const dbb = DBBlock.fromBlockDTO(block) - await this.updateBlocksComputedVars(current, dbb); + this.updateBlocksComputedVars(current, dbb) // Saves the block (DAL) await dal.saveBlock(dbb); @@ -461,13 +461,17 @@ export class DuniterBlockchain extends MiscIndexedBlockchain { } } - updateBlocksComputedVars(current:DBBlock, block:DBBlock): Promise<void> { + updateBlocksComputedVars( + current:{ unitbase:number, monetaryMass:number }|null, + block:{ number:number, unitbase:number, dividend:number|null, membersCount:number, monetaryMass:number }): void { // Unit Base block.unitbase = (block.dividend && block.unitbase) || (current && current.unitbase) || 0; // Monetary Mass update if (current) { block.monetaryMass = (current.monetaryMass || 0) + (block.dividend || 0) * Math.pow(10, block.unitbase || 0) * block.membersCount; + } else { + block.monetaryMass = 0 } // UD Time update if (block.number == 0) { @@ -476,7 +480,6 @@ export class DuniterBlockchain extends MiscIndexedBlockchain { else if (!block.dividend) { block.dividend = null; } - return Promise.resolve() } static pushStatsForBlocks(blocks:BlockDTO[], dal:any) { diff --git a/app/lib/computation/QuickSync.ts b/app/lib/computation/QuickSync.ts index 98c3fc4179d6ff2fcd26e446684cf4dbe75ffab9..1047aeda6980129863794dfd8ed0485f36fb7454 100644 --- a/app/lib/computation/QuickSync.ts +++ b/app/lib/computation/QuickSync.ts @@ -61,6 +61,8 @@ export class QuickSynchronizer { } for (const block of blocks) { block.fork = false; + const current:BlockDTO|null = await getBlock(block.number - 1) + this.blockchain.updateBlocksComputedVars(current, block) } // Transactions recording await this.updateTransactionsForBlocks(blocks, getBlockByNumberAndHash);