|
|
|
@ -5,14 +5,16 @@ from mythril.support.support_utils import Singleton |
|
|
|
|
class TimeHandler(object, metaclass=Singleton): |
|
|
|
|
def __init__(self): |
|
|
|
|
self._start_time = None |
|
|
|
|
self._execution_time = None |
|
|
|
|
self._transaction_execution_timeout = None |
|
|
|
|
|
|
|
|
|
def start_execution(self, execution_time: int, transaction_count: int): |
|
|
|
|
self._start_time = int(time.time() * 1000) |
|
|
|
|
self._execution_time = execution_time * 1000 // transaction_count |
|
|
|
|
self._transaction_execution_timeout = execution_time * 1000 // transaction_count |
|
|
|
|
|
|
|
|
|
def time_remaining(self): |
|
|
|
|
return self._execution_time - (int(time.time() * 1000) - self._start_time) |
|
|
|
|
def transaction_time_remaining(self): |
|
|
|
|
return self._transaction_execution_timeout - ( |
|
|
|
|
int(time.time() * 1000) - self._start_time |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
time_handler = TimeHandler() |
|
|
|
|