From a72d436ea844a7685f0828ce1b0ceb8556500164 Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Thu, 26 Jan 2017 17:41:42 +0100 Subject: [PATCH] [fix] #800 wotb module could make Duniter crash --- app/lib/dup/indexer.js | 4 +++- app/lib/wot.js | 5 +++++ package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/lib/dup/indexer.js b/app/lib/dup/indexer.js index 70a67b431..d615d30cb 100644 --- a/app/lib/dup/indexer.js +++ b/app/lib/dup/indexer.js @@ -1523,7 +1523,8 @@ function reduceBy(reducables, properties) { function checkPeopleAreNotOudistanced (pubkeys, newLinks, newcomers, conf, dal) { return co(function *() { - let wotb = dal.wotb; + // let wotb = dal.wotb; + let wotb = dal.wotb.memcopy(); let current = yield dal.getCurrentBlockOrNull(); let membersCount = current ? current.membersCount : 0; // TODO: make a temporary copy of the WoT in RAM @@ -1559,6 +1560,7 @@ function checkPeopleAreNotOudistanced (pubkeys, newLinks, newcomers, conf, dal) // Undo temp links/nodes tempLinks.forEach((link) => wotb.removeLink(link.from, link.to)); newcomers.forEach(() => wotb.removeNode()); + wotb.clear(); return error ? true : false; }); } diff --git a/app/lib/wot.js b/app/lib/wot.js index d2173e31e..5543c780f 100644 --- a/app/lib/wot.js +++ b/app/lib/wot.js @@ -12,8 +12,13 @@ module.exports = { function WoTBWrapper(instance) { + this.memcopy = () => { + return new WoTBWrapper(instance.memCopy()); + }; + this.setVerbose = wotb.setVerbose; this.resetWoT = instance.resetWoT; + this.clear = instance.clear; this.showWoT = instance.showWoT; this.showGraph = () => instance.showGraph(); diff --git a/package.json b/package.json index c5e46744a..e5b549805 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "unzip": "0.1.11", "unzip2": "0.2.5", "winston": "2.2.0", - "wotb": "0.4.14" + "wotb": "0.4.15" }, "devDependencies": { "coveralls": "2.11.4", -- GitLab