mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 08:51:32 +00:00
parent
223b62554e
commit
95fa5d37c3
1 changed files with 6 additions and 4 deletions
|
@ -189,7 +189,8 @@ class LNWorker(Logger, NetworkRetryManager[LNPeerAddr]):
|
||||||
self.logger.info('handshake failure from incoming connection')
|
self.logger.info('handshake failure from incoming connection')
|
||||||
return
|
return
|
||||||
peer = Peer(self, node_id, transport)
|
peer = Peer(self, node_id, transport)
|
||||||
self._peers[node_id] = peer
|
with self.lock:
|
||||||
|
self._peers[node_id] = peer
|
||||||
await self.taskgroup.spawn(peer.main_loop())
|
await self.taskgroup.spawn(peer.main_loop())
|
||||||
try:
|
try:
|
||||||
# FIXME: server.close(), server.wait_closed(), etc... ?
|
# FIXME: server.close(), server.wait_closed(), etc... ?
|
||||||
|
@ -233,12 +234,13 @@ class LNWorker(Logger, NetworkRetryManager[LNPeerAddr]):
|
||||||
self.logger.info(f"adding peer {peer_addr}")
|
self.logger.info(f"adding peer {peer_addr}")
|
||||||
peer = Peer(self, node_id, transport)
|
peer = Peer(self, node_id, transport)
|
||||||
await self.taskgroup.spawn(peer.main_loop())
|
await self.taskgroup.spawn(peer.main_loop())
|
||||||
self._peers[node_id] = peer
|
with self.lock:
|
||||||
|
self._peers[node_id] = peer
|
||||||
return peer
|
return peer
|
||||||
|
|
||||||
def peer_closed(self, peer: Peer) -> None:
|
def peer_closed(self, peer: Peer) -> None:
|
||||||
if peer.pubkey in self._peers:
|
with self.lock:
|
||||||
self._peers.pop(peer.pubkey)
|
self._peers.pop(peer.pubkey, None)
|
||||||
|
|
||||||
def num_peers(self) -> int:
|
def num_peers(self) -> int:
|
||||||
return sum([p.is_initialized() for p in self.peers.values()])
|
return sum([p.is_initialized() for p in self.peers.values()])
|
||||||
|
|
Loading…
Add table
Reference in a new issue