Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.