Skip to content

Instantly share code, notes, and snippets.

@cyberpirate92
Created May 14, 2019 16:00
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 cyberpirate92/45b914689616e60cab744eb7c3005e43 to your computer and use it in GitHub Desktop.
Save cyberpirate92/45b914689616e60cab744eb7c3005e43 to your computer and use it in GitHub Desktop.
public void addBlock(Block block) throws NoSuchAlgorithmException {
block.previousBlockHash = chain.size() == 0 ? CryptoHelper.sha256("0") : chain.get(chain.size()-1).getHash();
// before adding a block to the blockchain
// mine block for the magic nonce value
block.mine(difficulty);
chain.add(block);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment