Skip to content
Snippets Groups Projects
Unverified Commit d8c1bcd4 authored by Holger Nahrstaedt's avatar Holger Nahrstaedt Committed by GitHub
Browse files

Merge pull request #103 from Flugschwein/master

Adding additional parameter to recharge time calculations
parents f7454ebb aecef850
No related branches found
No related tags found
No related merge requests found
...@@ -516,34 +516,45 @@ class Account(BlockchainObject): ...@@ -516,34 +516,45 @@ class Account(BlockchainObject):
return None return None
return ops[0]['creator'] return ops[0]['creator']
def get_recharge_time_str(self, voting_power_goal=100): def get_recharge_time_str(self, voting_power_goal=100, starting_voting_power=None):
""" Returns the account recharge time as string """ Returns the account recharge time as string
:param float voting_power_goal: voting power goal in percentage (default is 100) :param float voting_power_goal: voting power goal in percentage (default is 100)
:param float starting_voting_power: returns recharge time if current voting power is
the provided value.
""" """
remainingTime = self.get_recharge_timedelta(voting_power_goal=voting_power_goal) remainingTime = self.get_recharge_timedelta(voting_power_goal=voting_power_goal, starting_voting_power=starting_voting_power)
return formatTimedelta(remainingTime) return formatTimedelta(remainingTime)
def get_recharge_timedelta(self, voting_power_goal=100): def get_recharge_timedelta(self, voting_power_goal=100, starting_voting_power=None):
""" Returns the account voting power recharge time as timedelta object """ Returns the account voting power recharge time as timedelta object
:param float voting_power_goal: voting power goal in percentage (default is 100) :param float voting_power_goal: voting power goal in percentage (default is 100)
:param float starting_voting_power: returns recharge time if current voting power is
the provided value.
""" """
missing_vp = voting_power_goal - self.get_voting_power() if starting_voting_power is None:
missing_vp = voting_power_goal - self.get_voting_power()
elif isinstance(starting_voting_power, int) or isinstance(starting_voting_power, float):
missing_vp = voting_power_goal - starting_voting_power
else:
raise ValueError('starting_voting_power must be a number.')
if missing_vp < 0: if missing_vp < 0:
return 0 return 0
recharge_seconds = missing_vp * 100 * STEEM_VOTING_MANA_REGENERATION_SECONDS / STEEM_100_PERCENT recharge_seconds = missing_vp * 100 * STEEM_VOTING_MANA_REGENERATION_SECONDS / STEEM_100_PERCENT
return timedelta(seconds=recharge_seconds) return timedelta(seconds=recharge_seconds)
def get_recharge_time(self, voting_power_goal=100): def get_recharge_time(self, voting_power_goal=100, starting_voting_power=None):
""" Returns the account voting power recharge time in minutes """ Returns the account voting power recharge time in minutes
:param float voting_power_goal: voting power goal in percentage (default is 100) :param float voting_power_goal: voting power goal in percentage (default is 100)
:param float starting_voting_power: returns recharge time if current voting power is
the provided value.
""" """
return addTzInfo(datetime.utcnow()) + self.get_recharge_timedelta(voting_power_goal) return addTzInfo(datetime.utcnow()) + self.get_recharge_timedelta(voting_power_goal, starting_voting_power)
def get_manabar_recharge_time_str(self, manabar, recharge_pct_goal=100): def get_manabar_recharge_time_str(self, manabar, recharge_pct_goal=100):
""" Returns the account manabar recharge time as string """ Returns the account manabar recharge time as string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment