Getting started with blockchain | Block heights and bookkeeping

In many articles about blockchains, it is often seen that blockchains are bifurcated at a certain block height. So what is the block height, and why is there a fork at a certain block height? Today, Dabai will talk to you about the height of the block.

01 blockchain and bookkeeping

Block height, as the name suggests, is the height of the block, specifically the number of blocks connected to the blockchain. So to understand what is the block height, we have to first understand what a blockchain is. If the blockchain is a book, then a block is like every page of the book.

In the one page of the book, each account is clearly recorded. And in order for the transaction not to be tampered with and to ensure openness and transparency, the way the blockchain is booked is for everyone to keep accounts.

02 block height and billing page code

Since the blockchain is a small book, the amount of records that can be recorded on each page (block) is limited, so in order to distinguish and find out which block a transaction is recorded in, we can easily think of this. This sub is marked with the page number. Therefore, if the blockchain is a small booklet, the block height is like the page number of the book.

So the big white question comes. In the case of only one longest chain blockchain, assuming that the page number of the current bookkeeping page is 3, then this block is the number of blocks in the blockchain. Block? Answer: The 4th block.

Some small partners will 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 creation 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 in front of it, also called the number of ancestors of the block. And it is the 4th block of the chain itself.

03 block and book this page code generation

After figuring out 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 block book is the competition of the miners. For example, the current block height is 3. When the lucky miner solves the calculation problem, he will get the bookkeeping right of the page book with page number 4 (that is, the block with block height of 4), and will get a certain Reward.

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

04 fork and billing page repeat

Dabai said earlier that the miners can solve the computational problems to get the billing rights of the next block. Then the problem comes. If the current block height is 2, when two lucky miners solve the computational problems at the same time, then they will all Obtain the accounting rights for the block with a block height of 3.

This is equivalent to saying that the miner Xiaobai holds a page with a page number of 3, and the miner Xiaohe also holds a page with a page number of three, although the page numbers of the small white and the small black paper are the same, but the two records The contents of the paper record are not exactly the same.

However, according to the rules, the two pages of Xiaobai and Xiaohei are no problem. So which one is selected? At this time, some miners chose Xiaobai's sheet of paper to be placed behind the bookkeeping, and went on to “seek” the page of the page with the number 4, while some miners chose the black sheet of paper. Continue to “seek” the page book paper with page number 4 on the book.

This is equivalent to dividing the two bills in the page with the page number 2. In the blockchain, this behavior is called a fork. However, there is a “longest chain principle” in the blockchain, and the miners will choose the longest chain as the main chain to continue mining. For example, after the chain of Xiaobai, Xiaohong first dig into the block with a block height of 4, then the chain of Xiaohei will be abandoned, and the miners will choose to continue mining in the chain of Xiaobai.

In front of it, it is said that the block height is used to identify which block a transaction belongs to. But now there are two blocks with the same height in the block. How do you identify them?

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

In summary, the blockchain is like a bookkeeping, and the block is like a page of billing paper in the book, the block height is the page number of the book paper, when two identical pages appear at the same time. A fork occurs when the page number is reached.

Do you know what the block height is and how to identify the blocks with the same height? Feel free to share your opinion in the message area.


Author | Yuxing produced | vernacular blockchain (ID: hellobtc)

『Declaration : This series of content is only for the introduction of blockchain science, and does not constitute any investment advice or advice. If there are any errors or omissions, please leave a message. You are not allowed to reprint this article by any third party without the authorization of the "Baihua Blockchain" sourced from this article.