Blockchain Learning (7) consensus

Source: Internet
Author: User

As already mentioned in the previous article, Bitcoin is a decentralized, distributed ledger, so the nodes are not trusted by each other. So how do all the participants in the Bitcoin network reach a consensus on any ownership? This article will show you how to solve this problem.

The bitcoin consensus is generated by the interaction of the 4 independent processes of all nodes:

1. Each node (mining node) independently verifies each transaction according to the standard

2. Mining node by completing the proof of work, the transaction is packaged separately into the new block

3. Each node independently verifies the new block and assembles it into the blockchain.

4. Each node chooses the blockchain independently, and selects the largest accumulated work block chain under the proof of workload mechanism.

At the same time, mining will be rewarded with a certain amount of bitcoin, mining is an incentive mechanism, this mechanism to achieve the security of the Central. With mining incentives, miners have the power to work. The number of bitcoins generated by miners by creating a new chunk is roughly halved every four years. That is to say, start with 50 bitcoins for each block in January 2009, then halve by November 2012 for 25 bitcoins per block. Until 2140. All Bitcoins are released by then. The miners ' main benefit will come from the transaction fee.

Workload Proof algorithm

Miners get the right to account by repeatedly calculating the hash value, in order to ensure that only 10 minutes or so only one person can book, you have to improve the difficulty of accounting, so that the result of the hash must be a number of 0 start. In order to satisfy this condition, a random number variable is introduced in the hash. Prior to the introduction of the chunk header in the previous article referred to the nonce (random number), the miners by using different nonce values to calculate the hash of the chunk header until the computed hash value is less than the difficulty value. The smaller the difficulty, the greater the difficulty of the calculation, for example, throw a dice to get less than a specific point of the game. The first inning is less than 6. As long as you don't throw 6, you will win. Then the next inning is less than 2. Then you can only throw 1.

Longest chain selection

When there are two miners in almost the same time, each calculated the workload proof solution, then immediately spread their own chunks into the network, first spread to the neighboring nodes and then spread to the entire network. Each node that receives a valid chunk merges it into and extends the blockchain, resulting in two different chains. For example, the generation of two blocks #3458a and #3458b, node or the largest selection of work, in the entire blockchain network, some nodes will accept the #3458a, some nodes accept #3458b.

When the #3458a node is received, a new candidate block is immediately created with this chunk as the parent block, and an attempt is made to find a proof solution for the candidate block. Similarly, the node that accepts the #3458b chunk begins to generate a new block with the vertex of that chunk, extending the chain (hereinafter referred to as the B-chain). Suppose the node of the #3458b block is selected first to calculate the next chunk #3459b, and broadcast to the whole network, which is the chain below the chain longer than above, then choose a longer chain.

Blockchain Learning (7) consensus

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.