Don't insert gapped gossip data upon restart

This commit is contained in:
nymkappa 2022-08-02 17:56:46 +02:00
parent d7f2f4136c
commit 5b521cfc7c
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04

View File

@ -255,10 +255,10 @@ class LightningStatsImporter {
const fileList = await fsPromises.readdir(this.topologiesFolder); const fileList = await fsPromises.readdir(this.topologiesFolder);
fileList.sort().reverse(); fileList.sort().reverse();
const [rows]: any[] = await DB.query('SELECT UNIX_TIMESTAMP(added) AS added FROM lightning_stats'); const [rows]: any[] = await DB.query('SELECT UNIX_TIMESTAMP(added) as added, node_count FROM lightning_stats');
const existingStatsTimestamps = {}; const existingStatsTimestamps = {};
for (const row of rows) { for (const row of rows) {
existingStatsTimestamps[row.added] = true; existingStatsTimestamps[row.added] = rows[0];
} }
for (const filename of fileList) { for (const filename of fileList) {
@ -266,6 +266,7 @@ class LightningStatsImporter {
// Stats exist already, don't calculate/insert them // Stats exist already, don't calculate/insert them
if (existingStatsTimestamps[timestamp] !== undefined) { if (existingStatsTimestamps[timestamp] !== undefined) {
latestNodeCount = existingStatsTimestamps[timestamp].node_count;
continue; continue;
} }