From 992fdb0f1d7bd28c504115d53d21917365ddb0e3 Mon Sep 17 00:00:00 2001 From: Benoit Lavenier <benoit.lavenier@e-is.pro> Date: Tue, 6 Jun 2023 12:27:50 +0200 Subject: [PATCH] fix(1446): When reverting a block, delete source condition index only if no create record exists - fix #1446 --- app/lib/dal/indexDAL/leveldb/LevelDBSindex.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/lib/dal/indexDAL/leveldb/LevelDBSindex.ts b/app/lib/dal/indexDAL/leveldb/LevelDBSindex.ts index b58aa9aa3..6569d4393 100644 --- a/app/lib/dal/indexDAL/leveldb/LevelDBSindex.ts +++ b/app/lib/dal/indexDAL/leveldb/LevelDBSindex.ts @@ -310,7 +310,8 @@ export class LevelDBSindex const updateRecord = await this.getOrNull(updateKey); // Undo consumption if (updateRecord && updateRecord.writtenOn === writtenOn) { - conditions.push(updateRecord.conditions); + // Delete from condition index only if no createRecord exists - fix #1446 + if (!createRecord) conditions.push(updateRecord.conditions); await this.del(updateKey); } // Undo creation? @@ -318,11 +319,10 @@ export class LevelDBSindex conditions.push(createRecord.conditions); await this.del(createKey); } - // Update balance - // 1. Conditions + // Update condition index const uniqConditions = Underscore.uniq(conditions); for (const condition of uniqConditions) { - // Remove this source from the balance + // Remove this source from the condition await this.trimConditions(condition, id); } } @@ -346,7 +346,7 @@ export class LevelDBSindex // If some sources are left for this "condition", persist what remains await this.indexForConditions.put(condition, trimmed); } else { - // Otherwise just delete the "account" + // Otherwise just delete the "condition" await this.indexForConditions.del(condition); } -- GitLab