diff --git a/frontend/src/app/lightning/channel/channel.component.html b/frontend/src/app/lightning/channel/channel.component.html index c775135cb..29a55df57 100644 --- a/frontend/src/app/lightning/channel/channel.component.html +++ b/frontend/src/app/lightning/channel/channel.component.html @@ -52,7 +52,7 @@
-

{{ channel.alias_left }}

+

{{ channel.alias_left || '?' }}

{{ channel.node1_public_key | shortenString : 18 }} @@ -96,7 +96,7 @@
-

{{ channel.alias_right }}

+

{{ channel.alias_right || '?' }}

{{ channel.node2_public_key | shortenString : 18 }} diff --git a/frontend/src/app/lightning/channels-list/channels-list.component.html b/frontend/src/app/lightning/channels-list/channels-list.component.html index 2ca201ca6..88b3c4ab1 100644 --- a/frontend/src/app/lightning/channels-list/channels-list.component.html +++ b/frontend/src/app/lightning/channels-list/channels-list.component.html @@ -3,17 +3,23 @@ + - - + + - + - - + + diff --git a/frontend/src/app/lightning/node-statistics/node-statistics.component.html b/frontend/src/app/lightning/node-statistics/node-statistics.component.html index 0bfbce647..6991e2b66 100644 --- a/frontend/src/app/lightning/node-statistics/node-statistics.component.html +++ b/frontend/src/app/lightning/node-statistics/node-statistics.component.html @@ -3,7 +3,7 @@
Capacity
+ ngbTooltip="Percentage change past week" placement="bottom"> @@ -13,7 +13,7 @@
Nodes
+ ngbTooltip="Percentage change past week" placement="bottom">
{{ statistics.latest.node_count | number }}
@@ -25,7 +25,7 @@
Channels
+ ngbTooltip="Percentage change past week" placement="bottom">
{{ statistics.latest.channel_count | number }}
diff --git a/lightning-backend/src/api/nodes/channels.api.ts b/lightning-backend/src/api/explorer/channels.api.ts similarity index 100% rename from lightning-backend/src/api/nodes/channels.api.ts rename to lightning-backend/src/api/explorer/channels.api.ts diff --git a/lightning-backend/src/api/nodes/channels.routes.ts b/lightning-backend/src/api/explorer/channels.routes.ts similarity index 100% rename from lightning-backend/src/api/nodes/channels.routes.ts rename to lightning-backend/src/api/explorer/channels.routes.ts diff --git a/lightning-backend/src/api/nodes/nodes.api.ts b/lightning-backend/src/api/explorer/nodes.api.ts similarity index 98% rename from lightning-backend/src/api/nodes/nodes.api.ts rename to lightning-backend/src/api/explorer/nodes.api.ts index c64ec1bf3..5ed30c0e4 100644 --- a/lightning-backend/src/api/nodes/nodes.api.ts +++ b/lightning-backend/src/api/explorer/nodes.api.ts @@ -38,7 +38,7 @@ class NodesApi { public async $getLatestStatistics(): Promise { try { const [rows]: any = await DB.query(`SELECT * FROM statistics ORDER BY id DESC LIMIT 1`); - const [rows2]: any = await DB.query(`SELECT * FROM statistics ORDER BY id DESC LIMIT 1 OFFSET 71`); + const [rows2]: any = await DB.query(`SELECT * FROM statistics ORDER BY id DESC LIMIT 1 OFFSET 72`); return { latest: rows[0], previous: rows2[0], diff --git a/lightning-backend/src/api/nodes/nodes.routes.ts b/lightning-backend/src/api/explorer/nodes.routes.ts similarity index 100% rename from lightning-backend/src/api/nodes/nodes.routes.ts rename to lightning-backend/src/api/explorer/nodes.routes.ts diff --git a/lightning-backend/src/server.ts b/lightning-backend/src/server.ts index 26608b0c4..954be4f0a 100644 --- a/lightning-backend/src/server.ts +++ b/lightning-backend/src/server.ts @@ -3,8 +3,8 @@ import * as express from 'express'; import * as http from 'http'; import logger from './logger'; import config from './config'; -import nodesRoutes from './api/nodes/nodes.routes'; -import channelsRoutes from './api/nodes/channels.routes'; +import nodesRoutes from './api/explorer/nodes.routes'; +import channelsRoutes from './api/explorer/channels.routes'; class Server { private server: http.Server | undefined; diff --git a/lightning-backend/src/tasks/node-sync.service.ts b/lightning-backend/src/tasks/node-sync.service.ts index cd257a483..57d301642 100644 --- a/lightning-backend/src/tasks/node-sync.service.ts +++ b/lightning-backend/src/tasks/node-sync.service.ts @@ -3,7 +3,7 @@ import DB from '../database'; import logger from '../logger'; import lightningApi from '../api/lightning/lightning-api-factory'; import { ILightningApi } from '../api/lightning/lightning-api.interface'; -import channelsApi from '../api/nodes/channels.api'; +import channelsApi from '../api/explorer/channels.api'; import bitcoinClient from '../api/bitcoin/bitcoin-client'; class NodeSyncService { @@ -33,6 +33,7 @@ class NodeSyncService { await this.$saveChannel(channel); } + await this.$findInactiveNodesAndChannels(); await this.$scanForClosedChannels(); } catch (e) { @@ -40,7 +41,21 @@ class NodeSyncService { } } - private async $scanForClosedChannels() { + // Looking for channels whos nodes are inactive + private async $findInactiveNodesAndChannels(): Promise { + try { + // @ts-ignore + const [channels]: [ILightningApi.Channel[]] = await DB.query(`SELECT channels.id FROM channels WHERE channels.status = 1 AND ((SELECT COUNT(*) FROM nodes WHERE nodes.public_key = channels.node1_public_key) = 0 OR (SELECT COUNT(*) FROM nodes WHERE nodes.public_key = channels.node2_public_key) = 0)`); + + for (const channel of channels) { + await this.$updateChannelStatus(channel.id, 0); + } + } catch (e) { + logger.err('$findInactiveNodesAndChannels() error: ' + (e instanceof Error ? e.message : e)); + } + } + + private async $scanForClosedChannels(): Promise { try { const channels = await channelsApi.$getChannelsByStatus(0); for (const channel of channels) { @@ -152,6 +167,14 @@ class NodeSyncService { } } + private async $updateChannelStatus(channelShortId: string, status: number): Promise { + try { + await DB.query(`UPDATE channels SET status = ? WHERE id = ?`, [status, channelShortId]); + } catch (e) { + logger.err('$updateChannelStatus() error: ' + (e instanceof Error ? e.message : e)); + } + } + private async $setChannelsInactive(): Promise { try { await DB.query(`UPDATE channels SET status = 0 WHERE status = 1`);
Node AliasNode ID Status Fee RateChannel ID CapacityTransaction IDChannel ID
- {{ channel.alias_left }} + {{ channel.alias_left || '?' }} + + + {{ channel.node1_public_key | shortenString : 10 }} + + Inactive @@ -25,8 +31,14 @@ - {{ channel.alias_right }} + + {{ channel.alias_right || '?' }} + + + {{ channel.node2_public_key | shortenString : 10 }} + + Inactive @@ -37,23 +49,20 @@ {{ channel.node2_fee_rate / 10000 | number }}% - {{ channel.id }} - - - {{ channel.transaction_id | shortenString : 10 }} - - - + {{ channel.id }} +
+ +