Skip to content

Commit

Permalink
Merge pull request #16 from ethereumjs/micah
Browse files Browse the repository at this point in the history
Minor cleanups.
  • Loading branch information
MicahZoltu authored May 17, 2018
2 parents 6d6262e + cee6eb0 commit 964e6cf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/block-reconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ const rollback = async <TBlock extends Block>(blockHistory: BlockHistory<TBlock>
return blockHistory;
}

const backfill = async <TBlock extends Block>(getBlockByHash: GetBlockByHash<TBlock>, blockHistory: BlockHistory<TBlock>, newBlock: TBlock, onBlockAdded: (block: TBlock) => Promise<void>, onBlockRemoved: (block: TBlock) => Promise<void>, blockRetention: number) => {
const backfill = async <TBlock extends Block>(getBlockByHash: GetBlockByHash<TBlock>, blockHistory: BlockHistory<TBlock>, newBlock: TBlock, onBlockAdded: (block: TBlock) => Promise<void>, onBlockRemoved: (block: TBlock) => Promise<void>, blockRetention: number): Promise<BlockHistory<TBlock>> => {
if (newBlock.parentHash === "0x0000000000000000000000000000000000000000000000000000000000000000")
return rollback(blockHistory, onBlockRemoved);
return await rollback(blockHistory, onBlockRemoved);
const parentBlock = await getBlockByHash(newBlock.parentHash);
if (parentBlock === null) throw new Error("Failed to fetch parent block.");
if (parseInt(parentBlock.number, 16) + blockRetention < parseInt(blockHistory.last().number, 16))
return rollback(blockHistory, onBlockRemoved);
return await rollback(blockHistory, onBlockRemoved);
blockHistory = await reconcileBlockHistory(getBlockByHash, blockHistory, parentBlock, onBlockAdded, onBlockRemoved, blockRetention);
return await reconcileBlockHistory(getBlockByHash, blockHistory, newBlock, onBlockAdded, onBlockRemoved, blockRetention);
}
Expand Down

0 comments on commit 964e6cf

Please sign in to comment.