Add /api/v1/mining/blocks/fee-rates/{interval} API

This commit is contained in:
nymkappa
2022-04-14 15:37:03 +09:00
parent 056b1db8b3
commit 0ba34594a2
4 changed files with 63 additions and 1 deletions

View File

@@ -670,6 +670,22 @@ class Routes {
}
}
public async $getHistoricalBlockFeeRates(req: Request, res: Response) {
try {
const blockFees = await mining.$getHistoricalBlockFeeRates(req.params.interval ?? null);
const oldestIndexedBlockTimestamp = await BlocksRepository.$oldestBlockTimestamp();
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.setHeader('Expires', new Date(Date.now() + 1000 * 300).toUTCString());
res.json({
oldestIndexedBlockTimestamp: oldestIndexedBlockTimestamp,
blockFees: blockFees,
});
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public async getBlock(req: Request, res: Response) {
try {
const result = await bitcoinApi.$getBlock(req.params.hash);