Skip to content

Commit

Permalink
Delay peer start for wallet until after backup init (Chia-Network#6671)
Browse files Browse the repository at this point in the history
* Delay peer start for wallet until after backup init

* Make sure to only start peers once
  • Loading branch information
emlowe authored Jun 11, 2021
1 parent d13840f commit ae8497b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion chia/wallet/wallet_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class WalletNode:
full_node_peer: Optional[PeerInfo]
peer_task: Optional[asyncio.Task]
logged_in: bool
wallet_peers_initialized: bool

def __init__(
self,
Expand Down Expand Up @@ -111,6 +112,7 @@ def __init__(
self.logged_in_fingerprint: Optional[int] = None
self.peer_task = None
self.logged_in = False
self.wallet_peers_initialized = False
self.last_new_peak_messages = LRUCache(5)

def get_key_for_fingerprint(self, fingerprint: Optional[int]):
Expand Down Expand Up @@ -179,6 +181,15 @@ async def _start(
return False

self.backup_initialized = True

# Start peers here after the backup initialization has finished
# We only want to do this once per instantiation
# However, doing it earlier before backup initialization causes
# the wallet to spam the introducer
if self.wallet_peers_initialized is False:
asyncio.create_task(self.wallet_peers.start())
self.wallet_peers_initialized = True

if backup_file is not None:
json_dict = open_backup_file(backup_file, self.wallet_state_manager.private_key)
if "start_height" in json_dict["data"]:
Expand Down Expand Up @@ -322,7 +333,6 @@ def set_server(self, server: ChiaServer):
None,
self.log,
)
asyncio.create_task(self.wallet_peers.start())

async def on_connect(self, peer: WSChiaConnection):
if self.wallet_state_manager is None or self.backup_initialized is False:
Expand Down

0 comments on commit ae8497b

Please sign in to comment.