Browse Source

LNPeerAddr: fix equality tests and hence lnworker._last_tried_peer

follow-up 13d6997355
hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
adaa016e78
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 13
      electrum/lnutil.py
  2. 2
      electrum/lnworker.py

13
electrum/lnutil.py

@ -684,6 +684,19 @@ class LNPeerAddr:
def net_addr_str(self) -> str:
return self._net_addr_str
def __eq__(self, other):
if not isinstance(other, LNPeerAddr):
return False
return (self.host == other.host
and self.port == other.port
and self.pubkey == other.pubkey)
def __ne__(self, other):
return not (self == other)
def __hash__(self):
return hash((self.host, self.port, self.pubkey))
def get_compressed_pubkey_from_bech32(bech32_pubkey: str) -> bytes:
hrp, data_5bits = segwit_addr.bech32_decode(bech32_pubkey)

2
electrum/lnworker.py

@ -186,7 +186,7 @@ class LNWorker(Logger):
self.network = network
self.config = network.config
self.channel_db = self.network.channel_db
self._last_tried_peer = {} # LNPeerAddr -> unix timestamp
self._last_tried_peer = {} # type: Dict[LNPeerAddr, float] # LNPeerAddr -> unix timestamp
self._add_peers_from_config()
asyncio.run_coroutine_threadsafe(self.network.main_taskgroup.spawn(self.main_loop()), self.network.asyncio_loop)

Loading…
Cancel
Save