Skip to content

Commit

Permalink
DAA: Fix EDA when using checkpoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Mar 22, 2018
1 parent 1c1f488 commit 95713f4
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ public void checkDifficultyTransitions(final StoredBlock storedPrev, final Block
}
long mpt6blocks = 0;
try {
//Check to see if there are enough blocks before cursor to correctly calculate the median time
StoredBlock beforeCursor = cursor;
for (int i = 0; i < 10; i++) {
beforeCursor = blockStore.get(beforeCursor.getHeader().getPrevBlockHash());
if(beforeCursor == null)
return; //Not enough blocks to check difficulty.
}
mpt6blocks = blockChain.getMedianTimestampOfRecentBlocks(storedPrev, blockStore) - blockChain.getMedianTimestampOfRecentBlocks(cursor, blockStore);
} catch (NullPointerException x)
{
Expand Down

0 comments on commit 95713f4

Please sign in to comment.