Skip to content

Commit

Permalink
Merge pull request #482 from skalenetwork/hotfix/SKALE-4999-fix-rotat…
Browse files Browse the repository at this point in the history
…ion-conditions

Hotfix/skale 4999 fix rotation conditions
  • Loading branch information
dmytrotkk authored Feb 21, 2022
2 parents e25755c + ba54c75 commit 7595934
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion skale/contracts/manager/node_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,21 @@ def is_rotation_active(self, schain_name) -> bool:
The public function that tells whether rotation is in the active phase - the new group is
already generated
"""
return self.is_rotation_in_progress(schain_name) and self.is_new_node_found(schain_name)
finish_ts_reached = self.is_finish_ts_reached(schain_name)
return self.is_rotation_in_progress(schain_name) and not finish_ts_reached

def is_finish_ts_reached(self, schain_name) -> bool:
rotation = self.skale.node_rotation.get_rotation_obj(schain_name)
schain_finish_ts = self.get_schain_finish_ts(rotation.leaving_node_id, schain_name)

if not schain_finish_ts:
schain_finish_ts = 0

latest_block = self.skale.web3.eth.getBlock('latest')
current_ts = latest_block['timestamp']

logger.info(f'current_ts: {current_ts}, schain_finish_ts: {schain_finish_ts}')
return current_ts > schain_finish_ts

def wait_for_new_node(self, schain_name):
schain_id = self.schains.name_to_id(schain_name)
Expand Down

0 comments on commit 7595934

Please sign in to comment.