diff --git a/src/cutecoin/core/graph.py b/src/cutecoin/core/graph.py index 705c5fed234611233934e3ee8e4437c20946cfbb..669461734d288e1265e213c884b055153e49faec 100644 --- a/src/cutecoin/core/graph.py +++ b/src/cutecoin/core/graph.py @@ -223,23 +223,23 @@ class Graph(object): current_block_number = self.community.network.current_blockid.number if current_block_number and certifier['block_number']: - current_validations = current_block_number - certifier['block_number'] + 1 + current_confirmations = current_block_number - certifier['block_number'] + 1 else: - current_validations = 0 + current_confirmations = 0 members_pubkeys = yield from self.community.members_pubkeys() - max_validation = self.community.network.fork_window(members_pubkeys) + 1 + max_confirmation = self.community.network.fork_window(members_pubkeys) + 1 - # Current validation can be negative if self.community.network.current_blockid.number + # Current confirmation can be negative if self.community.network.current_blockid.number # is not refreshed yet - if max_validation > current_validations >= 0: + if max_confirmation > current_confirmations >= 0: if self.app.preferences['expert_mode']: - arc['validation_text'] = "{0}/{1}".format(current_validations, - max_validation) + arc['confirmation_text'] = "{0}/{1}".format(current_confirmations, + max_confirmation) else: - validation = current_validations / max_validation * 100 - arc['validation_text'] = "{0} %".format(QLocale().toString(float(validation), 'f', 0)) + confirmation = current_confirmations / max_confirmation * 100 + arc['confirmation_text'] = "{0} %".format(QLocale().toString(float(confirmation), 'f', 0)) else: - arc['validation_text'] = None + arc['confirmation_text'] = None # add arc to certifier self._graph[certifier['identity'].pubkey]['arcs'].append(arc) @@ -301,22 +301,22 @@ class Graph(object): current_block_number = self.community.network.current_blockid.number if current_block_number and certified['block_number']: - current_validations = current_block_number - certified['block_number'] + 1 + current_confirmations = current_block_number - certified['block_number'] + 1 else: - current_validations = 0 + current_confirmations = 0 members_pubkeys = yield from self.community.members_pubkeys() - max_validations = self.community.network.fork_window(members_pubkeys) + 1 + max_confirmations = self.community.network.fork_window(members_pubkeys) + 1 - if max_validations > current_validations >= 0: + if max_confirmations > current_confirmations >= 0: if self.app.preferences['expert_mode']: - arc['validation_text'] = "{0}/{1}".format(current_validations, - max_validations) + arc['confirmation_text'] = "{0}/{1}".format(current_confirmations, + max_confirmations) else: - validation = current_validations / max_validations * 100 - validation = 100 if validation > 100 else validation - arc['validation_text'] = "{0} %".format(QLocale().toString(float(validation), 'f', 0)) + confirmation = current_confirmations / max_confirmations * 100 + confirmation = 100 if confirmation > 100 else confirmation + arc['confirmation_text'] = "{0} %".format(QLocale().toString(float(confirmation), 'f', 0)) else: - arc['validation_text'] = None + arc['confirmation_text'] = None # replace old arc if this one is more recent new_arc = True diff --git a/src/cutecoin/core/registry/identity.py b/src/cutecoin/core/registry/identity.py index 9ede5dfa1a9ef5e4945ebf4e974bc50ac9765990..c944dddde0548b1508a21d36d0ca4d6b0fa0c41e 100644 --- a/src/cutecoin/core/registry/identity.py +++ b/src/cutecoin/core/registry/identity.py @@ -305,13 +305,12 @@ class Identity(QObject): certifier_data['pubkey'], BlockchainState.BUFFERED, community) - if certifier['identity'] not in [cert['identity'] for cert in certifiers]: - block = yield from community.bma_access.future_request(bma.blockchain.Block, - {'number': certifier_data['meta']['block_number']}) - certifier['cert_time'] = block['medianTime'] - certifier['block_number'] = None + block = yield from community.bma_access.future_request(bma.blockchain.Block, + {'number': certifier_data['meta']['block_number']}) + certifier['cert_time'] = block['medianTime'] + certifier['block_number'] = None - certifiers.append(certifier) + certifiers.append(certifier) except ValueError as e: logging.debug("Lookup error : {0}".format(str(e))) except NoPeerAvailable as e: @@ -320,6 +319,14 @@ class Identity(QObject): @asyncio.coroutine def unique_valid_certifiers_of(self, identities_registry, community): + """ + Get the certifications in the blockchain and in the pools + Get only unique and last certification for each pubkey + :param cutecoin.core.registry.identities.IdentitiesRegistry identities_registry: The identities registry + :param cutecoin.core.community.Community community: The community target to request the join date + :return: The list of the certifiers of this community + :rtype: list + """ certifier_list = yield from self.certifiers_of(identities_registry, community) unique_valid = [] # add certifiers of uid @@ -385,10 +392,9 @@ class Identity(QObject): certified_data['pubkey'], BlockchainState.BUFFERED, community) - if certified['identity'] not in [cert['identity'] for cert in certified_list]: - certified['cert_time'] = certified_data['meta']['timestamp'] - certified['block_number'] = None - certified_list.append(certified) + certified['cert_time'] = certified_data['meta']['timestamp'] + certified['block_number'] = None + certified_list.append(certified) except ValueError as e: if '404' in str(e): logging.debug('bma.wot.Lookup request error') diff --git a/src/cutecoin/core/transfer.py b/src/cutecoin/core/transfer.py index 8a6846ee49f06529ae48b3ee39fa3656e06e0f81..f2376d9e88adbed7f834af8354a793269cca4072 100644 --- a/src/cutecoin/core/transfer.py +++ b/src/cutecoin/core/transfer.py @@ -15,7 +15,7 @@ from enum import Enum class TransferState(Enum): """ TO_SEND means the transaction wasn't sent yet - AWAITING means the transaction is waiting to reach K blockchain validation + AWAITING means the transaction is waiting to reach K blockchain confrmation VALIDATED means the transaction was validated locally and is considered present in the blockchain REFUSED means the transaction took too long to be registered in the blockchain, therefore it is considered as refused @@ -84,7 +84,7 @@ class Transfer(QObject): ((self._not_found_in_blockchain, None, TransferState.REFUSED),), (TransferState.VALIDATING, (bool, Block, int)): - ((self._reached_enough_validation, None, TransferState.VALIDATED),), + ((self._reached_enough_confrmation, None, TransferState.VALIDATED),), (TransferState.VALIDATING, (bool, Block)): ((self._rollback_and_removed, lambda r, b: self._drop(), TransferState.DROPPED),), @@ -204,13 +204,13 @@ class Transfer(QObject): """ return 200 not in ret_codes - def _reached_enough_validation(self, rollback, current_block, fork_window): + def _reached_enough_confrmation(self, rollback, current_block, fork_window): """ - Check if the transfer reached enough validation in the blockchain + Check if the transfer reached enough confrmation in the blockchain :param bool rollback: True if we are in a rollback procedure :param ucoinpy.documents.Block current_block: The current block of the main blockchain - :param int fork_window: The number of validations needed on the network - :return: True if the transfer reached enough validations + :param int fork_window: The number of confrmations needed on the network + :return: True if the transfer reached enough confrmations :rtype: bool """ return not rollback and self.blockid.number + fork_window <= current_block.number @@ -260,7 +260,7 @@ class Transfer(QObject): def _wait(self, current_block): """ - Set the transfer as AWAITING validation. + Set the transfer as AWAITING confrmation. :param ucoinpy.documents.Block current_block: Current block of the main blockchain """ self.blockid = current_block.blockid diff --git a/src/cutecoin/gui/views/wot.py b/src/cutecoin/gui/views/wot.py index cae6725a83fa2602c953609018c35dd80897adf6..010638f7c577a67086be8777d79d7dc7ba2481f6 100644 --- a/src/cutecoin/gui/views/wot.py +++ b/src/cutecoin/gui/views/wot.py @@ -488,5 +488,5 @@ class Arc(QGraphicsLineItem): painter.setBrush(color) painter.drawPolygon(QPolygonF([head_point, destination_arrow_p1, destination_arrow_p2])) - if self.metadata["validation_text"]: - painter.drawText(head_point, self.metadata["validation_text"]) + if self.metadata["confirmation_text"]: + painter.drawText(head_point, self.metadata["confirmation_text"]) diff --git a/src/cutecoin/models/txhistory.py b/src/cutecoin/models/txhistory.py index 58097206e2e80d06da5efbb48a25e4d5931baab7..de5d3adc44113296f1768ab9bfbfe45eb8da3b6e 100644 --- a/src/cutecoin/models/txhistory.py +++ b/src/cutecoin/models/txhistory.py @@ -151,22 +151,22 @@ class TxFilterProxyModel(QSortFilterProxyModel): block_index = model.index(source_index.row(), block_col) block_data = model.data(block_index, Qt.DisplayRole) - current_validations = 0 + current_confirmations = 0 if state_data == TransferState.VALIDATING: current_blockid_number = self.community.network.current_blockid.number if current_blockid_number: - current_validations = current_blockid_number - block_data + current_confirmations = current_blockid_number - block_data elif state_data == TransferState.AWAITING: - current_validations = 0 + current_confirmations = 0 - max_validations = self.sourceModel().max_validations() + max_confirmations = self.sourceModel().max_confirmations() if self.app.preferences['expert_mode']: - return self.tr("{0} / {1} validations").format(current_validations, max_validations) + return self.tr("{0} / {1} confirmations").format(current_confirmations, max_confirmations) else: - validation = current_validations / max_validations * 100 - validation = 100 if validation > 100 else validation - return self.tr("Validating... {0} %").format(QLocale().toString(float(validation), 'f', 0)) + confirmation = current_confirmations / max_confirmations * 100 + confirmation = 100 if confirmation > 100 else confirmation + return self.tr("Confirming... {0} %").format(QLocale().toString(float(confirmation), 'f', 0)) return None @@ -188,7 +188,7 @@ class HistoryTableModel(QAbstractTableModel): self.community = community self.transfers_data = [] self.refresh_transfers() - self._max_validations = 0 + self._max_confirmations = 0 self.columns_types = ( 'date', @@ -316,15 +316,15 @@ class HistoryTableModel(QAbstractTableModel): transfers_data.append(data) try: members_pubkeys = yield from self.community.members_pubkeys() - self._max_validations = self.community.network.fork_window(members_pubkeys) + 1 + self._max_confirmations = self.community.network.fork_window(members_pubkeys) + 1 except NoPeerAvailable as e: logging.debug(str(e)) - self._max_validations = 0 + self._max_confirmations = 0 self.transfers_data = transfers_data self.endResetModel() - def max_validations(self): - return self._max_validations + def max_confirmations(self): + return self._max_confirmations def rowCount(self, parent): return len(self.transfers_data)