A method and apparatus for space recycling for IPFS

By establishing Merkle Tree nodes in IPFS and monitoring data operations, and independently performing space reclamation, the global locking problem in large-scale data storage is solved, achieving lock-free space reclamation and improving the availability and efficiency of storage services.

CN114490434BActive Publication Date: 2025-10-24SHANGHAI KUNYAO NETWORK SCI & TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210085537.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-25
Publication Date
2025-10-24
Estimated Expiration
2042-01-25

AI Technical Summary

Technical Problem

When storing large amounts of data, the existing IPFS requires global locking during the space reclamation process, which causes the storage service to be unavailable for a long time, affecting business operations.

Method used

By creating Merkle Tree nodes corresponding to Merkle DAG nodes in IPFS, setting node type and reference relationship attributes, monitoring data operations and modifying these attributes to determine reclaimable nodes, and independently performing space reclamation, global locking is avoided.

Benefits of technology

It enables space reclamation without affecting IPFS data operations, reduces global locking time, and improves the availability and efficiency of storage services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114490434B_ABST
    Figure CN114490434B_ABST
Patent Text Reader

Abstract

The purpose of the present application is to provide a space recycling method and device for IPFS. Compared with the prior art, the present application establishes a Merkle Tree node corresponding to each Merkle DAG node in the IPFS, wherein the Merkle Tree node is provided with a node type attribute and a reference relationship attribute, and saves the CID of the corresponding Merkle DAG node; when receiving a space recycling instruction, the Merkle Tree node is traversed to determine the recyclable node based on the node type attribute and the reference relationship attribute; the corresponding Merkle DAG node of the recyclable node is determined based on the CID saved in the recyclable node, and the space of the Merkle DAG node is recycled in the IPFS. In this way, the storage service and the space recycling service of the IPFS are separated, so that the space recycling is independent of the storage task, thereby, the IPFS does not need to be globally locked when recycling the space, and at the same time, the space recycling task does not limit the fixed operation of the IPFS on the data.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, and particularly relates to a space recycling technology for IPFS. BACKGROUND

[0002] When the disk space is insufficient, the space recycling period is reached or the ipfs repo gc command is run, the IPFS starts a disk space recycling task. In order to avoid the influence of the increase or deletion of the fixed operation during recycling, the IPFS performs global locking before starting the space recycling, and the locking is released after the recycling is completed. During the global locking time, the IPFS cannot perform the fixed operation. If the volume of the stored data of the IPFS is small, the time consumption of the space recycling is short, and the influence of the global locking is not great. However, when the volume of the stored data is large, the time required for the space recycling is quite long, and recycling 100 TB of data may take several hours. For a PB level of data volume, the global locking time during recycling may be as long as several days. However, in the actual application scenario, the enterprise-level storage service cannot accept such a long global locking, and the inability to perform the fixed operation will inevitably affect the storage business. Therefore, a space recycling method for the IPFS without global locking is needed, so that the recycling operation does not affect the storage service. SUMMARY

[0003] The purpose of the present application is to provide a space recycling method and device for IPFS.

[0004] According to one aspect of the present application, a method for space recycling of IPFS is provided, wherein the method comprises:

[0005] establishing a Merkle Tree node corresponding to each Merkle DAG node in the IPFS, wherein the Merkle Tree node is provided with a node type attribute and a reference relationship attribute, and saves the CID of the corresponding Merkle DAG node;

[0006] when receiving a space recycling instruction, traversing the Merkle Tree node to determine the recyclable node based on the node type attribute and the reference relationship attribute;

[0007] determining the corresponding Merkle DAG node based on the CID saved in the recyclable node, and recycling the space of the Merkle DAG node in the IPFS.

[0008] Further, the method further comprises:

[0009] According to the data operation on the Merkle DAG node in the IPFS, the node type attribute and / or the reference relationship attribute of the corresponding Merkle Tree node are changed, wherein the node type attribute and the reference relationship attribute have initial default values.

[0010] Further, the data operation includes direct fixing and recursive fixing, wherein the data operation on the Merkle DAG node in the IPFS changes the node type attribute and / or the reference relationship attribute of the corresponding Merkle Tree node, including:

[0011] If the data operation of the Merkle DAG node is direct fixing, the node type attribute of the corresponding Merkle Tree node is changed to a direct fixing attribute; or,

[0012] If the data operation of the Merkle DAG node is recursive fixing, the node type attribute of the corresponding Merkle Tree node is changed to a recursive fixing attribute, and the reference relationship attribute of all nodes of the Merkle Tree where the Merkle Tree node is located is changed.

[0013] Further, wherein the change of the reference relationship attribute of all nodes of the Merkle Tree where the Merkle Tree node is located includes:

[0014] Traversing the Merkle Tree where the Merkle Tree node is located;

[0015] The reference relationship attribute of the traversed Merkle Tree node is changed to the direct parent node information of the Merkle Tree node.

[0016] Further, the data operation also includes releasing direct fixing, and the data operation on the Merkle DAG node in the IPFS changes the node type attribute and / or the reference relationship attribute of the corresponding Merkle Tree node, including:

[0017] The node type attribute of the Merkle Tree node corresponding to the Merkle DAG node releasing direct fixing is changed to the initial default value.

[0018] Further, the data operation also includes releasing recursive fixing, and the data operation on the Merkle DAG node in the IPFS changes the node type attribute and / or the reference relationship attribute of the corresponding Merkle Tree node, including:

[0019] change the node type attribute of the Merkle Tree node corresponding to the Merkle DAG node of which recursion fixing is released to an initial default value;

[0020] traverse the Merkle Tree node to which the Merkle Tree node belongs;

[0021] change the reference relationship attribute of the traversed Merkle Tree node to an initial default value.

[0022] Further, the traversing the Merkle Tree node upon receiving the space recycling instruction to determine the recyclable node based on the node type attribute and the reference relationship attribute comprises:

[0023] traverse the Merkle Tree node upon receiving the space recycling instruction;

[0024] when the node type attribute and the reference relationship attribute of the traversed Merkle Tree node are both the initial default value, determine that the traversed Merkle Tree node is the recyclable node.

[0025] Preferably, the Merkle Tree node is further provided with a node ID attribute, and the traversing the Merkle Tree node upon receiving the space recycling instruction to determine the recyclable node based on the node type attribute and the reference relationship attribute comprises:

[0026] traverse the Merkle Tree node upon receiving the space recycling instruction and record the node ID attribute of the traversed Merkle Tree node;

[0027] after the change of the node type attribute and / or the reference relationship attribute of the Merkle Tree node corresponding to the data operation is completed, continue to traverse the Merkle Tree node according to the recorded node ID attribute.

[0028] Preferably, the determining the Merkle DAG node corresponding to the recyclable node based on the CID saved in the recyclable node and recycling the space of the Merkle DAG node in the IPFS further comprises:

[0029] accumulate and record the data block size of the Merkle DAG node corresponding to the recyclable node to count the size of the recycled space.

[0030] According to another aspect of the present application, a computer readable medium is also provided, which stores computer readable instructions executable by a processor to implement the operations of the foregoing method.

[0031] According to still another aspect of the present application, there is also provided a space recycling device for IPFS, wherein the device comprises:

[0032] one or more processors; and

[0033] a memory storing computer readable instructions that, when executed, cause the processor to perform the operations of the above method.

[0034] Compared with the prior art, the present application establishes a Merkle Tree node corresponding to each Merkle DAG node in the IPFS, wherein the Merkle Tree node is provided with a node type attribute and a reference relationship attribute, and saves the CID of the corresponding Merkle DAG node; when receiving a space recycling instruction, the Merkle Tree node is traversed to determine the recyclable node based on the node type attribute and the reference relationship attribute; the corresponding Merkle DAG node of the recyclable node is determined based on the CID saved in the recyclable node, and the space recycling of the Merkle DAG node is performed in the IPFS. In this way, the storage service and the space recycling service of the IPFS are separated, so that the space recycling is implemented independently of the storage task, thereby avoiding the global locking of the IPFS when recycling the space, and the space recycling task also does not limit the fixed operation of the IPFS on data. BRIEF DESCRIPTION OF DRAWINGS

[0035] Other features, objects, and advantages of the application will become more apparent from the following detailed description of non-limiting embodiments, when read in conjunction with the accompanying drawings:

[0036] Figure 1 a flow chart of a method for space recycling of IPFS according to an aspect of the present application is shown;

[0037] Figure 2 a flow chart of a method for space recycling of IPFS according to a preferred embodiment of the present application is shown.

[0038] The same or similar reference signs in the drawings represent the same or similar components. DETAILED DESCRIPTION

[0039] The present application will be further described in detail below with reference to the accompanying drawings.

[0040] In a typical configuration of the present application, the terminal, the device of the service network and the trusted party each comprise one or more processors (CPU), an input / output interface, a network interface and a memory.

[0041] Memory can include non-persistent memory, Random Access Memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash memory, in computer-readable media. Memory is an example of computer-readable media.

[0042] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology for storing information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device. According to the definition herein, computer-readable media does not include non-transitory computer-readable media, such as modulated data signals and carriers.

[0043] In order to further illustrate the technical means adopted by the present application and the effects achieved, the technical solutions of the present application will be described clearly and completely in conjunction with the drawings and preferred embodiments.

[0044] Figure 1 An aspect of the present application provides a method for, as shown in the figure, wherein the method comprises:

[0045] S11, a Merkle Tree node corresponding to each Merkle DAG node in the IPFS is established, wherein the Merkle Tree node is provided with a node type attribute and a reference relationship attribute, and saves the CID of the corresponding Merkle DAG node;

[0046] S12, when receiving a space recycling instruction, traversing the Merkle Tree node to determine the recyclable node based on the node type attribute and the reference relationship attribute;

[0047] S13, determining the corresponding Merkle DAG node based on the CID saved in the recyclable node, and recycling the space of the Merkle DAG node in the IPFS.

[0048] In this embodiment, in the step S11, a Merkle Tree node corresponding to each Merkle DAG node in the IPFS is established, wherein the Merkle Tree node is provided with a node type attribute and a reference relationship attribute, and saves the CID of the corresponding Merkle DAG node.

[0049] IPFS stores data in the form of a Merkle DAG. Files are split into multiple data blocks based on size, arranged in a tree structure, and each node in the tree is uniquely identified by a CID. The space reclamation service monitors the data storage service to fully map the Merkle DAG structure created by the data storage service. However, it does not store the actual data, but rather the index relationship between the corresponding Merkle DAG nodes of the data storage service and the CIDs of the Merkle DAG nodes' children. This process of fully mapping the data storage service's Merkle DAG can be implemented using a message queue. For example, when the data storage service splits a file into two data blocks, organizing the file into a Merkle DAG with one root node and two leaf nodes, the index relationship between these three nodes is written to the message queue. This means that the message queue will store three messages representing each node. The message representing the root node contains the root node's CID and the CIDs of its two child nodes, while the message representing the leaf nodes contains the CIDs of each leaf node. When a message exists in the message queue, the space reclamation task consumes it, establishes a corresponding Merkle Tree structure (since the tree structure established by the space reclamation service differs from the Merkle DAG, it is summarized as a Merkle Tree structure to distinguish it from the Merkle DAG structure established by the data storage service). The CID of the node in the message itself is stored in the Merkle Tree node, and the connection relationship of the Merkle Tree is established based on the CID of the child node in the message. In this way, a Merkle Tree structure corresponding to the data storage service is established. This Merkle Tree structure is consistent with the original Merkle DAG structure in terms of connection relationship, differing only in the specific content stored. It should be understood that the process of adding a Merkle Tree node corresponds to the IPFS operation of adding data. Only when IPFS adds a new Merkle DAG node will the space reclamation service add the corresponding Merkle Tree node. This method establishes a mapping of the IPFS data storage service and performs space reclamation services in the mapped Merkle Tree structure. This method separates the IPFS storage service from the space reclamation service, allowing space reclamation to be implemented independently of the storage task. Therefore, there is no need to globally lock IPFS during space reclamation. At the same time, the space reclamation task will not limit IPFS's fixed operations on data.

[0050] Further, according to the data operation on the Merkle DAG node in the IPFS, the node type attribute and / or the reference relationship attribute of the corresponding Merkle Tree node are changed, wherein the node type attribute and the reference relationship attribute have initial default values.

[0051] Here, the monitoring of the data storage service by the space recycling service includes but is not limited to the direct fixing operation and the recursive fixing operation of the IPFS (the nodes subjected to the fixing operation and the direct fixing operation will not be recycled in the space recycling), and the message queue records the type of the data operation and the CID of the operation object corresponding to the fixing operation or the recursive fixing operation. It should be noted that the operation object of the fixing operation and the recursive fixing operation is only the Merkle DAG node that has been stored in the IPFS, and therefore, the space recycling service only modifies the attribute of the established Merkle Tree node by consuming the message representing the fixing operation or the recursive fixing operation in the message queue. The message representing the fixing operation or the recursive fixing operation in the message queue saves the operation type and the CID of the operation object, and the space recycling service modifies the node type attribute and / or the reference relationship attribute of the Merkle Tree node by consuming such a message, wherein the initial default value of the node type attribute represents that the Merkle Tree node is a normal node, and the initial default value of the reference relationship attribute only represents the child node information of the Merkle Tree node, which can be the CID of the child node. The node type attribute and the reference relationship attribute both being the initial default value indicate that the node is a normal node that has not been subjected to the fixing operation and can be recycled in the space recycling.

[0052] Further, the data operation includes the direct fixing and the recursive fixing, and the changing of the node type attribute and / or the reference relationship attribute of the corresponding Merkle Tree node according to the data operation on the Merkle DAG node in the IPFS includes:

[0053] If the data operation of the Merkle DAG node is the direct fixing, the node type attribute of the corresponding Merkle Tree node is changed to the direct fixing attribute; or,

[0054] If the data operation of the Merkle DAG node is the recursive fixing, the node type attribute of the corresponding Merkle Tree node is changed to the recursive fixing attribute, and the reference relationship attribute of all nodes of the Merkle Tree where the Merkle Tree node is located is changed.

[0055] When the data operation is direct fixing, the message content of the operation in the message queue includes the CID of the operation object and the operation type is direct fixing. When the space recycling task consumes the message, the Merkle Tree node is indexed in the mapped Merkle Tree structure according to the CID of the operation object, and the node type attribute of the node is modified to the direct fixing attribute. When the data operation is recursive fixing, since the recursive fixing is to fix the entire Merkle DAG in which the operation object is located in the IPFS data storage service, when the space recycling task consumes the message, in addition to indexing the Merkle Tree node in the mapped Merkle Tree structure according to the CID of the operation object and modifying the node type attribute of the node to the recursive fixing attribute, the reference relationship attribute of all nodes of the Merkle Tree in which the Merkle Tree node is located also needs to be modified.

[0056] Further, the modification of the reference relationship attribute of all nodes of the Merkle Tree in which the Merkle Tree node is located includes:

[0057] traversing the Merkle Tree in which the Merkle Tree node is located; and changing the reference relationship attribute of the traversed Merkle Tree node to the direct parent node information of the Merkle Tree node.

[0058] Here, when modifying the reference relationship attribute in recursive fixing, first, the Merkle Tree node is indexed in the mapped Merkle Tree structure according to the CID of the operation object in the message queue, and then the Merkle Tree in which the Merkle Tree node is located is traversed. In the traversing process, the CID information saved in the currently traversed node is recorded. When the child node of the node is traversed, the saved CID information is added to the reference relationship attribute of the child node. Through the operation, the mapped Merkle Tree establishes a directed cyclic loop, so that, unlike the Merkle DAG structure of the IPFS data storage service, the space recycling service after recursive fixing actually establishes a directed cyclic graph structure.

[0059] Further, the data operation further includes direct fixing release, and the modification of the node type attribute and / or the reference relationship attribute of the corresponding Merkle Tree node of the Merkle DAG node in the IPFS according to the data operation of the Merkle DAG node includes:

[0060] the node type attribute of the Merkle Tree node corresponding to the Merkle DAG node to be released from direct fixing is changed to an initial default value.

[0061] In this case, the data operation monitored by the space recycling service includes, in addition to the direct fixing and the recursive fixing, the unfixing of the direct fixing. The message representing the unfixing of the direct fixing in the message queue also saves the CID of the operation type and the operation object. The space recycling service consumes the message, indexes the operation object corresponding to the Merkle Tree node in the mapped Merkle Tree through the CID of the operation object, and restores the node type attribute to the initial default value according to the operation type of the unfixing of the direct fixing. In this way, the directly fixed node is restored to a normal node that can be recycled.

[0062] Further, the data operation further includes the unfixing of the recursive fixing. The data operation performed on the Merkle DAG node in the IPFS changes the node type attribute and / or the reference relationship attribute of the corresponding Merkle Tree node, and includes:

[0063] The node type attribute of the Merkle Tree node corresponding to the Merkle DAG node to be un-fixed is changed to the initial default value. The Merkle Tree in which the Merkle Tree node is located is traversed. The reference relationship attribute of the traversed Merkle Tree node is changed to the initial default value.

[0064] In this case, the data operation monitored by the space recycling service includes, in addition to the direct fixing, the recursive fixing, and the unfixing of the direct fixing, the unfixing of the recursive fixing. The message representing the unfixing of the recursive fixing in the message queue also saves the CID of the operation type and the operation object. The space recycling service consumes the message, indexes the operation object corresponding to the Merkle Tree node in the mapped Merkle Tree through the CID of the operation object, and restores the node type attribute to the initial default value according to the operation type of the unfixing of the recursive fixing. In this way, the directly fixed node is restored to a normal node that can be recycled.

[0065] In this embodiment, when the space recycling instruction is received in the step S12, the Merkle Tree node is traversed to determine the recyclable node based on the node type attribute and the reference relationship attribute.

[0066] Further, when the space recycling instruction is received, the Merkle Tree node is traversed to determine the recyclable node based on the node type attribute and the reference relationship attribute.

[0067] When receiving the space recycling instruction, the Merkle Tree nodes are traversed; when the node type attribute and the reference relationship attribute of the traversed Merkle Tree node are both initial default values, it is determined that the traversed Merkle Tree node is a recyclable node.

[0068] Here, when the space recycling service receives the space recycling instruction, all the established Merkle Tree structures are traversed to perform global space recycling; when the node type attribute and the reference relationship attribute of the traversed node are both initial default values, it is determined that the traversed Merkle Tree node is a recyclable node.

[0069] Preferably, the Merkle Tree node is further provided with a node ID attribute, and the traversing the Merkle Tree nodes to determine the recyclable node based on the node type attribute and the reference relationship attribute when receiving the space recycling instruction comprises:

[0070] When receiving the space recycling instruction, the Merkle Tree nodes are traversed, and the node ID attribute of the traversed Merkle Tree node is recorded; after the node type attribute and / or the reference relationship attribute of the data operation corresponding Merkle Tree node are changed, the Merkle Tree nodes are continued to be traversed according to the recorded node ID attribute.

[0071] Here, a node ID attribute is set for each of the mapped Merkle Tree nodes, and the node ID attribute is the CID of the node. Further, when performing the space recycling task, the current traversal position can be recorded by recording the node ID attribute of the traversed Merkle Tree node. In this way, when a new data operation message enters the message queue during the traversal process, the message can be consumed first, the node type attribute and / or the reference relationship attribute of the operation object corresponding Merkle Tree node of the message are changed, and after the operation is completed, the traversal process of the previous space recycling is continued according to the recorded node ID attribute. This way realizes the interruptible and recoverable space recycling.

[0072] In another embodiment, the space recycling instruction contains the CID of the IPFS Merkle DAG node, so the Merkle Tree node corresponding to the Merkle DAG node can be indexed according to the CID of the Merkle DAG node, and the traversal process of the space recycling task is started from the Merkle Tree node. In this way, the recycling starting position of the space recycling task can be specified, and directional space recycling is realized.

[0073] In this embodiment, in the step S13, the corresponding Merkle DAG node of the recyclable node is determined based on the CID stored in the recyclable node, and the space of the Merkle DAG node is recycled in the IPFS.

[0074] Here, since the CID of the corresponding Merkle DAG node is stored in the mapped Merkle Tree node, when the recyclable node is determined, the corresponding Merkle DAG node in the IPFS data storage service is determined based on the CID stored in the recyclable node, and then the space of the Merkle DAG node is recycled.

[0075] In a preferred embodiment, referring to Figure 2 , wherein, Figure 2 The steps S21, S22 and S24 in Figure 1 The steps S11, S12 and S13 in the embodiment are the same or substantially the same as the steps S11, S12 and S13 in the embodiment, and thus are not described here again, but are included herein by reference. The step S23 includes: accumulating the data block size of the Merkle DAG node corresponding to the recyclable node to count the space size recycled this time.

[0076] Here, after the recyclable node is determined, the data block size of the Merkle DAG node corresponding to the IPFS data storage service of the recyclable node is counted, and in this way the total recycled space of this space recycling can be counted.

[0077] Compared with the prior art, the present application establishes the Merkle Tree node corresponding to the Merkle DAG node in the IPFS one by one, wherein the Merkle Tree node is provided with a node type attribute and a reference relationship attribute, and stores the CID of the corresponding Merkle DAG node; when receiving a space recycling instruction, the Merkle Tree node is traversed to determine the recyclable node based on the node type attribute and the reference relationship attribute; the corresponding Merkle DAG node of the recyclable node is determined based on the CID stored in the recyclable node, and the space of the Merkle DAG node is recycled in the IPFS. In this way, the storage service of the IPFS is separated from the space recycling service, so that the space recycling is realized independently of the storage task, so that the IPFS does not need to be globally locked when recycling the space, and at the same time, the space recycling task also does not limit the fixed operation of the IPFS on data.

[0078] In addition, the embodiment of the present application also provides a computer readable medium having computer readable instructions stored thereon, and the computer readable instructions can be executed by a processor to implement the foregoing method.

[0079] The embodiment of the present application also provides a space recycling device for IPFS, wherein the device comprises:

[0080] one or more processors; and

[0081] a memory storing computer readable instructions which, when executed, cause the processor to perform the operations of the foregoing method.

[0082] For example, the computer readable instructions, when executed, cause the one or more processors to: establish a Merkle Tree node corresponding to each Merkle DAG node in the IPFS, wherein the Merkle Tree node is provided with a node type attribute and a reference relationship attribute, and saves the CID of the corresponding Merkle DAG node;

[0083] When receiving a space recycling instruction, the Merkle Tree node is traversed to determine a recyclable node based on the node type attribute and the reference relationship attribute;

[0084] The corresponding Merkle DAG node of the recyclable node is determined based on the CID saved in the recyclable node, and the space of the Merkle DAG node is recycled in the IPFS.

[0085] It is apparent for those skilled in the art that the present application is not limited to the details of the foregoing exemplary embodiments, and the present application can be implemented in other concrete forms without departing from the spirit or essential characteristics of the present application. Therefore, the embodiments should be considered in all aspects as exemplary and non-restrictive, and the scope of the present application is defined by the appended claims rather than the foregoing description, and it is intended to encompass all changes falling within the meaning and scope of the equivalent elements of the claims. Any reference signs in the claims should not be considered as limiting the involved claims. Furthermore, it is apparent that the word “comprise” does not exclude other units or steps, and the singular does not exclude the plural. The plurality of units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to express names, and do not express any particular order.

Claims

1. A method for space recycling for IPFS, wherein, The method comprises: establishing a Merkle Tree node corresponding to each Merkle DAG node in the IPFS, wherein the Merkle Tree node does not save actual data, is provided with a node type attribute and a reference relationship attribute, and saves a CID of the corresponding Merkle DAG node, and the node type attribute and the reference relationship attribute have initial default values; according to a data operation on the Merkle DAG node in the IPFS, changing the node type attribute and / or the reference relationship attribute of the corresponding Merkle Tree node, wherein the data operation comprises direct fixing and recursive fixing, if the data operation on the Merkle DAG node is direct fixing, changing the node type attribute of the corresponding Merkle Tree node into a direct fixing attribute, if the data operation on the Merkle DAG node is recursive fixing, changing the node type attribute of the corresponding Merkle Tree node into a recursive fixing attribute, and changing the reference relationship attribute of all nodes of the Merkle Tree in which the Merkle Tree node is located; when receiving a space recycling instruction, traversing the Merkle Tree node to determine a recyclable node based on the node type attribute and the reference relationship attribute, wherein the recyclable node is a Merkle Tree node whose node type attribute and reference relationship attribute are initial default values; based on the CID saved in the recyclable node, determining the corresponding Merkle DAG node, and recycling the space of the Merkle DAG node in the IPFS.

2. The method of claim 1, wherein, The changing of the reference relationship attribute of all nodes of the Merkle Tree in which the Merkle Tree node is located comprises: traversing the Merkle Tree in which the Merkle Tree node is located; changing the reference relationship attribute of the traversed Merkle Tree node into the direct parent node information of the Merkle Tree node.

3. The method of claim 1, wherein the data operation further comprises unfixing, and the changing of the node type attribute and / or the reference relationship attribute of the corresponding Merkle Tree node according to the data operation on the Merkle DAG node in the IPFS comprises: changing the node type attribute of the corresponding Merkle Tree node of the Merkle DAG node being unfixed into the initial default value.

4. The method of claim 1, wherein the data operation further comprises unfixing, and the changing of the node type attribute and / or the reference relationship attribute of the corresponding Merkle Tree node according to the data operation on the Merkle DAG node in the IPFS comprises: changing the node type attribute of the corresponding Merkle Tree node of the Merkle DAG node being unrecursively fixed into the initial default value; traversing a Merkle Tree node to which the Merkle Tree node belongs; changing a reference relationship attribute of the traversed Merkle Tree node to an initial default value.

5. The method of claim 1, wherein the traversing the Merkle Tree node to determine the recyclable node based on the node type attribute and the reference relationship attribute when receiving the space recycling instruction comprises: traversing the Merkle Tree node when receiving the space recycling instruction; determining that the traversed Merkle Tree node is the recyclable node when the node type attribute and the reference relationship attribute of the traversed Merkle Tree node are both the initial default value.

6. The method of claim 1, wherein, The Merkle Tree node is further provided with a node ID attribute, and the traversing the Merkle Tree node to determine the recyclable node based on the node type attribute and the reference relationship attribute when receiving the space recycling instruction comprises: traversing the Merkle Tree node when receiving the space recycling instruction, and recording a node ID attribute of the traversed Merkle Tree node; continuing to traverse the Merkle Tree node according to the recorded node ID attribute after the change of the node type attribute and / or the reference relationship attribute of the Merkle Tree node corresponding to the data operation is completed.

7. The method of claim 1, wherein the determining the Merkle DAG node corresponding to the recyclable node based on the CID stored in the recyclable node further comprises: accumulating data block sizes of the Merkle DAG nodes corresponding to the recyclable nodes to calculate a size of the recycled space.

8. A computer-readable medium having computer-readable instructions stored thereon, the computer-readable instructions being executable by a processor to implement the method of any one of claims 1 to 7.

9. A space recycling device for IPFS, wherein, The device comprises: one or more processors; and a memory storing computer-readable instructions that, when executed, cause the processor to perform operations of the method of any one of claims 1 to 7. The device comprises: one or more processors; and a memory storing computer-readable instructions that, when executed, cause the processor to perform operations of the method of any one of claims 1 to 7.

Citation Information

Patent Citations

  • Combining merkle trees in graph databases

    US10242065B1