Blockchain data storage method, device, equipment and medium

By storing blockchain data in pieces and using sharded non-full nodes to store part of the data in the blockchain network, the problem of high maintenance costs and difficult to ensure stability in the blockchain network is solved, and maintenance costs are reduced and ensure safety effect.

CN112463889BActive Publication Date: 2024-11-08BEIJING ZHONGXIANG BIT TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011424777.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-08
Publication Date
2024-11-08
Estimated Expiration
2040-12-08

AI Technical Summary

Technical Problem

The maintenance cost of full nodes in blockchain networks is high and the stability and security are difficult to guarantee, mainly due to the problem of excessive data storage volume caused by the increase in the number of blocks.

Method used

By storing block data in pieces, storing part of the data using sharded non-full nodes, and determining the shard number set based on the block number, judging and storing unsynchronized shard data, reducing the number of full nodes and reducing maintenance costs. At the same time, ensure the security of the blockchain network.

Benefits of technology

It effectively reduces the number of full nodes in the blockchain network, reduces the maintenance cost of nodes, and ensures that there are enough complete block data in the blockchain network, ensuring network security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112463889B_ABST
    Figure CN112463889B_ABST
Patent Text Reader

Abstract

The present application discloses a blockchain data storage method, device, equipment and medium. The method includes: obtaining the current block number; determining the current shard number set corresponding to the current block number based on the current block number; judging whether there is at least one shard number of unsynchronized shard data in the current shard number set; if there is, storing the shard data corresponding to the current shard non-full node based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node. The problem of high maintenance cost of the full-node blockchain network is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application generally relates to the field of blockchain technology, and specifically to a blockchain data storage method, device, equipment and medium. Background Art

[0002] The blockchain network is a distributed data storage network with the characteristics of decentralization (i.e. not relying on a third party), immutability, full traceability, traceability, collective maintenance, and openness and transparency. It has been widely used in various fields of social life.

[0003] The blockchain network is composed of multiple nodes. When a new block is generated in the blockchain network, each node can use data synchronization technology to store the data corresponding to the new block in the blockchain ledger maintained by the node, thereby obtaining the complete ledger data of the blockchain network. This node that stores complete ledger data is called a full node.

[0004] Generally speaking, the more full nodes there are in a blockchain network, the more copies of the complete ledger data are saved, and the better the stability and security of the blockchain network. However, as the number of blocks in the blockchain network increases, the amount of data stored on the full nodes increases, making full node maintenance difficult and costly. Summary of the invention

[0005] In view of the above-mentioned defects or deficiencies in the prior art, it is desirable to provide a blockchain data storage method, apparatus, device and medium that can reduce the maintenance cost of the blockchain network and ensure the security of the blockchain network.

[0006] In a first aspect, the present application provides a blockchain data storage method, comprising:

[0007] Get the current block number;

[0008] Determine a current shard number set corresponding to the current block number based on the current block number, the current shard number set including at least one shard number corresponding to shard data, where the shard data is a portion of data elements in the block data;

[0009] Determine whether there is at least one shard number of unsynchronized shard data in the current shard number set;

[0010] If so, store the shard data corresponding to the current shard non-full node based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node;

[0011] In a second aspect, the present application provides a blockchain data storage device, comprising:

[0012] An acquisition module, configured to obtain the current block number;

[0013] A determination module is configured to determine a current shard number set corresponding to the current block number based on the current block number, the current shard number set including at least one shard number corresponding to shard data, the shard data being part of the data elements in the block data;

[0014] A determination module is configured to determine whether there is at least one shard number of unsynchronized shard data in the current shard number set;

[0015] The storage module is configured to store the shard data corresponding to the current shard non-full node based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node;

[0016] In a third aspect, the present application provides a computer device, the computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor being configured to implement the method of the first aspect when executing the program;

[0017] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, the computer program being used to implement the method of the first aspect.

[0018] The technical solution provided by the embodiments of the present application may have the following beneficial effects:

[0019] The blockchain data storage method, device, equipment and medium provided in the embodiment of the present application can obtain the current block number; determine the current shard number set corresponding to the current block number based on the current block number; determine whether there is at least one shard number of unsynchronized shard data in the current shard number set; if so, store the shard data corresponding to the current shard non-full node based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node. The number of full nodes in the blockchain network is reduced, the maintenance cost of the nodes is reduced, and at the same time, sufficient copies of complete block data are ensured in the blockchain network, thereby ensuring the security of the blockchain network. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0021] Figure 1 A schematic diagram of the structure of a blockchain network provided in an embodiment of the present application;

[0022] Figure 2 A flowchart of a blockchain data storage method provided in an embodiment of the present application;

[0023] Figure 3A flowchart of another blockchain data storage method provided in an embodiment of the present application;

[0024] Figure 4 A flowchart of another blockchain data storage method provided in an embodiment of the present application;

[0025] Figure 5 A schematic diagram of the structure of a blockchain data storage device provided in an embodiment of the present application;

[0026] Figure 6 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the invention are shown in the accompanying drawings.

[0028] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0029] Figure 1 is a schematic diagram of the structure of a blockchain network provided in an embodiment of the present application, such as Figure 1 As shown, the system includes multiple nodes, which can be divided into two types, full nodes 110 and non-full nodes 120. The full node 110 is used to store all data elements in the block data of the blockchain network, that is, the full node in the blockchain network can store the complete account data generated in the blockchain network, and the non-full node 120 is used to store some of the latest data elements in the block data of the blockchain network, that is, the non-full node in the blockchain network can store some of the account data generated in the blockchain network; wherein, the data element is the data of the block corresponding to any block number in the block data, and a wired network connection or a wireless network connection can be established between the full node 110 and the non-full node 120. It can be understood that the type of node in the system is determined based on the configuration information in the node configuration file, and the node can be a terminal device with data processing capabilities, such as a computer or a server.

[0030] Among them, the non-full node 120 can be a sharding non-full node and an ordinary non-full node. In the blockchain network, the ordinary non-full node can store part of the ledger data that the ordinary non-full node needs to maintain. The sharding non-full node can not only store part of the ledger data that the sharding non-full node needs to maintain, but also store at least one sharding data. The sharding data is a part of the data elements in the block data. The sharding data is stored in a sharding non-full node configured with a sharding number corresponding to the sharding data. The sharding number is a sharding identifier configured in the sharding non-full node for synchronizing the sharding data corresponding to the sharding number. At least one sharding non-full node in the blockchain network can jointly store at least one complete ledger data in the blockchain network. For example, Figure 1 As shown, the blockchain data storage system includes 4 nodes, among which node 1 is a full node and maintains a complete ledger data, and nodes 2, 3 and 4 are sharded non-full nodes, which can jointly maintain a complete ledger data.

[0031] In the blockchain network provided in the embodiment of the present application, when a new block is generated in the blockchain network, the full node in the blockchain network can synchronize the data elements corresponding to the current block (the new block) and update the complete ledger data maintained by the full node; the non-full node (including ordinary non-full nodes and sharded non-full nodes) can synchronize the data elements corresponding to the current block and update part of the ledger data maintained by the non-full node, wherein the amount of the latest data elements in the block data that can be stored by the non-full node can be determined based on actual needs, and the embodiment of the present application does not limit this, and after the non-full node obtains the data elements corresponding to the current block, it can discard the first stored data elements to ensure that the amount of data elements stored in the non-full node remains unchanged.

[0032] like Figure 1As shown, assuming that the block number of the latest generated block in the blockchain network is 30000, node 1 can synchronize the data elements corresponding to the block number 30000 to node 1 to update the complete ledger data in node 1, and node 2, node 3 and node 4 can synchronize the data elements corresponding to the block number 30000 to their respective nodes to update part of the ledger data in each node. Among them, node 1 acts as a full node, and in the updated complete ledger data corresponding to node 1, 30,000 data elements corresponding to block numbers 1 to 30,000 in the block data generated by the blockchain network are stored; node 2, node 3, and node 4 act as sharded non-full nodes. It is assumed that some of the latest data elements that the non-full nodes configured in the configuration information need to synchronize are: data elements corresponding to the latest 2,000 block numbers in the block data, then in the updated partial ledger data corresponding to node 2, node 3, and node 4, respectively, the 2,000 latest data elements in the block data are stored respectively, and the latest data elements are data elements corresponding to block numbers 28,001 to 30,000.

[0033] Further, since nodes 2, 3, and 4 are sharded non-full nodes, after each node updates part of the ledger data maintained by the sharded non-full node, and the entire blockchain network is in an idle state where no new data elements are generated in the block data, the current block number can be obtained; based on the current block number, the current shard number set corresponding to the current block number is determined; it is determined whether there is at least one shard number of unsynchronized shard data in the current shard number set; if so, based on the shard number of at least one unsynchronized shard data and the configuration information of the current sharded non-full node, the shard data corresponding to the current sharded non-full node is stored. Among them, the current block number is the latest block number in the block data that has been generated in the blockchain network, and the current shard number set includes at least one shard number of the shard data. It can be understood that by dividing the block data in the blockchain network into nodes and sharding storage, the number of full nodes in the blockchain network is reduced, the maintenance cost of the nodes is reduced, and the number of copies of complete block data in the blockchain network is guaranteed, and the security of the blockchain network is guaranteed. Moreover, the storage process of the shard data is carried out when the blockchain network is in an idle state, which will not affect the synchronous storage process of the ledger data in the blockchain network, and will not affect the normal generation and chaining of new blocks in the blockchain network.

[0034] The present application embodiment provides a blockchain data storage method, which is applied to Figure 1 In each shard non-full node in the blockchain network shown, the present application embodiment takes any shard non-full node as an example to illustrate the blockchain data storage method. Figure 2 As shown, the method includes:

[0035] Step 201, obtain the current block number.

[0036] In an embodiment of the present application, in a terminal device of a sharded non-full node, the configuration information in a configuration file may include at least three configuration items: a shard number, a shard storage directory, and a maximum shard storage space, wherein the shard storage directory represents the storage location identifier of the shard data corresponding to the shard number in the current node, and the maximum shard storage space represents the maximum value of the storage space allocated for storing shard data in the sharded non-full node.

[0037] In this step, when the current shard non-full node (any shard non-full node in the blockchain network) determines that the blockchain network is in an idle state, based on the marking result of the maximum shard storage space in its configuration information, it is determined whether the maximum shard storage space in the shard non-full node is full. If so, it is determined that the shard non-full node cannot store the shard data, and the synchronization process of the shard data is ended. If not, the current block number of the block data can be obtained to start the synchronization process of the shard data.

[0038] It can be understood that in the embodiment of the present application, after each shard non-full node stores shard data, it is necessary to determine whether the maximum shard storage space is full and mark the status of the maximum shard storage space to facilitate the subsequent shard storage to proceed smoothly.

[0039] Step 202: Determine a current shard number set corresponding to the current block number based on the current block number.

[0040] In this step, the current shard number set includes at least one shard number corresponding to the shard data. Figure 3 As shown, the process of determining the current shard number set corresponding to the current block number based on the current block number may include:

[0041] Step 2021: Determine the shard number corresponding to the current block number based on the first preset rule.

[0042] In this step, the process of determining the shard number corresponding to the current block number based on the first preset rule may include: determining a first parameter value, the first parameter value is the difference between the current block number and the standard value; determining a first ratio, the first ratio is the ratio between the first parameter value and the shard data volume; determining the integer part of the first ratio as the shard number corresponding to the current block number, wherein the shard data volume is the data volume of some data elements corresponding to the shard number in the block data. It can be understood that in the embodiment of the present application, the shard data volume can be determined based on actual needs, and the embodiment of the present application does not limit this, and the shard data volume can be configured in the configuration information of the shard non-full node, and the shard data volume in the configuration information of each shard non-full node in the blockchain network is consistent. For example, if the shard data volume is 10000, it means that in the blockchain network, each shard number can correspond to the data elements corresponding to 10000 block numbers in the storage block data.

[0043] It should be noted that in the embodiment of the present application, the integer part of the ratio can be determined based on the minimum shard number of all shard numbers contained in the configuration information of all shard non-full nodes in the blockchain network. For example, if the minimum shard number of all shard numbers is 0, the integer part of the first ratio can be rounded down to obtain the shard number corresponding to the current block number; if the minimum shard number of all shard numbers is 1, the integer part of the first ratio can be rounded up to obtain the shard number corresponding to the current block number. It can be understood that in the embodiment of the present application, each shard non-full node can synchronize at least one shard number in its own configuration information to other shard non-full nodes.

[0044] It should be further explained that in the embodiment of the present application, in the process of taking the integer part of the first ratio, negative numbers may appear, and there are no negative shard numbers in the shard numbers. At this time, it is determined that there is no shard number in the shard non-full node that has synchronized the shard data.

[0045] For example, the process of determining the shard number corresponding to the current block number can be implemented based on the following procedure:

[0046]

[0047] Among them, shardIndex indicates the shard number corresponding to the current block number, seq indicates the current block number, and ledgersPerShard indicates the amount of shard data. Indicates that the comparison value is rounded down.

[0048] Step 2022: Determine the maximum shard number in the current shard number set based on the shard number corresponding to the current block number.

[0049] In this step, the process of determining the maximum shard number in the current shard number set includes: determining a second parameter value, which is the sum of the shard number (shardIndex) corresponding to the current block number and the standard value; determining a third parameter value, which is the product of the second parameter value and the shard data volume (ledgersPerShard); judging whether the current block number is equal to the third parameter value; if not, determining the difference between the shard number corresponding to the current block number and the standard value as the maximum shard number (maxShardIndex); if equal, determining the shard number corresponding to the current block number as the maximum shard number. Wherein, the standard value is a value of 1.

[0050] For example, if ledgersPerShard=10000, in the configuration information of all sharded non-full nodes, the minimum shard number of at least one shard number is 0. Assuming seq=28001, it can be determined that shardIndex=2, (shardIndex+1)×ledgersPerShard=30000. Since seq≠30000, maxShardIndex=2-1=1; assuming seq=3000, based on the shardIndex determined in the above step 2021, (shardIndex+1)×ledgersPerShard=30000. Since seq=30000, maxShardIndex=2.

[0051] Step 2023: Determine the minimum shard number in the current shard number set.

[0052] In this step, the smallest shard number among all shard numbers in the configuration information of all shard non-full nodes may be determined as the smallest shard number in the current shard number set.

[0053] Step 2024: Determine the minimum shard number, the maximum shard number, and the shard numbers between the minimum shard number and the maximum shard number as the current shard number set.

[0054] For example, if ledgersPerShard=10000, the minimum shard number in the configuration information of all sharded non-full nodes is 0, assuming seq=28001, then the current shard number set determined based on the above steps 2021 to 2022 is [0, 1], assuming seq=3000, then the current shard number set determined based on the above steps 2021 to 2022 is [0, 1, 2].

[0055] Step 203: Determine whether there is at least one shard number of unsynchronized shard data in the current shard number set.

[0056] In an embodiment of the present application, during each shard data synchronization process, each shard non-full node needs to obtain and store the shard data corresponding to each shard number based on at least one shard number in the configuration information, and after synchronizing the shard data corresponding to the shard number, mark the shard number as a synchronized shard number, and synchronize the synchronized shard number to other shard non-full nodes.

[0057] In this step, based on at least one shard number included in the current shard number set and at least one synchronized shard number obtained, it can be determined whether at least one shard number in the current shard number set is consistent with at least one synchronized shard number. If not, it is determined that there is at least one shard number of unsynchronized shard data in the current shard number set, and the shard number of the at least one unsynchronized shard data is: the difference shard number between at least one shard number in the current shard number set and at least one synchronized shard number, and step 204 is executed; if consistent, it is determined that there is no at least one shard number of unsynchronized shard data in the current shard number set, and the shard data corresponding to each shard number in the current shard number set has been synchronized, and the shard data synchronization process is terminated, and the process returns to step 201. Among them, the synchronized shard number can be the shard number of the synchronized corresponding shard data sent by other shard non-full nodes received by the current shard non-full node, and / or the shard number of the synchronized corresponding shard data in the current shard non-full node marked in the current shard non-full node.

[0058] For example, if ledgersPerShard=10000, the minimum shard number in the configuration information of all shard non-full nodes is 0, assuming seq=28001, the current shard number set is determined to be [0,1], the synchronized shard numbers obtained are shard number 0 and shard 1, and at least one shard number in the current shard number set is shard number 0 and shard 1, then it can be determined that there is no shard number with unsynchronized shard data in the current shard number set; assuming seq=30000, the current shard number set is determined to be [0,2], the synchronized shard numbers obtained are shard number 0 and shard 1, and at least one shard number in the current shard number set is shard number 0, shard 1 and shard 2, then it can be determined that there is shard number 2 with unsynchronized shard data in the current shard number set.

[0059] It should be noted that in the embodiment of the present application, since the synchronization process of the ledger data needs to be performed first, there will be a situation where the shard data synchronization fails after a large number of new blocks are generated. Therefore, during the shard data synchronization process, the number of shard numbers with unsynchronized shard data in the determined current shard number set will be greater than 1. For example, if ledgersPerShard=10000, the minimum shard number in the configuration information of all shard non-full nodes is 0, assuming seq=40005, the determined current shard number set is [0,3]. Since the shard data synchronization process is not performed in the process of generating data elements corresponding to block numbers 20001 to 30000, the synchronized shard numbers that can be obtained are shard numbers 0 and shard 1, and it is determined that there are shard numbers 2 and shard numbers 3 with unsynchronized shard data in the current shard number set.

[0060] Step 204: If it exists, store the shard data corresponding to the current shard non-full node based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node.

[0061] In this step, if Figure 4 As shown, the process of storing the shard data corresponding to the current shard non-full node based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node may include:

[0062] Step 2041: Determine the shard number to be synchronized based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node.

[0063] In an embodiment of the present application, in the process of generating a configuration file for a sharded non-full node, for any sharded non-full node, only two configuration items, the sharded storage directory and the maximum sharded storage space, can be configured. At this time, the sharded non-full node can synchronize the sharded data corresponding to the shard number of any unsynchronized sharded data.

[0064] In this step, the process of determining the shard number to be synchronized based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node may be: judging whether the configuration information of the current shard non-full node contains at least one shard number; if not, determining any shard number of the shard number of at least one unsynchronized shard data as the shard number to be synchronized; if included, determining the intersection of the shard number of at least one unsynchronized shard data and at least one shard number in the configuration information as the shard number to be synchronized. If the intersection of the shard number of at least one unsynchronized shard data and at least one shard number in the configuration information is an empty set, it is proved that the shard non-full node does not need to perform shard data synchronization during the shard data synchronization process, and returns to step 201.

[0065] For example, assuming that the shard numbers configured in the configuration information of the current shard non-full node include: shard number 0, shard number 1 and shard number 2, and the determined shard number of the unsynchronized shard data is 2, then the three shard numbers in the configuration information and the shard number of the unsynchronized shard data are intersected to determine that the shard number to be synchronized is shard number 2; or, assuming that the shard numbers configured in the configuration information of the current shard non-full node include: shard number 0, shard number 2 and shard number 3, and the determined shard number of the unsynchronized shard data is 2 and the shard number of the unsynchronized shard data is 3, then the three shard numbers in the configuration information and the shard numbers of the two unsynchronized shard data are intersected to determine that the shard numbers to be synchronized are shard number 2 and shard number 3.

[0066] Step 2042: Determine the fragment data corresponding to the fragment number to be synchronized based on the second preset rule.

[0067] In this step, for each shard number to be synchronized, the process of determining the shard data corresponding to the shard number to be synchronized based on the second preset rule may include: determining a fourth parameter value, the fourth parameter value being the product of the shard number to be synchronized and the amount of shard data; determining that the sum of the fourth parameter value and the standard value is the minimum block number of the partial data elements corresponding to the shard number to be synchronized in the block data; determining a fifth parameter value, the fifth parameter value being the sum of the shard number to be synchronized and the standard value; determining that the product of the fifth parameter value and the amount of shard data is the maximum block number of the partial data elements corresponding to the shard number to be synchronized in the block data; determining that a plurality of data elements corresponding to the minimum block number, the maximum block number, and the block number between the minimum block number and the maximum block number in the block data are the shard data corresponding to the shard number to be synchronized. Wherein, the standard value is 1.

[0068] For example, the process of determining the shard data corresponding to the shard number to be synchronized can be implemented based on the following program:

[0069] [shardIndex*ledgersPerShard+1, (shardIndex+1)*ledgersPerShard]

[0070] Among them, shardIndex*ledgersPerShard+1 represents the minimum block number of some data elements corresponding to the shard number to be synchronized, and shardIndex+1)*ledgersPerShard represents the maximum block number of some data elements corresponding to the shard number to be synchronized. Then, the data elements corresponding to shardIndex*ledgersPerShard+1, the data elements corresponding to the maximum block number shardIndex+1)*ledgersPerShard, and each data element corresponding to the block number between the minimum block number and the maximum block number in the block data are determined to be the shard data corresponding to the shard number to be synchronized.

[0071] Step 2043: Obtain the shard data corresponding to the shard number to be synchronized.

[0072] In this step, the process of obtaining the shard data corresponding to the shard number to be synchronized may be: sending a shard data acquisition request to other nodes (full nodes and / or non-full nodes) in the blockchain network, wherein the shard data acquisition request includes the minimum block number and the maximum block number of some data elements corresponding to the shard number to be synchronized. For the full node, after receiving the shard data acquisition request, based on the minimum block number and the maximum block number, multiple data elements corresponding to the minimum block number, the maximum block number, and each block number between the minimum block number and the maximum block number can be obtained from the complete ledger data maintained by the full node, and the multiple data elements are packaged. The shard non-full node receives the shard data acquisition request. After receiving the shard data acquisition request, the shard non-full node can obtain, based on the minimum block number and the maximum block number, multiple data elements corresponding to the minimum block number, the maximum block number, and each block number between the minimum block number and the maximum block number from the partial ledger data maintained by the shard non-full node. If the partial ledger data does not include the multiple data elements, or the partial ledger data includes some of the multiple data elements, the partial data elements are obtained, and the search is continued from the shard data of the shard non-full node to obtain the remaining data elements of the multiple data elements.

[0073] It can be understood that in the embodiment of the present application, once the process of obtaining data elements in block data is involved, for a sharded non-full node, the data element can be first obtained from part of the ledger data maintained by the sharded non-full node. If the part of the ledger data does not contain the data element, or contains part of the data element, the remaining data elements can be searched from the shard data of the sharded non-full node, thereby improving the efficiency of obtaining data elements in block data.

[0074] Step 2044: store the shard data in the current shard non-full node.

[0075] In this step, the process of storing the shard data in the current shard non-full node can be: obtaining the shard storage directory in the configuration information of the current shard non-full node, calculating the data volume of at least one shard data already stored in the shard storage directory, and the sum of the data volumes of the shard data corresponding to the shard number to be synchronized. If the sum is greater than the maximum shard storage space, mark the maximum shard storage space as full; otherwise, store the shard data corresponding to the shard number to be synchronized in the shard storage directory, mark the shard number to be synchronized as synchronized, and broadcast the synchronized shard number to other shard non-full nodes.

[0076] It is understandable that in the blockchain network provided by the embodiment of the present application, the same shard number can be configured in the configuration information of different shard non-full nodes. When a shard non-full node cannot store the shard data corresponding to any shard number in the configuration information of the shard non-full node due to insufficient maximum shard storage space, the shard data corresponding to the shard number may be stored in other shard non-full nodes, which can ensure the integrity of the shard data and the number of copies of the complete account book data in the blockchain network. For example, the shard numbers configured in the configuration information of the shard non-full node A1 are shard number 0 and shard number 3, and the shard number configured in the configuration information of the shard non-full node A2 is shard number 3. Assuming that shard number 3 is determined to be the shard number to be synchronized, the shard non-full node A1 cannot store the shard data corresponding to the shard number 3 due to insufficient maximum shard storage space, but the shard data corresponding to the shard number 3 can be stored in the shard non-full node A2, ensuring the integrity of the shard data.

[0077] Optional, please continue to refer to Figure 1 , assuming that the block number of the latest generated block in the blockchain network is 30000, if new data elements continue to be generated in the block data of the blockchain network, the shard storage process for the new data elements can be: at the beginning of the establishment of the blockchain network, sufficient shard numbers and storage spaces are provided in the configuration information of the shard non-full node configuration file to meet the shard storage of more shard data, or, new shard non-full nodes are added to the blockchain network to perform shard storage on the data elements subsequently generated in the block data, or, the shard number configuration item in the configuration file of at least one shard non-full node in the existing blockchain network is modified to increase the shard number that can be used for shard storage of the data elements subsequently generated in the block data.

[0078] It can be understood that in an embodiment of the present application, if the configuration information in the configuration file of a non-full node of a shard is modified, after the terminal device of the non-full node of the shard is restarted, it is necessary to determine whether the synchronization process of the last shard data has not been completed. If not completed, continue to complete the synchronization process of the last shard data.

[0079] In summary, the blockchain data storage method provided by the embodiment of the present application can obtain the current block number; determine the current shard number set corresponding to the current block number based on the current block number; determine whether there is at least one shard number of unsynchronized shard data in the current shard number set; if so, store the shard data corresponding to the current shard non-full node based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node. The number of full nodes in the blockchain network is reduced, the maintenance cost of the nodes is reduced, and at the same time, sufficient copies of complete block data are ensured in the blockchain network, ensuring the security of the blockchain network.

[0080] The present application embodiment provides a blockchain data storage device, such as Figure 5 As shown, the device 30 includes:

[0081] The acquisition module 301 is configured to acquire the current block number;

[0082] The determination module 302 is configured to determine a current shard number set corresponding to the current block number based on the current block number, the current shard number set including at least one shard number corresponding to shard data, the shard data being part of the data elements in the block data;

[0083] The determination module 303 is configured to determine whether there is at least one shard number of unsynchronized shard data in the current shard number set;

[0084] The storage module 304 is configured to store the shard data corresponding to the current shard non-full node based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node, if any.

[0085] Optionally, the determination module 302 is configured to:

[0086] Determine a shard number corresponding to the current block number based on a first preset rule;

[0087] Determine the maximum shard number in the current shard number set based on the shard number corresponding to the current block number;

[0088] Determine the minimum shard number in the current shard number set;

[0089] Determine the minimum shard number, the maximum shard number, and the shard number between the minimum shard number and the maximum shard number as the current shard number set.

[0090] Optionally, the determination module 302 is configured to:

[0091] Determine a first parameter value, the first parameter value being a difference between a current block number and a standard value;

[0092] Determine a first ratio, where the first ratio is a ratio between the first parameter value and the shard data volume, where the shard data volume is a data volume of a portion of data elements corresponding to the shard number in the block data;

[0093] The integer part of the first ratio is determined to be a shard number corresponding to the current block number.

[0094] Optionally, the determination module 302 is configured to:

[0095] Determine a second parameter value, where the second parameter value is the sum of the shard number corresponding to the current block number and the standard value;

[0096] Determine a third parameter value, where the third parameter value is the product of the second parameter value and the amount of shard data;

[0097] Determine whether the current block number is equal to the third parameter value;

[0098] If not, determine the difference between the shard number corresponding to the current block number and the standard value as the maximum shard number;

[0099] If they are equal, determine that the shard number corresponding to the current block number is the maximum shard number.

[0100] Optionally, the storage module 304 is configured to:

[0101] Determine the shard number to be synchronized based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node;

[0102] Determine the shard data corresponding to the shard number to be synchronized based on the second preset rule;

[0103] Get the shard data corresponding to the shard number to be synchronized;

[0104] Store the shard data in the current shard's non-full node.

[0105] Optionally, the storage module 304 is configured to:

[0106] Determine whether the configuration information of the current shard non-full node contains at least one shard number;

[0107] If not included, determine any shard number among the shard numbers of at least one unsynchronized shard data as the shard number to be synchronized;

[0108] If included, determine that the intersection of the shard number of at least one unsynchronized shard data and at least one shard number in the configuration information is the shard number to be synchronized.

[0109] Optionally, the storage module 304 is configured to:

[0110] Determine a fourth parameter value, where the fourth parameter value is the product of the shard number to be synchronized and the shard data volume;

[0111] Determine that the sum of the fourth parameter value and the standard value is the minimum block number of the partial data elements corresponding to the shard number to be synchronized in the block data;

[0112] Determine a fifth parameter value, where the fifth parameter value is the sum of the shard number to be synchronized and the standard value;

[0113] Determine that the product of the fifth parameter value and the amount of shard data is the maximum block number of the partial data elements in the block data corresponding to the shard number to be synchronized;

[0114] Determine that a plurality of data elements in the block data corresponding to the minimum block number, the maximum block number, and the block number between the minimum block number and the maximum block number are the shard data corresponding to the shard number to be synchronized.

[0115] In summary, the blockchain data storage device provided by the embodiment of the present application can obtain the current block number; determine the current shard number set corresponding to the current block number based on the current block number; determine whether there is at least one shard number of unsynchronized shard data in the current shard number set; if so, store the shard data corresponding to the current shard non-full node based on the shard number of at least one unsynchronized shard data and the configuration information of the current shard non-full node. The number of full nodes in the blockchain network is reduced, the maintenance cost of the nodes is reduced, and at the same time, sufficient copies of complete block data are ensured in the blockchain network, ensuring the security of the blockchain network.

[0116] Figure 6 404. A computer device is shown according to an exemplary embodiment, which includes a central processing unit (CPU) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage part to a random access memory (RAM) 403. In RAM 403, various programs and data required for system operation are also stored. CPU 401, ROM 402 and RAM 403 are connected to each other through a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0117] The following components are connected to the I / O interface 405: an input section 406 including a keyboard, a mouse, etc.; an output section including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, a modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive is also connected to the I / O interface 405 as needed. A removable medium 411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 410 as needed, so that a computer program read therefrom is installed into the storage section 408 as needed.

[0118] In particular, according to the embodiments of the present application, the above Figures 2 to 4The described process can be implemented as a computer software program. For example, various embodiments of the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part, and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU) 401, the above-mentioned functions defined in the system of the present application are executed.

[0119] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0120] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the method, device and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0121] The units involved in the embodiments described in the present application may be implemented by software or by hardware, and the described units may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves. The described units or modules may also be set in a processor, for example, they may be described as: a processor includes an acquisition module, a determination module, a judgment module, and a storage module. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves, for example, the acquisition module may also be described as "an acquisition module for acquiring the current block number".

[0122] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the blockchain data storage method described in the above embodiment.

[0123] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the inventive concept. For example, the above features are replaced with (but not limited to) technical features with similar functions disclosed in the present application.

Claims

1. A blockchain data storage method, characterized in that: include: Obtaining a current block number of block data, wherein the block data includes a plurality of shard data; Determine a current shard number set corresponding to the current block number based on the current block number, the current shard number set including at least one shard number corresponding to shard data, the shard data being part of the data elements in the block data; Determine whether there is at least one shard number of unsynchronized shard data in the current shard number set; If so, store the shard data corresponding to the current shard non-full node based on the shard number of the at least one unsynchronized shard data and the configuration information of the current shard non-full node; The storing of the shard data corresponding to the current shard non-full node based on the shard number of the at least one unsynchronized shard data and the configuration information of the current shard non-full node includes: Determine the shard number to be synchronized based on the shard number of the at least one unsynchronized shard data and the configuration information of the current shard non-full node; Determine the shard data corresponding to the shard number to be synchronized based on a second preset rule; Obtain the shard data corresponding to the shard number to be synchronized; Storing the shard data in the current shard non-full node; The determining of the fragment data corresponding to the fragment number to be synchronized based on the second preset rule includes: Determine a fourth parameter value, where the fourth parameter value is the product of the shard number to be synchronized and the shard data volume; Determine that the sum of the fourth parameter value and the standard value is the minimum block number of the part of the data elements corresponding to the shard number to be synchronized in the block data; Determine a fifth parameter value, where the fifth parameter value is the sum of the shard number to be synchronized and a standard value; Determine that the product of the fifth parameter value and the amount of shard data is the maximum block number of the partial data elements in the block data corresponding to the shard number to be synchronized; Determine that a plurality of data elements in the block data corresponding to the minimum block number, the maximum block number, and the block number between the minimum block number and the maximum block number are the shard data corresponding to the shard number to be synchronized.

2. The method according to claim 1, characterized in that The determining, based on the current block number, a current shard number set corresponding to the current block number includes: Determine a shard number corresponding to the current block number based on a first preset rule; Determine the maximum shard number in the current shard number set based on the shard number corresponding to the current block number; Determine the minimum fragment number in the current fragment number set; Determine the minimum shard number, the maximum shard number, and shard numbers between the minimum shard number and the maximum shard number as a current shard number set.

3. The method according to claim 2, characterized in that The determining the shard number corresponding to the current block number based on the first preset rule includes: Determine a first parameter value, the first parameter value being a difference between the current block number and a standard value; Determine a first ratio, where the first ratio is a ratio between the first parameter value and a shard data amount, where the shard data amount is a data amount of a portion of data elements corresponding to a shard number in the block data; Determine the integer part of the first ratio as the shard number corresponding to the current block number.

4. The method according to claim 2, characterized in that: The determining the maximum shard number in the current shard number set based on the shard number corresponding to the current block number includes: Determine a second parameter value, where the second parameter value is the sum of the shard number corresponding to the current block number and a standard value; Determine a third parameter value, where the third parameter value is the product of the second parameter value and the amount of shard data; Determining whether the current block number is equal to the third parameter value; If not equal, determine that the difference between the shard number corresponding to the current block number and the standard value is the maximum shard number; If they are equal, determine that the shard number corresponding to the current block number is the maximum shard number.

5. The method according to claim 1, characterized in that The determining at least one shard number to be synchronized based on the shard number of the at least one unsynchronized shard data and the configuration information of the current shard non-full node includes: Determine whether the configuration information of the current shard non-full node contains at least one shard number; If not included, determining any shard number among the shard numbers of the at least one unsynchronized shard data as a shard number to be synchronized; If included, determine that the intersection of the shard number of the at least one unsynchronized shard data and the at least one shard number in the configuration information is the shard number to be synchronized.

6. A blockchain data storage device, characterized in that: include: An acquisition module, configured to obtain the current block number; A determination module is configured to determine a current shard number set corresponding to the current block number based on the current block number, wherein the current shard number set includes at least one shard number corresponding to shard data, and the shard data is a partial data element in the block data; A determination module is configured to determine whether there is at least one shard number of unsynchronized shard data in the current shard number set; The storage module is configured to store the shard data corresponding to the current shard non-full node based on the shard number of the at least one unsynchronized shard data and the configuration information of the current shard non-full node; The storage module is specifically configured to determine the shard number to be synchronized based on the shard number of the at least one unsynchronized shard data and the configuration information of the current shard non-full node; Determine the shard data corresponding to the shard number to be synchronized based on a second preset rule; Obtain the shard data corresponding to the shard number to be synchronized; Storing the shard data in the current shard non-full node; The storage module is further configured to determine a fourth parameter value, where the fourth parameter value is a product of the shard number to be synchronized and the shard data volume; Determine that the sum of the fourth parameter value and the standard value is the minimum block number of the partial data elements in the block data corresponding to the shard number to be synchronized; Determine a fifth parameter value, where the fifth parameter value is the sum of the shard number to be synchronized and a standard value; Determine that the product of the fifth parameter value and the amount of shard data is the maximum block number of the partial data elements in the block data corresponding to the shard number to be synchronized; Determine that a plurality of data elements in the block data corresponding to the minimum block number, the maximum block number, and the block number between the minimum block number and the maximum block number are the shard data corresponding to the shard number to be synchronized.

7. A computer device, characterized in that: The computer device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor is configured to implement the method according to any one of claims 1 to 5 when executing the program.

8. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is used to implement the method according to any one of claims 1 to 5.