Question
1. SUMMARY This project will involve the creation of a Blockchain miner that does all the following: Receives transactions from user or remote node. Sends
1. SUMMARY
This project will involve the creation of a Blockchain miner that does all the following:
Receives transactions from user or remote node.
Sends transactions to a remote node.
Manages incoming remote node messages using a Queue.
Generates a Merkle Tree and an eventual Merkle Root as part of Transaction processing.
Creates Blockchain Blocks using Proof of Work algorithm.
For this project, you will create the main functionality inside of an existing code base called
BlockchainBasics
. The
BlockchainBasics code that you will begin with is provided along with this document.
BlockchainBasics, once completed, will allow you to run two instances of this app on two different ports that pass
transactions to each other and mine blocks.
This app doesnt save the blocks into a blockchain, but the central functionality you code into this app will be able
to be plugged in directly into a larger Blockchain application (the code for this will be provided in the coming
weeks) that fully manages a Blockchain, connects to multiple networked nodes, and allows you to trade items on
the network.
However, you will only be turning in the BlockchainBasics code as specified at the end of this doc.
This project will involve the following:
- Socket programming
- Queue
- Multithreading
- Hashing: SHA-256
- Merkle Trees
- Blockchain Proof of Work
2. DETAILS
a. Download BlockchainBasics.zip
i. This includes the following classes:
1. BlockchainBasics.java
2. Miner.java
3. Block.java
4. MerkleNode.java
5. BlockchainUtil.java
6. P2PServer.java
7. P2PMessageQueue.java
8. P2PMessage.java
9. P2PUtil.java
b. You only add code where you see this:
####################
### ADD CODE HERE ###
####################
BlockchainUtil
i. generateHash:
1. This method generates a SHA-256 hash of the string passed in.
2. Code for this was reviewed in class and doesnt need to be changed.
This is BlockchainUtil code:
import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.util.Scanner; /** * This class has utility methods used by the Blockchain logic. */ public class BlockchainUtil { /** * This method produces an SHA-256 hash of the string input. * @param sOriginal * @return */ public static synchronized String generateHash(String sOriginal){ ##################### ### ADD CODE HERE ### ##################### } /** * This method can either use Scanner or JOptionPane approaches to get user input. * @param sQuestion * @return */ public String promptUser(String sQuestion){ // Using input dialog: //return JOptionPane.showInputDialog(sQuestion); // Using Scanner: System.out.print(sQuestion); Scanner oCommandInput = new Scanner(System.in); return oCommandInput.nextLine(); } /** * This method allows user to avoid extra typing and efficient code, especially if this class variable is one letter * such as u, thus: * u.p("hello"); * @param sMessage */ public void p(String sMessage){ System.out.println(sMessage); } /** * This is used by any thread that needs to sleep to allow updating of static variables or to alleviate * CPU usage on continuous looping. * @param lMillis */ public void sleep(long lMillis){ try{ Thread.sleep(lMillis); } catch(Exception ex){ // do nothing. } } }
Use IntellJ please. Because there only 1 question per post so I posted 1 by 1. Thank you. I posted anthoer 4 questions by seperated.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started