|
|
|
@ -95,22 +95,6 @@ public class BackwardChain { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
BlockHeader firstHeader = firstStoredAncestor.get(); |
|
|
|
|
if (firstHeader.getNumber() != blockHeader.getNumber() + 1) { |
|
|
|
|
throw new BackwardSyncException( |
|
|
|
|
"Wrong height of header " |
|
|
|
|
+ blockHeader.getHash().toHexString() |
|
|
|
|
+ " is " |
|
|
|
|
+ blockHeader.getNumber() |
|
|
|
|
+ " when we were expecting " |
|
|
|
|
+ (firstHeader.getNumber() - 1)); |
|
|
|
|
} |
|
|
|
|
if (!firstHeader.getParentHash().equals(blockHeader.getHash())) { |
|
|
|
|
throw new BackwardSyncException( |
|
|
|
|
"Hash of header does not match our expectations, was " |
|
|
|
|
+ blockHeader.toLogString() |
|
|
|
|
+ " when we expected " |
|
|
|
|
+ firstHeader.getParentHash().toHexString()); |
|
|
|
|
} |
|
|
|
|
headers.put(blockHeader.getHash(), blockHeader); |
|
|
|
|
chainStorage.put(blockHeader.getHash(), firstStoredAncestor.get().getHash()); |
|
|
|
|
firstStoredAncestor = Optional.of(blockHeader); |
|
|
|
|