URI: 
       tlnworker.peers: follow-up b5811e8072dafda7e2e740f8e5ca604680271291 - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 95fa5d37c365165aaf3f7af943bb6ffc86b955d8
   DIR parent 223b62554ead397bb94013c0d9c95b63a0708ea6
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Wed, 15 Apr 2020 22:41:16 +0200
       
       lnworker.peers: follow-up b5811e8072dafda7e2e740f8e5ca604680271291
       
       somehow I forgot writes...
       
       Diffstat:
         M electrum/lnworker.py                |      10 ++++++----
       
       1 file changed, 6 insertions(+), 4 deletions(-)
       ---
   DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py
       t@@ -189,7 +189,8 @@ class LNWorker(Logger, NetworkRetryManager[LNPeerAddr]):
                            self.logger.info('handshake failure from incoming connection')
                            return
                        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())
                    try:
                        # FIXME: server.close(), server.wait_closed(), etc... ?
       t@@ -233,12 +234,13 @@ class LNWorker(Logger, NetworkRetryManager[LNPeerAddr]):
                self.logger.info(f"adding peer {peer_addr}")
                peer = Peer(self, node_id, transport)
                await self.taskgroup.spawn(peer.main_loop())
       -        self._peers[node_id] = peer
       +        with self.lock:
       +            self._peers[node_id] = peer
                return peer
        
            def peer_closed(self, peer: Peer) -> None:
       -        if peer.pubkey in self._peers:
       -            self._peers.pop(peer.pubkey)
       +        with self.lock:
       +            self._peers.pop(peer.pubkey, None)
        
            def num_peers(self) -> int:
                return sum([p.is_initialized() for p in self.peers.values()])