diff --git a/backend/src/api/database-migration.ts b/backend/src/api/database-migration.ts index 816efc7cc..19f523eb3 100644 --- a/backend/src/api/database-migration.ts +++ b/backend/src/api/database-migration.ts @@ -4,7 +4,7 @@ import logger from '../logger'; import { Common } from './common'; class DatabaseMigration { - private static currentVersion = 34; + private static currentVersion = 35; private queryTimeout = 120000; private statisticsAddedIndexed = false; private uniqueLogs: string[] = []; @@ -315,6 +315,11 @@ class DatabaseMigration { if (databaseSchemaVersion < 34 && isBitcoin == true) { await this.$executeQuery('ALTER TABLE `lightning_stats` ADD clearnet_tor_nodes int(11) NOT NULL DEFAULT "0"'); } + + if (databaseSchemaVersion < 35 && isBitcoin == true) { + await this.$executeQuery('DELETE from `lightning_stats` WHERE added > "2021-09-19"'); + await this.$executeQuery('ALTER TABLE `lightning_stats` ADD CONSTRAINT added_unique UNIQUE (added);'); + } } /** diff --git a/backend/src/api/lightning/clightning/clightning-convert.ts b/backend/src/api/lightning/clightning/clightning-convert.ts index 75c8ec20c..5df51aadc 100644 --- a/backend/src/api/lightning/clightning/clightning-convert.ts +++ b/backend/src/api/lightning/clightning/clightning-convert.ts @@ -71,8 +71,11 @@ export async function convertAndmergeBidirectionalChannels(clChannels: any[]): P } export function convertChannelId(channelId): string { - const s = channelId.split('x').map(part => parseInt(part)); - return BigInt((s[0] << 40) | (s[1] << 16) | s[2]).toString(); + if (channelId.indexOf('/') !== -1) { + channelId = channelId.slice(0, -2); + } + const s = channelId.split('x').map(part => BigInt(part)); + return ((s[0] << 40n) | (s[1] << 16n) | s[2]).toString(); } /** diff --git a/backend/src/tasks/lightning/network-sync.service.ts b/backend/src/tasks/lightning/network-sync.service.ts index 826664cf4..405d39c37 100644 --- a/backend/src/tasks/lightning/network-sync.service.ts +++ b/backend/src/tasks/lightning/network-sync.service.ts @@ -430,10 +430,13 @@ class NetworkSyncService { } private toIntegerId(id: string): string { - if (config.LIGHTNING.BACKEND === 'lnd') { + if (config.LIGHTNING.BACKEND === 'cln') { + return convertChannelId(id); + } + else if (config.LIGHTNING.BACKEND === 'lnd') { return id; } - return convertChannelId(id); + return ''; } /** Decodes a channel id returned by lnd as uint64 to a short channel id */ diff --git a/backend/src/tasks/lightning/stats-updater.service.ts b/backend/src/tasks/lightning/stats-updater.service.ts index 8fea9eb30..d58ff0ae6 100644 --- a/backend/src/tasks/lightning/stats-updater.service.ts +++ b/backend/src/tasks/lightning/stats-updater.service.ts @@ -8,8 +8,8 @@ class LightningStatsUpdater { public async $startService(): Promise { logger.info('Starting Lightning Stats service'); - // LightningStatsImporter.$run(); - this.$runTasks(); + await this.$runTasks(); + LightningStatsImporter.$run(); } private setDateMidnight(date: Date): void { @@ -34,7 +34,7 @@ class LightningStatsUpdater { const date = new Date(); this.setDateMidnight(date); - logger.info(`Updating latest node stats`); + logger.info(`Updating latest networks stats`); const networkGraph = await lightningApi.$getNetworkGraph(); LightningStatsImporter.computeNetworkStats(date.getTime() / 1000, networkGraph); } diff --git a/frontend/src/app/components/master-page/master-page.component.html b/frontend/src/app/components/master-page/master-page.component.html index f152cb7b3..39acf122d 100644 --- a/frontend/src/app/components/master-page/master-page.component.html +++ b/frontend/src/app/components/master-page/master-page.component.html @@ -1,7 +1,7 @@