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

[fix] monetaryMass field had `0` value

parent f88de909
Branches
Tags
No related merge requests found
......@@ -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) {
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment