Refactor accelerated audits
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { query } from '../../utils/axios-query';
|
||||
import config from '../../config';
|
||||
import { BlockExtended, PoolTag } from '../../mempool.interfaces';
|
||||
|
||||
export interface Acceleration {
|
||||
txid: string,
|
||||
@@ -7,7 +8,7 @@ export interface Acceleration {
|
||||
}
|
||||
|
||||
class AccelerationApi {
|
||||
public async fetchAccelerations$(): Promise<Acceleration[]> {
|
||||
public async $fetchAccelerations(): Promise<Acceleration[]> {
|
||||
if (config.MEMPOOL_SERVICES.ACCELERATIONS) {
|
||||
const response = await query(`${config.MEMPOOL_SERVICES.API}/accelerations`);
|
||||
return (response as Acceleration[]) || [];
|
||||
@@ -15,6 +16,23 @@ class AccelerationApi {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public async $fetchPools(): Promise<PoolTag[]> {
|
||||
if (config.MEMPOOL_SERVICES.ACCELERATIONS) {
|
||||
const response = await query(`${config.MEMPOOL_SERVICES.API}/partners`);
|
||||
return (response as PoolTag[]) || [];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public async $isAcceleratedBlock(block: BlockExtended): Promise<boolean> {
|
||||
const pools = await this.$fetchPools();
|
||||
if (block?.extras?.pool?.id == null) {
|
||||
return false;
|
||||
}
|
||||
return pools.reduce((match, tag) => match || tag.uniqueId === block.extras.pool.id, false);
|
||||
}
|
||||
}
|
||||
|
||||
export default new AccelerationApi();
|
||||
Reference in New Issue
Block a user