mirror of
https://github.com/mempool/mempool.git
synced 2025-02-24 14:50:52 +01:00
Fix error handling in acceleration data polling
This commit is contained in:
parent
788a8693ee
commit
0bf0d79ee4
6 changed files with 20 additions and 18 deletions
|
@ -646,7 +646,7 @@ class BisqMarketsApi {
|
||||||
case 'year':
|
case 'year':
|
||||||
return strtotime('midnight first day of january', ts);
|
return strtotime('midnight first day of january', ts);
|
||||||
default:
|
default:
|
||||||
throw new Error('Unsupported interval: ' + interval);
|
throw new Error('Unsupported interval');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ class Mining {
|
||||||
public async $getPoolStat(slug: string): Promise<object> {
|
public async $getPoolStat(slug: string): Promise<object> {
|
||||||
const pool = await PoolsRepository.$getPool(slug);
|
const pool = await PoolsRepository.$getPool(slug);
|
||||||
if (!pool) {
|
if (!pool) {
|
||||||
throw new Error('This mining pool does not exist ' + escape(slug));
|
throw new Error('This mining pool does not exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
const blockCount: number = await BlocksRepository.$blockCount(pool.id);
|
const blockCount: number = await BlocksRepository.$blockCount(pool.id);
|
||||||
|
|
|
@ -75,8 +75,8 @@ class BlocksAuditRepositories {
|
||||||
expected_weight as expectedWeight
|
expected_weight as expectedWeight
|
||||||
FROM blocks_audits
|
FROM blocks_audits
|
||||||
JOIN blocks_templates ON blocks_templates.id = blocks_audits.hash
|
JOIN blocks_templates ON blocks_templates.id = blocks_audits.hash
|
||||||
WHERE blocks_audits.hash = "${hash}"
|
WHERE blocks_audits.hash = ?
|
||||||
`);
|
`, [hash]);
|
||||||
|
|
||||||
if (rows.length) {
|
if (rows.length) {
|
||||||
rows[0].missingTxs = JSON.parse(rows[0].missingTxs);
|
rows[0].missingTxs = JSON.parse(rows[0].missingTxs);
|
||||||
|
@ -101,8 +101,8 @@ class BlocksAuditRepositories {
|
||||||
const [rows]: any[] = await DB.query(
|
const [rows]: any[] = await DB.query(
|
||||||
`SELECT hash, match_rate as matchRate, expected_fees as expectedFees, expected_weight as expectedWeight
|
`SELECT hash, match_rate as matchRate, expected_fees as expectedFees, expected_weight as expectedWeight
|
||||||
FROM blocks_audits
|
FROM blocks_audits
|
||||||
WHERE blocks_audits.hash = "${hash}"
|
WHERE blocks_audits.hash = ?
|
||||||
`);
|
`, [hash]);
|
||||||
return rows[0];
|
return rows[0];
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
logger.err(`Cannot fetch block audit from db. Reason: ` + (e instanceof Error ? e.message : e));
|
logger.err(`Cannot fetch block audit from db. Reason: ` + (e instanceof Error ? e.message : e));
|
||||||
|
|
|
@ -478,7 +478,7 @@ class BlocksRepository {
|
||||||
public async $getBlocksByPool(slug: string, startHeight?: number): Promise<BlockExtended[]> {
|
public async $getBlocksByPool(slug: string, startHeight?: number): Promise<BlockExtended[]> {
|
||||||
const pool = await PoolsRepository.$getPool(slug);
|
const pool = await PoolsRepository.$getPool(slug);
|
||||||
if (!pool) {
|
if (!pool) {
|
||||||
throw new Error('This mining pool does not exist ' + escape(slug));
|
throw new Error('This mining pool does not exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
const params: any[] = [];
|
const params: any[] = [];
|
||||||
|
|
|
@ -139,7 +139,7 @@ class HashratesRepository {
|
||||||
public async $getPoolWeeklyHashrate(slug: string): Promise<any[]> {
|
public async $getPoolWeeklyHashrate(slug: string): Promise<any[]> {
|
||||||
const pool = await PoolsRepository.$getPool(slug);
|
const pool = await PoolsRepository.$getPool(slug);
|
||||||
if (!pool) {
|
if (!pool) {
|
||||||
throw new Error('This mining pool does not exist ' + escape(slug));
|
throw new Error('This mining pool does not exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find hashrate boundaries
|
// Find hashrate boundaries
|
||||||
|
|
|
@ -45,28 +45,30 @@ export class AcceleratorDashboardComponent implements OnInit {
|
||||||
this.pendingAccelerations$ = interval(30000).pipe(
|
this.pendingAccelerations$ = interval(30000).pipe(
|
||||||
startWith(true),
|
startWith(true),
|
||||||
switchMap(() => {
|
switchMap(() => {
|
||||||
return this.apiService.getAccelerations$();
|
return this.apiService.getAccelerations$().pipe(
|
||||||
}),
|
catchError(() => {
|
||||||
catchError((e) => {
|
return of([]);
|
||||||
return of([]);
|
}),
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
share(),
|
share(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.accelerations$ = this.stateService.chainTip$.pipe(
|
this.accelerations$ = this.stateService.chainTip$.pipe(
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
switchMap((chainTip) => {
|
switchMap(() => {
|
||||||
return this.apiService.getAccelerationHistory$({ timeframe: '1m' });
|
return this.apiService.getAccelerationHistory$({ timeframe: '1m' }).pipe(
|
||||||
}),
|
catchError(() => {
|
||||||
catchError((e) => {
|
return of([]);
|
||||||
return of([]);
|
}),
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
share(),
|
share(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.minedAccelerations$ = this.accelerations$.pipe(
|
this.minedAccelerations$ = this.accelerations$.pipe(
|
||||||
map(accelerations => {
|
map(accelerations => {
|
||||||
return accelerations.filter(acc => ['mined', 'completed'].includes(acc.status))
|
return accelerations.filter(acc => ['mined', 'completed'].includes(acc.status));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue