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> {
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;
const graphChannelsIds: string[] = [];
for (const channel of channels) {
await channelsApi.$saveChannel(channel);
if (!closedChannels[channel.channel_id]) {
await channelsApi.$saveChannel(channel);
}
graphChannelsIds.push(channel.channel_id);
++progress;