creation of a Blockchain miner


“Griffin Blockchain”

Don't use plagiarized sources. Get Your Custom Essay on
creation of a Blockchain miner
Just from $10/Page
Order Essay

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 doesn’t 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

  1. Download
  1. This includes the following classes:
  1. You only add code where you see this:




  1. CLASSES where you add code:
  1. Miner
  1. doProofOfWork method: The logic behind this will be reviewed in class.
    1. This method should first create a string that has as many zeros in it as oBlock.getDifficulty() equals.
      1. Hint: use a while loop here that keeps looping while the length of this string you’re creating is less than the target difficulty length.
  1. Then, this method should have another while loop that keeps looping until a valid nonce is found.
    1. There needs to be an if — else in this while loop.
  1. If bAbortPoW (an instance variable you’ll see at the top of the class) equals true, then this means another miner solved the block and this miner received it, so you need to:
    1. Set bAbortPoW back to false.
    2. Print out something to the user like:

“[miner] Aborted mining block, probably because another confirmed block received.”

  1. Return false so the method ends.
  1. Else perform another attempt at a valid nonce:
    1. The nonce should start at 0 before the while loop and increment each loop.
    2. A valid nonce, after it’s added to the block’s properties and the block is hashed, should result in a hash that has as many leading zeros as the string you created above (use String’s startsWith method for this check).
      1. So remember that on oBlock you have to call:
        1. Set nonce.
        2. Compute hash.
        3. Set hash to whatever came back from compute hash.
      2. Then check if hash on oBlock now begins with your leading zeroes string you created above.
        1. If it does, then return true.
  1. Block
  1. computeMerkleRoot:
  1. Choose which approach you want to take:
    1. The 90% approach is much easier and is based on what we’ve done in class but your max score for the project can only reach 90%.
    2. The 100% approach is much trickier, and you must figure out on your own.
  1. 90% Project Score Logic: This logic needs to account for possibly 2 or 4 items in lstItems that are passed in.
    1. This means your code should have 2 or 4 Merkle Tree leaves depending on how many items are passed in.
  2. 100% Project Score Logic: You can only get 90% on this project if everything else is done perfectly. To get 100%, you must make this method flexible to accept any power of 2 items. So lstItems could be 2,4,8,16,32, etc. and your code would be able to compute the Merkle Root.
  1. NOTE: There is a main method at the bottom of this class that you can use to test 2 and 4 items simply by right clicking on the tab for this class and selecting “Run Block.main()”
  1. populateMerkleNode:
    1. This method will work just as we did in class… set the left and right nodes and then call generateHash in the BlockchainUtil class and set the node’s hash.
  1. BlockchainUtil
  1. generateHash:
    1. This method generates a SHA-256 hash of the string passed in.
    2. Code for this was reviewed in class and doesn’t need to be changed.
  1. P2PMessageQueue
  1. enqueue:
    1. This adds a node to the queue.
    2. Code will be reviewed in class.
  1. dequeue:
    1. This removes and returns a node from the queue.
    2. Code will be reviewed in class.
  1. hasNodes:
    1. This returns true or false depending on if any nodes exist in queue.
    2. Code will be reviewed in class.
  1. P2PUtil
  1. connectForOneMessage:
    1. This method will connect to a given server via Socket for a one-time sending of a message to that server and it will return the reply from the server and disconnect.
    2. Code for the Socket communication will be reviewed in class.
  1. Testing Your Code
    1. You need to run two instances of this app so that they can communicate with each other.
      1. One app can be run from your IDE like you normally do.
      2. The other app must be ran from a PowerShell window or other command line tool as explained below.
  1. Running a separate instance of your app:
    1. Jar file generation
      1. You first need to build your code into a JAR file.
      2. Instructions are included with the project online and will be reviewed in class.
    2. Running your JAR file
      1. Navigate to your JAR file in file explorer.
        1. Shortcut if using IntelliJ:
          1. Find it in your left side file explorer in your IntelliJ IDE:
            1. …out > artifacts > BlockchainBasics_jar > BlockchainBasics.jar
          2. Right click on it and pic “Show in Explorer.”
      2. Make sure that no file is highlighted by LEFT clicking in right space.
      3. SHIFT + RIGHT click in white space as shown in class to get extra menu item of “Open PowerShell Window here”
      4. In PowerShell or other command line tool, type the following to run:

java -jar BlockchainBasics.jar

  1. Then make sure a different port is chosen for your IDE instance and your command line instance:
    1. For instance, choose 8800 for one and 8888 or the other.
  1. NOT PART OF PROJECT GRADING: Incorporating your code into larger in-class Griffin Blockchain app.
    1. All of the code you added to this BlockchainBasics project can also now be added to the Griffin Blockchain app to make it functional and partake in full Blockchain networking with others in class.
    2. Details will be provided in class, and this app’s code will be made available later.
Student has agreed that all tutoring, explanations, and answers provided by the tutor will be used to help in the learning process and in accordance with Studypool’s honor code & terms of service.

Get professional assignment help cheaply

Are you busy and do not have time to handle your assignment? Are you scared that your paper will not make the grade? Do you have responsibilities that may hinder you from turning in your assignment on time? Are you tired and can barely handle your assignment? Are your grades inconsistent?

Whichever your reason may is, it is valid! You can get professional academic help from our service at affordable rates. We have a team of professional academic writers who can handle all your assignments.

Our essay writers are graduates with diplomas, bachelor, masters, Ph.D., and doctorate degrees in various subjects. The minimum requirement to be an essay writer with our essay writing service is to have a college diploma. When assigning your order, we match the paper subject with the area of specialization of the writer.

Why choose our academic writing service?

  • Plagiarism free papers
  • Timely delivery
  • Any deadline
  • Skilled, Experienced Native English Writers
  • Subject-relevant academic writer
  • Adherence to paper instructions
  • Ability to tackle bulk assignments
  • Reasonable prices
  • 24/7 Customer Support
  • Get superb grades consistently


Order a unique copy of this paper
(550 words)

Approximate price: $22

Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

We value our customers and so we ensure that what we do is 100% original..
With us you are guaranteed of quality work done by our qualified experts.Your information and everything that you do with us is kept completely confidential.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

The Product ordered is guaranteed to be original. Orders are checked by the most advanced anti-plagiarism software in the market to assure that the Product is 100% original. The Company has a zero tolerance policy for plagiarism.

Read more

Free-revision policy

The Free Revision policy is a courtesy service that the Company provides to help ensure Customer’s total satisfaction with the completed Order. To receive free revision the Company requires that the Customer provide the request within fourteen (14) days from the first completion date and within a period of thirty (30) days for dissertations.

Read more

Privacy policy

The Company is committed to protect the privacy of the Customer and it will never resell or share any of Customer’s personal information, including credit card data, with any third party. All the online transactions are processed through the secure and reliable online payment systems.

Read more

Fair-cooperation guarantee

By placing an order with us, you agree to the service we provide. We will endear to do all that it takes to deliver a comprehensive paper as per your requirements. We also count on your cooperation to ensure that we deliver on this mandate.

Read more

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Open chat
You can contact our live agent via WhatsApp! Via +1 817 953 0426

Feel free to ask questions, clarifications, or discounts available when placing an order.

Order your essay today and save 20% with the discount code VICTORY