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

Fix #226 bad algorithm for memory cleaning of blocks

parent aed46783
No related branches found
No related tags found
No related merge requests found
......@@ -164,7 +164,8 @@ module.exports = {
INVALIDATE_CORE_CACHE: true,
WITH_SIGNATURES_AND_POW: true,
SAFE_FACTOR: 1.5,
MEMORY_CLEAN_INTERVAL: 60 * 60, // hourly
SAFE_FACTOR: 3,
BLOCKS_COLLECT_THRESHOLD: 30, // Blocks to collect from memory and persist
setUDID2Format: function () {
......
......@@ -86,7 +86,6 @@ function BlockDAL(loki, rootFS, getLowerWindowBlock) {
}
return co(function *() {
let filesBlocks = yield Q.all(_.range(start, Math.min(lowerInLoki.number, end + 1)).map((number) => rootFS.readJSON(pathOfBlock(number) + blockFileName(number) + '.json')));
yield migrateOldBlocks();
return filesBlocks.concat(lokiBlocks);
});
};
......@@ -184,8 +183,7 @@ function BlockDAL(loki, rootFS, getLowerWindowBlock) {
current = previousBlock;
};
function migrateOldBlocks() {
return co(function *() {
this.migrateOldBlocks = () => co(function *() {
let number = yield getLowerWindowBlock();
logger.debug("Clean some blocks from memory to disk...");
logger.debug("Lower block = %s", number);
......@@ -217,7 +215,6 @@ function BlockDAL(loki, rootFS, getLowerWindowBlock) {
logger.debug("LastUD in loki = %s", that.lastBlockWithDividend().number);
}
});
}
function getView() {
let view;
......
......@@ -167,6 +167,9 @@ function Server (dbConf, overrideConf) {
},
function (next){
that.PeeringService.regularSyncBlock(next);
},
function (next){
that.BlockchainService.regularCleanMemory(next);
}
], done);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment