The life of a Miner in Bitcoin Network
The first task is to validate the transactions and construct a new block. Once they have constructed a new block, they employ their hash power and vote on consensus to determine who will complete the work first and then propose that block as a new block. Add that new block to the existing bitcoin blockchain, and broadcast that updated blockchain to the peers. So that way, the entire blockchain gets propagated in the network.
Mining Bitcoin
- The first and foremost task is to join the network, listen for transactions, and validate the proposed transactions from the network clients.
- Listen for the new blocks proposed by other miners, validate, and re-broadcast to the peer nodes. However, re-broadcast to a node that resides in a subnet of the bitcoin network. This is the standard policy followed by the bitcoin network nodes to avoid the Sybil attack.
- Collect the transactions for a predefined time, and construct a new block that includes all the transactions not included in a block of the main bitcoin blockchain received from the peer nodes.
- Participate in the mining procedure, where the miner task is to find a nonce to make the new block valid by utilizing the predefined difficulty function. That means the proposed new block must have a certain minimum number of zeros at the prefix. This is also called “Proof of Work” for consensus that a miner had done some work quicker than other miners in the bitcoin network.
- Once a miner can generate a valid block and quicker compared to other miners. The miner will broadcast that new block to the peers, and everybody in the peering system will accept that block if it is part of the main chain.
- In the typical bitcoin network, multiple new valid blocks may be generated together by the different miners, and these blocks may or may not have a list of the same transactions.
- Flooding rule: If multiple valid blocks are received from the peer nodes to an individual (a node or miner), the individual will accept the valid blocks but rebroadcast the block received from more peers.
- The bitcoin blockchain always has the main chain and multiple orphans blocks. The main chain is the longest blockchain in the network, and orphans blocks are blocks from the fork chain that come out from the main chain but do not grow longer than the main chain.
- Whenever a miner finds a new valid block and can successfully append it to the main chain, the miner earns a certain reward. However, other mines may be trying to generate a valid block during the same period, but already one of the miners found the valid one. In that case, they will discard the generation process and start collecting all the new transactions that are not there in the new append block of the bitcoin blockchain.

Mining Difficulty
It is a measure of how difficult it is to find a hash below the giving target. The mining procedure says that we are going to generate a 256-bit hash value. And there is mining difficulty, and it is represented in this way. Out of 256-bit hash, at least the first 64 bit should be zeros. This says that you have to generate a hash value wherein the final hash result, at least the first 64 bits, should be zero, and after that, the remaining bits can be zeros and ones.
This is the difficulty of the mining procedure, and based on that, we defined a metric called mining difficulty. These difficulty parameters change for every 2016 block or every two weeks. The desire rate of generation of a block is every 10 minutes. If the system tries to generate a new block every 10 minutes, then 2 weeks are required to generate 2016 blocks.
Difficulty level readjustment mechanism (Valid for every 2 weeks or 2016 blocks):
The difficulty level readjustment works as follows. The system finds out whether miners can generate 2016 blocks within 2 weeks or not. If they are taking less time, that means the difficulty is too simple for the miners. So the system increases the difficulty parameters for the next round of 2016 blocks. On the other hand, if the miners take more than 2 weeks to generate 2016 blocks. It means that the current difficulty is too hard for the miners. So the system reduces the difficulty parameters for the next round of 2016 blocks.
This way, the bitcoin network dynamically changes the difficulty levels. In general, the change in difficulty is in proportion to the amount of time over or under two weeks the previous 2016 blocks took to find.
Difficulty formula
The difficulty level readjustment happens after every two weeks or 2016 blocks, whichever comes first. The expectation is that within 2 weeks, 2016 blocks must be generated so that inter-block generation time becomes equal to 10 minutes. The formula to generate or find the current difficulty is as follows:

Hash-rate versus Difficulty
The hash is a random number between 0 and . To find a block, the hash must be less than a given target.
- The offset for difficulty 1 is
. It means out of 265 bits, the initial 48 bits must be zeros, and the remaining can be either zeros or ones.
- In general, the offset for difficulty D is
. The D tells how many zeros would be there at the beginning. So the expected number of hashes need to be calculated as
.
The difficulty level dynamically changes the amount of hash that miners need to generate. If D is a more difficult value, then generate more hashes to get the resulted target well.
Summary
We have seen the different tasks of the miners, mining difficulties, difficulty setting, and the incentives mechanism that motivates miners to employ some economic features such as dedicated hardware in the environment to control the entire mining procedure.
References
- NPTEL lecture series on Blockchains Architecture, Design and Use Cases by Prof. Sandip Chakraborty, IIT Kharagpur.