mirror of
https://github.com/mempool/mempool.git
synced 2025-02-24 06:47:52 +01:00
Always use local data for pending/historical accelerations
This commit is contained in:
parent
efe43329a1
commit
c8e7cc773a
1 changed files with 14 additions and 42 deletions
|
@ -18,26 +18,11 @@ class AccelerationRoutes {
|
|||
}
|
||||
|
||||
private async $getAcceleratorAccelerations(req: Request, res: Response): Promise<void> {
|
||||
if (config.MEMPOOL_SERVICES.PREFER_LOCAL) {
|
||||
const accelerations = mempool.getAccelerations();
|
||||
res.status(200).send(Object.values(accelerations));
|
||||
} else {
|
||||
const url = `${config.MEMPOOL_SERVICES.API}/${req.originalUrl.replace('/api/v1/services/', '')}`;
|
||||
try {
|
||||
const response = await axios.get(url, { responseType: 'stream', timeout: 10000 });
|
||||
for (const key in response.headers) {
|
||||
res.setHeader(key, response.headers[key]);
|
||||
}
|
||||
response.data.pipe(res);
|
||||
} catch (e) {
|
||||
logger.err(`Unable to get current accelerations from ${url} in $getAcceleratorAccelerations(), ${e}`, this.tag);
|
||||
res.status(500).end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async $getAcceleratorAccelerationsHistory(req: Request, res: Response): Promise<void> {
|
||||
if (config.MEMPOOL_SERVICES.PREFER_LOCAL) {
|
||||
const history = await AccelerationRepository.$getAccelerationInfo(null, req.query.blockHeight ? parseInt(req.query.blockHeight as string, 10) : null);
|
||||
res.status(200).send(history.map(accel => ({
|
||||
txid: accel.txid,
|
||||
|
@ -50,19 +35,6 @@ class AccelerationRoutes {
|
|||
blockHeight: accel.height,
|
||||
pools: [accel.pool],
|
||||
})));
|
||||
} else {
|
||||
const url = `${config.MEMPOOL_SERVICES.API}/${req.originalUrl.replace('/api/v1/services/', '')}`;
|
||||
try {
|
||||
const response = await axios.get(url, { responseType: 'stream', timeout: 10000 });
|
||||
for (const key in response.headers) {
|
||||
res.setHeader(key, response.headers[key]);
|
||||
}
|
||||
response.data.pipe(res);
|
||||
} catch (e) {
|
||||
logger.err(`Unable to get acceleration history from ${url} in $getAcceleratorAccelerationsHistory(), ${e}`, this.tag);
|
||||
res.status(500).end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async $getAcceleratorAccelerationsHistoryAggregated(req: Request, res: Response): Promise<void> {
|
||||
|
|
Loading…
Add table
Reference in a new issue