diff --git a/res/i18n/ts/fr_FR.ts b/res/i18n/ts/fr_FR.ts index de43bd2a5d65bcf2c3907edb40c54fa4cdb6f352..15f90e31caef5e0568c102877f9d7ab8620dc9e3 100644 --- a/res/i18n/ts/fr_FR.ts +++ b/res/i18n/ts/fr_FR.ts @@ -55,37 +55,37 @@ <translation type="obsolete">du {0}</translation> </message> <message> - <location filename="../../../src/cutecoin/core/account.py" line="53"/> + <location filename="../../../src/cutecoin/core/account.py" line="93"/> <source>Units</source> <translation>Unités</translation> </message> <message> - <location filename="../../../src/cutecoin/core/account.py" line="53"/> + <location filename="../../../src/cutecoin/core/account.py" line="93"/> <source>UD</source> <translation>DU</translation> </message> <message> - <location filename="../../../src/cutecoin/core/account.py" line="53"/> + <location filename="../../../src/cutecoin/core/account.py" line="93"/> <source>Quant Z-sum</source> <translation>Quant. som. 0</translation> </message> <message> - <location filename="../../../src/cutecoin/core/account.py" line="53"/> + <location filename="../../../src/cutecoin/core/account.py" line="93"/> <source>Relat Z-sum</source> <translation>Rel. som. 0</translation> </message> <message> - <location filename="../../../src/cutecoin/core/account.py" line="53"/> + <location filename="../../../src/cutecoin/core/account.py" line="93"/> <source>UD {0}</source> <translation>DU {0}</translation> </message> <message> - <location filename="../../../src/cutecoin/core/account.py" line="53"/> + <location filename="../../../src/cutecoin/core/account.py" line="93"/> <source>Q0 {0}</source> <translation>Q0 {0}</translation> </message> <message> - <location filename="../../../src/cutecoin/core/account.py" line="53"/> + <location filename="../../../src/cutecoin/core/account.py" line="93"/> <source>R0 {0}</source> <translation>R0 {0}</translation> </message> @@ -842,7 +842,7 @@ Revoking your UID can only success if it is not already validated by the network <translation></translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="78"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="72"/> <source> <table cellpadding="5"> <tr><td align="right"><b>{:}</b></div></td><td>{:} {:}</td></tr> @@ -865,42 +865,42 @@ Revoking your UID can only success if it is not already validated by the network </translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="78"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="72"/> <source>Universal Dividend UD(t) in</source> <translation>Dividende Universel DU(t) en</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="67"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="72"/> <source>Monetary Mass M(t) in</source> - <translation type="obsolete">Masse Monétaire M(t) en</translation> + <translation>Masse Monétaire M(t) en</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="78"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="72"/> <source>Members N(t)</source> <translation>Membres N(t)</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="67"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="72"/> <source>Monetary Mass per member M(t)/N(t) in</source> - <translation type="obsolete">Masse Monétaire par membre M(t)/N(t) en</translation> + <translation>Masse Monétaire par membre M(t)/N(t) en</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="78"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="72"/> <source>Actual growth c = UD(t)/[M(t-1)/N(t)]</source> <translation>Croissance actuelle c = DU(t)/[M(t -1)/N(t)]</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="78"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="72"/> <source>Next UD date and time (t+1)</source> <translation>Prochain DU, date et heure (t+1)</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="164"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="160"/> <source>No Universal Dividend created yet.</source> <translation>Pas de dividende universel créé pour le moment.</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="139"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="135"/> <source> <table cellpadding="5"> <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> @@ -911,37 +911,37 @@ Revoking your UID can only success if it is not already validated by the network <translation></translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="139"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="135"/> <source>{:2.0%} / {:} days</source> <translation>{:2.0%} / {:} jours</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="139"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="135"/> <source>Fundamental growth (c) / Delta time (dt)</source> <translation>Croissance fondamentale (c) / Delta de temps (dt)</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="116"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="135"/> <source>UD(t+1) = MAX { UD(t) ; c * M(t) / N(t) }</source> - <translation type="obsolete">DU(t+1) = MAX { DU(t) ; c * M(t) / N(t) }</translation> + <translation>DU(t+1) = MAX { DU(t) ; c * M(t) / N(t) }</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="139"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="135"/> <source>Universal Dividend (formula)</source> <translation>Dividende Universel (formule)</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="139"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="135"/> <source>{:} = MAX {{ {:} {:} ; {:2.0%} * {:} {:} / {:} }}</source> <translation></translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="139"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="135"/> <source>Universal Dividend (computed)</source> <translation>Dividende Universel (calculé)</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="167"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="163"/> <source> <table cellpadding="5"> <tr><td align="right"><b>{:2.0%} / {:} days</b></td><td>{:}</td></tr> @@ -968,47 +968,47 @@ Revoking your UID can only success if it is not already validated by the network </translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="167"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="163"/> <source>Fundamental growth (c)</source> <translation>Croissance fondamentale (c)</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="167"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="163"/> <source>Initial Universal Dividend UD(0) in</source> <translation>Dividende Universel Initial DU(0) en</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="167"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="163"/> <source>Time period (dt) in days (86400 seconds) between two UD</source> <translation>Période de temps (dt) en jours (86400 secondes) entre deux DU</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="167"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="163"/> <source>Number of blocks used for calculating median time</source> <translation>Nombre de blocs utilisés pour calculer le temps median</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="167"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="163"/> <source>The average time in seconds for writing 1 block (wished time)</source> <translation>Le temps moyen en secondes pour écrire un bloc (temps espéré)</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="167"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="163"/> <source>The number of blocks required to evaluate again PoWMin value</source> <translation>Le nombre de blocs requis pour évaluer une nouvelle valeur de PoWMin</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="167"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="163"/> <source>The number of previous blocks to check for personalized difficulty</source> <translation>Le nombre de blocs précédents pour vérifier la difficulté personnalisée</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="167"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="163"/> <source>The percent of previous issuers to reach for personalized difficulty</source> <translation>Le pourcentage d'utilisateurs précédents atteignant la difficulté personnalisée</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="202"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="198"/> <source> <table cellpadding="5"> <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> @@ -1022,44 +1022,44 @@ Revoking your UID can only success if it is not already validated by the network <translation></translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="202"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="198"/> <source>Minimum delay between 2 identical certifications (in days)</source> <translation>Le délai minimum entre 2 certifications identiques (en jours)</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="202"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="198"/> <source>Maximum age of a valid signature (in days)</source> <translation>Age maximum d'une signature valide (en jours)</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="202"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="198"/> <source>Minimum quantity of signatures to be part of the WoT</source> <translation>Nombre de signatures minimum pour faire partie de la TdC</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="202"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="198"/> <source>Minimum quantity of valid made certifications to be part of the WoT for distance rule</source> <translation>Quantité minimum de certifications valides pour faire partie de la TdC suivant la règle de distance</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="202"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="198"/> <source>Maximum age of a valid membership (in days)</source> <translation>Age maximum d'un statut de membre valide (en jours)</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/informations_tab.py" line="202"/> + <location filename="../../../src/cutecoin/gui/informations_tab.py" line="198"/> <source>Maximum distance between each WoT member and a newcomer</source> <translation>Distance maximum entre chaque membre de la TdC et un nouveau venu</translation> </message> <message> <location filename="../../../src/cutecoin/gui/informations_tab.py" line="78"/> <source>Monetary Mass M(t-1) in</source> - <translation>Masse Monétaire M(t-1) en</translation> + <translation type="obsolete">Masse Monétaire M(t-1) en</translation> </message> <message> <location filename="../../../src/cutecoin/gui/informations_tab.py" line="78"/> <source>Monetary Mass per member M(t-1)/N(t) in</source> - <translation>Masse Monétaire par membre M(t-1)/N(t) en</translation> + <translation type="obsolete">Masse Monétaire par membre M(t-1)/N(t) en</translation> </message> <message> <location filename="../../../src/cutecoin/gui/informations_tab.py" line="127"/> @@ -1069,7 +1069,7 @@ Revoking your UID can only success if it is not already validated by the network <message> <location filename="../../../src/cutecoin/gui/informations_tab.py" line="139"/> <source>UD(t+1) = MAX { UD(t) ; c * M(t) / N(t+1) }</source> - <translation>DU(t+1) = MAX { DU(t) ; c * M(t) / N(t+1) }</translation> + <translation type="obsolete">DU(t+1) = MAX { DU(t) ; c * M(t) / N(t+1) }</translation> </message> </context> <context> diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index d48cb31d922a9ad356a40fedd9f815043c58f3a9..e713887c7f903ef556dfd4e8927e3f6eb482364c 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -1,8 +1,8 @@ -''' +""" Created on 1 févr. 2014 @author: inso -''' +""" from ucoinpy import PROTOCOL_VERSION from ucoinpy.api import bma @@ -12,6 +12,7 @@ from ucoinpy.key import SigningKey import logging import time +import math from PyQt5.QtCore import QObject, pyqtSignal, QCoreApplication, QT_TRANSLATE_NOOP @@ -22,23 +23,62 @@ from ..tools.exceptions import ContactAlreadyExists def quantitative(units, community): + """ + Return quantitative value of units + + :param int units: Value + :param cutecoin.core.community.Community community: Community instance + :return: int + """ return int(units) def relative(units, community): - ud = community.dividend + """ + Return relaive value of units + + :param int units: Value + :param cutecoin.core.community.Community community: Community instance + :return: float + """ + # fixme: the value "community.nb_members" is not up to date, luckyly the good value is in "community.get_ud_block()['membersCount']" + # calculate ud(t+1) + ud = math.ceil( + max(community.dividend, + community.parameters['c'] * community.monetary_mass / community.get_ud_block()['membersCount']) + ) relative_value = units / float(ud) return relative_value def quantitative_zerosum(units, community): - median = community.get_ud_block(1)['monetaryMass'] / community.nb_members - return units - median + """ + Return quantitative value of units minus the average value + + :param int units: Value + :param cutecoin.core.community.Community community: Community instance + :return: int + """ + # fixme: the value "community.nb_members" is not up to date, luckyly the good value is in "community.get_ud_block()['membersCount']" + average = community.monetary_mass / community.get_ud_block()['membersCount'] + return units - average def relative_zerosum(units, community): - median = community.get_ud_block(1)['monetaryMass'] / community.nb_members - ud = community.dividend + """ + Return relative value of units minus the average value + + :param int units: Value + :param cutecoin.core.community.Community community: Community instance + :return: float + """ + # fixme: the value "community.nb_members" is not up to date, luckyly the good value is in "community.get_ud_block()['membersCount']" + median = community.monetary_mass / community.nb_members + # calculate ud(t+1) + ud = math.ceil( + max(community.dividend, + community.parameters['c'] * community.monetary_mass / community.get_ud_block()['membersCount']) + ) relative_value = units / float(ud) relative_median = median / ud return relative_value - relative_median @@ -250,8 +290,8 @@ class Account(QObject): logging.debug("Certification : {0}".format(signed_cert)) data = {'pubkey': certified.pubkey, - 'self_': selfcert.signed_raw(), - 'other': "{0}\n".format(certification.inline())} + 'self_': selfcert.signed_raw(), + 'other': "{0}\n".format(certification.inline())} logging.debug("Posted data : {0}".format(data)) community.broadcast(bma.wot.Add, {}, data) @@ -346,8 +386,8 @@ class Account(QObject): selfcert.sign([key]) logging.debug("Key publish : {0}".format(selfcert.signed_raw())) community.broadcast(bma.wot.Add, {}, {'pubkey': self.pubkey, - 'self_': selfcert.signed_raw(), - 'other': []}) + 'self_': selfcert.signed_raw(), + 'other': []}) def send_membership(self, password, community, mstype): ''' @@ -363,14 +403,14 @@ class Account(QObject): blockid = community.current_blockid() membership = Membership(PROTOCOL_VERSION, community.currency, - selfcert.pubkey, blockid['number'], - blockid['hash'], mstype, selfcert.uid, - selfcert.timestamp, None) + selfcert.pubkey, blockid['number'], + blockid['hash'], mstype, selfcert.uid, + selfcert.timestamp, None) key = SigningKey(self.salt, password) membership.sign([key]) logging.debug("Membership : {0}".format(membership.signed_raw())) community.broadcast(bma.blockchain.Membership, {}, - {'membership': membership.signed_raw()}) + {'membership': membership.signed_raw()}) def jsonify(self): ''' diff --git a/src/cutecoin/gui/informations_tab.py b/src/cutecoin/gui/informations_tab.py index 26d9bfe55e6ff40978945d47486e8846a7071545..93db5e17fbb334ae257fa4db4d88a2b68e545e55 100644 --- a/src/cutecoin/gui/informations_tab.py +++ b/src/cutecoin/gui/informations_tab.py @@ -48,30 +48,24 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget): return False if block: - ud = round(self.get_referential_diff_value(block['dividend'])) + ud = self.get_referential_diff_value(block['dividend']) if isinstance(ud, int): # use the float type of 64bits, to avoid display a 32bit signed integer... localized_ud = QLocale().toString(float(ud), 'f', 0) - localized_monetary_mass_minus_1 = QLocale().toString( - float(self.get_referential_value(block_t_minus_1['monetaryMass'])), 'f', 0 - ) - localized_mass_minus_1_per_member = QLocale().toString( - float(self.get_referential_value(block_t_minus_1['monetaryMass'] / block['membersCount'])), 'f', 0 + localized_mass_per_member = QLocale().toString( + float(self.get_referential_diff_value(block['monetaryMass'] / block['membersCount'])), 'f', 0 ) localized_monetary_mass = QLocale().toString( - float(self.get_referential_value(block['monetaryMass'])), 'f', 0 + float(self.get_referential_diff_value(block['monetaryMass'])), 'f', 0 ) else: localized_ud = QLocale().toString(ud, 'f', 6) - localized_monetary_mass_minus_1 = QLocale().toString( - round(self.get_referential_value(block_t_minus_1['monetaryMass'])), 'f', 6 - ) - localized_mass_minus_1_per_member = QLocale().toString( - round(self.get_referential_value(block_t_minus_1['monetaryMass'] / block['membersCount']), 'f', 6) + localized_mass_per_member = QLocale().toString( + self.get_referential_diff_value(block['monetaryMass'] / block['membersCount']), 'f', 6 ) localized_monetary_mass = QLocale().toString( - round(self.get_referential_value(block['monetaryMass'])), 'f', 6 + self.get_referential_diff_value(block['monetaryMass']), 'f', 6 ) # set infos in label @@ -88,15 +82,15 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget): """).format( localized_ud, self.tr('Universal Dividend UD(t) in'), - self.get_referential_name(), - localized_monetary_mass_minus_1, - self.tr('Monetary Mass M(t-1) in'), - self.get_referential_name(), + self.get_referential_diff_name(), + localized_monetary_mass, + self.tr('Monetary Mass M(t) in'), + self.get_referential_diff_name(), block['membersCount'], self.tr('Members N(t)'), - localized_mass_minus_1_per_member, - self.tr('Monetary Mass per member M(t-1)/N(t) in'), - self.get_referential_name(), + localized_mass_per_member, + self.tr('Monetary Mass per member M(t)/N(t) in'), + self.get_referential_diff_name(), block['dividend'] / (block_t_minus_1['monetaryMass'] / block['membersCount']), params['dt'] / 86400, self.tr('Actual growth c = UD(t)/[M(t-1)/N(t)]'), @@ -117,7 +111,8 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget): float( self.get_referential_diff_value( math.ceil( - max(block['dividend'], params['c'] * block['monetaryMass'] / block['membersCount'])) + max(block['dividend'], params['c'] * block['monetaryMass'] / block['membersCount']) + ) ) ), 'f', @@ -128,7 +123,8 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget): float( self.get_referential_diff_value( math.ceil( - max(block['dividend'], params['c'] * block['monetaryMass'] / block['membersCount'])) + max(block['dividend'], params['c'] * block['monetaryMass'] / block['membersCount']) + ) ) ), 'f', @@ -146,15 +142,15 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget): """).format( self.tr('{:2.0%} / {:} days').format(params['c'], params['dt'] / 86400), self.tr('Fundamental growth (c) / Delta time (dt)'), - self.tr('UD(t+1) = MAX { UD(t) ; c * M(t) / N(t+1) }'), + self.tr('UD(t+1) = MAX { UD(t) ; c * M(t) / N(t) }'), self.tr('Universal Dividend (formula)'), self.tr('{:} = MAX {{ {:} {:} ; {:2.0%} * {:} {:} / {:} }}').format( localized_ud_t1, localized_ud, - self.get_referential_name(), + self.get_referential_diff_name(), params['c'], localized_monetary_mass, - self.get_referential_name(), + self.get_referential_diff_name(), block['membersCount'] ), self.tr('Universal Dividend (computed)') @@ -233,3 +229,6 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget): def get_referential_name(self): return self.account.ref_name(self.community.short_currency) + + def get_referential_diff_name(self): + return self.account.diff_ref_name(self.community.short_currency)