Merge pull request #58 from nicksavers/master

Verify that stateRoot equals the latest block stateRoot
This commit is contained in:
romanman 2014-07-07 23:03:30 +01:00
commit 5b1e40f168
2 changed files with 11 additions and 2 deletions

View File

@ -110,6 +110,15 @@ public class Blockchain {
}
for (int i = blocks.size() - 1; i >= 0 ; --i) {
this.addBlock(blocks.get(i));
/* Debug check to see if the state is still as expected */
if(logger.isWarnEnabled()) {
String blockStateRootHash = Hex.toHexString(blocks.get(i).getStateRoot());
String worldStateRootHash = Hex.toHexString(WorldManager.getInstance().getRepository().getWorldState().getRootHash());
if(!blockStateRootHash.equals(worldStateRootHash))
logger.warn("WARNING: STATE CONFLICT! worldstate {} mismatch", worldStateRootHash);
}
}
// Remove all wallet transactions as they already approved by the net
for (Block block : blocks) {
@ -135,7 +144,7 @@ public class Blockchain {
this.updateGasPrice(block);
this.setLastBlock(block);
if (logger.isDebugEnabled())
logger.debug("block added to the chain with hash: {}", Hex.toHexString(block.getHash()));
logger.debug("block added {}", block.toFlatString());
} else {
logger.warn("Invalid block with nr: {}", block.getNumber());
}

View File

@ -26,7 +26,7 @@ public class StaticMessages {
public static HelloMessage generateHelloMessage() {
byte[] peerIdBytes = HashUtil.randomPeerId();
return new HelloMessage((byte) 0x16, (byte) 0x00,
return new HelloMessage((byte) 0x17, (byte) 0x00,
"EthereumJ [v0.5.1] by RomanJ", Byte.parseByte("00000111", 2),
(short) 30303, peerIdBytes);
}