Skip to content
Snippets Groups Projects
Commit 294b822e authored by inso's avatar inso
Browse files

Fix implicit revocation time

parent 2fb0ecb0
No related branches found
No related tags found
No related merge requests found
...@@ -465,6 +465,23 @@ class Identity(QObject): ...@@ -465,6 +465,23 @@ class Identity(QObject):
certified_list = await self.certified_by(identities_registry, community) certified_list = await self.certified_by(identities_registry, community)
return await self._unique_valid(certified_list, community) return await self._unique_valid(certified_list, community)
async def identity_revocation_time(self, community):
"""
Get the remaining time before identity implicit revocation
:param sakia.core.Community community: the community
:return: the remaining time
:rtype: int
"""
membership = await self.membership(community)
join_block = membership['blockNumber']
block = await community.get_block(join_block)
join_date = block['medianTime']
parameters = await community.parameters()
# revocation date is join_date + 1 sigvalidity (expiration date) + 2*sigvalidity
revocation_date = join_date + 3*parameters['sigValidity']
current_time = time.time()
return revocation_date - current_time
async def membership_expiration_time(self, community): async def membership_expiration_time(self, community):
""" """
Get the remaining time before membership expiration Get the remaining time before membership expiration
......
...@@ -212,14 +212,14 @@ The publication of this document will remove your identity from the network.</p> ...@@ -212,14 +212,14 @@ The publication of this document will remove your identity from the network.</p>
try: try:
person = await self.app.identities_registry.future_find(self.app.current_account.pubkey, self.community) person = await self.app.identities_registry.future_find(self.app.current_account.pubkey, self.community)
expiration_time = await person.membership_expiration_time(self.community) expiration_time = await person.membership_expiration_time(self.community)
revokation_time = await person.identity_revocation_time(self.community)
parameters = await self.community.parameters() parameters = await self.community.parameters()
sig_validity = parameters['sigValidity'] sig_validity = parameters['sigValidity']
warning_expiration_time = int(sig_validity / 3) warning_expiration_time = int(sig_validity / 3)
will_expire_soon = (expiration_time < warning_expiration_time) will_expire_soon = (expiration_time < warning_expiration_time)
revokation_deadline = expiration_time + 2*sig_validity revokation_soon = (revokation_time < 2*warning_expiration_time)
revokation_soon = (time.time() > revokation_deadline)
if revokation_soon: if revokation_soon:
days = int((revokation_deadline - time.time()) / 3600 / 24) days = int(revokation_time / 3600 / 24)
if 'warning_revokation' not in self.status_info: if 'warning_revokation' not in self.status_info:
self.status_info.append('warning_revokation') self.status_info.append('warning_revokation')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment