Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Last active January 21, 2018 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/7286b6782944179cd67dad4dab18dd43 to your computer and use it in GitHub Desktop.
Save ssaurel/7286b6782944179cd67dad4dab18dd43 to your computer and use it in GitHub Desktop.
Blockchain in action for a tutorial on toutsurlebitcoin.fr
package fr.toutsurlebitcoin.myblockchain;
public class Main {
public static void main(String[] args) {
Blockchain blockchain = new Blockchain(4);
blockchain.addBlock(blockchain.newBlock("Tout sur le Bitcoin"));
blockchain.addBlock(blockchain.newBlock("Sylvain Saurel"));
blockchain.addBlock(blockchain.newBlock("https://www.toutsurlebitcoin.fr"));
System.out.println("Blockchain valid ? " + blockchain.isBlockChainValid());
System.out.println(blockchain);
// add an invalid block to corrupt Blockchain
blockchain.addBlock(new Block(15, System.currentTimeMillis(), "aaaabbb", "Block invalid"));
System.out.println("Blockchain valid ? " + blockchain.isBlockChainValid());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment