Created
May 14, 2019 15:44
-
-
Save cyberpirate92/46d3c208b7fef79b8cb229b4f5cba5a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
try { | |
var blockChain = new BlockChain(); | |
Block block1 = new Block("Hello"); | |
Block block2 = new Block("World"); | |
Block block3 = new Block("Whatever"); | |
blockChain.addBlock(block1); | |
blockChain.addBlock(block2); | |
blockChain.addBlock(block3); | |
for (Block block: blockChain.chain) { | |
System.out.println(block); | |
} | |
System.out.println("Is valid chain : " + blockChain.isValid()); | |
// modify second block's data.. | |
blockChain.chain.get(1).transactionData = "World1"; | |
System.out.println("Is valid chain : " + blockChain.isValid()); // will be false | |
} | |
catch(Exception e) { | |
System.err.println(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment