Skip to content

Commit

Permalink
Merge pull request #460 from hoprnet/jean/core-crashing-on-node-unrea…
Browse files Browse the repository at this point in the history
…chable

Fix core too strongly bound to underlying nodes
  • Loading branch information
jeandemeusy authored Jan 12, 2024
2 parents 17ae929 + fa87c8d commit 9a9b6ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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

0 comments on commit 9a9b6ea

Please sign in to comment.