Skip to content
Snippets Groups Projects
Commit 992fdb0f authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

fix(1446): When reverting a block, delete source condition index only if no...

fix(1446): When reverting a block, delete source condition index only if no create record exists - fix #1446
parent 4938e5dd
No related branches found
No related tags found
No related merge requests found
...@@ -310,7 +310,8 @@ export class LevelDBSindex ...@@ -310,7 +310,8 @@ export class LevelDBSindex
const updateRecord = await this.getOrNull(updateKey); const updateRecord = await this.getOrNull(updateKey);
// Undo consumption // Undo consumption
if (updateRecord && updateRecord.writtenOn === writtenOn) { 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); await this.del(updateKey);
} }
// Undo creation? // Undo creation?
...@@ -318,11 +319,10 @@ export class LevelDBSindex ...@@ -318,11 +319,10 @@ export class LevelDBSindex
conditions.push(createRecord.conditions); conditions.push(createRecord.conditions);
await this.del(createKey); await this.del(createKey);
} }
// Update balance // Update condition index
// 1. Conditions
const uniqConditions = Underscore.uniq(conditions); const uniqConditions = Underscore.uniq(conditions);
for (const condition of uniqConditions) { for (const condition of uniqConditions) {
// Remove this source from the balance // Remove this source from the condition
await this.trimConditions(condition, id); await this.trimConditions(condition, id);
} }
} }
...@@ -346,7 +346,7 @@ export class LevelDBSindex ...@@ -346,7 +346,7 @@ export class LevelDBSindex
// If some sources are left for this "condition", persist what remains // If some sources are left for this "condition", persist what remains
await this.indexForConditions.put(condition, trimmed); await this.indexForConditions.put(condition, trimmed);
} else { } else {
// Otherwise just delete the "account" // Otherwise just delete the "condition"
await this.indexForConditions.del(condition); await this.indexForConditions.del(condition);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment