Mise à jour de GitLab prévue ce samedi 23 octobre 2021 à partir de 9h00 CET

Commit 4416946b authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] loki data commiting and trimming should be triggered every 30 blocks

parent df868d27
......@@ -18,8 +18,8 @@ import {
IndexEntry,
Indexer,
MindexEntry,
SimpleSindexEntryForWallet, SimpleTxEntryForWallet, SimpleUdEntryForWallet,
SindexEntry
SimpleTxEntryForWallet,
SimpleUdEntryForWallet
} from "../indexer"
import {ConfDTO} from "../dto/ConfDTO"
import {BlockDTO} from "../dto/BlockDTO"
......@@ -37,7 +37,6 @@ import {DataErrors} from "../common-libs/errors"
import {NewLogger} from "../logger"
import {DBTx} from "../db/DBTx"
import {Underscore} from "../common-libs/underscore"
import {DividendEntry, UDSource} from "../dal/indexDAL/abstract/DividendDAO"
import {OtherConstants} from "../other_constants"
export class DuniterBlockchain {
......@@ -205,6 +204,13 @@ export class DuniterBlockchain {
}
logger.info('Block #' + block.number + ' added to the blockchain in %s ms', (Date.now() - start));
// Periodically, we trim the blockchain
if (block.number % CommonConstants.BLOCKS_COLLECT_THRESHOLD === 0) {
// Database trimming
await dal.loki.flushAndTrimData()
}
return BlockDTO.fromJSONObject(added)
}
catch(err) {
......
......@@ -307,6 +307,8 @@ export const CommonConstants = {
MAX_AGE_OF_PEER_IN_BLOCKS: 200, // blocks
INITIAL_DOWNLOAD_SLOTS: 1, // 1 peer
BLOCKS_COLLECT_THRESHOLD: 30, // Number of blocks to wait before trimming the loki data
}
function exact (regexpContent:string) {
......
......@@ -147,11 +147,6 @@ export class BlockchainContext {
const block = forks[0];
await this.checkAndAddBlock(BlockDTO.fromJSONObject(block))
this.logger.debug('Applied block #%s', block.number);
// Periodically, we trim the blockchain
if (block.number % 30 === 0) {
// Database trimming
await this.dal.loki.flushAndTrimData()
}
}
async checkAndAddBlock(block:BlockDTO, trim = true) {
......
......@@ -176,7 +176,6 @@ module.exports = {
NO_FORK_ALLOWED: false,
SAFE_FACTOR: 3,
BLOCKS_COLLECT_THRESHOLD: 30, // Blocks to collect from memory and persist
MUTE_LOGS_DURING_UNIT_TESTS: OtherConstants.MUTE_LOGS_DURING_UNIT_TESTS,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment