The blockchain technology is also referred to as a distributed ledger technology. As a distributed Internet database technology, the blockchain technology is characterized by decentralization, transparency, non-tampering, and trustworthiness. A network constructed based on the blockchain technology can be referred to as a blockchain network. The blockchain network includes a network node (which can also be referred to as a blockchain node). Each network node corresponds to at least one blockchain, and each blockchain includes at least one block.
When receiving data to be stored, the network node broadcasts the data to be stored to other network nodes in the blockchain network. Therefore, each network node in the blockchain network stores full data of the blockchain network, and data stored on one network node is consistent with that stored on another node.
Data is generally stored in the blockchain network in two stages: In a first stage, the blockchain network receives data to be stored, and broadcasts the data all over the blockchain network. As such, each node in the blockchain network receives the data to be stored. In this case, each network node in the blockchain network writes the data to be stored in a cache. In a second stage, a network node in the blockchain network that obtains permission to store the data to be stored writes the data to be stored in a block when obtaining recording permission, and adds the block to an existing blockchain. It can be seen that the data is stored in the blockchain network by using an asynchronous writing policy.
However, in an actual service scenario, when service data is stored in a blockchain network by using an asynchronous writing policy, generally, a data processing queue is maintained in a first stage, and data to be stored is sequentially written into the data processing queue based on a timestamp of the data to be stored. As such, in a second stage, data to be stored in the data processing queue is written into a block based on a first in first out principle.
According to researches, in the previous method, there are following problems in storing data in the blockchain network: For services with relatively high service priorities, service data processing efficiency is relatively low, and consequently processing efficiency of these services is relatively low.