Fix difficulty indexing db queries to return bits
This commit is contained in:
parent
0924bb6ac0
commit
a863c17408
@ -539,7 +539,7 @@ class BlocksRepository {
|
|||||||
*/
|
*/
|
||||||
public async $getBlocksDifficulty(): Promise<object[]> {
|
public async $getBlocksDifficulty(): Promise<object[]> {
|
||||||
try {
|
try {
|
||||||
const [rows]: any[] = await DB.query(`SELECT UNIX_TIMESTAMP(blockTimestamp) as time, height, difficulty FROM blocks`);
|
const [rows]: any[] = await DB.query(`SELECT UNIX_TIMESTAMP(blockTimestamp) as time, height, difficulty, bits FROM blocks`);
|
||||||
return rows;
|
return rows;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err('Cannot get blocks difficulty list from the db. Reason: ' + (e instanceof Error ? e.message : e));
|
logger.err('Cannot get blocks difficulty list from the db. Reason: ' + (e instanceof Error ? e.message : e));
|
||||||
@ -848,7 +848,7 @@ class BlocksRepository {
|
|||||||
*/
|
*/
|
||||||
public async $getOldestConsecutiveBlock(): Promise<any> {
|
public async $getOldestConsecutiveBlock(): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const [rows]: any = await DB.query(`SELECT height, UNIX_TIMESTAMP(blockTimestamp) as timestamp, difficulty FROM blocks ORDER BY height DESC`);
|
const [rows]: any = await DB.query(`SELECT height, UNIX_TIMESTAMP(blockTimestamp) as timestamp, difficulty, bits FROM blocks ORDER BY height DESC`);
|
||||||
for (let i = 0; i < rows.length - 1; ++i) {
|
for (let i = 0; i < rows.length - 1; ++i) {
|
||||||
if (rows[i].height - rows[i + 1].height > 1) {
|
if (rows[i].height - rows[i + 1].height > 1) {
|
||||||
return rows[i];
|
return rows[i];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user