为广大币圈朋友提供币圈基础入门专业知识!
当前位置首页 > 区块链知识> 正文

区块链怎么同步数据,区块链 数据同步

发布时间:2023-12-06-07:34:00 来源:网络 区块链知识 区块   数据

区块链怎么同步数据,区块链 数据同步


请查看相关英文文档

㈠ How does the blockchain transmit data?

The blockchain is a combination of data blocks that are connected sequentially in chronological order. A chained data structure and a cryptographically guaranteed distributed ledger that cannot be tampered with or forged. Broadly speaking, blockchain technology uses block chain data structures to verify and store data, uses distributed node consensus algorithms to generate and update data, uses cryptography to ensure the security of data transmission and access, and uses automated scripts to A new distributed infrastructure and computing paradigm that uses smart contracts composed of code to program and manipulate data.

㈡ Why do the rise and fall of many digital currencies basically synchronize? What is going on?

From the stock market, it is very obvious that listed companies Different sectors have different profit and cost logic, and their performance will generally be different when dealing with the same good news and bad news. This is that diversification eliminates the simultaneous rise and fall. The companies in the U.S. stock market are more diversified and are not so affected by national policies, while most A-shares are exposed to the same policy effects, so A-shares will perform more in line with their rise and fall. The more diversified the investors participating in the stock market, the weaker the phenomenon of simultaneous rise and fall will be. Like A-shares, investors exhibit the same speculative behavior, selling high and buying low. Therefore, A shares appear to rise and fall together.

In the price differences of transactions on various platforms, there is a "brick" phenomenon. Hedging arbitrage, also called "currency hedging arbitrage", is actually an investment method that makes profit by obtaining the price difference between service platforms. Sometimes, the price of the same currency traded on different platforms is different, so there is a price difference between the two, which is usually very large. Decentralized platform transactions have different user numbers, scales, and market-making teams, which leads to differences in transaction liquidity on different platforms, thereby affecting the price of Bitcoin. In extreme market conditions, the difference in the trading load of platforms with different depths and the volume of assets on the market is particularly obvious.

㈢ Analysis of the relationship between distributed and blockchain

We have talked about the discussion of blockchain technology many times in previous articles, and also I have introduced to you which programming development languages ​​are used to realize the realization of the blockchain insight chain technology. Today we will learn together how to analyze and understand the structure of the blockchain from a distributed perspective.

Blockchain is the underlying technology in Bitcoin and is used to implement a centerless peer-to-peer cash system. Because there is no central organization involved, Bitcoin uses blocks Organize transaction data in the form of a chain to prevent "double spending" and reach transaction consensus.

Digital assets in the traditional sense, such as game currency, are managed in a centralized manner and can only be transferred in a single system, coordinated by a centralized organization. , usually stored in a database. From a macro perspective, blockchain and databaseThey are all used to save data, but the form of data access is different.

The blockchain is essentially a distributed database that is active in different places. The idea of ​​multi-activity in different places was originally to solve the disaster recovery problem of the system. It has been a direction explored in the field of distributed databases for many years, but with little success because multi-activity in different places needs to solve the problem of data conflicts. This problem is actually Not easy to solve. However, the blockchain born in Bitcoin has realized the world's largest remote multi-active database in a completely new way. It is completely open, has no boundaries, supports tens of thousands of nodes and can join and exit at random.

The problem of data conflicts is even more prominent in the blockchain. Each node in the blockchain is a completely peer-to-peer multi-active architecture, and tens of thousands of nodes must reach an agreement. , who should the data be based on? The method used by Bitcoin is POW. Everyone calculates a puzzle. Whoever calculates it first will have the right to keep accounts. In this cycle, the account he keeps shall prevail in the next cycle. Everyone recalculates. Nodes competing for accounting rights decide which Quanlu transactions are packaged into blocks and synchronize the blocks to other nodes. Other nodes still need to verify the transactions in the block based on local data, unlike the master-slave nodes of the database. This is the consensus algorithm in the blockchain. Although POW consumes a lot of computing power, the advantage is that in the process of competing for accounting rights, POW only needs to calculate hashes in its own nodes and does not need to go through network voting for election. The cost of network communication is small, and it is suitable for consensus among large-scale nodes. Shahe Computer Training believes that POW is a complete, simple and crude method in the current public chain and can stand the test, but the problem is that the efficiency is too low.

So PoS and DPoS were developed later. Whoever has more assets will have the right to bookkeeping, or everyone will vote, but this also introduces economic problems. For example, the so-called vote-buying issue is difficult to control. In traditional distributed databases, it is not called a consensus algorithm, but a consistency algorithm, which is essentially the same thing. However, the number of nodes in a distributed database is generally very small, and the network is trustworthy. Usually the nodes are safe and reliable. We can basically trust every node. Even if it fails and does not respond, it will never respond. False response. Therefore, in traditional company distributed data, Raft or Paxos protocols are used to implement this consistency algorithm.

㈣ Tutorials for getting started with blockchain


However, there are very few simple and easy-to-understand introductory articles. What exactly blockchain is and what makes it special is rarely explained.
Next, I will try to write a best-understood blockchain tutorial. After all, it is not difficult. The core concept is very simple and can be explained clearly in a few sentences. I hope that after reading this article, you will not only understand the blockchain, but also understand what mining is, why mining is getting more and more difficult, and other issues.
It should be noted that I am not an expert in this area. Although I have been paying attention to it for a long time, I have carefully understood the blockchain, or starting from the beginning of this year. You are welcome to correct any errors or inaccuracies in the article.
1. The essence of blockchain
What is blockchain? In a word, it is a special distributed database.
First of all, the main function of blockchain is to store information. Any information that needs to be saved can be written to the blockchain and read from it, so it is a database.
Secondly, anyone can set up a server, join the blockchain network, and become a node. In the world of blockchain, there is no central node. Every node is equal and stores the entire database. You can write/read data to any node, because all nodes will eventually be synchronized to ensure that the blockchain is consistent.
2. The biggest features of blockchain
Distributed databases are not a new invention, and there have been such products on the market for a long time. However, blockchain has a revolutionary feature.
Blockchain has no administrator, it is completely centerless. Other databases have administrators, but blockchain does not. If one wanted to add auditing to the blockchain, it would not be possible because it is designed to prevent the emergence of a central authority.
It is precisely because it is unmanageable that blockchain can be uncontrollable. Otherwise, once big companies and large groups control the management, they will control the entire platform, and other users will have to take orders from them.
However, without an administrator, everyone can write data into it. How can we ensure that the data is trustworthy? What if it is modified by a bad person? Please read on, this is the wonderful thing about blockchain place.
3. Block
Blockchain is composed of blocks. Blocks are much like database records. Every time data is written, a block is created.
Each block contains two parts.
Head: records the characteristic values ​​of the current block
Body: actual data
The block header contains multiple characteristic values ​​of the current block.
Generation time
Hash of the actual data (i.e. block body)
Hash of the previous block
...
Here, you need to understand what a hash is , which is necessary to understand blockchain.
The so-called hashing means that the computer can calculate a characteristic value of the same length for any content. The hash length of the blockchain is 256 bits, which means that no matter what the original content is, a 256-bit binary number will be calculated in the end. And it can be guaranteed that as long as the original content is different, the corresponding hash must be different.
For example, the hash of the string 123 is (hexadecimal), which is 256 bits when converted to binary, and only 123 can get this hash. (Theoretically, it is possible for other strings to get this hash, but the probability is extremely low and can be approximated as impossible.)
Therefore, there are two important inferences.
Corollary 1: The hash of each block is different, and the block can be identified by the hash.
Inference2: If the content of the block changes, its hash will definitely change.
4. The non-modifiable nature of Hash
Blocks and hashes have a one-to-one correspondence, and the hash of each block is calculated based on the block header (Head). That is to say, the characteristic values ​​​​of the block header are connected together in order to form a very long string, and then the hash is calculated on this string.
Hash = SHA256 (block header)
The above is the calculation formula of block hash. SHA256 is the hash algorithm of the blockchain. Note that this formula only contains the block header and not the block body. In other words, the hash is uniquely determined by the block header.
As mentioned before, the block header contains a lot of content, including the hash of the current block body. , and the hash of the previous block. This means that if the content of the current block body changes, or the hash of the previous block changes, it will definitely cause the hash of the current block to change.
This point has great significance for blockchain. If someone modifies a block, the hash of the block changes. In order for subsequent blocks to still be connected to it (because the next block contains the hash of the previous block), the person must modify all subsequent blocks in sequence, otherwise the modified block will be removed from the blockchain . Due to the reasons mentioned later, hash calculation is very time-consuming, and it is almost impossible to modify multiple blocks in a short period of time, unless someone controls more than 51% of the computing power of the entire network.
It is through this linkage mechanism that the blockchain ensures its own reliability. Once the data is written, it cannot be tampered with. This is just like history, what happened happened, and it can’t be changed from now on.
Each block is connected to the previous block, which is where the name blockchain comes from.
5. Mining
Since synchronization between nodes must be ensured, the adding speed of new blocks cannot be too fast. Just imagine, you have just synchronized a block and are preparing to generate the next block based on it, but at this time, another node generates a new block, and you have to give up half of the calculations and synchronize again. Because each block can only be followed by one block, you can only generate the next block after the latest block. So, you have no choice but to sync as soon as you hear the signal.
So, the inventor of the blockchain, Satoshi Nakamoto (this is a pseudonym, and his true identity is still unknown) deliberately made it difficult to add new blocks. His design is that on average, the entire network can generate a new block every 10 minutes, which is only six per hour.
This output speed is not achieved through commands, but by deliberately setting up massive calculations. In other words, only through an extremely large amount of calculations can the effective hash of the current block be obtained and the new block added to the blockchain. Because the amount of calculation is too large, it cannot be done quickly.
This process is called mining, because the difficulty of calculating a valid hash is like finding a grain of sand that meets the conditions among the sand in the world. The machine that calculates hashes is called a mining machine, and the person who operates the mining machine is calledBe a miner.
6. Difficulty coefficient
After reading this, you may have a question. People say that mining is difficult, but isn’t mining just about using a computer to calculate a hash? This is the strength of computers. How could it be? It becomes very difficult, why can’t it be calculated?
It turns out that not just any hash can be used, only hashes that meet the conditions will be accepted by the blockchain. This condition is particularly harsh, causing most hashes to fail to meet the requirements and must be recalculated.
It turns out that the block header contains a difficulty coefficient (difficulty), which determines the difficulty of calculating the hash. For example, the difficulty coefficient of the 100,000th block is 14484.16236122.
The blockchain protocol stipulates that the target value (target) can be obtained by dividing the difficulty coefficient by a constant. Obviously, the greater the difficulty coefficient, the smaller the target value.
The validity of the hash is closely related to the target value. Only hashes smaller than the target value are valid, otherwise the hash is invalid and must be recalculated. Since the target value is very small, the chance that the hash is smaller than this value is extremely slim, and it may be calculated 1 billion times before it is considered a hit. This is the fundamental reason why mining is so slow.
As mentioned earlier, the hash of the current block is uniquely determined by the block header. If the hash of the same block needs to be calculated repeatedly, it means that the block header must keep changing, otherwise it is impossible to calculate different hashes. All feature values ​​in the block header are fixed. In order to make the block header change, Satoshi Nakamoto deliberately added a random item called Nonce.
Nonce is a random value. The role of the miner is actually to guess the value of Nonce so that the hash of the block header can be smaller than the target value so that it can be written to the blockchain. Nonce is very difficult to guess. At present, we can only use trial and error one by one through exhaustive methods. According to the protocol, Nonce is a 32-bit binary value, which can reach a maximum of 2.147 billion. The Nonce value of the 100,000th block is 274148111. It can be understood that the miner started from 0 and calculated 274 million times before obtaining a valid Nonce value so that the calculated hash can meet the conditions.
If you are lucky, you may find Nonce in a while. If you are unlucky, you may have calculated it 2.147 billion times without finding the Nonce, that is, it is impossible to calculate a hash that meets the conditions for the current block body. At this time, the protocol allows miners to change the block body and start a new calculation.
7. Dynamic adjustment of difficulty coefficient
As mentioned in the previous section, mining is random, and there is no guarantee that a block will be produced in exactly ten minutes. Sometimes it can be calculated in one minute, and sometimes it may take several hours. No result. Overall, with the improvement of hardware equipment and the increase in the number of mining machines, the computing speed will definitely become faster and faster.
In order to keep the output rate constant at ten minutes, Satoshi Nakamoto also designed a dynamic adjustment mechanism for the difficulty coefficient. He stipulates that the difficulty level will increase every two weeks (2016 blocks) adjust once. If the average block generation speed in these two weeks is 9 minutes, it means that it is 10% faster than the legal speed, so the next difficulty factor will be increased by 10%; if the average block generation speed is 11 minutes, it means It is 10% slower than the legal speed, so the difficulty factor of the next step must be lowered by 10%.
The difficulty coefficient is adjusted higher and higher (the target value is getting smaller and smaller), which makes mining more and more difficult.
8. Forks of the blockchain
Even if the blockchain is reliable, there is still an unresolved problem: if two people write data to the blockchain at the same time, that is to say, two people write data to the blockchain at the same time. Blocks join because they are connected to the previous block, forming a fork. Which block should be adopted at this time?
The current rule is that new nodes always adopt the longest blockchain. If there is a fork in the blockchain, it will look at which branch is behind the fork to reach 6 new blocks first (called six confirmations). Based on a block calculation of 10 minutes, it can be confirmed in one hour.
Since the generation speed of new blocks is determined by computing power, this rule means that the branch with the most computing power is the authentic blockchain.
9. Summary
Blockchain, as an unmanaged distributed database, has been running for 8 years since 2009 without major problems. This proves it works.
However, in order to ensure the reliability of data, blockchain also has its own price. The first is efficiency. You have to wait at least ten minutes to write data to the blockchain. All nodes synchronize the data, which requires more time. The second is energy consumption. The generation of blocks requires miners to perform countless meaningless calculations. This is Very energy consuming.
Therefore, the applicable scenarios of blockchain are actually very limited.
There is no management authority that all members trust
The written data does not require real-time use
The benefits of mining can make up for its own costs
If the above conditions cannot be met, then the traditional database is Better solution.
Currently, the largest application scenario (and possibly the only application scenario) of blockchain is the cryptocurrency represented by Bitcoin.

5 Blockchain synchronizes all users’ data to all users’ computers, right or wrong

True.
In layman's terms, Internet data can travel tens of thousands of kilometers and reach the computer users who need it. This is mainly because the Internet world has formed a unified information dissemination mechanism, so it is correct.
Blockchain is a chain composed of blocks one after another. Each block stores a certain amount of information, and they are connected into a chain in the order in which they were generated. This chain is saved in all servers. As long as one server in the entire system can work, the entire blockchain is safe.

博客主人唯心底涂
男,单身,无聊上班族,闲着没事喜欢研究股票,无时无刻分享股票入门基础知识,资深技术宅。
  • 36692 文章总数
  • 3637265访问次数
  • 3078建站天数