From 5d81a13a80e26b417740afd6599237525693066c Mon Sep 17 00:00:00 2001 From: nymkappa Date: Fri, 5 Aug 2022 10:11:29 +0200 Subject: [PATCH 1/4] Always show channels map in node page - auto zoom on the node --- .../app/lightning/node/node.component.html | 20 +++------ .../src/app/lightning/node/node.component.ts | 9 ---- .../nodes-channels-map.component.html | 3 -- .../nodes-channels-map.component.scss | 3 +- .../nodes-channels-map.component.ts | 41 +++++++++---------- 5 files changed, 27 insertions(+), 49 deletions(-) diff --git a/frontend/src/app/lightning/node/node.component.html b/frontend/src/app/lightning/node/node.component.html index ac50ed51b..de6c816f0 100644 --- a/frontend/src/app/lightning/node/node.component.html +++ b/frontend/src/app/lightning/node/node.component.html @@ -102,9 +102,7 @@ -
- -
+
-
- + -
-
-

All channels ({{ channelsListStatus === 'open' ? node.opened_channel_count : node.closed_channel_count }})

-
- -
+

Channels ({{ channelsListStatus === 'open' ? node.opened_channel_count : node.closed_channel_count }})

- - -
-
\ No newline at end of file +
diff --git a/frontend/src/app/lightning/node/node.component.ts b/frontend/src/app/lightning/node/node.component.ts index 6f9358090..a81849388 100644 --- a/frontend/src/app/lightning/node/node.component.ts +++ b/frontend/src/app/lightning/node/node.component.ts @@ -19,7 +19,6 @@ export class NodeComponent implements OnInit { publicKey$: Observable; selectedSocketIndex = 0; qrCodeVisible = false; - channelsListMode = 'list'; channelsListStatus: string; error: Error; publicKey: string; @@ -83,14 +82,6 @@ export class NodeComponent implements OnInit { this.selectedSocketIndex = index; } - channelsListModeChange(toggle) { - if (toggle === true) { - this.channelsListMode = 'map'; - } else { - this.channelsListMode = 'list'; - } - } - onChannelsListStatusChanged(e) { this.channelsListStatus = e; } diff --git a/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.html b/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.html index 1208a906a..5ccb9f3bc 100644 --- a/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.html +++ b/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.html @@ -3,9 +3,6 @@
Lightning nodes channels world map -
(Tor nodes excluded)
diff --git a/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.scss b/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.scss index 7914a5364..7e6b9f050 100644 --- a/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.scss +++ b/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.scss @@ -20,7 +20,8 @@ } .full-container.nodepage { - margin-top: 50px; + margin-top: 25px; + margin-bottom: 25px; } .full-container.widget { diff --git a/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.ts b/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.ts index c71ff88ad..e0063858b 100644 --- a/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.ts +++ b/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.ts @@ -3,7 +3,6 @@ import { SeoService } from 'src/app/services/seo.service'; import { ApiService } from 'src/app/services/api.service'; import { Observable, switchMap, tap, zip } from 'rxjs'; import { AssetsService } from 'src/app/services/assets.service'; -import { download } from 'src/app/shared/graphs.utils'; import { ActivatedRoute, ParamMap, Router } from '@angular/router'; import { RelativeUrlPipe } from 'src/app/shared/pipes/relative-url/relative-url.pipe'; import { StateService } from 'src/app/services/state.service'; @@ -21,6 +20,7 @@ export class NodesChannelsMap implements OnInit, OnDestroy { @Input() publicKey: string | undefined; observable$: Observable; + center: number[] | undefined = undefined; chartInstance = undefined; chartOptions: EChartsOption = {}; @@ -42,6 +42,8 @@ export class NodesChannelsMap implements OnInit, OnDestroy { ngOnDestroy(): void {} ngOnInit(): void { + this.center = this.style === 'widget' ? [0, 0, -10] : undefined; + if (this.style === 'graph') { this.seoService.setTitle($localize`Lightning nodes channels world map`); } @@ -52,13 +54,21 @@ export class NodesChannelsMap implements OnInit, OnDestroy { return zip( this.assetsService.getWorldMapJson$, this.apiService.getChannelsGeo$(params.get('public_key') ?? undefined), + [params.get('public_key') ?? undefined] ).pipe(tap((data) => { registerMap('world', data[0]); const channelsLoc = []; const nodes = []; const nodesPubkeys = {}; + let thisNodeGPS: number[] | undefined = undefined; for (const channel of data[1]) { + if (!thisNodeGPS && data[2] === channel[0]) { + thisNodeGPS = [channel[2], channel[3]]; + } else if (!thisNodeGPS && data[2] === channel[4]) { + thisNodeGPS = [channel[6], channel[7]]; + } + channelsLoc.push([[channel[2], channel[3]], [channel[6], channel[7]]]); if (!nodesPubkeys[channel[0]]) { nodes.push({ @@ -77,6 +87,13 @@ export class NodesChannelsMap implements OnInit, OnDestroy { nodesPubkeys[channel[4]] = true; } } + if (this.style === 'nodepage' && thisNodeGPS) { + // 1ML 0217890e3aad8d35bc054f43acc00084b25229ecff0ab68debd82883ad65ee8266 + // New York GPS [-74.0068, 40.7123] + // Map center [-20.55, 0, -9.85] + this.center = [thisNodeGPS[0] * -20.55 / -74.0068, 0, thisNodeGPS[1] * -9.85 / 40.7123]; + } + this.prepareChartOptions(nodes, channelsLoc); })); }) @@ -111,10 +128,10 @@ export class NodesChannelsMap implements OnInit, OnDestroy { } }, viewControl: { - center: this.style === 'widget' ? [0, 0, -10] : undefined, + center: this.center, minDistance: 1, maxDistance: 60, - distance: this.style === 'widget' ? 22 : 60, + distance: this.style === 'widget' ? 22 : this.style === 'nodepage' ? 22 : 60, alpha: 90, rotateSensitivity: 0, panSensitivity: this.style === 'widget' ? 0 : 1, @@ -204,22 +221,4 @@ export class NodesChannelsMap implements OnInit, OnDestroy { } }); } - - onSaveChart() { - // @ts-ignore - const prevBottom = this.chartOptions.grid.bottom; - const now = new Date(); - // @ts-ignore - this.chartOptions.grid.bottom = 30; - this.chartOptions.backgroundColor = '#11131f'; - this.chartInstance.setOption(this.chartOptions); - download(this.chartInstance.getDataURL({ - pixelRatio: 2, - excludeComponents: ['dataZoom'], - }), `lightning-nodes-heatmap-clearnet-${Math.round(now.getTime() / 1000)}.svg`); - // @ts-ignore - this.chartOptions.grid.bottom = prevBottom; - this.chartOptions.backgroundColor = 'none'; - this.chartInstance.setOption(this.chartOptions); - } } From 5a50a0d973141c170461498981c83ed2336f2d39 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Fri, 5 Aug 2022 12:32:20 +0200 Subject: [PATCH 2/4] Make sure lightning stats are not duplicated in db --- backend/src/api/database-migration.ts | 7 ++++++- backend/src/tasks/lightning/stats-updater.service.ts | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) 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/tasks/lightning/stats-updater.service.ts b/backend/src/tasks/lightning/stats-updater.service.ts index 0fd147eef..fbbef4021 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 { @@ -35,7 +35,7 @@ class LightningStatsUpdater { this.setDateMidnight(date); date.setUTCHours(24); - logger.info(`Updating latest node stats`); + logger.info(`Updating latest networks stats`); const networkGraph = await lightningApi.$getNetworkGraph(); LightningStatsImporter.computeNetworkStats(date.getTime() / 1000, networkGraph); } From 5612a033d56f297151c09ddebce1092c2bb5b9ad Mon Sep 17 00:00:00 2001 From: softsimon Date: Sat, 6 Aug 2022 04:25:21 +0400 Subject: [PATCH 3/4] Right align mempool logo on mobile with dual logos --- .../app/components/master-page/master-page.component.html | 2 +- .../app/components/master-page/master-page.component.scss | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 @@