Merge pull request #1423 from mempool/nymkappa/bugfix/hashrate-indexing
If we have incomplete data for the day/week, don't index hashrate
This commit is contained in:
commit
502ef29e54
@ -113,12 +113,16 @@ class Mining {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const blockStats: any = await BlocksRepository.$blockCountBetweenTimestamp(
|
// Check if we have blocks for the previous week (which mean that the week
|
||||||
null, fromTimestamp, toTimestamp);
|
// we are currently indexing has complete data)
|
||||||
if (blockStats.blockCount === 0) { // We are done indexing, no blocks left
|
const blockStatsPreviousWeek: any = await BlocksRepository.$blockCountBetweenTimestamp(
|
||||||
|
null, fromTimestamp - 604800, toTimestamp - 604800);
|
||||||
|
if (blockStatsPreviousWeek.blockCount === 0) { // We are done indexing
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const blockStats: any = await BlocksRepository.$blockCountBetweenTimestamp(
|
||||||
|
null, fromTimestamp, toTimestamp);
|
||||||
const lastBlockHashrate = await bitcoinClient.getNetworkHashPs(blockStats.blockCount,
|
const lastBlockHashrate = await bitcoinClient.getNetworkHashPs(blockStats.blockCount,
|
||||||
blockStats.lastBlockHeight);
|
blockStats.lastBlockHeight);
|
||||||
|
|
||||||
@ -207,12 +211,16 @@ class Mining {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const blockStats: any = await BlocksRepository.$blockCountBetweenTimestamp(
|
// Check if we have blocks for the previous day (which mean that the day
|
||||||
null, fromTimestamp, toTimestamp);
|
// we are currently indexing has complete data)
|
||||||
if (blockStats.blockCount === 0) { // We are done indexing, no blocks left
|
const blockStatsPreviousDay: any = await BlocksRepository.$blockCountBetweenTimestamp(
|
||||||
|
null, fromTimestamp - 86400, toTimestamp - 86400);
|
||||||
|
if (blockStatsPreviousDay.blockCount === 0) { // We are done indexing
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const blockStats: any = await BlocksRepository.$blockCountBetweenTimestamp(
|
||||||
|
null, fromTimestamp, toTimestamp);
|
||||||
const lastBlockHashrate = await bitcoinClient.getNetworkHashPs(blockStats.blockCount,
|
const lastBlockHashrate = await bitcoinClient.getNetworkHashPs(blockStats.blockCount,
|
||||||
blockStats.lastBlockHeight);
|
blockStats.lastBlockHeight);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user