Home > web3.0 > What is block height?

What is block height?

DDD
Release: 2024-03-06 13:31:43
forward
565 people have browsed it

In many articles about blockchain, we often see that the blockchain forks at a certain block height.

So what exactly is a block height, and why does a fork occur at a certain block height? Today Dabai will talk to you about block height.

01. Blockchain and ledger

What is block height?

The block height is as the name suggests. The height of a block, to be precise, is the number of blocks attached to the blockchain. Therefore, if we want to understand what block height is, we must first understand what blockchain is. If the blockchain is a ledger, then a block is like each page of the ledger.

Every account is clearly recorded in the pages of the accounting book. And in order to prevent transactions from being tampered with and ensure openness and transparency, the blockchain accounting method is that everyone keeps accounts together.

02. Block height and accounting book page number

Since the blockchain is a small accounting book, then each page (block) can record the number of accounts It is limited, so in order to distinguish and find which block a transaction is recorded in, we can easily think of marking the page number in this book. Therefore, if the blockchain is a small accounting book, the block height is like the page number of this accounting book.

Here comes the simple thinking question. In the case of a blockchain with only one longest chain, assuming that the page number of this page of the current ledger is 3, then this block is this block How many blocks in the chain is it? Answer: Block 4.

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

03. Block generation and ledger page number generation

Understanding what a block is After the height, Dabai will continue to talk to everyone about how the block height is formed. In the blockchain with the mining mechanism, the page numbers of the small bookkeeping booklet of the blockchain are obtained by miners through competition. For example, the current block height is 3. When a lucky miner solves the calculation problem, he will get the accounting rights of the page of the ledger with page number 4 (that is, the block with a block height of 4), and will receive a certain amount of rewards. At this time, this block will record the transactions that have been packaged and confirmed by the miner. When this block has been formed, miners will continue to compete on the block with block height 4 to get the block with block height 5.

04. Duplication of bifurcation and ledger page numbers

What is block height?Dabai mentioned earlier , miners obtain the accounting rights of the next block by solving calculation problems. Then the question arises. If the current block height is 2, when two lucky miners solve the calculation problems at the same time, they will both obtain the block height. The accounting right of the block is 3.

This is equivalent to saying that miner Xiaobai is holding a page with page number 3, and miner Xiaohei is also holding a page with page number 3, although the page numbers of Xiaobai and Xiaohei's paper are The same, but the contents recorded on the two accounting papers are not exactly the same.

But according to the rules, there is no problem with the two pages of Xiaobai and Xiaohei, so which accounting paper should I choose? At this time, some miners will choose Xiaobai's page to be stapled at the back of the accounting book and continue to "seek" the page of accounting paper with page number 4, while some miners will choose Xiaohei's page to be stapled to the back of the accounting book. Continue to "search" for the accounting paper with page number 4 in the accounting book.

This is equivalent to dividing the page with page number 2 into two accounting books. In blockchain, this behavior is called forking. But there is a "longest chain principle" in the blockchain. Miners will choose the longest chain as the main chain to continue mining. For example, after Xiaobai's chain, Xiaohong first mines 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 chaindig.

Dabai mentioned earlier that block height is used to identify which block a certain transaction belongs to. But now there are two blocks with the same height, so 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 height of the block is the same, the content recorded in the block is not exactly the same. Therefore, the hash of the block (obtained from the content of the block) must not be the same, so the hash of the block can be used to Uniquely identifies a block.

In summary, the blockchain is like a ledger, and the blocks are like pages of accounting paper in the ledger. The height of the block is the page number of the accounting paper. A fork occurs when two identical page numbers appear at the same time.

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

The above is the detailed content of What is block height?. For more information, please follow other related articles on the PHP Chinese website!

source:zhihu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template