From 59f5e6efe65cd698d938ad3eedc12a74dd3cd521 Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Tue, 10 Jan 2017 17:27:19 +0100
Subject: [PATCH] [enh] Protocol: always fill in `conditions` field for SINDEX

---
 app/lib/dup/indexer.js | 5 +++--
 doc/Protocol.md        | 6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/app/lib/dup/indexer.js b/app/lib/dup/indexer.js
index 84bbc11a0..4289d94e0 100644
--- a/app/lib/dup/indexer.js
+++ b/app/lib/dup/indexer.js
@@ -233,8 +233,8 @@ const indexer = module.exports = {
           unlock: txObj.unlocks[k],
           amount: input.amount,
           base: input.base,
-          consumed: true,
           conditions: null,
+          consumed: true,
           txObj: txObj
         });
         k++;
@@ -253,8 +253,8 @@ const indexer = module.exports = {
           locktime: obj.locktime,
           amount: output.amount,
           base: output.base,
-          consumed: false,
           conditions: output.conditions,
+          consumed: false,
           txObj: obj
         });
       }
@@ -713,6 +713,7 @@ const indexer = module.exports = {
         amount: ENTRY.amount,
         base: ENTRY.base
       });
+      ENTRY.conditions = reduce(reducable).conditions; // We valuate the input conditions, so we can map these records to a same account
       ENTRY.available = reduce(reducable).consumed === false;
     }));
 
diff --git a/doc/Protocol.md b/doc/Protocol.md
index bb6e3012b..d765e2432 100644
--- a/doc/Protocol.md
+++ b/doc/Protocol.md
@@ -2027,11 +2027,13 @@ Else:
     
 EndIf
 
-####### BR_G46 - ENTRY.available
+####### BR_G46 - ENTRY.available and ENTRY.conditions
 
 For each `LOCAL_SINDEX[op='UPDATE'] as ENTRY`:
 
-    ENTRY.available = REDUCE(GLOBAL_SINDEX[identifier=ENTRY.identifier,pos=ENTRY.pos,amount=ENTRY.amount,base=ENTRY.base]).consumed == false
+    INPUT = REDUCE(GLOBAL_SINDEX[identifier=ENTRY.identifier,pos=ENTRY.pos,amount=ENTRY.amount,base=ENTRY.base])
+    ENTRY.conditions = INPUT.conditions
+    ENTRY.available = INPUT.consumed == false
 
 ####### BR_G47 - ENTRY.isLocked
 
-- 
GitLab