Block height and accounting books | Introduction to the vernacular blockchain 222

Author |
Produced by Yuxing |Vernacular Blockchain (ID: hellobtc)

In many articles about blockchain, it is often seen that the blockchain forks at a certain block height . What is the block height, and why does it fork at a certain block height? Today, Dabai will talk to you about the block height.

 01 
Blockchain and Accounting Book

As the name implies, the block height is the height of the block, which is precisely the number of blocks connected to the blockchain. Therefore, to understand what the block height is, we must first understand what a blockchain is. If the blockchain is a bookkeeping book, then a block is like every page of the bookkeeping book.

In the pages of the book, every account is clearly recorded. And in order not to be tampered with and to ensure openness and transparency, the blockchain accounting method is that everyone keeps the account together.

 02 
block height and accounting of the page

Since the blockchain is a small bookkeeping book, the accounts that can be recorded on each page (block) are limited, so in order to distinguish and find which block a transaction is recorded in, we can easily think of this The book indicates the page number. Therefore, if the blockchain is a small bookkeeping book, the block height is like the page number of the bookkeeping book.

So the question is coming. In the case of only one blockchain with the longest chain, assuming that the page number of the current ledger is 3, then how many areas is this block in this blockchain? Where's the block? Answer: The fourth block.

Some friends may wonder why it is not the third block? The reason is that there is also a block with a block height of 0 in the blockchain, which is the genesis block. Its page number is 0, so when it comes to a block with a page number of 3, it means that there are 3 blocks before it, which is also called the number of ancestors of the block. And it itself is the 4th block of this chain.

             

 03 
Block out and accounting page code generation

After understanding what the block height is, Dabai will continue to talk to you about how the block height is formed . In the blockchain of the mining mechanism, the page number of the small bookkeeping book of the blockchain is obtained by competition among miners. For example, the current block height is 3. When the lucky miner solves the calculation problem, he will get the bookkeeping rights of the book page with page number 4 (that is, the block with the block height of 4), and will get a certain amount Rewards.

At this time, this block will record the transactions packaged by the miner and confirmed. When this block has been formed, miners will continue to compete for a block with a block height of 4 to obtain a block with a block height of 5.

 04 
Forking and billing page code duplication

Dabai mentioned earlier that miners obtain the right to book the next block by solving the calculation problem. Then the problem comes. If the current block height is 2, when two lucky miners solve the calculation problem at the same time, then both Obtain the accounting right of the block with a block height of 3.

This is equivalent to saying that miner Xiaobai is holding a page with page number 3, and miner Xiaohei is holding a page with page number 3. Although Xiaobai and Xiaohei’s paper have the same page number, they have two records. The contents of the accounting records are not exactly the same.

But according to the rules, the two pages of Xiaobai and Xiaohei are fine, so which accounting paper should I choose? At this time, some mining unions chose Xiaobai’s page to be placed at the back of the accounting book, and continued to "seek" the accounting paper with page number 4. Some mining unions chose Xiaohei’s page to staple it. Continue to "seeking" the accounting paper with page number 4 on the accounting book.

This is equivalent to dividing the page with page number 2 into two bookkeeping books. In the blockchain, this behavior is called bifurcation. However, there is a "longest chain principle" in the blockchain, and miners will choose the longest chain as the main chain to continue mining. For example, after Xiaobai's chain, Xiaohong first digs to a block with a block height of 4, then Xiaohei's chain will be abandoned, and miners will choose to continue mining on Xiaobai's chain.

I mentioned earlier that the block height is used to identify which block a transaction belongs to. But now there are two blocks with the same height. How to identify them?

In fact, in the blockchain, the block hash is used to uniquely identify a block, not the block height. Because even if the block height is the same, the content recorded in the block is not exactly the same, so the hash of the block (obtained from the content of the block) must not be the same, so you can use the hash of the block to go Uniquely identifies a block.

In summary, the blockchain is like an accounting book, and the block is like a page of accounting paper in this accounting book. The height of the block is the page number of the accounting paper. When two identical pages appear at the same time Bifurcation occurs when the page number occurs.

Do you know what a block height is and how to identify two blocks with the same height? Welcome to share your views in the message area.

This article is reissued from an old one with slight adjustments

Link to the original text: Block height and accounting books

——End——

"Sound Description: This series is only for entry-block chain science learning, does not constitute any investment advice or recommendations. If there are any errors or omissions, please leave a message to point out.

Dear, it’s said that 99.9% of the tasteful people have ordered "Watching"????

Guess you like

Origin blog.csdn.net/mrRqAEr7ci9s2v0/article/details/110015817