Refactor the LN backend and add more logs
This commit is contained in:
parent
2a6f48d8c8
commit
61e512b8f7
@ -73,7 +73,7 @@ class NetworkSyncService {
|
|||||||
logger.info(`${progress} nodes updated`);
|
logger.info(`${progress} nodes updated`);
|
||||||
|
|
||||||
// If a channel if not present in the graph, mark it as inactive
|
// If a channel if not present in the graph, mark it as inactive
|
||||||
// nodesApi.$setNodesInactive(graphNodesPubkeys);
|
nodesApi.$setNodesInactive(graphNodesPubkeys);
|
||||||
|
|
||||||
if (config.MAXMIND.ENABLED) {
|
if (config.MAXMIND.ENABLED) {
|
||||||
$lookupNodeLocation();
|
$lookupNodeLocation();
|
||||||
@ -107,6 +107,61 @@ class NetworkSyncService {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err(`Cannot update channel list. Reason: ${(e instanceof Error ? e.message : e)}`);
|
logger.err(`Cannot update channel list. Reason: ${(e instanceof Error ? e.message : e)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTimeout(() => { this.$runTasks(); }, 1000 * config.LIGHTNING.STATS_REFRESH_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the `nodes` table to reflect the current network graph state
|
||||||
|
*/
|
||||||
|
private async $updateNodesList(nodes: ILightningApi.Node[]): Promise<void> {
|
||||||
|
let progress = 0;
|
||||||
|
|
||||||
|
const graphNodesPubkeys: string[] = [];
|
||||||
|
for (const node of nodes) {
|
||||||
|
await nodesApi.$saveNode(node);
|
||||||
|
graphNodesPubkeys.push(node.pub_key);
|
||||||
|
++progress;
|
||||||
|
|
||||||
|
const elapsedSeconds = Math.round((new Date().getTime() / 1000) - this.loggerTimer);
|
||||||
|
if (elapsedSeconds > 10) {
|
||||||
|
logger.info(`Updating node ${progress}/${nodes.length}`);
|
||||||
|
this.loggerTimer = new Date().getTime() / 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info(`${progress} nodes updated`);
|
||||||
|
|
||||||
|
// If a channel if not present in the graph, mark it as inactive
|
||||||
|
// nodesApi.$setNodesInactive(graphNodesPubkeys);
|
||||||
|
|
||||||
|
if (config.MAXMIND.ENABLED) {
|
||||||
|
$lookupNodeLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the `channels` table to reflect the current network graph state
|
||||||
|
*/
|
||||||
|
private async $updateChannelsList(channels: ILightningApi.Channel[]): Promise<void> {
|
||||||
|
let progress = 0;
|
||||||
|
|
||||||
|
const graphChannelsIds: string[] = [];
|
||||||
|
for (const channel of channels) {
|
||||||
|
await channelsApi.$saveChannel(channel);
|
||||||
|
graphChannelsIds.push(channel.channel_id);
|
||||||
|
++progress;
|
||||||
|
|
||||||
|
const elapsedSeconds = Math.round((new Date().getTime() / 1000) - this.loggerTimer);
|
||||||
|
if (elapsedSeconds > 10) {
|
||||||
|
logger.info(`Updating channel ${progress}/${channels.length}`);
|
||||||
|
this.loggerTimer = new Date().getTime() / 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info(`${progress} channels updated`);
|
||||||
|
|
||||||
|
// If a channel if not present in the graph, mark it as inactive
|
||||||
|
channelsApi.$setChannelsInactive(graphChannelsIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method look up the creation date of the earliest channel of the node
|
// This method look up the creation date of the earliest channel of the node
|
||||||
|
@ -24,7 +24,6 @@ class LightningStatsUpdater {
|
|||||||
private async $logStatsDaily(): Promise<void> {
|
private async $logStatsDaily(): Promise<void> {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
Common.setDateMidnight(date);
|
Common.setDateMidnight(date);
|
||||||
|
|
||||||
const networkGraph = await lightningApi.$getNetworkGraph();
|
const networkGraph = await lightningApi.$getNetworkGraph();
|
||||||
LightningStatsImporter.computeNetworkStats(date.getTime() / 1000, networkGraph);
|
LightningStatsImporter.computeNetworkStats(date.getTime() / 1000, networkGraph);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user