Created
May 14, 2019 16:04
-
-
Save cyberpirate92/224b1e73e704c92ceea622ab5264bc85 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 difficulty = 5; | |
var blockChain = new BlockChain(difficulty); | |
Block block1 = new Block("Hello"); | |
Block block2 = new Block("World"); | |
Block block3 = new Block("Whatever"); | |
blockChain.addBlock(block1); | |
blockChain.addBlock(block2); | |
blockChain.addBlock(block3); | |
System.out.println(String.format("%64s\t%13s\t%7s\t%s", "Previous Block's hash", "Timestamp", "Nonce", "Transaction Data")); | |
for (Block block: blockChain.chain) { | |
System.out.println(block); | |
} | |
System.out.println("Is valid chain : " + blockChain.isValid()); | |
blockChain.chain.get(1).transactionData = "World1"; | |
System.out.println("Is valid chain : " + blockChain.isValid()); | |
} | |
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