Skip to content

Instantly share code, notes, and snippets.

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