Mining dashboard still runs fine if Bitcoin Core becomes unavailable

This commit is contained in:
nymkappa
2022-05-24 11:16:01 +02:00
parent 1ba0077666
commit be3d8b5ed9
4 changed files with 49 additions and 11 deletions

View File

@@ -121,6 +121,19 @@ class BlocksRepository {
}
}
/**
* Return most recent block height
*/
public async $mostRecentBlockHeight(): Promise<number> {
try {
const [row] = await DB.query('SELECT MAX(height) as maxHeight from blocks');
return row[0]['maxHeight'];
} catch (e) {
logger.err(`Cannot count blocks for this pool (using offset). Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get blocks count for a period
*/