Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created January 21, 2018 10:47
Show Gist options
  • Save ssaurel/09645ad61fbe2658328389d1fa415625 to your computer and use it in GitHub Desktop.
Save ssaurel/09645ad61fbe2658328389d1fa415625 to your computer and use it in GitHub Desktop.
Add and Mining Block for toutsurlebitcoin.fr
public Block latestBlock() {
return blocks.get(blocks.size() - 1);
}
public Block newBlock(String data) {
Block latestBlock = latestBlock();
return new Block(latestBlock.getIndex() + 1, System.currentTimeMillis(),
latestBlock.getHash(), data);
}
public void addBlock(Block b) {
if (b != null) {
b.mineBlock(difficulty);
blocks.add(b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment