We simulate a multi-user network for a cryptocurrency as Bitcoin. Once a transaction is made, the user randomly picks some of his peers to notify who in turn notify others. Once a user accumulates n transactions, it strives to form a block by doing a computationally expensive task and announce it afterwards. Users who receive the announced block, add it to their version of blockchain (ledger) and if a majority consent is reached for the current ledger version, users of different versions throw them away and adopt the new one.
- Compile all files.
- Run the
Main.java
file in thesrc/main
folder. - Call
test2()
for a longer chain substitution scenario, ortest1()
for an almost random scenario.
- Java 😍
- Java SE Security
✨ صايبر الرباعي