fix lnwatcher: network triggers were renamed

This commit is contained in:
SomberNight 2018-09-24 16:38:59 +02:00
parent af16e32257
commit 2d24ac150a
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9
4 changed files with 9 additions and 5 deletions

View file

@ -161,7 +161,7 @@ class Interface(PrintError):
self.group = SilentTaskGroup()
def diagnostic_name(self):
return self.host
return 'iface:{}'.format(self.host)
def _set_proxy(self, proxy: dict):
if proxy:

View file

@ -93,7 +93,7 @@ class LNWatcher(PrintError):
e_tx2 = EncumberedTransaction.from_json(e_tx)
self.sweepstore[funding_outpoint][ctx_txid].add(e_tx2)
self.network.register_callback(self.on_network_update, ['updated'])
self.network.register_callback(self.on_network_update, ['network_updated', 'blockchain_updated', 'verified'])
def write_to_disk(self):
# FIXME: json => every update takes linear instead of constant disk write
@ -128,6 +128,10 @@ class LNWatcher(PrintError):
@aiosafe
async def on_network_update(self, event, *args):
if event == 'verified':
wallet = args[0]
if wallet != self.addr_sync:
return
if not self.addr_sync.synchronizer:
self.print_error("synchronizer not set yet")
return

View file

@ -57,7 +57,7 @@ class LNWorker(PrintError):
self._last_tried_peer = {} # LNPeerAddr -> unix timestamp
self._add_peers_from_config()
# wait until we see confirmations
self.network.register_callback(self.on_network_update, ['updated', 'verified', 'fee']) # thread safe
self.network.register_callback(self.on_network_update, ['network_updated', 'verified', 'fee']) # thread safe
asyncio.run_coroutine_threadsafe(self.network.main_taskgroup.spawn(self.main_loop()), self.network.asyncio_loop)
def _add_peers_from_config(self):
@ -346,7 +346,8 @@ class LNWorker(PrintError):
asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)
async def main_loop(self):
await self.on_network_update('updated') # shortcut (don't block) if funding tx locked and verified
await self.on_network_update('network_updated') # shortcut (don't block) if funding tx locked and verified
await self.network.lnwatcher.on_network_update('network_updated') # ping watcher to check our channels
while True:
await asyncio.sleep(1)
now = time.time()

View file

@ -127,7 +127,6 @@ class SPV(NetworkJobOnDefaultServer):
vtx_info = VerifiedTxInfo(tx_height, header.get('timestamp'), pos, header_hash)
self.wallet.add_verified_tx(tx_hash, vtx_info)
if self.is_up_to_date() and self.wallet.is_up_to_date():
self.network.trigger_callback('updated')
self.wallet.save_verified_tx(write=True)
@classmethod