This question is sorted out as follows:
Assuming the latest block height is 10,000, it is dug out at 10:00, the miner quickly builds a block with a height of 10,000, and then at 10:05, Dabai released a deal at 10:06. The latest block was dug up, and the package was released to release the deal. Why? It stands to reason that when the new deal was released, the miners had already built up the candidate block, and the deal was definitely not in the candidate block that he originally built.
- Data behind the seven major production-reducing coins: the average price of coins rose by 143%, and the mining revenue rose by an average of 77%
- Getting started with blockchain | Block heights and bookkeeping
- Defects of the heaviest chain rule: "The Crown Prince" in the "Public Ancestral Blocks"
- Spam attack? Bitcoin average block size suddenly soared to more than 3MB
Today we will try to answer this question.
Mining is constantly trying random numbers
In the article "A classic story, let you understand Bitcoin mining in 3 minutes," the vernacular blockchain has been introduced. The process of mining is to continuously try random numbers and try to find a solution that meets the requirements. After constructing the block, the miner constantly tries random numbers until someone finds a random number that meets the requirements (the hash value of the block head ≤ target value), the new block is dug out, and the miner gets a block reward.
02 limited random number
The random numbers that can be tried in the Bitcoin system are limited, with only 2^32 possible values. After the miners build the block, iterate through all the random numbers and it is likely that the solution is still not met. In this case, what should the miners do? The hash function is characterized by a change in the input value: it can be to change the order, increase the content, reduce the content, etc., and the result of the output value will vary from day to day. So in this case, the miner can rebuild the block, for example, the other content is unchanged, package a just-released transaction into the block, and then try the random number. In this case, if you just find a solution that meets the requirements, new The block was dug up and the new deal was confirmed. This also answers the question we started with.
03 Other adjustment methods for miners
In the case that after traversing all the random numbers, the solution that meets the requirements is still not found, what other adjustment schemes does the miner have in addition to adjusting the transactions packaged in the block?
We know that the condition for dig out a new block is: the hash value of the block header ≤ difficulty target.
The block header content contains:
Excluding the random number field, the version field in the block header, the parent block header hash value, and the difficulty target are all determined and cannot be adjusted, and the range of the timestamp field is very limited. In this way, the Merkel root field is left in the part that is easy to adjust. The block header does not contain the transaction data of the block, but the hash value of the transaction information is taken, and then the hash value of the transaction is merged and then the hash value is taken until the final form a field, this field is formed. It is the Merkel root field, which will be stored in the block header.
▲Image from the network: Merkel tree
So when there is no suitable solution for traversing all the random numbers, the miner can adjust the transactions in the block: including the order of the transactions, increasing the packaged transactions, reducing the packaged transactions, etc. These adjustments will eventually result in the block header. The Merkel root has a hash value that affects the hash of the entire block header. But such processing is an auxiliary way, and miners are more common in modifying the extra random number of a particular transaction (Extra Nonce), which is relatively more efficient.
This special transaction is a coin-operated transaction in which bitcoin is awarded. The transaction was created "out of thin air" by the system, so the transaction is uninputted, meaning that its input field (input field) is empty by default. The miner can modify this field to find a solution that meets the requirements. The coin trading input field provides 8 bytes of space for additional random numbers. In other words, this expands the random number from the original 2^32 possibilities to 2^96 possibilities, and the miner traverses 2^96 species. Possibilities, generally can find solutions that meet the requirements.
It is also worth mentioning that the input field of this special transaction is still a "window" of many people's information, such as the "hand of the sacred fish , and the old man. The mermaid to winter and winter" is written in the coin transaction. In the input field.
If you are a miner and want to enter the domain "Show Love" in the coin trading, you should write the message "Xiu Enai" before the block is dug out, or wait until the block is dug out and then write it? why? Welcome to write your opinion in the message area.
Author | Yan Wenchun 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. 』