Merge branch 'master' into nymkappa/bugfix/missing-last-data-charts

This commit is contained in:
wiz
2022-08-08 15:59:34 +09:00
committed by GitHub
11 changed files with 55 additions and 58 deletions

View File

@@ -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);');
}
}
/**

View File

@@ -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();
}
/**

View File

@@ -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 */

View File

@@ -8,8 +8,8 @@ class LightningStatsUpdater {
public async $startService(): Promise<void> {
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);
}