Skip to content

Commit

Permalink
switch to enable loading of all peers, not only top 50 trusted
Browse files Browse the repository at this point in the history
  • Loading branch information
hclivess committed Mar 2, 2023
1 parent 345281e commit c74be0e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ops/peer_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ def sort_dict_value(values: list, key: str) -> list:
return []


async def load_ips(logger, port, fail_storage, unreachable, minimum=3) -> list:
async def load_ips(logger, port, fail_storage, unreachable, minimum=3, top_50=True) -> list:
"""load peers from drive, sort by trust, test in batches asynchronously,
return when limit is reached"""
bad_peers = set(fail_storage + list(unreachable.keys()))

bad_peers = set(fail_storage + list(unreachable.keys()))
peer_files= glob.glob(f"{get_home()}/peers/*.dat")

if len(peer_files) < minimum:
Expand All @@ -128,7 +128,11 @@ async def load_ips(logger, port, fail_storage, unreachable, minimum=3) -> list:
logger.info(f"Failed to load {peer}: {e}")

ip_sorted = []
candidates_sorted = sort_dict_value(candidates, key="peer_trust")[:50]

candidates_sorted = sort_dict_value(candidates, key="peer_trust")
if top_50:
candidates_sorted = sort_dict_value(candidates, key="peer_trust")[:50]


for entry in candidates_sorted:
ip = entry["peer_ip"]
Expand Down

0 comments on commit c74be0e

Please sign in to comment.