Move the part of process_gossip that requires access to channel_db into in LNGossip.
This commit is contained in:
@@ -25,7 +25,7 @@ from aiorpcx import run_in_thread, TaskGroup, NetAddress
|
||||
|
||||
from . import constants, util
|
||||
from . import keystore
|
||||
from .util import profiler
|
||||
from .util import profiler, chunks
|
||||
from .invoices import PR_TYPE_LN, PR_UNPAID, PR_EXPIRED, PR_PAID, PR_INFLIGHT, PR_FAILED, PR_ROUTING, LNInvoice, LN_EXPIRY_NEVER
|
||||
from .util import NetworkRetryManager, JsonRPCClient
|
||||
from .lnutil import LN_MAX_FUNDING_SAT
|
||||
@@ -518,6 +518,27 @@ class LNGossip(LNWorker):
|
||||
progress_percent = 0
|
||||
return current_est, total_est, progress_percent
|
||||
|
||||
async def process_gossip(self, chan_anns, node_anns, chan_upds):
|
||||
await self.channel_db.data_loaded.wait()
|
||||
self.logger.debug(f'process_gossip {len(chan_anns)} {len(node_anns)} {len(chan_upds)}')
|
||||
# note: data processed in chunks to avoid taking sql lock for too long
|
||||
# channel announcements
|
||||
for chan_anns_chunk in chunks(chan_anns, 300):
|
||||
self.channel_db.add_channel_announcement(chan_anns_chunk)
|
||||
# node announcements
|
||||
for node_anns_chunk in chunks(node_anns, 100):
|
||||
self.channel_db.add_node_announcement(node_anns_chunk)
|
||||
# channel updates
|
||||
for chan_upds_chunk in chunks(chan_upds, 1000):
|
||||
categorized_chan_upds = self.channel_db.add_channel_updates(
|
||||
chan_upds_chunk, max_age=self.max_age)
|
||||
orphaned = categorized_chan_upds.orphaned
|
||||
if orphaned:
|
||||
self.logger.info(f'adding {len(orphaned)} unknown channel ids')
|
||||
orphaned_ids = [c['short_channel_id'] for c in orphaned]
|
||||
await self.add_new_ids(orphaned_ids)
|
||||
if categorized_chan_upds.good:
|
||||
self.logger.debug(f'on_channel_update: {len(categorized_chan_upds.good)}/{len(chan_upds_chunk)}')
|
||||
|
||||
class LNWallet(LNWorker):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user