Last active
June 22, 2018 11:05
-
-
Save felixklauke/879c17c528f632ce7691f01074fde915 to your computer and use it in GitHub Desktop.
Simple block chains service layer implementation.
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
@Service | |
public class BlockChainService { | |
private BlockChain blockChain = new BlockChain(); | |
public BlockChainService() { | |
blockChain.addBlock(new Block(0, "", new ArrayList<>(), 0)); | |
} | |
public void addTransaction(Transaction transaction) { | |
blockChain.addTransaction(transaction); | |
} | |
public List<Block> getBlockChainContent() { | |
return new ArrayList<>(blockChain.getBlocks()); | |
} | |
public Block startMining() { | |
Block block = blockChain.mineBlock(); | |
blockChain.addBlock(block); | |
return block; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment