From 2eb29b0e62a7ef2552ca3e9f7d711cbb229e72fc Mon Sep 17 00:00:00 2001
From: librelois <elois@ifee.fr>
Date: Thu, 9 Jan 2020 21:44:47 +0100
Subject: [PATCH] [fix] #11: rule BR_G27 : do not count certs being replayed
 twice

---
 rfc/0010_Duniter_Blockchain_Protocol_V12.md | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/rfc/0010_Duniter_Blockchain_Protocol_V12.md b/rfc/0010_Duniter_Blockchain_Protocol_V12.md
index 4d56c00..cd91d12 100644
--- a/rfc/0010_Duniter_Blockchain_Protocol_V12.md
+++ b/rfc/0010_Duniter_Blockchain_Protocol_V12.md
@@ -2150,8 +2150,19 @@ For each ENTRY in local MINDEX where `op = 'UPDATE', expired_on = 0`:
 
 For each ENTRY in local MINDEX where `type == 'JOIN' OR type == 'ACTIVE'`:
 
-    ENTRY.enoughCerts = COUNT(GLOBAL_CINDEX[receiver=ENTRY.pub,expired_on=null]) + COUNT(LOCAL_CINDEX[receiver=ENTRY.pub,expired_on=null]) >= sigQty 
-    
+If `HEAD.version >= 12`
+
+    BLOCKCHAIN = REDUCE_BY(GLOBAL_CINDEX[receiver=ENTRY.pub], 'issuer')[expired_on=0]
+    INCOMING = LOCAL_CINDEX[receiver=ENTRY.pub]
+    UNIQUE_ISSUERS = UNIQ(CONCAT(
+        PICK(BLOCKCHAIN, 'issuer'),
+        PICK(INCOMING, 'issuer')))
+    ENTRY.enoughCerts = COUNT(UNIQUE_ISSUERS) >= sigQty
+
+else
+
+    ENTRY.enoughCerts = COUNT(GLOBAL_CINDEX[receiver=ENTRY.pub,expired_on=0]) + COUNT(LOCAL_CINDEX[receiver=ENTRY.pub,expired_on=0]) >= sigQty
+
 > Functionally: any member or newcomer needs `[sigQty]` certifications coming *to* him to be in the WoT
 
 For each ENTRY in local MINDEX where `!(type == 'JOIN' OR type == 'ACTIVE')`:
-- 
GitLab