Blockchain is a trustless environment where nobody has to trust each other, and there is no central authority to ensure trust between the transacting parties. So how does blockchain ensure that valid transactions are performed in the network? Blockchain employs a set of validation checks known as consensus mechanisms for the validity of transactions. Let’s learn about the consensus in detail.
In blockchain, mathematical algorithms are used to verify transactions and ensure trust between transacting parties. Transacting parties have to trust the output achieved using these mathematical algorithms. These algorithms together are known as the consensus mechanism in the blockchain. The consensus can be for a transaction or for an entire block.
The consensus for the verification of a transaction includes the checks for the following:
The consensus for a block is for the following condition:
Hash(HDR) < Difficulty Level
The consensus mechanism is difficult to achieve and easy to verify. The above-mentioned consensus mechanism is known as proof of work. In the proof of work consensus, miner nodes have to solve a computationally difficult problem to compute the hash for the current block. The network sets a difficulty target for the miners. This difficulty level plays a vital role in the consensus as well as in the mining process. Let’s learn more about the difficulty level in the upcoming video.
The difficulty value, also known as the target value, sets the difficulty level of the network. The difficulty level is used to regulate the mining of blocks in the network. The bitcoin network has a block creation time set to 10 mins and this value has to be maintained. The difficulty value adjusts with every block creation such that the value of block creation remains constant.
The formula for the calculation of a difficulty level in the bitcoin blockchain network is:
Difficulty Level = (Previous Difficulty Level * 20160) / (Time taken to mine last 2016 block)
In case the time taken for the last block is greater than 10 mins, the new value of difficulty level is lower than the previous one such that the blocks are created faster. In case the time taken for the last block is less than 10 mins, the new value of difficulty level is greater than the previous one such that the blocks are created slower.