Skip to content

Commit

Permalink
Log next queued leg-related balances in route logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dowlandaiello committed Oct 3, 2024
1 parent 8ebba6c commit b1de2fb
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,34 @@ def log_route(

prefix = ""

balance_resp_in = try_multiple_clients(
self.clients[route.legs[0].backend.chain_id],
lambda client: client.query_bank_balance(
Address(
self.wallet.public_key(), prefix=route.legs[0].backend.chain_prefix
),
route.legs[0].in_asset(),
curr_leg = next(
(
leg
for (leg_repr, leg) in zip(route.route, route.legs)
if not leg_repr.executed
),
default=None,
)

if balance_resp_in:
prefix += f"balance[{route.legs[0].in_asset()[:DENOM_BALANCE_PREFIX_MAX_DENOM_LEN]}]: {balance_resp_in} "
if curr_leg:
balance_resp_in = try_multiple_clients(
self.clients[curr_leg.backend.chain_id],
lambda client: client.query_bank_balance(
Address(
self.wallet.public_key(),
prefix=route.legs[0].backend.chain_prefix,
),
curr_leg.in_asset(),
),
)

if balance_resp_in:
prefix += f"balance[{curr_leg.in_asset()[:DENOM_BALANCE_PREFIX_MAX_DENOM_LEN]}]: {balance_resp_in} "

balance_resp_base_denom = try_multiple_clients(
self.clients[route.legs[0].backend.chain_id],
self.clients[curr_leg.backend.chain_id],
lambda client: client.query_bank_balance(
Address(
self.wallet.public_key(), prefix=route.legs[0].backend.chain_prefix
),
Address(self.wallet.public_key(), prefix=curr_leg.backend.chain_prefix),
self.cli_args["base_denom"],
),
)
Expand Down

0 comments on commit b1de2fb

Please sign in to comment.