leap-node
Version:
[](https://codecov.io/gh/leapdao/leap-node) [](https://quay.io/re
15 lines (13 loc) • 523 B
JavaScript
const { Period } = require('leap-core');
module.exports = async (bridgeState, db, heightOrTag) => {
let height = heightOrTag;
if (heightOrTag === 'latest') {
height = bridgeState.blockHeight;
} else if (typeof height === 'string' && height.startsWith('0x')) {
height = parseInt(height, 16);
}
const [periodStart, periodEnd] = Period.periodBlockRange(height);
const periodData = await db.getPeriodData(periodStart);
if (!periodData) return null;
return { periodStart, periodEnd, ...periodData };
};