Last active
April 20, 2020 15:37
-
-
Save DannyMor/2cd5274d69e6891f3a9097c6d446e665 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def get_tokens_amount_to_consume(consumption_rate, current_consumption_time, last_consumption_time, total_tokens): | |
time_from_last_consumption = current_consumption_time - last_consumption_time | |
calculated_tokens_to_consume = math.floor(time_from_last_consumption / consumption_rate) | |
tokens_to_consume = min(total_tokens, calculated_tokens_to_consume) | |
return tokens_to_consume |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment