From 7ef0be61b693e3945549264ee126c8491939aa4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Moreau?= <cem.moreau@gmail.com> Date: Thu, 7 Jun 2018 13:12:28 +0200 Subject: [PATCH] [fix] certification expiration may duplicate `kick: true` --- app/lib/indexer.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/lib/indexer.ts b/app/lib/indexer.ts index f4df3584c..6e5616d20 100644 --- a/app/lib/indexer.ts +++ b/app/lib/indexer.ts @@ -183,6 +183,14 @@ export interface Ranger { (n:number, m:number): Promise<DBHead[]> } +export interface ExclusionByCert { + op: 'UPDATE' + pub: string + written_on: string + writtenOn: number + kick: true +} + function pushIindex(index: IndexEntry[], entry: IindexEntry): void { index.push(entry) } @@ -1766,16 +1774,17 @@ export class Indexer { // BR_G95 static async ruleIndexGenExclusionByCertificatons(HEAD: DBHead, cindex: CindexEntry[], iindex: IindexEntry[], conf: ConfDTO, dal:FileDAL) { - const exclusions = []; + const exclusions: ExclusionByCert[] = []; const expiredCerts = Underscore.filter(cindex, (c: CindexEntry) => c.expired_on > 0); for (const CERT of expiredCerts) { const just_expired = Underscore.filter(cindex, (c: CindexEntry) => c.receiver == CERT.receiver && c.expired_on > 0); const just_received = Underscore.filter(cindex, (c: CindexEntry) => c.receiver == CERT.receiver && c.expired_on == 0); const non_expired_global = await dal.cindexDAL.getValidLinksTo(CERT.receiver); if ((count(non_expired_global) - count(just_expired) + count(just_received)) < conf.sigQty) { - const isInExcluded = Underscore.filter(iindex, (i: IindexEntry) => i.member === false && i.pub === CERT.receiver)[0]; + const isInExcluded = Underscore.filter(iindex, (i: IindexEntry) => i.member === false && i.pub === CERT.receiver)[0] + const isInKicked = Underscore.filter(exclusions, e => e.pub === CERT.receiver)[0] const idty = await dal.iindexDAL.getFullFromPubkey(CERT.receiver) - if (!isInExcluded && idty.member) { + if (!isInExcluded && !isInKicked && idty.member) { exclusions.push({ op: 'UPDATE', pub: CERT.receiver, -- GitLab