Skip to content

Commit

Permalink
Less get_oracles calls (#219)
Browse files Browse the repository at this point in the history
* Less get_oracles calls

* Revert "Less get_oracles calls"

This reverts commit a9fde1e.

* Delay get_oracles

* Review fixes

* Review fixes
  • Loading branch information
evgeny-stakewise authored Nov 2, 2023
1 parent afd7ea2 commit eaee390
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/validators/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,17 @@ async def register_validators(

metrics.stakeable_assets.set(int(vault_balance))

# get latest oracles
oracles = await get_oracles()
logger.debug('Fetched latest oracles: %s', oracles)

approval_max_validators = oracles.validators_approval_batch_limit

# calculate number of validators that can be registered
validators_count: int = min(approval_max_validators, vault_balance // DEPOSIT_AMOUNT)
validators_count = vault_balance // DEPOSIT_AMOUNT
if not validators_count:
# not enough balance to register validators
return

# get latest oracles
oracles = await get_oracles()

validators_count = min(oracles.validators_approval_batch_limit, validators_count)

if not await check_gas_price():
return

Expand Down

0 comments on commit eaee390

Please sign in to comment.