Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix core too strongly bound to underlying nodes #460

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ct-app/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ def subgraph_safes_balance_url(self, subgraph: SubgraphType) -> str:

async def _retrieve_address(self):
addresses = await self.api.get_address("all")
if not addresses:
self.warning("No address retrieved from node.")
return
if "hopr" not in addresses or "native" not in addresses:
self.warning("Invalid address retrieved from node.")
return
self.address = Address(addresses["hopr"], addresses["native"])

@flagguard
Expand Down Expand Up @@ -343,7 +349,8 @@ async def distribute_rewards(self):
async def get_fundings(self):
from_address = self.params.subgraph.from_address
ct_safe_addresses = {
(await node.api.node_info()).node_safe for node in self.network_nodes
getattr(await node.api.node_info(), "node_safe", None)
for node in self.network_nodes
}

transactions = []
Expand Down
6 changes: 4 additions & 2 deletions ct-app/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ async def fund_channels(self):
]

low_balances = [
c for c in out_opens if int(c.balance)/1e18 <= self.params.channel.min_balance
c
for c in out_opens
if int(c.balance) / 1e18 <= self.params.channel.min_balance
]

self.debug(f"Low balance channels: {len(low_balances)}")
Expand All @@ -255,7 +257,7 @@ async def fund_channels(self):
for channel in low_balances:
if channel.destination_peer_id in peer_ids:
ok = await self.api.fund_channel(
channel.channel_id, self.params.channel.funding_amount*1e18
channel.channel_id, self.params.channel.funding_amount * 1e18
)
if ok:
self.debug(f"Funded channel {channel.channel_id}")
Expand Down
Loading