From aa1519c18eb06c0917fefb84940583126a3cf37c Mon Sep 17 00:00:00 2001 From: nymkappa Date: Thu, 8 Sep 2022 18:56:25 +0200 Subject: [PATCH 01/96] Show zero base fee tag on channels --- .../channel-box/channel-box.component.html | 103 +++++++++++------- .../app/shared/pipes/amount-shortener.pipe.ts | 3 +- 2 files changed, 68 insertions(+), 38 deletions(-) diff --git a/frontend/src/app/lightning/channel/channel-box/channel-box.component.html b/frontend/src/app/lightning/channel/channel-box/channel-box.component.html index 8b486eff5..4a421480d 100644 --- a/frontend/src/app/lightning/channel/channel-box/channel-box.component.html +++ b/frontend/src/app/lightning/channel/channel-box/channel-box.component.html @@ -11,44 +11,73 @@
-
-
- - - - - - - - - - - - - - - - - - - - - - - -
Fee rate - {{ channel.fee_rate ?? '-' }} ppm ({{ channel.fee_rate / 10000 | number }}%) -
Base fee - -
Min HTLC - -
Max HTLC - -
Timelock delta - -
-
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Fee rate + + {{ channel.fee_rate !== null ? (channel.fee_rate | amountShortener : 2 : undefined : true) : '-' }} ppm ({{ channel.fee_rate !== null ? '(' + (channel.fee_rate / 10000 | amountShortener : 2 : undefined : true) + '%)' : '' }} + + + {{ channel.fee_rate !== null ? (channel.fee_rate | number) : '-' }} ppm {{ channel.fee_rate !== null ? '(' + (channel.fee_rate / 10000 | number) + '%)' : '' }} + +
Base fee +
+ + + {{ channel.base_fee_mtokens !== null ? (channel.base_fee_mtokens / 1000 | amountShortener : 2 : undefined : true) : '-' }} + sats + + + Zero base fee + + +
+
+ + + + Zero base fee + + +
+
Min HTLC + +
Max HTLC + +
Timelock delta + +
{{ i }} blocks diff --git a/frontend/src/app/shared/pipes/amount-shortener.pipe.ts b/frontend/src/app/shared/pipes/amount-shortener.pipe.ts index db3d94284..71ff76f77 100644 --- a/frontend/src/app/shared/pipes/amount-shortener.pipe.ts +++ b/frontend/src/app/shared/pipes/amount-shortener.pipe.ts @@ -7,6 +7,7 @@ export class AmountShortenerPipe implements PipeTransform { transform(num: number, ...args: any[]): unknown { const digits = args[0] ?? 1; const unit = args[1] || undefined; + const isMoney = args[2] || false; if (num < 1000) { return num.toFixed(digits); @@ -16,7 +17,7 @@ export class AmountShortenerPipe implements PipeTransform { { value: 1, symbol: '' }, { value: 1e3, symbol: 'k' }, { value: 1e6, symbol: 'M' }, - { value: 1e9, symbol: 'G' }, + { value: 1e9, symbol: isMoney ? 'B' : 'G' }, { value: 1e12, symbol: 'T' }, { value: 1e15, symbol: 'P' }, { value: 1e18, symbol: 'E' } From faec398cf02e15bb628da434d665249e9c313078 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Wed, 24 Aug 2022 15:39:52 +0200 Subject: [PATCH 02/96] Log correct maxmind mysql updates - fix stats import processed files counter --- .../lightning/sync-tasks/node-locations.ts | 45 +++++++++++++++---- .../lightning/sync-tasks/stats-importer.ts | 3 ++ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/backend/src/tasks/lightning/sync-tasks/node-locations.ts b/backend/src/tasks/lightning/sync-tasks/node-locations.ts index 9069e0fff..ba59e9e48 100644 --- a/backend/src/tasks/lightning/sync-tasks/node-locations.ts +++ b/backend/src/tasks/lightning/sync-tasks/node-locations.ts @@ -4,11 +4,14 @@ import nodesApi from '../../../api/explorer/nodes.api'; import config from '../../../config'; import DB from '../../../database'; import logger from '../../../logger'; +import { ResultSetHeader } from 'mysql2'; import * as IPCheck from '../../../utils/ipcheck.js'; export async function $lookupNodeLocation(): Promise { let loggerTimer = new Date().getTime() / 1000; let progress = 0; + let nodesUpdated = 0; + let geoNamesInserted = 0; logger.info(`Running node location updater using Maxmind`); try { @@ -71,51 +74,72 @@ export async function $lookupNodeLocation(): Promise { city.location?.accuracy_radius, node.public_key ]; - await DB.query(query, params); + let result = await DB.query(query, params); + if (result[0].changedRows ?? 0 > 0) { + ++nodesUpdated; + } // Store Continent if (city.continent?.geoname_id) { - await DB.query( + result = await DB.query( `INSERT IGNORE INTO geo_names (id, type, names) VALUES (?, 'continent', ?)`, [city.continent?.geoname_id, JSON.stringify(city.continent?.names)]); + if (result[0].changedRows ?? 0 > 0) { + ++geoNamesInserted; + } } // Store Country if (city.country?.geoname_id) { - await DB.query( + result = await DB.query( `INSERT IGNORE INTO geo_names (id, type, names) VALUES (?, 'country', ?)`, [city.country?.geoname_id, JSON.stringify(city.country?.names)]); + if (result[0].changedRows ?? 0 > 0) { + ++geoNamesInserted; + } } // Store Country ISO code if (city.country?.iso_code) { - await DB.query( + result = await DB.query( `INSERT IGNORE INTO geo_names (id, type, names) VALUES (?, 'country_iso_code', ?)`, [city.country?.geoname_id, city.country?.iso_code]); + if (result[0].changedRows ?? 0 > 0) { + ++geoNamesInserted; + } } // Store Division if (city.subdivisions && city.subdivisions[0]) { - await DB.query( + result = await DB.query( `INSERT IGNORE INTO geo_names (id, type, names) VALUES (?, 'division', ?)`, [city.subdivisions[0].geoname_id, JSON.stringify(city.subdivisions[0]?.names)]); + if (result[0].changedRows ?? 0 > 0) { + ++geoNamesInserted; + } } // Store City if (city.city?.geoname_id) { - await DB.query( + result = await DB.query( `INSERT IGNORE INTO geo_names (id, type, names) VALUES (?, 'city', ?)`, [city.city?.geoname_id, JSON.stringify(city.city?.names)]); + if (result[0].changedRows ?? 0 > 0) { + ++geoNamesInserted; + } } // Store AS name if (isp?.autonomous_system_organization ?? asn?.autonomous_system_organization) { - await DB.query( + result = await DB.query( `INSERT IGNORE INTO geo_names (id, type, names) VALUES (?, 'as_organization', ?)`, [ asOverwrite?.asn ?? isp?.autonomous_system_number ?? asn?.autonomous_system_number, JSON.stringify(asOverwrite?.name ?? isp?.isp ?? asn?.autonomous_system_organization) ]); + if (result[0].changedRows ?? 0 > 0) { + ++geoNamesInserted; + } } } @@ -128,7 +152,12 @@ export async function $lookupNodeLocation(): Promise { } } } - logger.info(`${progress} nodes location data updated`); + + if (nodesUpdated > 0) { + logger.info(`${nodesUpdated} nodes maxmind data updated, ${geoNamesInserted} geo names inserted`); + } else { + logger.debug(`${nodesUpdated} nodes maxmind data updated, ${geoNamesInserted} geo names inserted`); + } } catch (e) { logger.err('$lookupNodeLocation() error: ' + (e instanceof Error ? e.message : e)); } diff --git a/backend/src/tasks/lightning/sync-tasks/stats-importer.ts b/backend/src/tasks/lightning/sync-tasks/stats-importer.ts index e3dfe6652..6d6c9e4d3 100644 --- a/backend/src/tasks/lightning/sync-tasks/stats-importer.ts +++ b/backend/src/tasks/lightning/sync-tasks/stats-importer.ts @@ -360,9 +360,11 @@ class LightningStatsImporter { fileContent = await fsPromises.readFile(`${this.topologiesFolder}/${filename}`, 'utf8'); } catch (e: any) { if (e.errno == -1) { // EISDIR - Ignore directorie + totalProcessed++; continue; } logger.err(`Unable to open ${this.topologiesFolder}/${filename}`); + totalProcessed++; continue; } @@ -372,6 +374,7 @@ class LightningStatsImporter { graph = await this.cleanupTopology(graph); } catch (e) { logger.debug(`Invalid topology file ${this.topologiesFolder}/${filename}, cannot parse the content. Reason: ${e instanceof Error ? e.message : e}`); + totalProcessed++; continue; } From b6296fcbeb7780be963ad4acd7b10cb5080bbdbd Mon Sep 17 00:00:00 2001 From: softsimon Date: Mon, 12 Sep 2022 19:20:22 +0200 Subject: [PATCH 03/96] Suggest block height in search result --- .../search-form/search-form.component.html | 2 +- .../search-form/search-form.component.ts | 18 ++++++++++++----- .../search-results.component.html | 20 ++++++++++++------- .../search-results.component.ts | 9 +++++---- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/frontend/src/app/components/search-form/search-form.component.html b/frontend/src/app/components/search-form/search-form.component.html index 8badcc3cf..f8cb05d1c 100644 --- a/frontend/src/app/components/search-form/search-form.component.html +++ b/frontend/src/app/components/search-form/search-form.component.html @@ -3,7 +3,7 @@
- +
diff --git a/frontend/src/app/components/search-form/search-form.component.ts b/frontend/src/app/components/search-form/search-form.component.ts index 712f7438c..abddc3b6e 100644 --- a/frontend/src/app/components/search-form/search-form.component.ts +++ b/frontend/src/app/components/search-form/search-form.component.ts @@ -74,6 +74,7 @@ export class SearchFormComponent implements OnInit { switchMap((text) => { if (!text.length) { return of([ + '', [], { nodes: [], @@ -84,11 +85,14 @@ export class SearchFormComponent implements OnInit { this.isTypeaheading$.next(true); if (!this.stateService.env.LIGHTNING) { return zip( + of(text), this.electrsApiService.getAddressesByPrefix$(text).pipe(catchError(() => of([]))), - [{ nodes: [], channels: [] }] + [{ nodes: [], channels: [] }], + of(this.regexBlockheight.test(text)), ); } return zip( + of(text), this.electrsApiService.getAddressesByPrefix$(text).pipe(catchError(() => of([]))), this.apiService.lightningSearch$(text).pipe(catchError(() => of({ nodes: [], @@ -102,10 +106,12 @@ export class SearchFormComponent implements OnInit { return result[0].map((address: string) => 'B' + address); } return { - addresses: result[0], - nodes: result[1].nodes, - channels: result[1].channels, - totalResults: result[0].length + result[1].nodes.length + result[1].channels.length, + searchText: result[0], + blockHeight: this.regexBlockheight.test(result[0]) ? [parseInt(result[0], 10)] : [], + addresses: result[1], + nodes: result[2].nodes, + channels: result[2].channels, + totalResults: result[1].length + result[2].nodes.length + result[2].channels.length, }; }) ); @@ -121,6 +127,8 @@ export class SearchFormComponent implements OnInit { selectedResult(result: any) { if (typeof result === 'string') { this.search(result); + } else if (typeof result === 'number') { + this.navigate('/block/', result.toString()); } else if (result.alias) { this.navigate('/lightning/node/', result.public_key); } else if (result.short_id) { diff --git a/frontend/src/app/components/search-form/search-results/search-results.component.html b/frontend/src/app/components/search-form/search-results/search-results.component.html index cc289ddac..9ed829aff 100644 --- a/frontend/src/app/components/search-form/search-results/search-results.component.html +++ b/frontend/src/app/components/search-form/search-results/search-results.component.html @@ -1,25 +1,31 @@ -