UNPKG

leap-node

Version:

[![codecov](https://codecov.io/gh/leapdao/leap-node/branch/master/graph/badge.svg)](https://codecov.io/gh/leapdao/leap-node) [![Docker Repository on Quay](https://quay.io/repository/leapdao/leap-node/status "Docker Repository on Quay")](https://quay.io/re

15 lines (13 loc) 523 B
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 }; };