Skip to content
Snippets Groups Projects
Commit 68de9a52 authored by inso's avatar inso
Browse files

Display the identities informations

parent 57fdc18b
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ from ..entities import Identity
from duniterpy.api import bma, errors
from duniterpy import PROTOCOL_VERSION
from duniterpy.key import SigningKey
from duniterpy.documents import SelfCertification
from duniterpy.documents import SelfCertification, BlockUID
from aiohttp.errors import ClientError
from sakia.errors import NoPeerAvailable
......@@ -86,7 +86,25 @@ class IdentitiesProcessor:
:rtype: sakia.data.entities.Identity
"""
return self._identities_repo.get_written(**{'currency': currency, 'pubkey': pubkey})
return self._identities_repo.get_written(currency=currency, pubkey=pubkey)
def get_identity(self, currency, pubkey, uid):
"""
Return the identity corresponding to a given pubkey, uid and currency
:param str currency:
:param str pubkey:
:param str uid:
:rtype: sakia.data.entities.Identity
"""
written = self.get_written(currency=currency, pubkey=pubkey)
if not written:
identities = self._identities_repo.get_all(currency=currency, pubkey=pubkey, uid=uid)
recent = identities[0]
for i in identities:
if i.blockstamp > recent.blockstamp:
recent = i
return recent
def commit_identity(self, identity):
"""
......
......@@ -34,10 +34,11 @@ class InformationsController(ComponentController):
def create(cls, parent, app, **kwargs):
connection = kwargs['connection']
blockchain_service = kwargs['blockchain_service']
identities_service = kwargs['identities_service']
sources_service = kwargs['sources_service']
view = InformationsView(parent.view)
model = InformationsModel(None, app, connection, blockchain_service, sources_service)
model = InformationsModel(None, app, connection, blockchain_service, identities_service, sources_service)
informations = cls(parent, view, model)
model.setParent(informations)
informations.init_view_text()
......
......@@ -15,7 +15,7 @@ class InformationsModel(ComponentModel):
"""
localized_data_changed = pyqtSignal(dict)
def __init__(self, parent, app, connection, blockchain_service, sources_service):
def __init__(self, parent, app, connection, blockchain_service, identities_service, sources_service):
"""
Constructor of an component
......@@ -23,12 +23,14 @@ class InformationsModel(ComponentModel):
:param sakia.app.Application app: the app
:param sakia.data.entities.Connection connection: the user connection of this node
:param sakia.services.BlockchainService blockchain_service: the service watching the blockchain state
:param sakia.services.IdentitiesService identities_service: the service watching the identities state
:param sakia.services.SourcesService sources_service: the service watching the sources states
"""
super().__init__(parent)
self.app = app
self.connection = connection
self.blockchain_service = blockchain_service
self.identities_service = identities_service
self.sources_service = sources_service
async def get_localized_data(self):
......@@ -112,12 +114,11 @@ class InformationsModel(ComponentModel):
localized_amount = await self.app.current_ref.instance(amount, self.connection.currency, self.app)\
.localized(units=True,
international_system=self.app.parameters.international_system_of_units)
account_identity = await self.app.current_account.identity(self.connection.currency)
mstime_remaining_text = self.tr("Expired or never published")
outdistanced_text = self.tr("Outdistanced")
requirements = await account_identity.requirements(self.connection.currency)
requirements = await self.identities_service.requirements(self.connection.currency, self.connection.pubkey,
self.connection.uid)
mstime_remaining = 0
nb_certs = 0
if requirements:
......
......@@ -258,9 +258,9 @@ class InformationsView(QWidget, Ui_InformationsWidget):
self.tr('Maximum delay a certification can wait before being expired for non-writing.'),
params.xpercent,
self.tr('Minimum percent of sentries to reach to match the distance rule'),
params.ms / 86400,
params.ms_validity / 86400,
self.tr('Maximum age of a valid membership (in days)'),
params['stepMax'],
params.step_max,
self.tr('Maximum distance between each WoT member and a newcomer'),
)
)
......
......@@ -38,6 +38,7 @@ class NavigationModel(ComponentModel):
'title': connection.currency,
'component': "Informations",
'blockchain_service': self.app.blockchain_services[connection.currency],
'identities_service': self.app.identities_services[connection.currency],
'sources_service': self.app.sources_services[connection.currency],
'connection':connection,
},
......
......@@ -236,3 +236,18 @@ class IdentitiesService(QObject):
for identity in set(need_refresh):
refresh_futures.append(self.refresh_requirements(identity))
await asyncio.gather(refresh_futures)
async def requirements(self, currency, pubkey, uid):
"""
Get the requirements for a given currency and pubkey
:param str currency:
:param str pubkey:
:param str uid:
:rtype: dict
"""
requirements_data = await self._bma_connector.get(currency, bma.wot.Requirements, req_args={'search': pubkey})
for req in requirements_data['identities']:
if req['uid'] == uid:
return req
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment