[blocks] add 2 endpoints to retreive pools-v2.json hashes

This commit is contained in:
nymkappa
2024-11-29 17:13:28 +01:00
parent c8e967cc0c
commit ac997f3d9e
5 changed files with 49 additions and 2 deletions

View File

@@ -33,8 +33,8 @@ import AccelerationRepository from '../repositories/AccelerationRepository';
import { calculateFastBlockCpfp, calculateGoodBlockCpfp } from './cpfp';
import mempool from './mempool';
import CpfpRepository from '../repositories/CpfpRepository';
import accelerationApi from './services/acceleration';
import { parseDATUMTemplateCreator } from '../utils/bitcoin-script';
import database from '../database';
class Blocks {
private blocks: BlockExtended[] = [];
@@ -1462,6 +1462,19 @@ class Blocks {
// not a fatal error, we'll try again next time the indexer runs
}
}
public async $getBlockDefinitionHashes(): Promise<string[]> {
try {
const [rows]: any = await database.query(`SELECT DISTINCT(definition_hash) FROM blocks`);
if (rows && rows.length) {
return rows.map(r => r.definition_hash);
}
} catch (e) {
// we just return an empty array
}
logger.debug(`Unable to retreive list of blocks.definition_hash from db`);
return [];
}
}
export default new Blocks();