A method and device for segmented storage and consensus based on blockchain
By creating two segmented networks in the blockchain system and using network-wide consensus and preparatory algorithms to divide nodes, segmented storage and synchronization of blockchain data is achieved, solving the storage pressure and problems caused by the increase in the amount of blockchain data. Resource consumption issues ensure data integrity and decentralization.
Patent Information
- Application Number
- CN202110757938.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-05
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2041-07-05
AI Technical Summary
The growth of blockchain data volume has led to node storage pressure and excessive storage resource consumption, which may lead to network centralization and difficulty in joining new nodes.
Create two segmented networks in the blockchain system, one as a storage segmented network and the other as a backup segmented network. The nodes are divided through network-wide consensus and preparation algorithms to achieve segmented storage and synchronization of data, and periodic reloading. Set up segmented networks to manage data volumes.
Through segmented storage and consensus mechanisms, the integrity of blockchain data and decentralized distributed storage are ensured, avoiding storage pressure and resource consumption caused by the increase in data volume, and maintaining the decentralized characteristics of the network.
Smart Images

Figure CN113487432B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a method and device for segmented storage and consensus based on blockchain. Background Art
[0002] The blockchain system adopts a distributed data storage mode, and each node has a ledger data. As time goes by, there will be more and more transactions on the blockchain, which will cause the data capacity of the blockchain to continue to increase. Due to the redundant backup of the blockchain, synchronizing a large amount of data is a very time-consuming task and wastes related hard disk resources.
[0003] As the amount of data increases, the burden on each witness node will also increase, and the cost of synchronizing the entire node data will become increasingly expensive. This means that fewer people may have the ability to become witness nodes in the future. This may hinder the addition of new nodes and will lead to the concentration of most of the network in the hands of a few mining groups.
[0004] In reality, the issue of data storage is also a technical barrier for blockchain. The blockchain database records every transaction that has occurred since its creation, so every node that wants to participate must download, store, and update in real time a data packet from the genesis block to the present. If the data of each node is completely synchronized, the hardware requirements related to the storage space capacity of blockchain data may become a key issue restricting its development.
[0005] As the size of the blockchain increases, the storage, bandwidth, and computing power required by full nodes in the network will also increase. At a certain point, only a few nodes can provide the resources to process blocks - which brings centralization risks.
[0006] Therefore, it is necessary to provide a new method and device for segmented storage and consensus based on blockchain to solve the above technical problems. Summary of the invention
[0007] The main purpose of the present invention is to provide a method of segmented storage and consensus based on blockchain, aiming to solve the technical problems of related technologies, such as node storage pressure and huge consumption of storage resources caused by the rapid growth of on-chain data.
[0008] To achieve the above purpose, the present invention provides a block chain-based segmented storage and consensus method, comprising the following steps:
[0009] S10, initially creating two segmented networks in the blockchain system;
[0010] S20, setting one of the segmented networks as a storage segmented network, and setting another of the segmented networks as a standby segmented network;
[0011] S30, when the storage segment network is storing, the whole network consensus is carried out, and a proposal is made to divide the standby segment network into two segment networks according to the preparation algorithm; wherein, after the block data is stored on a node of the storage segment network, the node broadcasts and reaches consensus in the storage segment network to achieve data synchronization between the nodes in the storage segment network;
[0012] S40, when the block height of the storage segment network reaches the segment range, enter the step S20 again to reset the storage segment network.
[0013] Preferably, the step S30 specifically includes:
[0014] S31, when the storage segment network performs storage, a consensus is performed across the entire network;
[0015] S32, making a proposal to divide the standby segmented network into two segmented networks according to the preparation algorithm.
[0016] Preferably, the step S32 specifically includes:
[0017] S321, setting the number of nodes in each segment network according to a preset formula;
[0018] S322, dividing each of the nodes into different segmented networks according to a performance balancing algorithm;
[0019] S323, obtaining the storage capacity of the node with the smallest storage capacity in the segmented network, and setting the corresponding data capacity of the segmented network according to the storage capacity.
[0020] Preferably, the step S32 further includes:
[0021] S324, determining the corresponding number of blocks according to the block height of each segmented network.
[0022] In order to solve the above technical problems, the present invention also provides a device for segmented storage and consensus based on blockchain, comprising:
[0023] An initial module, wherein the initial module is used to initially create two segment networks in the blockchain system;
[0024] A setting module, the setting module is used to set one of the segmented networks as a storage segmented network and another of the segmented networks as a standby segmented network;
[0025] A preparation module, wherein the preparation module is used to, when the storage segment network is storing, conduct a network-wide consensus and make a proposal, and divide the standby segment network into two segment networks according to a preparation algorithm; wherein, after the block data is stored on a node of the storage segment network, the node broadcasts and reaches a consensus in the storage segment network to achieve data synchronization between the nodes in the storage segment network;
[0026] A reset module is used to restart the preparation module to reset the storage segment network when the block height of the storage segment network reaches the segment range.
[0027] Preferably, the preparation module specifically includes:
[0028] A storage module, the storage module is used to perform network-wide consensus when the storage segment network performs storage;
[0029] The partitioning module is used to make a proposal and divide the backup segmented network into two segmented networks according to a preparation algorithm.
[0030] Preferably, the division module is specifically used for:
[0031] Setting the number of nodes in each segment network according to a preset formula;
[0032] Dividing each of the nodes into different segmented networks according to a performance balancing algorithm;
[0033] The storage capacity of the node with the smallest storage capacity in the segmented network is obtained, and the data capacity of the corresponding segmented network is set according to the storage capacity.
[0034] Preferably, the division module is further used for:
[0035] The corresponding number of blocks is determined according to the block height of each segmented network.
[0036] The present invention provides a method and device for segmented storage and consensus based on blockchain. Initially, two segmented networks are created in the blockchain system; one of the segmented networks is set as a storage segmented network, and the other segmented network is set as a backup segmented network; when the storage segmented network performs storage, a full network consensus is performed, and a proposal is made, and the backup segmented network is divided into two segmented networks according to a preparation algorithm; wherein, after block data is stored on a node of the storage segmented network, the node broadcasts and reaches a consensus in the storage segmented network to achieve data synchronization between the nodes in the storage segmented network; when the block height of the storage segmented network reaches the segmented range, one of the segmented networks is set as a storage segmented network again, and the other segmented network is set as a backup segmented network to reset the storage segmented network.
[0037] The data on the chain is stored in segments, and consensus is carried out in the same segment network to ensure data consistency. The data between different segment networks is relatively independent. Through segment storage, segment consensus and overall consensus, the integrity of blockchain data and the characteristics of decentralized distributed storage are guaranteed, avoiding the node storage pressure and huge consumption of storage resources caused by the rapid growth of on-chain data.
[0038] The present invention adopts a certain algorithm to store the data on the blockchain in different segments, thereby achieving the technical effect of segmented storage of the on-chain data and cooperating with segment consensus to ensure the integrity of the on-chain data, thereby solving the technical problems of huge storage pressure and storage resource consumption during the operation of the blockchain system. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 A flowchart of a preferred implementation of the method for segmented storage and consensus based on blockchain provided by the present invention;
[0040] Figure 2 for Figure 1 The work flow chart of step S30 shown;
[0041] Figure 3 for Figure 2 The work flow chart of step S32 shown;
[0042] Figure 4 An architectural diagram of a preferred embodiment of the method for segmented storage and consensus based on blockchain provided by the present invention;
[0043] Figure 5 for Figure 4 The architectural diagram of the partitioning module is shown.
[0044] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0045] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0046] The present invention provides a block chain-based segmented storage and consensus method.
[0047] See also Figure 1 To achieve the above purpose, in one embodiment of the present invention, a method for segmented storage and consensus based on blockchain includes the following steps:
[0048] S10, initially creating two segmented networks in the blockchain system;
[0049] S20, setting one of the segmented networks as a storage segmented network, and setting another of the segmented networks as a standby segmented network;
[0050] S30, when the storage segment network is storing, the whole network consensus is carried out, and a proposal is made to divide the standby segment network into two segment networks according to the preparation algorithm; wherein, after the block data is stored on a node of the storage segment network, the node broadcasts and reaches consensus in the storage segment network to achieve data synchronization between the nodes in the storage segment network;
[0051] S40, when the block height of the storage segment network reaches the segment range, enter the step S20 again to reset the storage segment network.
[0052] The present invention provides a method for segmented storage and consensus based on blockchain. Initially, two segmented networks are created in the blockchain system; one of the segmented networks is set as a storage segmented network, and the other segmented network is set as a backup segmented network; when the storage segmented network performs storage, a full network consensus is performed, and a proposal is made, and the backup segmented network is divided into two segmented networks according to a preparation algorithm; wherein, after block data is stored on a node of the storage segmented network, the node broadcasts and reaches a consensus in the storage segmented network to achieve data synchronization between the nodes in the storage segmented network; when the block height of the storage segmented network reaches the segmented range, one of the segmented networks is set as a storage segmented network again, and the other segmented network is set as a backup segmented network to reset the storage segmented network.
[0053] The data on the chain is stored in segments, and consensus is carried out in the same segment network to ensure data consistency. The data between different segment networks is relatively independent. Through segment storage, segment consensus and overall consensus, the integrity of blockchain data and the characteristics of decentralized distributed storage are guaranteed, avoiding the node storage pressure and huge consumption of storage resources caused by the rapid growth of on-chain data.
[0054] The present invention adopts a certain algorithm to store the data on the blockchain in different segments, thereby achieving the technical effect of segmented storage of the on-chain data and cooperating with segment consensus to ensure the integrity of the on-chain data, thereby solving the technical problems of huge storage pressure and storage resource consumption during the operation of the blockchain system.
[0055] See also Figure 2 , the step S30 specifically includes:
[0056] S31, when the storage segment network performs storage, a consensus is performed across the entire network;
[0057] S32, making a proposal to divide the standby segmented network into two segmented networks according to the preparation algorithm.
[0058] See also Figure 3 , the step S32 specifically includes:
[0059] S321, setting the number of nodes in each segment network according to a preset formula;
[0060] Calculate the number of nodes in the segmented network according to the formula P=T / C;
[0061] P: the number of nodes in the segmented network;
[0062] T: total number of nodes in the standby segment network;
[0063] C: The number of each segment network that is set in advance, for example, 2. (Note: It is necessary to set the minimum value of P. When P<=Pmin, no data is stored in the segment temporarily. When a new node is added, it is configured to the segment first so that the segment can participate in data storage as soon as possible).
[0064] S322, dividing each of the nodes into different segmented networks according to a performance balancing algorithm;
[0065] According to x=s*w, x is the node performance, and the higher the value, the better the performance;
[0066] s is the inter-block communication speed;
[0067] w represents the stability coefficient;
[0068] The location of the node server is the first factor, that is, try to keep the nodes in the same area in the same segment; secondly, try to make the storage level of the nodes in the same segment roughly the same, because the nodes in the same segment store the same data, which can maximize the utilization of the node storage space.
[0069] Based on the above two points, it is also necessary to balance the node performance and make a comprehensive judgment to complete the node segmentation.
[0070] S323, obtaining the storage capacity of the node with the smallest storage capacity in the segmented network, and setting the corresponding data capacity of the segmented network according to the storage capacity.
[0071] When a blockchain system is first built, the amount of data for each block is usually set; when building two segmented networks, 80% of the node with the smallest storage capacity in the current segment is taken as the rated storage capacity (leaving a certain amount of capacity for other node configurations and operations). Because the blockchain has the concept of block height, the number of blocks that can be stored in different segments can be calculated.
[0072] S324, determining the corresponding number of blocks according to the block height of each segmented network.
[0073] To facilitate the understanding of the technical solution, the following examples are given for specific explanation:
[0074] When a new block is generated in the blockchain network, the miner node broadcasts the message. After the whole network reaches a consensus, the new block needs to be uploaded to the chain and stored in the current segment.
[0075] It should be noted that the blockchain system creates two initial segments at the beginning, Segment 1 and Segment 2. Then, when the first segment starts to be stored, the whole network needs to reach a consensus and make a proposal to select the next segment, which is Segment 3.
[0076] In this way, there are always two preliminary segments in the blockchain system, and the number of blocks that can be stored is calculated based on the rated storage capacity of the nodes in the segment. When the block height on the blockchain reaches the segment range, it can be automatically stored in the next segment.
[0077] After a block is stored on a node in the current segment, the node achieves data synchronization among nodes in the segment network by broadcasting and consensus in the current segment network.
[0078] The present invention also provides a device for segmented storage and consensus based on blockchain.
[0079] See also Figure 4 To achieve the above purpose, in one embodiment of the present invention, a device for segmented storage and consensus based on blockchain includes:
[0080] An initial module, wherein the initial module is used to initially create two segment networks in the blockchain system;
[0081] A setting module, the setting module is used to set one of the segmented networks as a storage segmented network and another of the segmented networks as a standby segmented network;
[0082] A preparation module, wherein the preparation module is used to, when the storage segment network is storing, conduct a network-wide consensus and make a proposal, and divide the standby segment network into two segment networks according to a preparation algorithm; wherein, after the block data is stored on a node of the storage segment network, the node broadcasts and reaches a consensus in the storage segment network to achieve data synchronization between the nodes in the storage segment network;
[0083] A reset module is used to restart the preparation module to reset the storage segment network when the block height of the storage segment network reaches the segment range.
[0084] The present invention provides a device for segmented storage and consensus based on blockchain. Initially, two segmented networks are created in the blockchain system; one of the segmented networks is set as a storage segmented network, and the other segmented network is set as a backup segmented network; when the storage segmented network performs storage, a full network consensus is performed, and a proposal is made, and the backup segmented network is divided into two segmented networks according to a preparation algorithm; wherein, after block data is stored on a node of the storage segmented network, the node broadcasts and reaches a consensus in the storage segmented network to achieve data synchronization between the nodes in the storage segmented network; when the block height of the storage segmented network reaches the segmented range, one of the segmented networks is set as a storage segmented network again, and the other segmented network is set as a backup segmented network to reset the storage segmented network.
[0085] The data on the chain is stored in segments, and consensus is carried out in the same segment network to ensure data consistency. The data between different segment networks is relatively independent. Through segment storage, segment consensus and overall consensus, the integrity of blockchain data and the characteristics of decentralized distributed storage are guaranteed, avoiding the node storage pressure and huge consumption of storage resources caused by the rapid growth of on-chain data.
[0086] The present invention adopts a certain algorithm to store the data on the blockchain in different segments, thereby achieving the technical effect of segmented storage of the on-chain data and cooperating with segment consensus to ensure the integrity of the on-chain data, thereby solving the technical problems of huge storage pressure and storage resource consumption during the operation of the blockchain system.
[0087] See also Figure 5 , the preparation module specifically includes:
[0088] A storage module, the storage module is used to perform network-wide consensus when the storage segment network performs storage;
[0089] The partitioning module is used to make a proposal and divide the backup segmented network into two segmented networks according to a preparation algorithm.
[0090] The partitioning module is specifically used for:
[0091] Setting the number of nodes in each segment network according to a preset formula;
[0092] Calculate the number of nodes in the segmented network according to the formula P=T / C;
[0093] P: the number of nodes in the segmented network;
[0094] T: total number of nodes in the standby segment network;
[0095] C: The number of each segment network that is set in advance, for example, 2. (Note: It is necessary to set the minimum value of P. When P<=Pmin, no data is stored in the segment temporarily. When a new node is added, it is configured to the segment first so that the segment can participate in data storage as soon as possible).
[0096] Dividing each of the nodes into different segmented networks according to a performance balancing algorithm;
[0097] According to x=s*w, x is the node performance, and the higher the value, the better the performance;
[0098] s is the inter-block communication speed;
[0099] w represents the stability coefficient;
[0100] The node server location is the first factor, that is, try to keep nodes in the same area in the same segment;
[0101] Secondly, try to make the storage level of nodes in the same segment roughly the same, because the nodes in the same segment store the same data, which can maximize the use of node storage space;
[0102] Based on the above two points, it is also necessary to balance the node performance and make a comprehensive judgment to complete the node segmentation.
[0103] The storage capacity of the node with the smallest storage capacity in the segmented network is obtained, and the data capacity of the corresponding segmented network is set according to the storage capacity.
[0104] When a blockchain system is first built, the amount of data for each block is usually set; when building two segmented networks, 80% of the node with the smallest storage capacity in the current segment is taken as the rated storage capacity (leaving a certain amount of capacity for other node configurations and operations). Because the blockchain has the concept of block height, the number of blocks that can be stored in different segments can be calculated.
[0105] The corresponding number of blocks is determined according to the block height of each segmented network.
[0106] To facilitate the understanding of the technical solution, the following examples are given for specific explanation:
[0107] When a new block is generated in the blockchain network, the miner node broadcasts the message. After the whole network reaches a consensus, the new block needs to be uploaded to the chain and stored in the current segment.
[0108] It should be noted that the blockchain system creates two initial segments at the beginning, Segment 1 and Segment 2. Then, when the first segment starts to be stored, the whole network needs to reach a consensus and make a proposal to select the next segment, which is Segment 3.
[0109] In this way, there are always two preliminary segments in the blockchain system, and the number of blocks that can be stored is calculated based on the rated storage capacity of the nodes in the segment. When the block height on the blockchain reaches the segment range, it can be automatically stored in the next segment.
[0110] After a block is stored on a node in the current segment, the node achieves data synchronization among nodes in the segment network by broadcasting and consensus in the current segment network.
[0111] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a computer-readable storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for enabling a terminal device to enter the method described in each embodiment of the present invention.
[0112] In the description of this specification, the description with reference to the terms "an embodiment", "another embodiment", "other embodiments", or "first embodiment to Xth embodiment" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, method steps or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0113] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0114] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0115] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method of segmented storage and consensus based on blockchain, characterized in that: The steps include: S10, initially creating two segmented networks in the blockchain system; S20, setting one of the segmented networks as a storage segmented network, and setting another of the segmented networks as a standby segmented network; S30, when the storage segment network is storing, the whole network consensus is carried out, and a proposal is made to divide the standby segment network into two segment networks according to the preparation algorithm; wherein, after the block data is stored on a node of the storage segment network, the node broadcasts and reaches consensus in the storage segment network to achieve data synchronization between the nodes in the storage segment network; S40, when the block height of the storage segment network reaches the segment range, according to the two segment networks divided by the backup segment network in step S30, entering step S20 again to reset the storage segment network; The step S30 specifically includes: S31, when the storage segment network performs storage, a consensus is performed across the entire network; S32, making a proposal to divide the standby segment network into two segment networks according to a preparation algorithm; The step S32 specifically includes: S321, setting the number of nodes in each segment network according to a preset formula; Calculate the number of nodes in the segmented network according to the formula P=T / C; P: the number of nodes in the segmented network; T: total number of nodes in the standby segment network; C: The number of pre-set segment networks is 2; the minimum value of P needs to be set. When P<=Pmin, no data is stored in the segment. When a new node is added, it is configured to the segment first, so that the segment can participate in data storage as soon as possible. S322, dividing each of the nodes into different segmented networks according to a performance balancing algorithm; According to x=s*w, x is the node performance, and the higher the value, the better the performance; s is the inter-block communication speed; w represents the stability coefficient; S323, obtaining the storage capacity of the node with the smallest storage capacity in the segmented network, and setting the data capacity of the corresponding segmented network according to the storage capacity; The step S32 specifically further includes: S324, determining the corresponding number of blocks according to the block height of each segmented network.
2. A device for segmented storage and consensus based on blockchain, characterized in that: include: An initial module, wherein the initial module is used to initially create two segment networks in the blockchain system; A setting module, the setting module is used to set one of the segmented networks as a storage segmented network and another of the segmented networks as a standby segmented network; A preparation module, wherein the preparation module is used to, when the storage segment network is storing, conduct a network-wide consensus and make a proposal, and divide the standby segment network into two segment networks according to the preparation algorithm; wherein, after the block data is stored in a node of the storage segment network, the node broadcasts and reaches a consensus in the storage segment network to achieve data synchronization between the nodes in the storage segment network; A reset module, wherein the reset module is used to, when the block height of the storage segment network reaches the segment range, start the setting module again according to the two segment networks divided by the standby segment network in the preparation module to reset the storage segment network; The preparation module specifically includes: A storage module, the storage module is used to perform network-wide consensus when the storage segment network performs storage; A division module, the division module is used to make a proposal, and divide the standby segment network into two segment networks according to a preparation algorithm; The division module is specifically used for: Setting the number of nodes in each segment network according to a preset formula; Calculate the number of nodes in the segmented network according to the formula P=T / C; P: the number of nodes in the segmented network; T: total number of nodes in the standby segment network; C: The number of pre-set segment networks is 2; the minimum value of P needs to be set. When P<=Pmin, no data is stored in the segment. When a new node is added, it is configured to the segment first, so that the segment can participate in data storage as soon as possible. Dividing each of the nodes into different segmented networks according to a performance balancing algorithm; According to x=s*w, x is the node performance, and the higher the value, the better the performance; s is the inter-block communication speed; w represents the stability coefficient; Obtaining the storage capacity of the node with the smallest storage capacity in the segmented network, and setting the data volume of the corresponding segmented network according to the storage capacity; the partitioning module is further specifically used for: The corresponding number of blocks is determined according to the block height of each segmented network.
