diff --git a/app/lib/computation/QuickSync.ts b/app/lib/computation/QuickSync.ts index 5d8853884b2da9e9e1d21816ec66a3469ae67483..36fdbb26e081e43ad71856663d2a686bae198d32 100644 --- a/app/lib/computation/QuickSync.ts +++ b/app/lib/computation/QuickSync.ts @@ -123,11 +123,8 @@ export class QuickSynchronizer { const local_cindex = Indexer.cindex(index); const local_sindex = Indexer.sindex(index); const local_mindex = Indexer.mindex(index); - sync_iindex = sync_iindex.concat(local_iindex); - sync_cindex = sync_cindex.concat(local_cindex); - sync_mindex = sync_mindex.concat(local_mindex); - const HEAD = await Indexer.quickCompleteGlobalScope(block, sync_currConf, sync_bindex, sync_iindex, sync_mindex, sync_cindex, { + const HEAD = await Indexer.quickCompleteGlobalScope(block, sync_currConf, sync_bindex, local_iindex, local_mindex, local_cindex, { getBlock: (number: number) => { return Promise.resolve(sync_allBlocks[number]); }, @@ -184,12 +181,12 @@ export class QuickSynchronizer { await this.dal.iindexDAL.insertBatch(sync_iindex); await this.dal.sindexDAL.insertBatch(sync_sindex); await this.dal.cindexDAL.insertBatch(sync_cindex); - sync_mindex = []; - sync_iindex = []; - sync_cindex = []; - sync_sindex = local_sindex; + sync_iindex = local_iindex + sync_cindex = local_cindex + sync_mindex = local_mindex + sync_sindex = local_sindex - sync_sindex = sync_sindex.concat(await Indexer.ruleIndexGenDividend(HEAD, this.dal)); + sync_sindex = sync_sindex.concat(await Indexer.ruleIndexGenDividend(HEAD, local_iindex, this.dal)); sync_sindex = sync_sindex.concat(await Indexer.ruleIndexGarbageSmallAccounts(HEAD, sync_sindex, sync_memoryDAL)); if (nextExpiringChanged) { sync_cindex = sync_cindex.concat(await Indexer.ruleIndexGenCertificationExpiry(HEAD, this.dal)); @@ -201,21 +198,26 @@ export class QuickSynchronizer { // Update balances with UD + local garbagings await this.blockchain.updateWallets(sync_sindex, sync_memoryDAL) - // --> Update links - await this.dal.updateWotbLinks(local_cindex.concat(sync_cindex)); - - // Flush the INDEX again - await this.dal.mindexDAL.insertBatch(sync_mindex); + // Flush the INDEX again (needs to be done *before* the update of wotb links because of block#0) await this.dal.iindexDAL.insertBatch(sync_iindex); + await this.dal.mindexDAL.insertBatch(sync_mindex); await this.dal.sindexDAL.insertBatch(sync_sindex); await this.dal.cindexDAL.insertBatch(sync_cindex); - sync_mindex = []; + + // --> Update links + await this.dal.updateWotbLinks(local_cindex.concat(sync_cindex)); sync_iindex = []; + sync_mindex = []; sync_cindex = []; sync_sindex = []; // Create/Update nodes in wotb await this.blockchain.updateMembers(block, this.dal) + } else { + // Concat the results to the pending data + sync_iindex = sync_iindex.concat(local_iindex); + sync_cindex = sync_cindex.concat(local_cindex); + sync_mindex = sync_mindex.concat(local_mindex); } // Trim the bindex diff --git a/app/lib/dal/fileDAL.ts b/app/lib/dal/fileDAL.ts index 2cbd5d10251ee0aa6d505b3e3cb196951ed9f88f..4e441a89b32026b162f0621f6933a9bdcca29cbd 100644 --- a/app/lib/dal/fileDAL.ts +++ b/app/lib/dal/fileDAL.ts @@ -28,7 +28,6 @@ import {DBBlock} from "../db/DBBlock" import {DBMembership} from "./sqliteDAL/MembershipDAL" import {MerkleDTO} from "../dto/MerkleDTO" import {CommonConstants} from "../common-libs/constants" -import { ProxiesConf } from '../proxy'; import {PowDAL} from "./fileDALs/PowDAL"; const fs = require('fs') @@ -697,7 +696,7 @@ export class FileDAL { let iindex = indexer.iindex(index); let sindex = indexer.sindex(index); let cindex = indexer.cindex(index); - sindex = sindex.concat(await indexer.ruleIndexGenDividend(HEAD, this)); + sindex = sindex.concat(await indexer.ruleIndexGenDividend(HEAD, iindex, this)); sindex = sindex.concat(await indexer.ruleIndexGarbageSmallAccounts(HEAD, sindex, this)); cindex = cindex.concat(await indexer.ruleIndexGenCertificationExpiry(HEAD, this)); mindex = mindex.concat(await indexer.ruleIndexGenMembershipExpiry(HEAD, this)); diff --git a/app/lib/indexer.ts b/app/lib/indexer.ts index 42b8cea8882caa6a8623f4fe8070a519b4cde1ca..8b05ab264857ddb9554e034957cdd1ffe0ee20ad 100644 --- a/app/lib/indexer.ts +++ b/app/lib/indexer.ts @@ -1542,10 +1542,10 @@ export class Indexer { } // BR_G91 - static async ruleIndexGenDividend(HEAD: DBHead, dal: any) { + static async ruleIndexGenDividend(HEAD: DBHead, local_iindex: IindexEntry[], dal: any) { const dividends = []; if (HEAD.new_dividend) { - const members = await dal.iindexDAL.getMembersPubkeys() + const members = (await dal.iindexDAL.getMembersPubkeys()).concat(local_iindex.filter(i => i.member)) for (const MEMBER of members) { dividends.push({ op: 'CREATE', diff --git a/doc/Protocol.md b/doc/Protocol.md index f8b7c0b58e659a0e0826e7d2dfb5429270279e63..b34e1f1c95278210669e4544c1512faf31c319ca 100644 --- a/doc/Protocol.md +++ b/doc/Protocol.md @@ -2678,6 +2678,21 @@ For each `REDUCE_BY(GLOBAL_IINDEX[member=true], 'pub') as IDTY` then if `IDTY.me consumed = false ) +For each `LOCAL_IINDEX[member=true] as IDTY` add a new LOCAL_SINDEX entry: + + SINDEX ( + op = 'CREATE' + identifier = IDTY.pub + pos = HEAD.number + written_on = BLOCKSTAMP + written_time = MedianTime + amount = HEAD.dividend + base = HEAD.unitBase + locktime = null + conditions = REQUIRE_SIG(MEMBER.pub) + consumed = false + ) + ###### BR_G106 - Low accounts Set: