Storage space recovery method, device, equipment and storage medium
By generating smart contracts in the blockchain, obtaining traceability status and data, filtering and sorting unrecovered blocks, and generating a second side chain, the problem of high blockchain storage space expansion costs is solved and data recovery efficiency and consensus efficiency are improved.
Patent Information
- Application Number
- CN202311587436.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-24
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2043-11-24
AI Technical Summary
The existing blockchain technology has the problem of high storage space expansion costs, which affects data synchronization and consensus efficiency.
By generating a smart contract and based on the side chain data recovery rules, the traceability status and traceability data of the product are obtained, the unrecovered blocks are filtered, the upload frequency is calculated and sorted, and a second side chain is generated to recycle storage space.
It reduces the cost of storage space expansion, improves data recovery efficiency, and reduces the impact on data synchronization and consensus efficiency.
Smart Images

Figure CN118819392B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a storage space recovery method, device, equipment, and storage medium. Background Art
[0002] In existing blockchains, whether public or consortium, with both mainchains and sidechains, the processing of on-chain data is constantly increasing. As data continues to enter the blockchain system, the local storage pressure on each node in the blockchain gradually increases. When the local storage space of each blockchain node is about to be exhausted, there are three ways to expand storage space: 1) Add external storage: Deployed servers can add external disk space to store more on-chain data; 2) Replace servers with larger storage: Deployed servers are replaced with servers with larger storage space to store more on-chain data; 3) Convert local storage to distributed storage: Deployed servers modify their storage logic, switching from local storage to distributed storage to store more on-chain data. Distributed storage here includes storing data in a hashed format across multiple storage nodes, as well as creating a new chain to transfer and store existing on-chain data.
[0003] The common disadvantages of these three methods are: the need to continuously expand the storage space of data, resulting in increasing storage costs; and the solution of replacing the server with larger storage will also cause the service of the blockchain node to be suspended, which will affect the data synchronization and consensus efficiency of the interface with other nodes. Summary of the Invention
[0004] The main purpose of the present invention is to provide a storage space recovery method, device, equipment and storage medium, aiming to solve the technical problems of high storage space expansion cost and impact on data synchronization and consensus efficiency in the existing technology.
[0005] To achieve the above object, the present invention provides a storage space recovery method, which comprises the following steps:
[0006] Generate a smart contract based on the side chain data recovery rules, and publish the smart contract to a blockchain, wherein the blockchain includes a main chain and a first side chain, and the main chain and the first side chain include multiple blocks;
[0007] Obtaining the traceability status and traceability data of the product in the first side chain, and executing the smart contract according to the traceability status and traceability data of the product to obtain the data to be recovered;
[0008] Filtering the blocks in the first side chain according to the data to be recycled to obtain unrecycled blocks;
[0009] Calculating the upload frequency of the traceability data of the unrecovered blocks, and sorting the unrecovered blocks according to the upload frequency to generate a second side chain;
[0010] Storage space recovery is performed based on the second side chain.
[0011] Optionally, the smart contract includes a first contract function and a second contract function, and obtaining the traceability status and traceability data of the commodity in the first side chain, and executing the smart contract according to the traceability status and traceability data of the commodity to obtain the data to be recovered includes:
[0012] Obtaining the traceability status and traceability data of the product in the first side chain;
[0013] Executing the first contract function and the second contract function according to the traceability status and traceability data of the commodity to obtain a target commodity and a table of data to be recycled;
[0014] The data to be recycled is determined according to the target product and the table of data to be recycled.
[0015] Optionally, determining the data to be recycled based on the target product and the table of data to be recycled includes:
[0016] The traceability data corresponding to the target product is packaged into blocks and sent to the main chain for consensus and storage to obtain the stored target product;
[0017] Obtaining the identifier of the stored target commodity, and updating the to-be-recycled data table according to the identifier;
[0018] Query the recycling status corresponding to each commodity identifier in the to-be-recycled data table to obtain the number of unrecycled traceability data;
[0019] The data to be recovered is determined based on the amount of unrecovered traceability data.
[0020] Optionally, calculating the upload frequency of the traceability data of the unrecovered blocks, sorting the unrecovered blocks according to the upload frequency, and generating the second side chain includes:
[0021] Calculate the upload frequency of the traceability data of the unrecovered blocks;
[0022] Sorting the unrecycled blocks according to the upload frequency to obtain a sorting result;
[0023] Adjusting the traceability data and the unrecovered blocks in the unrecovered blocks according to the sorting result to obtain an unrecovered block sequence;
[0024] A second side chain is obtained according to the unrecovered block sequence.
[0025] Optionally, generating a smart contract based on the side chain data recovery rule and publishing the smart contract to the blockchain includes:
[0026] Generate smart contracts based on sidechain data recovery rules;
[0027] Publishing the smart contract to a first sidechain of the blockchain;
[0028] The smart contract is reached through consensus among the nodes in the blockchain to obtain a consensus smart contract;
[0029] The smart contract is stored in the first side chain through each node in the blockchain.
[0030] Optionally, the obtaining of the traceability status and traceability data of the commodity in the first side chain, and executing the smart contract according to the traceability status and traceability data of the commodity, before determining the data to be recycled, further includes:
[0031] Packaging the on-chain data into blocks and publishing them to the first sidechain, wherein the on-chain data includes the traceability status and traceability data of the product;
[0032] The nodes in the blockchain reach a consensus on the on-chain data to obtain the consensus on-chain data;
[0033] The consensus-based on-chain data is stored in the first side chain through each node in the blockchain.
[0034] Optionally, the reclaiming storage space based on the second side chain includes:
[0035] Determine duplicate data in the main chain based on the data to be recovered;
[0036] Deleting duplicate data in the main chain and deleting the first side chain;
[0037] The second side chain is used as a new first side chain to achieve storage space recovery.
[0038] In addition, to achieve the above-mentioned purpose, the present invention further provides a storage space recovery device, the storage space recovery device comprising:
[0039] A publishing module, configured to generate a smart contract based on the side chain data recovery rules and publish the smart contract to a blockchain, wherein the blockchain includes a main chain and a first side chain, and the main chain and the first side chain include multiple blocks;
[0040] an execution module, configured to obtain the traceability status and traceability data of the commodity in the first side chain, and execute the smart contract according to the traceability status and traceability data of the commodity to obtain the data to be recovered;
[0041] a filtering module, configured to filter the blocks in the first side chain according to the data to be recycled to obtain unrecycled blocks;
[0042] a sorting module, configured to calculate the upload frequency of the traceability data of the unrecovered blocks, and sort the unrecovered blocks according to the upload frequency to generate a second side chain;
[0043] A recycling module is used to recycle storage space based on the second side chain.
[0044] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage space recovery device, which includes: a memory, a processor, and a storage space recovery program stored on the memory and runnable on the processor, and the storage space recovery program is configured to implement the steps of the storage space recovery method described above.
[0045] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which a storage space recovery program is stored. When the storage space recovery program is executed by a processor, the steps of the storage space recovery method described above are implemented.
[0046] The present invention generates a smart contract based on the side chain data recovery rule and publishes the smart contract to the blockchain, wherein the blockchain includes a main chain and a first side chain, and the main chain and the first side chain include multiple blocks; the traceability status and traceability data of the goods in the first side chain are obtained, and the smart contract is executed according to the traceability status and traceability data of the goods to obtain the data to be recovered; the blocks in the first side chain are filtered according to the data to be recovered to obtain unrecovered blocks; the upload frequency of the traceability data of the unrecovered blocks is calculated, and the unrecovered blocks are sorted according to the upload frequency to generate a second side chain; storage space is recovered based on the second side chain. Through the above method, the smart contract is executed according to the traceability status and traceability data of the goods to determine the data to be recovered, and the first side chain is filtered according to the data to be recovered to obtain unrecovered blocks, thereby generating a second side chain and performing storage space recovery, solving the problems of high storage space expansion cost, affecting data synchronization and consensus efficiency, reducing data storage cost, and high data recovery efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 It is a structural diagram of a storage space recovery device in a hardware operating environment involved in an embodiment of the present invention;
[0048] Figure 2Schematic diagram of the flow of a first embodiment of a storage space reclamation method according to the present invention;
[0049] Figure 3 This is a schematic diagram of the smart contract data structure of an embodiment of the storage space recovery method of the present invention;
[0050] Figure 4 This is a schematic diagram of a side chain data storage space recovery process according to an embodiment of a storage space recovery method of the present invention;
[0051] Figure 5 is a flow chart of a second embodiment of a storage space reclamation method according to the present invention;
[0052] Figure 6 A schematic diagram of side chain data in accordance with an embodiment of a storage space recovery method according to the present invention;
[0053] Figure 7 This is a schematic diagram of a state in which no data is recycled in the current round in a new side chain according to an embodiment of a storage space recycling method of the present invention;
[0054] Figure 8 This is a deployment architecture diagram of the underlying service device of the consortium blockchain according to an embodiment of the storage space recovery method of the present invention;
[0055] Figure 9 This is a structural block diagram of the first embodiment of the storage space recovery device of the present invention.
[0056] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0057] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0058] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of a storage space recovery device in a hardware operating environment according to an embodiment of the present invention.
[0059] like Figure 1As shown, the storage space recovery device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the user interface 1003 may optionally include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk storage. The memory 1005 may optionally be a storage device independent of the aforementioned processor 1001.
[0060] Those skilled in the art will understand that Figure 1 The structure shown in does not constitute a limitation on the storage space recovery device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0061] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a storage space recovery program.
[0062] exist Figure 1 In the storage space recovery device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the storage space recovery device of the present invention can be set in the storage space recovery device, and the storage space recovery device calls the storage space recovery program stored in the memory 1005 through the processor 1001, and executes the storage space recovery method provided by the embodiment of the present invention.
[0063] The embodiment of the present invention provides a storage space recovery method, referring to Figure 2 , Figure 2 FIG. 1 is a flow chart of a first embodiment of a storage space reclamation method according to the present invention.
[0064] In this embodiment, the storage space recovery method includes the following steps:
[0065] Step S10: Generate a smart contract based on the side chain data recovery rule, and publish the smart contract to the blockchain, wherein the blockchain includes a main chain and a first side chain, and the main chain and the first side chain include multiple blocks.
[0066] It should be noted that the execution subject of this embodiment is a storage space recovery device, and other devices with the same or similar functions may also be used. This embodiment is not limited to this. This embodiment uses the storage space recovery device as an example for description.
[0067] It is understandable that blockchain is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. It is also called distributed ledger technology and is an Internet database technology.
[0068] In the specific implementation, a smart contract is written with the side chain data space recycling rules as the core, and the smart contract is published to the side chain of the blockchain (at this time there is only one side chain, numbered side chain 1, i.e. the first side chain), and the block is marked as a side chain block.
[0069] Furthermore, generating a smart contract based on the side chain data recovery rule and publishing the smart contract to the blockchain includes: generating a smart contract based on the side chain data recovery rule; publishing the smart contract to a first side chain of the blockchain; reaching consensus on the smart contract through each node in the blockchain to obtain a consensus smart contract; and storing the smart contract on the first side chain through each node in the blockchain.
[0070] In the specific implementation, each node in the blockchain reaches a consensus on the smart contract based on the consensus algorithm. After reaching a consensus, each node in the blockchain stores the smart contract locally on the first side chain (there is only one side chain at this time, numbered side chain 1).
[0071] like Figure 3 As shown, Figure 3The following is a diagram of the smart contract data structure. The smart contract data structure used in the side chain space recovery scenario contains three data areas: contract metadata area, contract area and contract data verification area. Among them, the contract metadata area (ContractMetaData) mainly contains the metadata information of the contract, and the main fields include the contract number (string field type, field name contract_num), contract name (string field type, field name contract_name), contract version (string field type, field name contract_version), and contract trigger method (integer field type, field name contract_runway); the contract area (Contract) mainly contains a function list consisting of several contract functions and business interface callbacks, such as contract function 1 and contract function 2; the contract data verification area (ContractVerifyData) mainly includes the contract metadata area and the verification of the contract area data, so as to verify the integrity and authenticity of the data in the blockchain. Therefore, it is divided into contract metadata verification metaVerify and contract area data verification contractVerify.
[0072] It is understandable that there are many ways to trigger a contract, including but not limited to time-based triggering (real-time triggering and timed triggering) and data volume-based triggering. In the time-based triggering method, when triggering in real time, contract_runway=0; when triggering on a timed basis, the trigger time is written in the form of an integer string, such as 2023-04-1010:00:00 can be written as 20230410100000, that is, contract_runway=20230410100000. In the data volume-based triggering method, the contract is triggered according to the number of data items that meet the triggering conditions. This embodiment is used for the recovery of side chain data storage space. Therefore, the data volume-based triggering method is selected. By default, 10 pieces of data can trigger the recovery of side chain storage space. The 10 pieces of data corresponding to this scenario refer to the accumulation of 10 traceable commodity data items, which can trigger the recovery of side chain data storage space.
[0073] It is worth noting that the verification data is calculated based on the MD5 value of the JSON of each set of data. Taking the data verification data generation in the metadata area as an example: the contract number (string field type, field name contract_num), contract name (string field type, field name contract_name), contract version (string field type, field name contract_version), contract trigger method (integer field type, field name contract_runway) and their corresponding values are organized into JSON format. The specific implementation code is as follows:
[0074]
[0075] Generate contract metadata verification metaVerify from JSON according to the MD5 algorithm, that is, contract metadata verification metaVerify = MD5 (JSON).
[0076] It is understandable that when a smart contract needs to be generated, the values of the corresponding fields are filled in according to the data structure of the smart contract to complete the assembly of the smart contract data. The contract is then published on the chain and enters the alliance chain for consensus and localized storage of the contract on each node.
[0077] Step S20: Obtain the traceability status and traceability data of the product in the first side chain, and execute the smart contract according to the traceability status and traceability data of the product to obtain the data to be recovered.
[0078] It should be noted that product traceability status includes three states: traceability start, traceability in progress, and traceability completed. Traceability data refers to data that can be used to trace the production, processing, transportation, and sales processes of a product or item. Traceability data can provide information on a product's origin, production conditions, quality control, and other aspects, helping consumers understand its authenticity and reliability.
[0079] In a specific implementation, before obtaining the traceability status and traceability data of the product in the first side chain, it also includes: packaging the data that needs to be uploaded to the chain into blocks and publishing them to the first side chain, wherein the data that needs to be uploaded to the chain includes the traceability status and traceability data of the product.
[0080] It can be understood that the traceability status and traceability data of the goods are used as input parameters to execute the smart contract, and the data to be recovered is determined based on the execution results of the smart contract.
[0081] Step S30: filtering the blocks in the first side chain according to the data to be recycled to obtain unrecycled blocks.
[0082] It should be noted that the data to be recovered is a list of identifiers of commodities that have reached the traceability completion status. The data to be recovered is traversed through each block of the first side chain (i.e., side chain 1) and filtered. That is, the blocks are filtered according to the traceability completion status in the first side chain to obtain unrecovered blocks.
[0083] In a specific implementation, each block of the numbered first side chain is traversed and filtered according to the identifier list List data. The filtered data is sorted by data uniqueness identifier and estimated synchronization time to the main chain. Blocks are then constructed from the most recent to the most distant data synchronized to the main chain, grouped by data uniqueness identifier (if the block size is exceeded, the blocks are divided into multiple blocks), to build the second side chain, Side Chain 2. This facilitates efficient recovery of side chain data in the next round. In this embodiment, the data uniqueness identifier is the product ID number.
[0084] Step S40: Calculate the upload frequency of the traceability data of the unrecovered blocks, and sort the unrecovered blocks according to the upload frequency to generate a second side chain.
[0085] It should be noted that the time it takes to complete product traceability can be predicted based on the frequency of uploading source data. The more frequent the upload, that is, the smaller the upload frequency, the more likely it is that the traceability data will be uploaded the earliest.
[0086] It is understood that unrecycled blocks are blocks corresponding to data that will not be recycled in this round. Unrecycled blocks are sorted according to their upload frequency, and the order is determined by the data organization method of the pre-created second side chain.
[0087] Furthermore, the calculating the upload frequency of the traceability data of the unrecovered blocks and sorting the unrecovered blocks according to the upload frequency to generate the second side chain includes: calculating the upload frequency of the traceability data of the unrecovered blocks; sorting the unrecovered blocks according to the upload frequency to obtain a sorting result; adjusting the traceability data and the unrecovered blocks in the unrecovered blocks according to the sorting result to obtain an unrecovered block sequence; and obtaining the second side chain based on the unrecovered block sequence.
[0088] In the specific implementation, after obtaining the data to be recycled, a new second sidechain is created, numbered Sidechain 2 (there are now two sidechains, numbered Sidechain 1 and Sidechain 2). The starting point of the sidechain is the genesis block. The sidechain numbered Sidechain 1 stops adding new block data. If new data is sent to the sidechain in the form of a block, the data of this new block is written to Sidechain 2. The writing of data to Sidechain 2 uses the same consensus algorithm and storage method as Sidechain 1. The blocks in the first sidechain are filtered according to the data to be recycled to obtain the blocks corresponding to the data not to be recycled in this round. The blocks are then sorted according to the upload frequency of the traceability data of the unrecovered blocks, and the blocks are constructed according to the sorting method to generate the final second sidechain.
[0089] It should be noted that this embodiment takes a single side chain as an example to illustrate the normal chaining of reconstructed blocks of non-recycled data in this round and newly chained data by creating a new second side chain.
[0090] It is understandable that when there are N (N≥2) sidechains in the main chain of a blockchain, creating N new sidechains will obviously put pressure on the local storage space of each node in the blockchain. Therefore, an algorithm and process based on sidechain data recovery and block reconstruction is proposed.
[0091] In practice, data recovery for multiple sidechains involves recycling sidechain by sidechain. Specifically, if there are N (N ≥ 2) sidechains in the mainchain, and the sidechains are numbered Sidechain 1, Sidechain 2, and so on, Sidechain N, data recovery for Sidechain 1, Sidechain 2, and so on is performed according to the process described in Section 5.0. This involves creating a new sidechain, completing data recovery and block reconstruction for Sidechain 1, and then performing data recovery and block reconstruction for Sidechain 2. New sidechains can be created by either establishing N new sidechains sequentially or by maintaining a single sidechain. Compared to recycling a single sidechain, the sequential establishment of N new sidechains results in N sidechains remaining unchanged after data recovery, while the single sidechain approach simplifies the number of sidechains through the recovery process, facilitating unified management.
[0092] Implementing data recycling on multiple side chains also includes: recycling all side chains together, that is, identifying the data to be recycled in each side chain, and sorting the data that will not be recycled in this round in each side chain according to the data unique identifier and the predicted time for the data to be fully uploaded to the chain, organizing the block data with the data unique identifier, and adding the block data to a new side chain.
[0093] It is worth noting that the sorting of unrecovered blocks is determined according to the frequency value corresponding to the traceability data in each block. When multiple side chains are recovered simultaneously, the frequency values of the remaining unrecovered blocks of the original side chains can be determined separately, and then the frequency values of the original side chain data uploads corresponding to the unrecovered blocks are calculated accordingly. Finally, the original side chains are sorted according to the frequency values, and the original side chains are integrated according to the sorting. For example, before recovery, there are 3 side chains, namely side chain 1, side chain 2, and side chain 3. Side chain 1 includes block 1-1, block 1-2, and block 1-3; side chain 2 includes block 2-1, block 2-2, block 2-3, and block 2-4; side chain 3 includes block 3-1, block 3-2, block 3-3, block 3-4, block 3-5, and block 3-6. After data filtering, the sidechain distribution is as follows: Sidechain 1 includes blocks 1-2 and 1-3; Sidechain 2 includes blocks 2-1 and 2-4; and Sidechain 3 includes blocks 3-1, 3-3, 3-4, and 3-6. When merging or synchronously recovering multiple sidechains, a new Sidechain 4 is created to organize the remaining unrecovered blocks from Sidechains 1, 2, and 3. The data upload frequency of each block in each sidechain is first calculated, and then the average value is used to determine the data upload frequency of each sidechain. For example, the frequency value of side chain 1 is A1, the frequency value of side chain 2 is A2, and the frequency value of side chain 3 is A3, and A1>A2>A3, then the order of the new side chain 4 is block 1-2, block 1-3, block 2-1, block 2-4, block 3-1, block 3-3, block 3-4, block 3-6, and the newly added blocks are arranged after blocks 3-6.
[0094] Step S50: reclaiming storage space based on the second side chain.
[0095] It should be noted that the first sidechain is deleted, the second sidechain is used as the new first sidechain, and the next round of sidechain data space recycling process begins. The sidechain data that has been agreed upon on the mainchain can be continuously recycled, and the local storage space and block storage of each node in the blockchain are continuously optimized. The newly recycled sidechain data organization facilitates the efficient recycling of the next round of sidechain data.
[0096] Furthermore, the storage space recovery based on the second side chain includes: determining duplicate data in the main chain based on the data to be recovered; deleting the duplicate data in the main chain and deleting the first side chain; and using the second side chain as a new first side chain to achieve storage space recovery.
[0097] It should be noted that after completing the data recovery of the first side chain, which is numbered as side chain 1, the side chain 1 data will be deleted locally. And the deletion results (data that uniquely identify which data has been deleted, in this scenario, it is the product ID number list of agricultural products) are packaged into a block, marked as a side chain block, and published to the blockchain. The block will be written to the side chain numbered by the second side chain, side chain 2. After the data of this block is consensus-based in the side chain, side chain 1 has been deleted from all nodes, and side chain 2 has been built and is still in consensus data. At this time, the data that is duplicated with the side chain on the main chain is deleted, thereby partially releasing the storage space of each node for reuse of this part of the space. At this time, there is only one side chain, and its number is changed from side chain 2 to side chain 1.
[0098] like Figure 4 As shown, Figure 4 This is a diagram of the sidechain data storage space reclamation process. The blockchain consists of three chains: the main chain, Sidechain 1, and Sidechain 2. The main chain and sidechains all start from the genesis block and are composed of multiple blocks. The main chain stores all data for final consensus; Sidechain 1 temporarily stores data requiring rapid consensus. Sidechain 2 is created when Sidechain 1 needs to reclaim data (the reclaimed data has already been stored on the main chain and is therefore duplicated). Users reassemble existing data from Sidechain 1 that does not need to be reclaimed into new blocks and incorporate them into Sidechain 2. When reclaiming duplicate data, Sidechain 1 no longer accepts incoming data from the sidechain, and the data is inserted into Sidechain 2. In other words, Sidechain 2's data comes from two sources: data from Sidechain 1 that does not need to be reclaimed, and newly added data from the sidechain. The reclaim process between Sidechain 1 and Sidechain 2 interacts with each other. During the initial data recovery, the first sidechain, numbered Sidechain 1, is used to temporarily store data requiring fast consensus. When data recovery is needed on the first sidechain, a second sidechain, numbered Sidechain 2, is established to handle any unused data from the first sidechain and any newly uploaded data. Once the first sidechain has recovered and processed duplicate data, it is deleted, leaving only the second sidechain, now numbered Sidechain 1. The process of establishing and revoking Sidechains 1 and 2 repeats. Throughout the entire data recovery and data upload process, only one sidechain is performing fast consensus and data storage.
[0099] This embodiment generates a smart contract based on the side chain data recovery rule and publishes the smart contract to the blockchain, wherein the blockchain includes a main chain and a first side chain, and the main chain and the first side chain include multiple blocks; obtains the traceability status and traceability data of the goods in the first side chain, and executes the smart contract according to the traceability status and traceability data of the goods to obtain the data to be recovered; filters the blocks in the first side chain according to the data to be recovered to obtain unrecovered blocks; calculates the upload frequency of the traceability data of the unrecovered blocks, and sorts the unrecovered blocks according to the upload frequency to generate a second side chain; and recycles storage space based on the second side chain. Through the above method, the smart contract is executed according to the traceability status and traceability data of the goods to determine the data to be recovered, and the first side chain is filtered according to the data to be recovered to obtain unrecovered blocks, thereby generating a second side chain and reclaiming storage space, solving the problems of high storage space expansion cost, affecting data synchronization and consensus efficiency, reducing data storage cost, and high data recovery efficiency.
[0100] refer to Figure 5 , Figure 5 FIG. 4 is a flow chart of a second embodiment of a storage space reclamation method according to the present invention.
[0101] Based on the first embodiment described above, the smart contract includes a first contract function and a second contract function. Step S20 in the storage space recovery method of this embodiment includes:
[0102] Step S201: Obtain the traceability status and traceability data of the product in the first side chain.
[0103] It should be noted that product traceability status includes three states: traceability start, traceability in progress, and traceability completed. Traceability data refers to data that can be used to trace the production, processing, transportation, and sales processes of a product or item. Traceability data can provide information on a product's origin, production conditions, quality control, and other aspects, helping consumers understand its authenticity and reliability.
[0104] Step S202: Execute the first contract function and the second contract function according to the traceability status and traceability data of the commodity to obtain a target commodity and a table of data to be recycled.
[0105] It should be noted that the smart contract includes a first contract function and a second contract function. The first contract function is used to determine whether the on-chain data has reached the trigger for the side chain data to be submitted to the main chain; the second contract function is used to control the side chain data recovery. The format of the contract function is as follows:
[0106] Return value function contract name (input parameter list) {
[0107] Function implementation
[0108] }
[0109] The first contract function, which is the contract function for determining when the sidechain data is submitted to the mainchain, has the following implementation code:
[0110] Boolean function is2mainchain(int goodStatus){
[0111] / / Specific process for determining whether certain data on the side chain is submitted to the main chain
[0112] return TRUE or FALSE;
[0113] }
[0114] The second contract function, which controls the sidechain data recovery, has the following implementation code:
[0115] List <int>function recovery(){
[0116] / / Specific process for determining whether side chain data can be recycled
[0117] return List <int>;
[0118] }
[0119] It is understandable that the traceability status and traceability data of the product are used as input parameters to execute the smart contract. If the execution result of the first contract function indicates that certain side chain data (at this time, there is only one side chain, numbered Side Chain 1) needs to be submitted to the main chain, then the certain side chain data that needs to be submitted to the main chain (at this time, there is only one side chain, numbered Side Chain 1) will be packaged into a block, and then the block will be published to the blockchain, marking the block as the main chain block. Among them, certain side chain data refers to all traceability data of certain products that have reached the traceability completion status. Each node in the blockchain reaches a consensus on the main chain block based on the consensus algorithm. After consensus, each node in the blockchain will localize and store the main chain block on the main chain.
[0120] It is worth noting that if the second contract function indicates that certain data needs to be recovered, a new second side chain will be created to recover the data. The certain data is the data to be recovered, which refers to all traceability data of certain products that have reached the traceability completion status.
[0121] In the specific implementation, the process of determining whether certain data on the side chain is submitted to the main chain includes: determining the product traceability status (divided into three states: traceability start, traceability in progress, and traceability end; when traceability starts, goodStatus = 0; when traceability is in progress, goodStatus = 1; when traceability ends, goodStatus = 2) field, that is, the value of goodStatus. If goodStatus = 0 or 1, the process ends. If goodStatus = 2, the first contract function returns TRUE, which means that the traceability information corresponding to the product can be packaged into a block and sent to the main chain for consensus and storage.
[0122] The process of whether the side chain data can be recovered includes: querying the number K of unrecovered data in the data table to be recovered; if K ≥ the contract_runway field (contract trigger method) in the contract data structure, that is, K ≥ contract_runway, it means that the side chain data storage space can be recovered, and the contract_runway data is queried from the data table to be recovered, and its corresponding isRecovery (recovery status) is set to 1, indicating that it is being recovered, and the process ends; otherwise, no data is returned, that is, empty data is returned.
[0123] As shown in Table 1, Table 1 is a table of data to be recycled, which includes number, field name, field type and remarks. The field name of number 1 is id, the field type is int (integer type), and the remarks are the database auto-increment id; the field name of number 2 is goodId, the field type is int (integer type), and the remarks are the traceability product ID, and the product has completed traceability; the field name of number 3 isRecovery, the field type is int (integer type), and the remarks are whether it has been recycled, that is, the recycling status, which defaults to 0, 0 indicates not recycled, 1 indicates recycling, and 2 indicates recycled.
[0124] Table 1
[0125]
[0126] It should be noted that if the traceability data corresponding to a certain sidechain product identifier, goodId, has been agreed upon and stored on the mainchain, the data for that goodId will be written to the pending recovery data table as a record of the sidechain data to be recovered. If certain data in the pending recovery data table has already been recovered with the sidechain, the corresponding isRecovery value will be set to 1, indicating that it is being recovered; if certain data in the table has already been recovered with the sidechain, the corresponding isRecovery value will be set to 2, indicating that it has been recovered.
[0127] Step S203: determining the data to be recycled according to the target product and the table of data to be recycled.
[0128] It should be noted that the target product is a product that has reached the traceability completion status. The to-be-recovered data table is queried according to the traceability completion status of the target product to obtain the to-be-recovered data.
[0129] like Figure 6 As shown, Figure 6 This is a sidechain data diagram. Information on four products with goodids 1, 2, 3, and 4 is stored in blocks 1, 2, 3, and 4 on the blockchain sidechain. "status" indicates the product's traceability status: "status = 0" indicates traceability has begun; "status = 1" indicates traceability is in progress; and "status = 2" indicates traceability has ended. "time" indicates when the traceability data was uploaded to the blockchain. In the diagram, the product with goodid 1 has completed traceability. If the smart contract data recovery calculation begins at this point, the data for product with goodid 1 can be recovered, meaning it is pending. The data for products with goodid ≠ 1, i.e., products with goodids 2, 3, or 4, must be retained and reassembled in Sidechain 2. The status of goods with goodid=2, 3 or 4 is all in tracing in progress. At this time, the data of goods with goodid=2, 3 or 4 scattered in the four blocks of block 1, block 2, block 3 and block 4 are taken out and summarized by goodid. The result of the summary is: the goods with goodid=2 have data 1.2, data 2.2, data 3.2 and data 4.2; the goods with goodid=3 have data 1.3, data 2.3, data 3.3 and data 4.3; the goods with goodid=4 have data 3.4 and data 4.4.
[0130] like Figure 7 As shown, Figure 7 Figure 7 shows the status of the new side chain in which data is not recycled in this round. The block status of the goods with goodid = 2, 3, or 4 in the new side chain is shown in Figure 7. The time for completing traceability of the goods with goodid = 2, 3, or 4 is predicted, that is, the frequency of uploaded traceability data is used for estimation. That is, the more frequent the upload, that is, the smaller the frequency value, the more likely it is that the traceability data will be uploaded the earliest. The first upload time of goodid=2 is 2023-01-02 12:00:00, and the last upload time is 2023-02-02 12:00:00. A total of 31 days have been uploaded 4 times, with an average upload frequency of 7.78 days / time; the first upload time of goodid=3 is 2023-01-03 12:00:00, and the last upload time is 2023-01-18 12:00:00. A total of 16 days have been uploaded 4 times, with an average upload frequency of 4 days / time; the first upload time of goodid=4 is 2023-01-11 12:00:00. The last upload time is 2023-03-03 12:00:00. A total of 52 days have passed and the upload has been done twice, with an average upload frequency of 26 days / time. Therefore, the order of completion of traceability for products with goodid=2, 3, or 4 is predicted to be goodid=3, goodid=2, and goodid=4.
[0131] Furthermore, the determining of the data to be recycled based on the target product and the data table to be recycled includes: packaging the traceability data corresponding to the target product into blocks and sending them to the main chain for consensus and storage to obtain the stored target product; obtaining the identifier of the stored target product and updating the data table to be recycled based on the identifier; querying the recycling status corresponding to each product identifier in the data table to be recycled to obtain the number of unrecovered traceability data; and determining the data to be recycled based on the number of unrecovered traceability data.
[0132] It should be noted that the traceability data corresponding to the stored target product identifier goodId has been agreed upon and stored in the main chain. The data of the stored target product identifier goodId will be written into the table to be recovered data table as the data record to be recovered in the side chain.
[0133] It can be understood that the recycling status corresponding to each commodity identifier in the data table to be recycled is queried to obtain the number of unrecycled traceability data, that is, the number K of unrecycled data in the data table to be recycled is queried; if K≥the contract_runway field in the contract data structure (contract triggering method), that is, K≥contract_runway, it means that the side chain data storage space can be recycled, and the contract_runway data is queried from the data table to be recycled to obtain the data to be recycled.
[0134] Furthermore, before step S20, the process also includes packaging the on-chain data into blocks and publishing them to the first side chain, wherein the on-chain data includes the traceability status and traceability data of the product; reaching consensus on the on-chain data through each node in the blockchain to obtain the consensus on-chain data; and storing the consensus on-chain data to the first side chain through each node in the blockchain.
[0135] It should be noted that the data that needs to be uploaded to the chain is packaged into a block and published to the first side chain, which is marked as the main side block. Each node in the blockchain reaches a consensus on the data that needs to be uploaded to the chain based on the consensus algorithm. After the consensus, each node in the blockchain stores the data locally on the first side chain to facilitate the subsequent acquisition of the product's traceability status and traceability data, and to execute smart contracts to improve recycling efficiency. The data that needs to be uploaded to the chain includes the product's traceability status and traceability data. The traceability status includes three states: traceability start, traceability in progress, and traceability end.
[0136] It can be understood that the underlying service device of the alliance chain blockchain is divided into the various alliance node management platforms and blockchain node services of the blockchain alliance chain; the alliance node management platform mainly includes sub-modules such as alliance management, alliance key generation, encryption, platform login and authentication, and smart contract issuance; the blockchain node service mainly includes sub-modules such as block design and packaging, P2P network construction, consensus algorithm for block chain, and local storage of blocks.
[0137] like Figure 8 As shown, Figure 8 This is the deployment architecture diagram of the alliance chain blockchain underlying service device. The alliance chain underlying service must first start the alliance super node of the alliance chain. This node has the alliance chain node management capability, which is provided by the alliance node management platform. After the platform is started, each node in the alliance chain can start by itself. When the node starts, it will interact with the alliance node management platform for data, mainly involving the acquisition of the alliance node list in order to establish a communication network with other nodes, and the acquisition of the public and private keys for encryption and decryption of the alliance node.
[0138] It is worth noting that when a smart contract needs to be generated, the values of the corresponding fields are filled in according to the data structure of the smart contract to complete the assembly of the smart contract data. Subsequently, the contract is published on the management backend of the blockchain alliance chain and enters the alliance chain for consensus and local storage of the contract at each node.
[0139] After each node of the blockchain reaches consensus according to the consensus algorithm, the smart contract needs to be stored locally. As shown in Table 2, Table 2 is the storage table of the smart contract in the local relational database. The table includes the number, field name, field type and field meaning. The field names include int, contract_name, contract_version, contract_runway, etc. The field types include int, Varchar (100), datetime, tinyint, etc. The field meaning includes the default auto-increment id in the database, which is regarded as the contract number, contract name, contract version, contract trigger method, contract metadata storage, contract data storage, contract storage, contract metadata verification, contract data area verification, contract area data verification, data entry time, contract status, when offline, the value is 1, the default is 0, which is the non-offline state, etc. For the convenience of reading, writing and maintainability, the fields in the table are named the same as the fields in the contract. The metadata, data area, contract area data and corresponding verification data in the contract are written into the 1st to 10th fields of the table respectively. This completes the storage of local data.
[0140] Table 2
[0141]
[0142] It should be noted that after the smart contract is reached through consensus and localized storage at each node in the alliance chain, the data on the chain can be uploaded to the chain for consensus and storage based on actual conditions. The data on the chain includes the traceability data of the goods, which may be agricultural products.
[0143] It is understood that after the on-chain data is packaged into a block (marked as a sidechain block), consensus is formed in the consortium chain sidechain and local storage can be performed. To facilitate the recovery of the sidechain's data space, the business data in the block is stored from a block perspective, as shown in Table 3. Table 3 is a table of on-chain data stored in the block. The table includes the number, field name, field type, and field meaning. Field names include int, block_num, goodid, good_info, create_time, side_num, etc. Field types include int, text, datetime, etc. The int field means the default auto-increment id in the database. The block_num field means the block number on the sidechain. The next block of the genesis block is numbered 1, and subsequent numbers are continuously incremented. The goodid field means the traceability product number. The create_time field means the data entry time. The side_num field means the sidechain number. The first sidechain is numbered 1 and the second sidechain is numbered 2. When the first sidechain is recovered, the second sidechain data field is changed to 1.
[0144] Table 3
[0145]
[0146] It is understood that after the sidechain data is on-chain consensus and stored, the sidechain data storage space recovery smart contract is executed. When the execution result of contract function 1 (i.e., the contract function that determines whether certain sidechain data has been submitted to the main chain) is TRUE, the data traceable in the consensus block can be packaged as a whole into the main chain consensus and storage. The current business data is retrieved from the data table to be recovered, and the data to be recovered is obtained. The data query condition is that the data when goodid meets the requirements and side_num = 1.
[0147] This embodiment obtains the traceability status and traceability data of the product in the first side chain; executes the first contract function and the second contract function based on the traceability status and traceability data of the product to obtain the target product and the data table to be recovered; and determines the data to be recovered based on the target product and the data table to be recovered. In this way, the contract function in the smart contract is executed based on the traceability status and traceability data of the product to obtain the target product and the data table to be recovered and determine the data to be recovered, thereby recovering storage space based on the data to be recovered, thereby improving storage space recovery efficiency.
[0148] Reference Figure 9 , Figure 9 This is a structural block diagram of the first embodiment of the storage space recovery device of the present invention.
[0149] like Figure 9 As shown, the storage space recovery device proposed in the embodiment of the present invention includes:
[0150] The publishing module 10 is used to generate a smart contract based on the side chain data recovery rules and publish the smart contract to the blockchain, wherein the blockchain includes a main chain and a first side chain, and the main chain and the first side chain include multiple blocks.
[0151] The execution module 20 is used to obtain the traceability status and traceability data of the goods in the first side chain, and execute the smart contract according to the traceability status and traceability data of the goods to obtain the data to be recovered.
[0152] The filtering module 30 is configured to filter the blocks in the first side chain according to the data to be recycled to obtain unrecycled blocks.
[0153] The sorting module 40 is configured to calculate the upload frequency of the traceability data of the unrecovered blocks, and sort the unrecovered blocks according to the upload frequency to generate a second side chain.
[0154] The recycling module 50 is configured to recycle storage space based on the second side chain.
[0155] This embodiment generates a smart contract based on the side chain data recovery rule and publishes the smart contract to the blockchain, wherein the blockchain includes a main chain and a first side chain, and the main chain and the first side chain include multiple blocks; obtains the traceability status and traceability data of the goods in the first side chain, and executes the smart contract according to the traceability status and traceability data of the goods to obtain the data to be recovered; filters the blocks in the first side chain according to the data to be recovered to obtain unrecovered blocks; calculates the upload frequency of the traceability data of the unrecovered blocks, and sorts the unrecovered blocks according to the upload frequency to generate a second side chain; and recycles storage space based on the second side chain. Through the above method, the smart contract is executed according to the traceability status and traceability data of the goods to determine the data to be recovered, and the first side chain is filtered according to the data to be recovered to obtain unrecovered blocks, thereby generating a second side chain and reclaiming storage space, solving the problems of high storage space expansion cost, affecting data synchronization and consensus efficiency, reducing data storage cost, and high data recovery efficiency.
[0156] In one embodiment, the execution module 20 is further used to obtain the traceability status and traceability data of the goods in the first side chain; execute the first contract function and the second contract function according to the traceability status and traceability data of the goods to obtain the target goods and the data table to be recovered; and determine the data to be recovered based on the target goods and the data table to be recovered.
[0157] In one embodiment, the execution module 20 is further used to package the traceability data corresponding to the target product into blocks and send them to the main chain for consensus and storage to obtain the stored target product; obtain the identifier of the stored target product, and update the data table to be recycled according to the identifier; query the recycling status corresponding to each product identifier in the data table to be recycled to obtain the number of unrecovered traceability data; determine the data to be recycled based on the number of unrecovered traceability data.
[0158] In one embodiment, the sorting module 40 is further configured to calculate an upload frequency of the traceability data of the unrecovered blocks; sort the unrecovered blocks according to the upload frequency to obtain a sorting result; adjust the traceability data and the unrecovered blocks in the unrecovered blocks according to the sorting result to obtain an unrecovered block sequence; and obtain a second side chain based on the unrecovered block sequence.
[0159] In one embodiment, the publishing module 10 is further used to generate a smart contract based on the side chain data recovery rules; publish the smart contract to the first side chain of the blockchain; reach consensus on the smart contract through each node in the blockchain to obtain a consensus smart contract; and store the smart contract to the first side chain through each node in the blockchain.
[0160] In one embodiment, the execution module 20 is further used to package the on-chain data into blocks and publish them to the first side chain, wherein the on-chain data includes the traceability status and traceability data of the product; consensus is reached on the on-chain data through each node in the blockchain to obtain the consensus on-chain data; and the consensus on-chain data is stored in the first side chain through each node in the blockchain.
[0161] In one embodiment, the recycling module 50 is further used to determine duplicate data in the main chain based on the data to be recycled; delete the duplicate data in the main chain and delete the first side chain; and use the second side chain as a new first side chain to achieve storage space recycling.
[0162] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage space recovery device, which includes: a memory, a processor, and a storage space recovery program stored on the memory and runnable on the processor, and the storage space recovery program is configured to implement the steps of the storage space recovery method described above.
[0163] Since the storage space recovery device adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0164] In addition, an embodiment of the present invention further provides a storage medium having a storage space recovery program stored thereon. When the storage space recovery program is executed by a processor, the steps of the storage space recovery method described above are implemented.
[0165] Since the storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0166] It should be understood that the above is only an example and does not constitute any limitation to the technical solution of the present invention. In specific applications, those skilled in the art can make settings as needed, and the present invention does not impose any limitation on this.
[0167] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of it according to actual needs to achieve the purpose of the embodiment scheme, and no limitation is made here.
[0168] In addition, for technical details not fully described in this embodiment, reference can be made to the storage space recovery method provided in any embodiment of the present invention, and will not be repeated here.
[0169] In addition, it should be noted that, in this document, the terms "comprise," "include," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a..." does not preclude the presence of other identical elements in the process, method, article, or system comprising the element.
[0170] It should be understood that, although the various steps in the flowchart in the embodiment of the present application are shown in sequence according to the indication of the arrows, these steps are not necessarily performed in sequence in the order indicated by the arrows. Unless clearly stated herein, the execution of these steps is not strictly limited in order, and they can be performed in other orders. Moreover, at least a portion of the steps in the figure may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and their execution order is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of other steps or sub-steps or stages of other steps.
[0171] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0172] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, or of course by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0173] 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 description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.< / int> < / int>
Claims
1. A storage space recovery method, characterized in that: The method comprises: Generate a smart contract based on the side chain data recovery rules, and publish the smart contract to a blockchain, wherein the blockchain includes a main chain and a first side chain, and the main chain and the first side chain include multiple blocks; Obtaining the traceability status and traceability data of the product in the first side chain; Executing the first contract function and the second contract function of the smart contract according to the traceability status and traceability data of the commodity to obtain a target commodity and a data table to be recycled; Determining the data to be recycled according to the target product and the table of data to be recycled; Filtering the blocks in the first side chain according to the data to be recycled to obtain unrecycled blocks; Calculate the upload frequency of the traceability data of the unrecovered blocks; Sorting the unrecycled blocks according to the upload frequency to obtain a sorting result; Adjusting the traceability data and the unrecovered blocks in the unrecovered blocks according to the sorting result to obtain an unrecovered block sequence; Obtaining a second side chain according to the unrecovered block sequence; Determine duplicate data in the main chain based on the data to be recovered; Deleting duplicate data in the main chain and deleting the first side chain; The second side chain is used as a new first side chain to achieve storage space recovery.
2. The method according to claim 1, wherein The determining of the data to be recycled according to the target product and the table of data to be recycled includes: The traceability data corresponding to the target product is packaged into blocks and sent to the main chain for consensus and storage to obtain the stored target product; Obtaining the identifier of the stored target commodity, and updating the to-be-recycled data table according to the identifier; Query the recycling status corresponding to each commodity identifier in the to-be-recycled data table to obtain the number of unrecycled traceability data; The data to be recovered is determined based on the amount of unrecovered traceability data.
3. The method according to claim 1, wherein The generating of a smart contract based on the side chain data recovery rules and publishing the smart contract to the blockchain includes: Generate smart contracts based on sidechain data recovery rules; Publishing the smart contract to a first sidechain of the blockchain; The smart contract is reached through consensus among the nodes in the blockchain to obtain a consensus smart contract; The smart contract is stored in the first side chain through each node in the blockchain.
4. The method according to claim 1, wherein The obtaining of the traceability status and traceability data of the commodity in the first side chain, and executing the smart contract according to the traceability status and traceability data of the commodity, and determining the data to be recovered, further includes: Packaging the on-chain data into blocks and publishing them to the first sidechain, wherein the on-chain data includes the traceability status and traceability data of the product; The nodes in the blockchain reach a consensus on the on-chain data to obtain the consensus on-chain data; The consensus-based on-chain data is stored in the first side chain through each node in the blockchain.
5. A storage space recovery device, characterized in that: The storage space recovery device includes: A publishing module, configured to generate a smart contract based on the side chain data recovery rules and publish the smart contract to a blockchain, wherein the blockchain includes a main chain and a first side chain, and the main chain and the first side chain include multiple blocks; an execution module, configured to obtain the traceability status and traceability data of the commodity in the first side chain; execute the first contract function and the second contract function of the smart contract according to the traceability status and traceability data of the commodity to obtain a target commodity and a table of data to be recovered; and determine the data to be recovered according to the target commodity and the table of data to be recovered; a filtering module, configured to filter the blocks in the first side chain according to the data to be recycled to obtain unrecycled blocks; a sorting module, configured to calculate an upload frequency of the traceability data of the unrecovered blocks; sort the unrecovered blocks according to the upload frequency to obtain a sorting result; adjust the traceability data and unrecovered blocks in the unrecovered blocks according to the sorting result to obtain an unrecovered block sequence; and obtain a second side chain based on the unrecovered block sequence; The recycling module is used to determine duplicate data in the main chain according to the data to be recycled; delete the duplicate data in the main chain and delete the first side chain; and use the second side chain as a new first side chain to realize storage space recycling.
6. A storage space recovery device, characterized in that: The storage space recovery device includes: a memory, a processor, and a storage space recovery program stored in the memory and executable on the processor, wherein the storage space recovery program is configured to implement the storage space recovery method according to any one of claims 1 to 4.
7. A storage medium, characterized in that: The storage medium stores a storage space recovery program, which, when executed by a processor, implements the storage space recovery method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Commodity traceability system based on block chain and big data technology
CN111539750A
Industrial product circulation life cycle tracing management system based on permissioned blockchain and application thereof
CN112348539A