Don't run the ln network update if the graph is emtpy
This commit is contained in:
parent
80f1ee45b5
commit
00cd3ee9bf
@ -28,7 +28,7 @@ import nodesRoutes from './api/explorer/nodes.routes';
|
|||||||
import channelsRoutes from './api/explorer/channels.routes';
|
import channelsRoutes from './api/explorer/channels.routes';
|
||||||
import generalLightningRoutes from './api/explorer/general.routes';
|
import generalLightningRoutes from './api/explorer/general.routes';
|
||||||
import lightningStatsUpdater from './tasks/lightning/stats-updater.service';
|
import lightningStatsUpdater from './tasks/lightning/stats-updater.service';
|
||||||
import nodeSyncService from './tasks/lightning/node-sync.service';
|
import networkSyncService from './tasks/lightning/network-sync.service';
|
||||||
import statisticsRoutes from './api/statistics/statistics.routes';
|
import statisticsRoutes from './api/statistics/statistics.routes';
|
||||||
import miningRoutes from './api/mining/mining-routes';
|
import miningRoutes from './api/mining/mining-routes';
|
||||||
import bisqRoutes from './api/bisq/bisq.routes';
|
import bisqRoutes from './api/bisq/bisq.routes';
|
||||||
@ -136,8 +136,8 @@ class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.LIGHTNING.ENABLED) {
|
if (config.LIGHTNING.ENABLED) {
|
||||||
nodeSyncService.$startService()
|
networkSyncService.$startService()
|
||||||
.then(() => lightningStatsUpdater.$startService());
|
.then(() => lightningStatsUpdater.$startService());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.server.listen(config.MEMPOOL.HTTP_PORT, () => {
|
this.server.listen(config.MEMPOOL.HTTP_PORT, () => {
|
||||||
|
@ -10,7 +10,7 @@ import { $lookupNodeLocation } from './sync-tasks/node-locations';
|
|||||||
import lightningApi from '../../api/lightning/lightning-api-factory';
|
import lightningApi from '../../api/lightning/lightning-api-factory';
|
||||||
import { convertChannelId } from '../../api/lightning/clightning/clightning-convert';
|
import { convertChannelId } from '../../api/lightning/clightning/clightning-convert';
|
||||||
|
|
||||||
class NodeSyncService {
|
class NetworkSyncService {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
public async $startService() {
|
public async $startService() {
|
||||||
@ -28,6 +28,11 @@ class NodeSyncService {
|
|||||||
logger.info(`Updating nodes and channels...`);
|
logger.info(`Updating nodes and channels...`);
|
||||||
|
|
||||||
const networkGraph = await lightningApi.$getNetworkGraph();
|
const networkGraph = await lightningApi.$getNetworkGraph();
|
||||||
|
if (networkGraph.nodes.length === 0 || networkGraph.edges.length === 0) {
|
||||||
|
logger.info(`LN Network graph is empty, retrying in 10 seconds`);
|
||||||
|
setTimeout(this.$runUpdater, 10000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (const node of networkGraph.nodes) {
|
for (const node of networkGraph.nodes) {
|
||||||
await this.$saveNode(node);
|
await this.$saveNode(node);
|
||||||
@ -376,6 +381,10 @@ class NodeSyncService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async $setChannelsInactive(graphChannelsIds: string[]): Promise<void> {
|
private async $setChannelsInactive(graphChannelsIds: string[]): Promise<void> {
|
||||||
|
if (graphChannelsIds.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await DB.query(`
|
await DB.query(`
|
||||||
UPDATE channels
|
UPDATE channels
|
||||||
@ -447,4 +456,4 @@ class NodeSyncService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new NodeSyncService();
|
export default new NetworkSyncService();
|
Loading…
x
Reference in New Issue
Block a user