From e96f1ccdbf662578de5140930ab3c6fe7971237d Mon Sep 17 00:00:00 2001
From: blavenie <benoit.lavenier@e-is.pro>
Date: Mon, 30 Jan 2017 19:50:53 +0100
Subject: [PATCH] Currency wot rules: sentries formula - fix #291

---
 www/i18n/locale-en-GB.json                 |  2 ++
 www/i18n/locale-en.json                    |  2 ++
 www/i18n/locale-fr-FR.json                 |  6 ++++--
 www/js/controllers/currency-controllers.js |  2 ++
 www/templates/currency/items_wot.html      | 18 ++++++++++++++++--
 5 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/www/i18n/locale-en-GB.json b/www/i18n/locale-en-GB.json
index 7020aae5d..c0e1a55db 100644
--- a/www/i18n/locale-en-GB.json
+++ b/www/i18n/locale-en-GB.json
@@ -156,6 +156,8 @@
       "SIG_WINDOW": "Maximum delay before a certification<br/>will be treated",
       "STEP_MAX": "Maximum distance between<br/>each WoT member and a newcomer.",
       "WOT_RULES_DIVIDER": "Rules for web of trust",
+      "SENTRIES": "Required number of certifications<br/>to become a sentries",
+      "SENTRIES_FORMULA": "Required number of certifications<br/>to become a sentries (formula)",
       "XPERCENT":"Minimum percent of sentries<br />to reach to match the distance rule",
       "AVG_GEN_TIME": "The average time between 2 blocks",
       "CURRENT": "current"
diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json
index 5a54fb125..59d1b94ca 100644
--- a/www/i18n/locale-en.json
+++ b/www/i18n/locale-en.json
@@ -156,6 +156,8 @@
       "SIG_WINDOW": "Maximum delay before a certification<br/>will be treated",
       "STEP_MAX": "Maximum distance between<br/>each WoT member and a newcomer.",
       "WOT_RULES_DIVIDER": "Rules for web of trust",
+      "SENTRIES": "Required number of certifications<br/>to become a sentries",
+      "SENTRIES_FORMULA": "Required number of certifications<br/>to become a sentries (formula)",
       "XPERCENT":"Minimum percent of sentries<br />to reach to match the distance rule",
       "AVG_GEN_TIME": "The average time between 2 blocks",
       "CURRENT": "current"
diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json
index 0ff4393ae..b2fa40cb6 100644
--- a/www/i18n/locale-fr-FR.json
+++ b/www/i18n/locale-fr-FR.json
@@ -154,9 +154,11 @@
       "SIG_STOCK": "Nombre maximal de certifications émises<br/>par membre",
       "SIG_PERIOD": "Délai minimal d'attente entre 2 certifications<br/>successives émises par une même personne.",
       "SIG_WINDOW": "Délai maximal d'attente avant<br/>prise en compte d'une certification",
-      "STEP_MAX": "Distance maximale dans la toile de confiance <br /> entre chaque membre et un nouvel entrant.",
+      "STEP_MAX": "Distance maximale dans la toile de confiance <br/> entre chaque membre et un nouvel entrant.",
       "WOT_RULES_DIVIDER": "Règles de la toile de confiance",
-      "XPERCENT":"Pourcentage minimum de sentinelle<br/>à atteindre pour respecter la règle de distance.",
+      "SENTRIES": "Nombre de certification requises<br/>pour être sentinelle",
+      "SENTRIES_FORMULA": "Nombre de certification<br/>pour être sentinelle (formule)",
+      "XPERCENT":"Pourcentage minimum de sentinelle<br/>à atteindre pour respecter la règle de distance",
       "AVG_GEN_TIME": "Temps moyen entre deux blocs",
       "CURRENT": "actuel"
     }
diff --git a/www/js/controllers/currency-controllers.js b/www/js/controllers/currency-controllers.js
index 6e6be9721..10c1a0fd1 100644
--- a/www/js/controllers/currency-controllers.js
+++ b/www/js/controllers/currency-controllers.js
@@ -154,6 +154,7 @@ function CurrencyViewController($scope, $q, $timeout, BMA, UIUtils, csSettings,
     difficulty : 0,
     Nprev: 0,
     stepMax: 0,
+    sentries: 0,
     xpercent: 0,
     durationFromLastUD: 0,
     blockUid: null,
@@ -281,6 +282,7 @@ function CurrencyViewController($scope, $q, $timeout, BMA, UIUtils, csSettings,
       data.UD = data.currentUD;
       data.durationFromLastUD = lastUDTime ? data.medianTime - lastUDTime : 0;
       data.useRelative = $scope.formData.useRelative;
+      data.sentries = Math.ceil(Math.pow(data.N, 1/ data.stepMax));
 
       // Apply to formData
       angular.copy(data, $scope.formData);
diff --git a/www/templates/currency/items_wot.html b/www/templates/currency/items_wot.html
index 8fece4eac..b48a0c03a 100644
--- a/www/templates/currency/items_wot.html
+++ b/www/templates/currency/items_wot.html
@@ -1,7 +1,7 @@
 
   <ion-list bind-notifier="{ rebind:formData.useRelative }">
 
-    <ion-item class="item-icon-left">
+    <ion-item class="item-icon-left item-text-wrap">
         <i class="icon ion-person-stalker"></i>
         <span translate>CURRENCY.VIEW.MEMBERS</span> (N<sub>{{'CURRENCY.VIEW.CURRENT'|translate}}</sub>)
         <span class="badge badge-assertive" ng-if="!loading">{{formData.N | formatInteger}}</span>
@@ -17,6 +17,12 @@
       </div>
     </ion-item>
 
+    <ion-item  class="item-icon-left item-text-wrap">
+      <i class="icon ion-ribbon-b"></i>
+      <b class="ion-star " style="color: yellow; position: absolute; font-size: 16px; left: 25px; bottom: 32px"></b>
+      <span translate>CURRENCY.VIEW.SENTRIES</span>
+      <span class="badge badge-royal" ng-if="!loading">{{formData.sentries}}</span>
+    </ion-item>
 
     <div id="helptip-currency-rules"
          class="item item-divider">
@@ -54,10 +60,18 @@
 
     <ion-item class="item-icon-left item-text-wrap">
       <i class="icon ion-steam"></i>
-      <span class="col col-75" translate>CURRENCY.VIEW.STEP_MAX</span>
+      <b class="ion-person" style="position: absolute; font-size: 16px; left: 38px; top: 17px"></b>
+      <span class="col col-75"><span ng-bind-html="'CURRENCY.VIEW.STEP_MAX'|translate"></span> (stepMax)</span>
       <span class="badge badge-stable" ng-if="!loading">{{formData.stepMax}}</span>
     </ion-item>
 
+    <ion-item  class="item-icon-left item-text-wrap">
+      <i class="icon ion-ribbon-b"></i>
+      <b class="ion-star " style="color: yellow; position: absolute; font-size: 16px; left: 25px; bottom: 32px"></b>
+      <span ng-bind-html="'CURRENCY.VIEW.SENTRIES_FORMULA'|translate"></span>
+      <span class="item-note dark" ng-if="!loading">CEIL( N<sub>t</sub><sup>^ (1 / stepMax)</sup>)</span>
+    </ion-item>
+
     <ion-item class="item-icon-left item-text-wrap">
       <i class="icon ion-pull-request"></i>
       <span class="col col-75" translate>CURRENCY.VIEW.XPERCENT</span>
-- 
GitLab