Created
January 21, 2018 10:47
-
-
Save ssaurel/09645ad61fbe2658328389d1fa415625 to your computer and use it in GitHub Desktop.
Add and Mining Block for toutsurlebitcoin.fr
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 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