controllers - recent-blocks - guard against empty block

This commit is contained in:
kumavis 2018-05-24 13:43:16 -07:00
parent ee800de025
commit 49ef93b991
1 changed files with 3 additions and 3 deletions

View File

@ -64,6 +64,7 @@ class RecentBlocksController {
async processBlock (newBlockNumberHex) {
const newBlockNumber = Number.parseInt(newBlockNumberHex, 16)
const newBlock = await this.getBlockByNumber(newBlockNumber, true)
if (!newBlock) return
const block = this.mapTransactionsToPrices(newBlock)
@ -135,10 +136,9 @@ class RecentBlocksController {
await Promise.all(targetBlockNumbers.map(async (targetBlockNumber) => {
try {
const newBlock = await this.getBlockByNumber(targetBlockNumber, true)
if (!newBlock) return
if (newBlock) {
this.backfillBlock(newBlock)
}
this.backfillBlock(newBlock)
} catch (e) {
log.error(e)
}