Merge pull request #2336 from mempool/nymkappa/feature/stop-updating-closed-channels

If a channel is closed, stop updating it
This commit is contained in:
wiz 2022-08-21 22:17:08 +09:00 committed by GitHub
commit 3201caf54e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,11 +95,19 @@ class NetworkSyncService {
*/ */
private async $updateChannelsList(channels: ILightningApi.Channel[]): Promise<void> { private async $updateChannelsList(channels: ILightningApi.Channel[]): Promise<void> {
try { try {
const [closedChannelsRaw]: any[] = await DB.query(`SELECT id FROM channels WHERE status = 2`);
const closedChannels = {};
for (const closedChannel of closedChannelsRaw) {
closedChannels[Common.channelShortIdToIntegerId(closedChannel.id)] = true;
}
let progress = 0; let progress = 0;
const graphChannelsIds: string[] = []; const graphChannelsIds: string[] = [];
for (const channel of channels) { for (const channel of channels) {
if (!closedChannels[channel.channel_id]) {
await channelsApi.$saveChannel(channel); await channelsApi.$saveChannel(channel);
}
graphChannelsIds.push(channel.channel_id); graphChannelsIds.push(channel.channel_id);
++progress; ++progress;