Skip to content

Commit

Permalink
Release v3.2.2
Browse files Browse the repository at this point in the history
* The hearbeat is retried if the call fails
  • Loading branch information
iosifpeterfi committed Oct 26, 2023
1 parent b3e9841 commit 09ab53f
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions node/etny-node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,11 +1132,15 @@ def process_dp_request(self):
time.sleep(timeout_in_seconds)

seconds += timeout_in_seconds
if seconds >= config.contract_call_frequency:
seconds = 0
self.__call_heart_beat()

# self.cancel_dp_request(self.__dprequest)
self.__call_heart_beat()

if seconds >= config.contract_call_frequency:
if self.__network == 'POLYGON':
seconds = 0;
else:
self.cancel_dp_request(self.__dprequest)
return;

def add_processor_to_order(self, order_id):
unicorn_txn = self.__etny.functions._addProcessorToOrder(order_id, self.__resultaddress).buildTransaction(
Expand Down Expand Up @@ -1365,6 +1369,24 @@ def __run_integration_test(self):
self.__clean_up_integration_test()

def __can_run_auto_update(self, file_path, interval):
current_timestamp = int(time.time())
if os.path.exists(file_path):
with open(file_path, 'r') as file:
value = file.read().strip()
if not value.isdigit():
saved_timestamp = 0
else:
saved_timestamp = int(value)

if current_timestamp - saved_timestamp >= interval:
return True
else:
return False
else:
return True


def __write_auto_update_cache(self, file_path, interval):
current_timestamp = int(time.time())
if os.path.exists(file_path):
with open(file_path, 'r') as file:
Expand All @@ -1386,6 +1408,7 @@ def __can_run_auto_update(self, file_path, interval):

return True


def __enforce_update(self):
logger.info('Checking if the auto update can be performed...')
if self.__can_run_auto_update(config.auto_update_file_path, 24 * 60 * 60):
Expand Down Expand Up @@ -1413,6 +1436,7 @@ def __call_heart_beat(self):
receipt = self.__w3.eth.waitForTransactionReceipt(_hash)
if receipt.status == 1:
logger.info('Heart beat successfully called...')
self.__write_auto_update_cache(config.heart_beat_log_file_path, heartbeat_frequency);
except Exception as e:
logger.info(f'error = {e}, type = {type(e)}')
raise
Expand Down

0 comments on commit 09ab53f

Please sign in to comment.