Skip to content

Commit

Permalink
Rename testnet peer dbs. (Chia-Network#6353)
Browse files Browse the repository at this point in the history
* Rename testnet peer dbs.

* Add selected_network to all constructors.
  • Loading branch information
fchirica authored Jun 2, 2021
1 parent f595deb commit 59d415f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions chia/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def set_server(self, server: ChiaServer):
self.config["introducer_peer"],
dns_servers,
self.config["peer_connect_interval"],
self.config["selected_network"],
self.log,
)
except Exception as e:
Expand Down
11 changes: 11 additions & 0 deletions chia/server/node_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,19 @@ def __init__(
introducer_info: Optional[Dict],
dns_servers: List[str],
peer_connect_interval: int,
selected_network: str,
log,
):
self.server: ChiaServer = server
self.message_queue: asyncio.Queue = asyncio.Queue()
self.is_closed = False
self.target_outbound_count = target_outbound_count
# This is a double check to make sure testnet and mainnet peer databases never mix up.
# If the network is not 'mainnet', it names the peer db differently, including the selected_network.
if selected_network != "mainnet":
if not peer_db_path.endswith(".sqlite"):
raise ValueError(f"Invalid path for peer table db: {peer_db_path}. Make the path end with .sqlite")
peer_db_path = peer_db_path[:-7] + "_" + selected_network + ".sqlite"
self.peer_db_path = path_from_root(root_path, peer_db_path)
self.dns_servers = dns_servers
if introducer_info is not None:
Expand Down Expand Up @@ -470,6 +477,7 @@ def __init__(
introducer_info,
dns_servers,
peer_connect_interval,
selected_network,
log,
):
super().__init__(
Expand All @@ -480,6 +488,7 @@ def __init__(
introducer_info,
dns_servers,
peer_connect_interval,
selected_network,
log,
)
self.relay_queue = asyncio.Queue()
Expand Down Expand Up @@ -639,6 +648,7 @@ def __init__(
introducer_info,
dns_servers,
peer_connect_interval,
selected_network,
log,
) -> None:
super().__init__(
Expand All @@ -649,6 +659,7 @@ def __init__(
introducer_info,
dns_servers,
peer_connect_interval,
selected_network,
log,
)

Expand Down
1 change: 1 addition & 0 deletions chia/wallet/wallet_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ def set_server(self, server: ChiaServer):
self.config["introducer_peer"],
[],
self.config["peer_connect_interval"],
self.config["selected_network"],
self.log,
)
asyncio.create_task(self.wallet_peers.start())
Expand Down

0 comments on commit 59d415f

Please sign in to comment.