Methods, devices, equipment and storage media for dynamic data storage in blockchain networks
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-06
- Publication Date
- 2026-08-14
AI Technical Summary
然而,由于IoT设备的存储和计算资源通常有限,处理这些大量动态数据成为了一个挑战
[0014]本发明还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如上述任一种区块链网络中动态数据存储方法。
Smart Images

Figure CN118051521B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, and in particular to dynamic data storage methods, apparatus, devices, and storage media in blockchain networks. Background Technology
[0002] The rapid expansion of IoT technology has led to the generation of massive amounts of dynamic data. In this context, dynamic data refers to data that is generated in real time and changes frequently, typically collected by various sensors and IoT devices. This type of data requires rapid processing and analysis to enable functions such as real-time monitoring and decision support. However, processing this large volume of dynamic data presents a challenge due to the typically limited storage and computing resources of IoT devices.
[0003] In the blockchain field, while it offers advantages such as data immutability and decentralized storage, traditional blockchain solutions are inefficient at processing dynamic data. Each node in a blockchain needs to store all data and participate in the consensus process, which can lead to network congestion and excessive storage costs as the volume of dynamic data increases. Therefore, how to reduce storage overhead while maintaining the characteristics of blockchain is a problem worthy of research. Summary of the Invention
[0004] This invention provides a method, apparatus, device, and storage medium for dynamic data storage in a blockchain network, designed to adapt to the characteristics of lightweight IoT blockchain networks and solve the problem of real-time processing and storage of large amounts of dynamic data.
[0005] This invention provides a dynamic data storage method in a blockchain network, comprising: identifying nodes under the overlay network and grouping the nodes; establishing a logical network for each group as a whole; adjusting the time window according to preset factors; wherein the preset factors include at least one of data access frequency, data production time, and compression cost; each node in the group performing network encoding on block data outside the time window according to the network encoding scheme, and storing the encoded data fragments in a distributed manner among each node in the group, with each node storing only a portion of the encoded fragments; each node in the group storing block data within the time window in memory; and optimizing storage through cross-group collaboration when the storage capacity of a group reaches a threshold.
[0006] According to the present invention, a dynamic data storage method in a blockchain network adjusts the time window based on preset factors, including: initializing the time window; periodically acquiring data access frequency, data output time, compression cost, a first weight corresponding to the data access frequency, a second weight corresponding to the data output time, and a third weight corresponding to the compression cost; and adjusting the time window based on the data access frequency, data output time, compression cost, the first weight, the second weight, and the third weight.
[0007] According to the present invention, a dynamic data storage method in a blockchain network is provided, wherein each node in the group performs network encoding on block data outside the time window according to the network encoding scheme, including: each group selects a duty node in each T time interval, wherein the duty node is randomly selected by the nodes in the group; the duty node encodes the data and sends the encoded data to the peer nodes in the group.
[0008] According to a dynamic data storage method in a blockchain network provided by the present invention, a duty node encodes data and sends the encoded data to peer nodes within the group, including: establishing a verification chain within the group; wherein the verification chain is used to verify the correctness of the encoded blocks and locate the positions of the encoded blocks; the duty node encodes and divides block data outside the time window using erasure coding, adds descriptive locators to all encoded blocks, and performs hash calculations on the encoded blocks and descriptive locators respectively to obtain hash values, and uploads the hash values to the verification chain; the duty node distributes the encoded blocks equally among the nodes in the group according to the hash values of the IP addresses of the nodes in the group and the hash values of the encoded block descriptive locators, using the storage capacity of each node and a distributed consistent hash algorithm.
[0009] According to a dynamic data storage method in a blockchain network provided by the present invention, each group selects a duty node within each T time interval, including: each node in the group randomly selects a node from the N nodes that have been in the group the longest; the selection result of each node is broadcast within the group, and the node with the most votes becomes the duty node; wherein the time when the duty node joined the group is reset.
[0010] According to the present invention, a dynamic data storage method in a blockchain network involves each node in a group performing network encoding on block data outside a time window according to a network encoding scheme. The encoded data fragments are distributed and stored in each node of the group, with each node storing only a portion of the encoded fragments. The method includes: when a node needs to recover complete block data, it first identifies the missing block fragments; it distributes the data fragment recovery task to other nodes, which then complete their respective data fragment recovery tasks in parallel; after completing their tasks, the other nodes send the decoded data fragments to the node that issued the task; and the node that issued the task combines the decoded data fragments and the received data fragments to form complete block data.
[0011] According to a dynamic data storage method in a blockchain network provided by the present invention, when the storage capacity of a group reaches a threshold, storage optimization is performed through cross-group collaboration, including: selecting relay nodes and storage monitoring nodes within each group; wherein the relay nodes are used to record the duty nodes of other groups, and the storage monitoring nodes are used to monitor the overall storage status within the group; when a duty node in a group receives a storage capacity alarm message from the storage monitoring node of its group, it triggers a deletion process and obtains information about the duty nodes of other groups from the relay nodes of its group; the duty node queries the recorded information of data blocks requested to be retained by other groups on its own node, and selects non-duplicate data blocks for retention; the duty node issues a deletion request, and after receiving confirmation from the duty nodes of other groups, the duty node issues a request to the duty nodes within other groups to obtain the block fragment data to be retained; after receiving the request, the duty nodes within other groups verify the legality of the request, and at the same time ensure that the requested data is data of their own group; if legal, the node records the request information and agrees to the request; the duty node notifies the nodes within the group, and after receiving the notification, the nodes within the group execute the deletion operation, deleting the data related to the unretained block fragments.
[0012] This invention also provides a dynamic data storage device in a blockchain network, comprising: a node grouping module for determining nodes under the coverage network and grouping the nodes; each group as a whole establishes a logical network; a time window adjustment module for adjusting the time window according to preset factors; wherein the preset factors include at least one of data access frequency, data production time, and compression cost; a data storage module for each node in the group to perform network encoding on block data outside the time window according to the network encoding scheme, and to distribute and store the encoded data fragments in each node in the group, with each node storing only a portion of the encoded fragments; each node in the group to store block data within the time window in memory; and a data deletion module for optimizing storage through cross-group collaboration when the storage capacity of a group reaches a threshold.
[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a dynamic data storage method in any of the above-described blockchain networks.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a dynamic data storage method in any of the above-described blockchain networks.
[0015] This invention provides a method, apparatus, device, and storage medium for dynamic data storage in a blockchain network. The method includes: identifying nodes within the overlay network and grouping them; establishing a logical network for each group as a whole; adjusting time windows according to preset factors; each node within a group performing network encoding on block data outside the time window according to a network encoding scheme, with the encoded data fragments being distributed and stored across all nodes within the group, each node storing only a portion of the encoded fragments; each node within a group storing block data within the time window in memory; and optimizing storage through cross-group collaboration when the storage capacity of a group reaches a threshold. This invention distinguishes between active and inactive data by introducing adaptive time windows and a multi-layered architecture, and implements different storage methods for data with varying levels of activity. This not only improves storage space utilization but also enhances the overall system performance, ensuring the scalability of the blockchain network and data security under limited resources. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating the dynamic data storage method in a blockchain network provided in an embodiment of the present invention;
[0018] Figure 2 This is a schematic diagram of the design of a dynamic data storage scheme in a blockchain network provided in an embodiment of the present invention;
[0019] Figure 3 This is a schematic diagram of the duty node code distribution process provided in an embodiment of the present invention;
[0020] Figure 4 This is a schematic diagram of the cross-group collaborative storage optimization process provided in an embodiment of the present invention;
[0021] Figure 5This is a schematic diagram of the structure of a dynamic data storage device in a blockchain network provided in an embodiment of the present invention;
[0022] Figure 6 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0024] This invention provides a method for dynamic data storage in a blockchain network. Please refer to [link / reference]. Figures 1-2 , Figure 1 This is a flowchart illustrating the dynamic data storage method in a blockchain network provided in this embodiment of the invention. Figure 2 This is a schematic diagram of a dynamic data storage scheme in a blockchain network provided in an embodiment of the present invention. In this embodiment, the dynamic data storage method in a blockchain network may include steps S110 to S140, each step of which is as follows:
[0025] S110: Determine the nodes under the coverage network and group the nodes; establish a logical network for each group as a whole.
[0026] In a public blockchain network, each node stores a global ledger of data. Nodes in the blockchain network voluntarily choose to join the overlay network of this scheme, and for ease of node management, nodes are grouped for management purposes.
[0027] Therefore, in this embodiment, nodes selected to join the coverage network of this scheme can be grouped. It should be noted that after grouping, each group forms a logical network as a whole.
[0028] S120: Adjust the time window according to preset factors; wherein the preset factors include at least one of data access frequency, data output time and compression cost.
[0029] This embodiment balances storage space and query performance by dynamically adjusting the time window. This comprehensive adaptive time window strategy is closer to actual needs, enabling the system to intelligently adapt to different data access patterns while minimizing storage costs.
[0030] Specifically, the time window is adjusted based on preset factors, including at least one of data access frequency, data output time, and compression cost.
[0031] S130: Each node in the group performs network encoding on block data outside the time window according to the network encoding scheme. The encoded data fragments are distributed and stored in each node in the group, with each node storing only a part of the encoded fragments. Each node in the group stores block data within the time window in memory.
[0032] In this embodiment, the strategy for storing data based on time windows for nodes added to a group is as follows:
[0033] 1) Block data outside the time window is network encoded according to the network encoding scheme. The encoded data fragments are stored in each group, and each node only stores a part of the encoded fragments to reduce storage.
[0034] 2) Store the block data within the time window in memory.
[0035] S140: When the storage capacity of a group reaches a threshold, storage optimization is performed through cross-group collaboration.
[0036] In this embodiment, the storage capacity of each group can also be detected. When the storage capacity of a group reaches a threshold, storage optimization is performed through cross-group collaboration, and data redundancy is eliminated.
[0037] In summary, this embodiment provides a dynamic data storage method in a blockchain network. By introducing an adaptive time window and a multi-layered architecture, it distinguishes between active and inactive data and implements different storage methods for data with varying levels of activity. This not only improves storage space utilization but also enhances the overall system performance, ensuring the scalability of the blockchain network and data security under limited resources.
[0038] In some embodiments, adjusting the time window according to preset factors includes: initializing the time window; periodically acquiring data access frequency, data output time, compression cost, a first weight corresponding to the data access frequency, a second weight corresponding to the data output time, and a third weight corresponding to the compression cost; and adjusting the time window based on the data access frequency, data output time, compression cost, the first weight, the second weight, and the third weight.
[0039] This embodiment proposes an adaptive time window design. The size of the time window needs to be adaptively adjusted based on three factors: the frequency of data access, the time of data production, and the compression cost. The following is the implementation process of the adaptive time window algorithm:
[0040] Step 1: Initialize the time window.
[0041] Set the initial time window size and initialize the weight parameters for data access frequency, data output time, and compression cost.
[0042] Step 2: Real-time monitoring of data access.
[0043] Record the access time and number of accesses for each data item, and update the data access frequency statistics regularly.
[0044] Step 3: Evaluate the trade-off indicators.
[0045] Calculate the trade-offs for each data item, taking into account access frequency, output time, and compression costs, and calculate the weighted average of the trade-offs for each data item.
[0046] Step 4: Dynamically adjust the time window.
[0047] The time window size is dynamically adjusted based on the changing trend of the comprehensive trade-off index. If the comprehensive trade-off index exceeds a certain threshold, the time window is increased; if it falls below the threshold, the time window is decreased.
[0048] Step 5: Update the algorithm regularly.
[0049] Periodically reassess and update the weighting parameters for data access frequency, output time, and compression cost. Regularly adjust the time window size to adapt to changes in data access patterns.
[0050] Furthermore, the adaptive time window design in this embodiment can also include functions for monitoring algorithm performance and flexibility.
[0051] Monitor algorithm performance: Set up a monitoring mechanism to monitor the performance of the adaptive algorithm in real time, ensuring that it can effectively achieve a balance between frequency and time.
[0052] Flexibility considerations: The algorithm is designed to be flexible, allowing administrators to manually adjust some parameters as needed to adapt to special situations or requirements.
[0053] Through these steps and functions, this embodiment can ensure that an appropriate time window size can be found under different data access modes, achieving the best balance between storage and query performance.
[0054] In some embodiments, each node in the group performs network encoding on block data outside the time window according to the network encoding scheme, including: each group selects a duty node in each T time interval, wherein the duty node is randomly selected by the nodes in the group; the duty node encodes the data and sends the encoded data to the peer nodes in the group.
[0055] In some embodiments, each group selects a duty node within each T time interval, including: each node in the group randomly selects a node from the N nodes that have been in the group the longest; the selection result of each node is broadcast within the group, and the node with the most votes becomes the duty node; wherein the time when the duty node joined the group is reset.
[0056] In some embodiments, the duty node encodes the data and sends the encoded data to peer nodes within the group, which may include: establishing a verification chain within the group; wherein the verification chain is used to verify the correctness of the encoded blocks and locate the position of the encoded blocks; the duty node encodes and divides the block data outside the time window using erasure coding, adds descriptive locators to all encoded blocks, and performs hash calculations on the encoded blocks and descriptive locators respectively to obtain hash values, and uploads the hash values to the verification chain; the duty node distributes the encoded blocks equally among the nodes in the group according to the hash values of the IP addresses of the nodes in the group and the hash values of the encoded block descriptive locators, using the storage capacity of each node and a distributed consistent hash algorithm.
[0057] This embodiment proposes an intra-group coding allocation strategy, which first requires selecting a duty node within the group to encode the data.
[0058] It should be noted that, since the grouping is a completely autonomous environment, the selected duty node is not given any privileges.
[0059] Selection of duty shifts and tasks:
[0060] For communication with other groups and for tasks within groups, each group needs to select a duty node at each T interval. The duty node is randomly selected by voting from the nodes within the group.
[0061] 1. Select rules.
[0062] The selection rules include three aspects: selection scope, selection method, and time reset. Specifically:
[0063] (1) Selection range: Each node in the group randomly selects a node from the N nodes that have been in the group the longest. For example, the value of N can be 2, 3, 4, 5, etc., and can be determined according to the actual situation.
[0064] (2) Selection method: The selection result of each node is broadcast within the group, and the node with the most votes becomes the duty node. Therefore, the longer a node has been in the group, the more likely it is to be selected as the duty node. The longer a node has been in the group, the higher its stability and reliability will be.
[0065] (3) Joining time reset: When a node is selected as a duty node, its joining group time will be reset, thereby ensuring a more balanced chance for nodes in the group to become duty nodes.
[0066] 2. Selection process.
[0067] When selecting a duty node, each node in the group randomly selects a node from the three nodes with the longest joining time based on the node joining time in the group member IP list, and broadcasts the selection result within the group. After all nodes receive the information broadcast by their peer nodes, the duty node is determined by statistical analysis.
[0068] Optionally, if two nodes receive the same number of votes, the node with the longer membership time is selected as the on-duty node.
[0069] Specifically, nodes communicate using IP addresses. The group member IP list records the IP addresses of all current group members, and each node in the group stores the group member IP list.
[0070] If the duty node fails to send the encoded fragment within the specified time, the group members will remove the task node's IP from the group members' IP list, add the duty node's IP to the restriction list, and select a new duty node.
[0071] It should be noted that the restriction list is designed to prevent intermittent offline behavior of nodes. Nodes added to the restriction list will be prohibited from being added to the group member IP list for a certain period of time.
[0072] 3. Responsibilities for duty shifts.
[0073] The duty node is responsible for encoding the data and sending the encoded data to its peer nodes within the group. The duty node is also responsible for checking for malicious and selfish behavior and notifying other members of the group. Additionally, the duty node is responsible for contacting new nodes, checking for node exits, and communicating with duty nodes in other groups.
[0074] Please see Figure 3 , Figure 3 This is a schematic diagram of the duty node code distribution process provided in an embodiment of the present invention.
[0075] First, a verification chain is established within the group to verify the correctness of encoded blocks and locate their positions. The duty node encodes blocks outside the time window using erasure coding, adds descriptive locators to all encoded blocks, and performs hash calculations on both the encoded blocks and their descriptors to obtain hash values. These hash values are then uploaded to the verification chain. Based on the hash values of the IP addresses of nodes within the group and the hash values of the encoded fragment descriptors, the duty node distributes the encoded blocks evenly among the group's nodes using a distributed consistent hash algorithm that considers each node's storage capacity.
[0076] In some embodiments, each node in the group performs network encoding on block data outside the time window according to the network encoding scheme. The encoded data fragments are distributed and stored in each node in the group. Each node stores only a portion of the encoded fragments. The process includes: when a node needs to recover complete block data, it first identifies the missing block fragments of its own node; it distributes the data fragment recovery task to other nodes, and the other nodes complete their respective data fragment recovery tasks in parallel; after completing their respective tasks, the other nodes send the decoded data fragments to the node that issued the task; the node that issued the task combines the data fragments decoded by its own node with the received data fragments to form complete block data.
[0077] This embodiment proposes a fast block file recovery strategy. When a node needs to recover complete block data, it needs to use other encoded blocks to recover missing block fragments. This process takes a lot of time. To address this, this solution proposes to decompose the decoding task and assign it to other nodes in the group. The other nodes in the group execute the assigned task of decoding the required fragments in parallel. By having multiple nodes complete their assigned decoding tasks in parallel, the time for recovering missing block data is accelerated. The specific process is as follows:
[0078] Step 1: To recover a node from a block file, first identify the missing block fragments in this node.
[0079] The second step is to distribute the data fragments that need to be recovered to other nodes, allowing them to complete the recovery of their respective data fragments in parallel.
[0080] Step 3: After each node completes its own task, it divides the decoded data into blocks and sends them to the node that published the task.
[0081] Step 4: The node combines the received data blocks to form complete block data.
[0082] In some embodiments, when the storage capacity of a group reaches a threshold, storage optimization is performed through cross-group collaboration, including: selecting relay nodes and storage monitoring nodes within each group; wherein the relay nodes are used to record the on-call nodes of other groups, and the storage monitoring nodes are used to monitor the overall storage status within the group; when an on-call node in a group receives a storage capacity alarm from the storage monitoring node of its own group, it triggers a deletion process, obtaining information about the on-call nodes of other groups from the relay nodes of its own group; the on-call node queries the recorded information on data blocks requested to be retained by other groups on its own node, and selects non-duplicate data blocks for retention; the on-call node issues a deletion request, and after receiving confirmation from the on-call nodes of other groups, the on-call node issues a request to the on-call nodes of other groups to obtain the block fragment data to be retained; after receiving the request, the on-call nodes of other groups verify the legality of the request, while ensuring that the requested data is data of their own group; if legal, the node records the request information and agrees to the request; the on-call node notifies the nodes in the group, and after receiving the notification, the nodes in the group execute the deletion operation, deleting the data related to the unretained block fragments.
[0083] This embodiment proposes a cross-group collaborative storage optimization mechanism, the cross-group collaborative storage optimization process includes:
[0084] Step 1: Select a relay node.
[0085] Within each group, select several highly stable nodes as relay nodes to record the duty nodes of other groups.
[0086] Step 2: Storage monitoring.
[0087] When a node in a group detects that the storage capacity of its group has reached a set threshold, it triggers the deletion process.
[0088] Step 3: Obtain information on the duty nodes of other groups.
[0089] Obtain information about other groups' duty nodes from the relay nodes in this group, including their addresses, statuses, etc.
[0090] Step 4: Select the data blocks to keep.
[0091] The duty node queries the records of other groups requesting to retain data blocks on this node, and then selects the data blocks that are not duplicated to retain.
[0092] Step 5: Send a deletion request and confirmation.
[0093] The duty node sends a deletion request and receives confirmation from other duty nodes.
[0094] Step 6: Issue a block fragment data request.
[0095] After receiving confirmation from other duty nodes, the duty node sends a request to other duty nodes in the same group to obtain the block fragment data to be retained.
[0096] Step 7: Confirm the duty shifts within other groups.
[0097] Upon receiving the request, other on-duty nodes within the same group verify its validity and ensure that the requested data belongs to their own group. If valid, the node records the request information and approves the request.
[0098] Step 8: Notify the nodes in the group.
[0099] The duty node notifies the nodes in the group which block fragments of data to retain, which can be achieved through broadcast notification or point-to-point communication.
[0100] Step 9: Data deletion.
[0101] Upon receiving the notification, nodes within the group execute a deletion operation, removing data associated with the unretained block fragments. This can be done through physical deletion or encryption.
[0102] Step 10: Record the operation.
[0103] The duty node and other nodes in the group record the deletion operations performed for subsequent auditing and monitoring.
[0104] This process ensures that when deleting data, the on-duty node first queries the data that other groups have requested to retain, avoiding the selection of data blocks that overlap with those of other groups. This guarantees that the data retained by each group is unique.
[0105] Please see Figure 4 , Figure 4 This is a schematic diagram of the cross-group collaborative storage optimization process provided in an embodiment of the present invention. Figure 4 It includes three groups: group1, group2, and group3. Each group contains one on-call node, one relay node, and one storage monitoring node. The specific process is as follows:
[0106] ①The storage monitoring node of group1 sends information about the storage status within the group.
[0107] ②The relay node of group1 sends information about the duty nodes of each group.
[0108] ③The duty node of group1 queries the data information retained by other groups.
[0109] ④ Select the data to retain for the duty node in group1.
[0110] ⑤ The duty node of group1 sends a data deletion request to the duty nodes of group2 and group3.
[0111] ⑥ The duty nodes of group2 and group3 replied with agreement.
[0112] ⑦The duty node of group1 requests the data to be retained.
[0113] ⑧ The duty nodes of group2 and group3 record request information.
[0114] ⑨ Group2 and group3 send the requested data to the duty node of group1.
[0115] ⑩The duty node of group1 notifies the nodes in the group to delete data.
[0116] The present invention also provides a dynamic data storage device in a blockchain network. The dynamic data storage device in a blockchain network provided by the present invention will be described below. The dynamic data storage device in a blockchain network described below can be referred to in correspondence with the dynamic data storage method in a blockchain network described above.
[0117] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of a dynamic data storage device in a blockchain network provided in an embodiment of the present invention. In this embodiment, the dynamic data storage device in the blockchain network may include a node grouping module 510, a time window adjustment module 520, a data storage module 530, and a data deletion module 540.
[0118] The node grouping module 510 is used to identify the nodes under the coverage network and group the nodes; each group is used as a whole to establish a logical network.
[0119] The time window adjustment module 520 is used to adjust the time window according to preset factors; wherein the preset factors include at least one of data access frequency, data output time and compression cost.
[0120] The data storage module 530 is used for each node in the group to perform network encoding on block data outside the time window according to the network encoding scheme, and to distribute and store the encoded data fragments in each node in the group, with each node storing only a part of the encoded fragments; and for each node in the group to store block data within the time window in memory.
[0121] The data deletion module 540 is used to optimize storage through cross-group collaboration when the storage capacity of a group reaches a threshold.
[0122] In some embodiments, the time window adjustment module 520 can be specifically used for:
[0123] Initialize the time window; periodically obtain data access frequency, data output time, compression cost, the first weight corresponding to the data access frequency, the second weight corresponding to the data output time, and the third weight corresponding to the compression cost; adjust the time window based on the data access frequency, data output time, compression cost, first weight, second weight, and third weight.
[0124] In some embodiments, the data storage module 530 includes an encoding module, which can be specifically used for:
[0125] Each group selects a duty node within each T time interval, where the duty node is randomly selected by voting among the nodes in the group; the duty node encodes the data and sends the encoded data to the peer nodes in the group.
[0126] In some embodiments, the encoding module may also be used for:
[0127] A verification chain is established within the group; the verification chain is used to verify the correctness of the encoded blocks and locate the positions of the encoded blocks; the duty node encodes the block data outside the time window using erasure coding, adds descriptive locators to all encoded blocks, and performs hash calculations on the encoded blocks and descriptive locators to obtain hash values, which are then uploaded to the verification chain; based on the hash values of the IP addresses of the nodes in the group and the hash values of the encoded block descriptive locators, the duty node uses the storage capacity of each node and a distributed consistent hash algorithm to distribute the encoded blocks evenly among the nodes in the group.
[0128] In some embodiments, the encoding module may also be used for:
[0129] Each node in the group randomly selects a node from the N nodes that have been in the group the longest; the selection result of each node is broadcast within the group, and the node with the most votes becomes the duty node; the time when the duty node joined the group is reset.
[0130] In some embodiments, the dynamic data storage device in the blockchain network may further include a data recovery module, which may be specifically used for:
[0131] When a node needs to recover complete block data, it first identifies the missing block fragments; then it distributes the data fragment recovery task to other nodes, which complete their respective data fragment recovery tasks in parallel; after completing their tasks, the other nodes send the decoded data fragments to the node that issued the task; the node that issued the task combines the decoded data fragments and the received data fragments to form complete block data.
[0132] In some embodiments, the data deletion module 540 may specifically be used for:
[0133] Within each group, relay nodes and storage monitoring nodes are selected. Relay nodes record the on-call nodes of other groups, while storage monitoring nodes monitor the overall storage status within the group. When an on-call node in a group receives a storage capacity alarm from its group's storage monitoring node, it triggers a deletion process, obtaining information about other groups' on-call nodes from its group's relay node. The on-call node queries its own records for data blocks requested for retention by other groups, selecting unique data blocks for retention. The on-call node issues a deletion request, and after confirmation from other groups' on-call nodes, it sends a request to other on-call nodes within those groups to obtain the block fragment data to be retained. Upon receiving the request, other on-call nodes verify its validity, ensuring the requested data belongs to their own group. If valid, the node records the request information and approves the request. The on-call node notifies other nodes within the group, who then execute the deletion operation, deleting data related to the unretained block fragments.
[0134] The present invention also provides an electronic device, please refer to [link / reference]. Figure 6 , Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. In this embodiment, the electronic device may include a memory 620, a processor 610, and a computer program stored in the memory 620 and executable on the processor 610. When the processor 610 executes the program, it implements the dynamic data storage method in the blockchain network provided by the above-described methods.
[0135] Optionally, the electronic device may further include a communication bus 630 and a communication interface 640, wherein the processor 610, the communication interface 640, and the memory 620 communicate with each other via the communication bus 630. The processor 610 can call a computer program in the memory 620 to execute a dynamic data storage method in the blockchain network, the method including:
[0136] The nodes under the coverage network are identified and grouped; each group is established as a logical network; the time window is adjusted according to preset factors; each node in the group performs network encoding on the block data outside the time window according to the network encoding scheme, and the encoded data fragments are distributed and stored in each node in the group, with each node storing only a part of the encoded fragments; each node in the group stores the block data within the time window in memory; when the storage capacity of a group reaches a threshold, storage optimization is performed through cross-group collaboration.
[0137] Furthermore, the logical instructions in the aforementioned memory 620 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0138] On the other hand, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, is implemented to perform the dynamic data storage method in the blockchain network provided by the above methods. The steps and principles of the method have been described in detail in the above methods and will not be repeated here.
[0139] Non-transitory computer-readable storage media can be any available medium or data storage device that can be accessed by a processor, including but not limited to magnetic storage (e.g., floppy disks, hard disks, magnetic tapes, magneto-optical disks (MOs), etc.), optical storage (e.g., CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (e.g., ROMs, EPROMs, EEPROMs, non-volatile memory (NAND flash), solid-state drives (SSDs)).
[0140] In summary, the dynamic data storage method, apparatus, device, and storage medium in the blockchain network provided by the embodiments of the present invention have the following technical effects:
[0141] 1) The size of the time window is determined by comprehensively considering three key factors: data access frequency, data output time, and compression cost. By dynamically adjusting the time window, the system performs query optimization within the window and erasure coding outside the window to balance storage space and query performance. This comprehensive adaptive time window strategy is closer to actual needs, enabling the system to intelligently adapt to different data access patterns while minimizing storage costs.
[0142] 2) By grouping nodes and assigning each node within a group to store a portion of the data, storage burden is shared across the entire group. Furthermore, when the storage capacity of a particular group is insufficient, a cross-group collaboration mechanism is introduced, enabling nodes from other groups to assist in sharing the storage load. This grouped storage management strategy helps improve the storage efficiency and scalability of the entire blockchain system, reduces the burden on individual nodes, and better adapts to dynamically changing storage needs.
[0143] 3) Intelligent upgrades to the block encoding, allocation, and recovery process: On-duty nodes within the group utilize erasure coding and distributed consistent hashing algorithms to encode and fairly allocate block data outside the time window, and verify the correctness of the encoding through a verification chain. For missing block data recovery, an intelligent parallel decoding strategy is proposed, decomposing the decoding task and distributing it to other nodes within the group, enabling multiple nodes to execute the decoding task in parallel. This intelligent collaborative optimization not only effectively utilizes the computing resources of nodes within the group to quickly recover missing block data but also improves the overall fault tolerance and performance of the system.
[0144] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0145] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0146] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for dynamic data storage in a blockchain network, characterized in that, include: Identify the nodes in the coverage network and group the nodes accordingly; Each group forms a logical network as a whole; Adjust the time window based on preset factors; The preset factors mentioned above include at least one of data access frequency, data output time, and compression cost; Each node in the group performs network encoding on the block data outside the time window according to the network encoding scheme. The encoded data fragments are distributed and stored in each node in the group, with each node storing only a portion of the encoded fragments. Each node in the group stores the block data within the time window in memory; When the storage capacity of a group reaches a threshold, storage optimization is performed through cross-group collaboration.
2. The dynamic data storage method in a blockchain network according to claim 1, characterized in that, The adjustment of the time window based on preset factors includes: Initialize the time window; The data access frequency, data output time, compression cost, a first weight corresponding to the data access frequency, a second weight corresponding to the data output time, and a third weight corresponding to the compression cost are periodically obtained. The adjustment time window is based on the data access frequency, the data output time, the compression cost, the first weight, the second weight, and the third weight.
3. The dynamic data storage method in a blockchain network according to claim 1, characterized in that, Each node within the group performs network coding on block data outside the time window according to the network coding scheme, including: Each group selects one duty node within each T time interval, wherein the duty node is randomly selected by the nodes within the group; The duty node encodes the data and sends the encoded data to the peer nodes in the group.
4. The dynamic data storage method in a blockchain network according to claim 3, characterized in that, The duty node encodes the data and sends the encoded data to its peer nodes within the group, including: A verification chain is established within the group; wherein the verification chain is used to verify the correctness of the encoded blocks and to locate the position of the encoded blocks. The duty node encodes and divides the block data outside the time window using erasure coding, adds descriptor locators to all the encoded blocks, and performs hash calculations on the encoded blocks and descriptor locators to obtain hash values, and uploads the hash values to the verification chain. The duty node distributes the encoded blocks equally among the nodes in the group based on the hash values of the IP addresses of the nodes in the group and the hash values of the encoded block descriptors, using the storage capacity of each node and a distributed consistent hash algorithm.
5. The dynamic data storage method in a blockchain network according to claim 3, characterized in that, Each group selects one duty node within each T time interval, including: Each node in the group is randomly selected from the N nodes that have been in the group the longest. The selection results for each node are broadcast within the group, and the node with the most votes becomes the duty node; the time when the duty node joins the group is reset.
6. The dynamic data storage method in a blockchain network according to claim 1, characterized in that, Each node in the group performs network encoding on the block data outside the time window according to the network encoding scheme. The encoded data fragments are distributed and stored among the nodes in the group, with each node storing only a portion of the encoded fragments, including: When a node needs to recover complete block data, first identify the missing block fragments of this node; The data that needs to be recovered is divided into blocks and distributed to other nodes, which then complete the recovery of their respective data segments in parallel. After completing their respective tasks, the other nodes will send the decoded data in blocks to the node that published the task. The node that issues the task combines the data blocks it decodes with the data blocks it receives to form a complete block of data.
7. The dynamic data storage method in a blockchain network according to claim 1, characterized in that, When the storage capacity of a certain group reaches a threshold, storage optimization is achieved through cross-group collaboration, including: Within each group, a relay node and a storage monitoring node are selected; wherein the relay node is used to record the duty nodes of other groups, and the storage monitoring node is used to monitor the overall storage status within the group; When a duty node in a group receives a storage capacity alarm from a storage monitoring node in its group, it triggers a deletion process and obtains information about duty nodes in other groups from the relay node in its group. The duty node queries the data block information of other groups that have requested to retain it on this node, and selects the unique data blocks to retain. The duty node sends a deletion request. After receiving confirmation from other duty nodes, the duty node sends a request to other duty nodes in the same group to obtain the block fragment data to be retained. When other duty nodes in the same group receive a request, they verify the validity of the request and ensure that the requested data is from their own group. If the request is valid, the node records the request information and approves the request. The duty node notifies the nodes in the group. After receiving the notification, the nodes in the group perform the deletion operation, deleting the data related to the unretained block fragments.
8. A dynamic data storage device in a blockchain network, characterized in that, include: The node grouping module is used to identify nodes in the overlay network and group the nodes. Each group forms a logical network as a whole; The time window adjustment module is used to adjust the time window according to preset factors; The preset factors mentioned above include at least one of data access frequency, data output time, and compression cost; The data storage module is used for each node in the group to perform network encoding on block data outside the time window according to the network encoding scheme, and to distribute and store the encoded data fragments in each node in the group, with each node storing only a portion of the encoded fragments; and for each node in the group to store block data within the time window in memory. The data deletion module is used to optimize storage through cross-group collaboration when the storage capacity of a group reaches a threshold.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the dynamic data storage method in the blockchain network as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the dynamic data storage method in a blockchain network as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Visualization method and device of block chain system
CN110851466A
Visualization method of block chain system
CN111597250A