Book Image

Bitcoin Essentials

By : Albert Szmigielski
Book Image

Bitcoin Essentials

By: Albert Szmigielski

Overview of this book

Blockchain is being billed as the technology of the future. Bitcoin is the first application of that technology. Mining is what makes it all possible. Exploring mining from a practical perspective will help you make informed decisions about your mining setup. Understanding what the future may hold for blockchains, and therefore for mining, will help you position yourself to take advantage of the impending changes. This practical guide starts with an introduction to Bitcoin wallets, as well as mining hardware and software. You will move on to learn about different mining techniques using the CPU, GPU, FPGA, and ultimately the ASIC as an example. After this, you will gain an insight into solo mining and pool mining, and see the differences between the two. The book will then walk you through large-scale mining and the challenges faced during such operations. Finally, you will take a look into the future to see a world where blockchain-based applications are commonplace and mining is ubiquitous.
Table of Contents (15 chapters)
Bitcoin Essentials
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Mining software


Let's now look at mining software. At the very beginning, mining software was built into the wallet software. Mining used only a single core of a CPU back then. Nowadays, there are a variety of devices that can perform the mining function. As such, there is some software needed to coordinate and manage the work done by these devices.

The need for mining software

As mentioned earlier, mining software coordinates and manages the work of different mining devices. In order for mining to move beyond utilizing a single core of a CPU, software was needed that could manage the work that multiple cores perform. This is to make sure that they do not do redundant work; hence, mining software was born. Later on, mining moved onto a multitude of devices and the need for a management software became even more apparent.

What does mining software do?

Bitcoin mining is basically a guessing game. The software constructs a candidate block. A candidate block includes the hash of the previous (last) block and it also includes transactions taken from the pending transaction pool. Finally, it includes the most important piece, called a nonce. A nonce is basically a counter. The software constructs the candidate block and then hashes it. If the result does not meet the difficulty criteria, then the nonce is incremented and another hash is taken.

Mining devices can make billions and even trillions of these hashes per second. When a successful hash is found, the software submits the solved block to the network for verification. We call this guessing rather than solving because solving implies a method other than repeated guessing and checking if it is correct.

Which mining software to choose?

There are a variety of different software miners. A good comprehensive list can be found at: https://en.bitcoin.it/wiki/Mining_software. The two most popular miners are cgminer and bfgminer; both are open source and can be downloaded from GitHub. Here, we will concentrate on cgminer.

Cgminer can be downloaded from a variety of sources on the Internet. We recommend going directly to the developer's website: http://ck.kolivas.org/apps/cgminer/.

Cgminer is available for Windows and Linux systems and it can also be built from source for Mac OS; there are also third party providers that host a compiled Mac OS version on their websites. Download the appropriate version for your system. Installation on Windows systems is straightforward. As an example, we are going to use cgminer version 3.7.2. This is the last version to support GPU mining; keep this in mind if you want to mine with your GPUs. (We will further discuss the versions of cgminer in the chapters on mining with specific devices.)

Note

Defintion

GPU: Graphics Processing Unit is a processor designed specifically for processing and displaying graphics on a computer screen.

Once you have cgminer installed, you may want to verify it by running the cgminer -n command in your terminal (also called command prompt in Windows). The output will look similar to this:

Fig. 1.11: Output from the cgminer -n command

It lists the required software (OpenCL in our case) and confirms that cgminer found some hardware in your system that it can use to mine. In our case, it is an AMD R9 Radeon GPU.

Now would be a good time to start cgminer and familiarize ourselves with the basic features. In order to run cgminer, we need to tell it where to get work from. This means a mining pool or your local wallet if you are mining solo (more on this will follow in the chapters on mining solo or with a pool).

Note

Definition

Mining pool: Bitcoin mining is very competitive and in order to have a better chance at being successful, individual miners combine their resources together and form groups, also called pools. Such a combined mining group is called a mining pool. A quick Internet search will show that there are a number of mining pools out there.

If you are already registered with a pool, run the following command to start mining:

cgminer -o <http://pool:port> -u <username> -p <password>

This tells cgminer to connect to the specified pool with the specified credentials (of course, replace the values in the angle brackets with your own pool information).

If successful, cgminer will start and display the following screen:

Fig. 1.12: Starting cgminer

As we can see, cgminer is running and it is connected to the pool we specified.

We will now briefly review the options that cgminer offers while it's running.

There are menu items for: Pool management, GPU management, Settings, and Display options. Let's examine them a little more closely. To get into a menu item, simply press the letter that corresponds to the item in question. The letters are wrapped in square brackets to indicate that they can be selected.

The following is the screenshot of Pool management:

Fig. 1.13: Pool management in cgminer

Here we can add more pools, remove ones we no longer need, disable, enable pools, or change the mining quota. We can also change our management strategy.

Fig. 1.14: Pool management strategy

As we can see, there are five options for pool management. We usually use the default option: Failover, which switches to the next pool in the case of the current pool's outage. These options are best explained in the README file that is included with cgminer.

The next option is GPU management—pressing G will bring up the following screen:

Fig. 1.15: GPU management screen

Here we can see the current statistics about our GPUs. The read-out shows temperature, fan speed, GPU clock, memory clock, and other information that maybe available for the particular hardware at hand. We can also manage our GPUs, in case we have multiple ones. We can disable or enable additional GPUs, change the intensity setting on each GPU, and change other settings as well.

Let's exit this menu (press space to exit) and go back to the main screen. Let's now look at the Settings menu. Pressing S will bring up the following screen:

Fig. 1.16: Settings options in cgminer

Here, the most interesting option is Write config file. Pressing W will save a config file that we can use in the future to start cgminer with the appropriate settings. We will go into details in a later chapter – right now we want you to be aware that such an option exists, as it will prove useful.

Finally, the Display option from the main screen of cgminer will let us control what we want to see on the screen while cgminer is working. Pressing D will bring us to the following screen:

Fig. 1.17: Display options

We find that the default display options are sufficient for most miners. If you are interested in additional details, you may want to delve into the options by reading the README file that is shipped with cgminer. We do recommend everyone to at least skim through that file, as it is filled with useful information. We will touch upon the most important functions of the software later on, but a full description and explanation of all the features is beyond the scope of this book.

Finally, we should note that exiting cgminer, for whatever reason, can be accomplished by pressing Q.