mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
lnpeer: send and handle "networks" param in "init" msg
This commit is contained in:
parent
85d7a13360
commit
71a4302ec0
1 changed files with 13 additions and 1 deletions
|
@ -131,7 +131,12 @@ class Peer(Logger):
|
||||||
async def initialize(self):
|
async def initialize(self):
|
||||||
if isinstance(self.transport, LNTransport):
|
if isinstance(self.transport, LNTransport):
|
||||||
await self.transport.handshake()
|
await self.transport.handshake()
|
||||||
self.send_message("init", gflen=0, flen=2, features=self.localfeatures)
|
# FIXME: "flen" hardcoded but actually it depends on "localfeatures"...:
|
||||||
|
self.send_message("init", gflen=0, flen=2, features=self.localfeatures,
|
||||||
|
init_tlvs={
|
||||||
|
'networks':
|
||||||
|
{'chains': constants.net.rev_genesis_bytes()}
|
||||||
|
})
|
||||||
self._sent_init = True
|
self._sent_init = True
|
||||||
self.maybe_set_initialized()
|
self.maybe_set_initialized()
|
||||||
|
|
||||||
|
@ -207,6 +212,13 @@ class Peer(Logger):
|
||||||
except IncompatibleLightningFeatures as e:
|
except IncompatibleLightningFeatures as e:
|
||||||
self.initialized.set_exception(e)
|
self.initialized.set_exception(e)
|
||||||
raise GracefulDisconnect(f"{str(e)}")
|
raise GracefulDisconnect(f"{str(e)}")
|
||||||
|
# check that they are on the same chain as us, if provided
|
||||||
|
their_networks = payload["init_tlvs"].get("networks")
|
||||||
|
if their_networks:
|
||||||
|
their_chains = list(chunks(their_networks["chains"], 32))
|
||||||
|
if constants.net.rev_genesis_bytes() not in their_chains:
|
||||||
|
raise GracefulDisconnect(f"no common chain found with remote. (they sent: {their_chains})")
|
||||||
|
# all checks passed
|
||||||
if isinstance(self.transport, LNTransport):
|
if isinstance(self.transport, LNTransport):
|
||||||
self.channel_db.add_recent_peer(self.transport.peer_addr)
|
self.channel_db.add_recent_peer(self.transport.peer_addr)
|
||||||
for chan in self.channels.values():
|
for chan in self.channels.values():
|
||||||
|
|
Loading…
Add table
Reference in a new issue