CN115080564A - Method and equipment for synchronizing merkel directed acyclic graph - Google Patents

Method and equipment for synchronizing merkel directed acyclic graph Download PDF

Info

Publication number
CN115080564A
CN115080564A CN202210632582.XA CN202210632582A CN115080564A CN 115080564 A CN115080564 A CN 115080564A CN 202210632582 A CN202210632582 A CN 202210632582A CN 115080564 A CN115080564 A CN 115080564A
Authority
CN
China
Prior art keywords
node
identification information
directed acyclic
acyclic graph
protocol
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210632582.XA
Other languages
Chinese (zh)
Inventor
钱欢欢
王鹏光
韩明军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Xuanling Technology Co ltd
Original Assignee
Shanghai Xuanling Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Xuanling Technology Co ltd filed Critical Shanghai Xuanling Technology Co ltd
Priority to CN202210632582.XA priority Critical patent/CN115080564A/en
Publication of CN115080564A publication Critical patent/CN115080564A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2291User-Defined Types; Storage management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/275Synchronous replication

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application aims at providing a method and equipment for synchronizing a Mercker directed acyclic graph, and the application sends a protocol of node identification information of the Mercker directed acyclic graph to a second service node by creating an identification information synchronization set; acquiring a node data packet fed back by the second service node, deserializing the node data packet and storing the deserialized node data packet into a local node data storage library; recursively acquiring all acquirable child node identification information of the child Mercker directed acyclic graph, and filtering the acquired child node identification information based on the existing identification information of the local node data storage library; and solving a difference set of the filtered residual identification information of the nodes to be synchronized and the identification information synchronization set, storing the obtained difference set into the identification information synchronization set, and synchronizing a new protocol of the node identification information of the Mercker directed acyclic graph to the second service node. Therefore, the synchronization completion sequence of the current node can be not depended, and the request times are also reduced.

Description

Method and equipment for synchronizing merkel directed acyclic graph
Technical Field
The present application relates to the field of computers, and in particular, to a method and an apparatus for merkel directed acyclic graph synchronization.
Background
The Merkle directed acyclic graph (Merkle DAG) is a directed acyclic graph, each node has an identifier, and the result is obtained by hashing the content of the node by using a cryptographic hash function such as SHA256, and the Merkle DAG is composed of two types, namely leaf nodes and link nodes, wherein the leaf nodes are used for storing data, and the link nodes are used for storing identifiers of all child nodes. Merkle DAG is similar to Merkle trees in that multiple branches can re-converge, i.e., a node can have multiple parents.
The synchronization problem for synchronizing Merkle DAG data from another node is that by starting from the root CID of Merkle DAG to traverse the whole Merkle DAG deeply or extensively, if the local node can not find the DAG node, the DAG node is synchronized from another node, and the adopted protocol is as follows: and sending a request containing the CID of the DAG node to the opposite side, and then returning DAG node data of the CID. Regardless of traversing the whole Merkle DAG through depth traversal or breadth traversal, the sequence of DAG nodes is relied on, however, a parallel DAG node synchronization method is adopted for improving the synchronization speed, the returned DAG node data sequence cannot be determined, and therefore backward traversal can be continued after the DAG nodes which are lost in the middle are synchronized. Moreover, each request needs to send a DAG node CID request, which results in wasted requests.
Disclosure of Invention
An object of the present application is to provide a method and an apparatus for merkel directed acyclic graph synchronization, which solve the problems in the prior art that depending on the synchronization completion sequence of the current merkel directed acyclic graph nodes, the synchronization can be continued only after the synchronization of the middle missing nodes is waited, and the number of requests for node data is large.
According to an aspect of the present application, there is provided a method for merkel directed acyclic graph synchronization, applied to a first service node, the method including:
creating an identification information synchronization set, and sending a protocol of node identification information of a Mercker directed acyclic graph including root node identification information to a second service node establishing a connection relation with the first service node;
acquiring a node data packet which is fed back after the second service node analyzes the protocol based on the received node identification information, deserializing the node data packet and storing the deserialized node data packet into a local node data storage library;
recursively acquiring all acquirable child node identification information of the child Mercker directed acyclic graph, and filtering the acquired child node identification information based on the existing identification information of the local node data storage library;
and solving a difference set of the filtered residual identification information of the nodes to be synchronized and the identification information synchronization set, storing the obtained difference set into the identification information synchronization set, and synchronizing a new protocol of the node identification information of the Mercker directed acyclic graph to the second service node, wherein the new protocol of the node identification information of the Mercker directed acyclic graph comprises the root node identification information and the difference set.
Optionally, after synchronizing the protocol of the node identification information of the new merkel directed acyclic graph to the second serving node, the method includes:
removing the identification information of the node in the protocol of the new merkel directed acyclic graph node identification information from the identification information synchronization set.
Optionally, before sending a protocol of node identification information of the merkel directed acyclic graph including root node identification information to a second service node establishing a connection relationship with the first service node, the protocol includes:
and storing the root node identification information of the Mercker directed acyclic graph in the identification information synchronization set, and packaging the root node identification information and the node identification information array of the Mercker directed acyclic graph into the node identification information of the Mercker directed acyclic graph.
Optionally, deserializing the node data packet and storing the deserialized node data packet in the local node data storage library includes:
and analyzing the node data packet, and putting the sub-node identification information array obtained by analysis into the temporary identification information array.
Optionally, recursively acquiring all available child node identification information of the child merkel directed acyclic graph, and filtering the acquired child node identification information based on existing identification information of the local node data repository, including:
judging whether the temporary identification information array is empty or not, if not, sequentially and recursively acquiring all acquirable child node identification information of the child Mercker directed acyclic graph from the temporary identification information array;
and judging whether each child node identification information exists or not based on the existing identification information of the local node data storage library, if not, putting the child node identification information into the temporary synchronous identification information set, and if so, acquiring the node data obtained by analysis again.
Optionally, calculating a difference set of the filtered remaining identification information of the node to be synchronized and the identification information synchronization set, and storing the obtained difference set into the identification information synchronization set, including:
if the temporary identification information array is empty, judging whether the temporary synchronous identification information set is empty, if not, calculating a difference set of the temporary synchronous identification information set and the identification information synchronous set, and putting elements in the identification information difference set into the identification information synchronous set;
if so, removing the previously received identification information from the identification information synchronization set, judging whether the identification information synchronization set is empty, if not, continuing to receive the node data packet returned by the second service node, and if so, completing synchronization.
Optionally, the method comprises:
and if the data error processing protocol fed back by the second service node is received, processing error information according to the received data error processing protocol.
According to another aspect of the present application, a method for merkel directed acyclic graph synchronization applied to a second service node is provided, and the method includes:
receiving a protocol of node identification information of a Mercker directed acyclic graph including root node identification information, which is sent by a first service node establishing a connection relation with a second service node;
analyzing the protocol of the node identification information, and acquiring node data of the Mercker directed acyclic graph according to an analysis result;
the method comprises the steps of packaging obtained node data to obtain a node data packet, and sending the node data packet to a first service node to obtain a difference set of node identification information of a Mercker directed acyclic graph;
and receiving a protocol of node identification information of a new merkel directed acyclic graph, which is synchronized by the first service node based on the node data packet, wherein the protocol of the node identification information of the new merkel directed acyclic graph includes the root node identification information and the difference set.
Optionally, obtaining node data of the merkel directed acyclic graph according to the parsing result includes:
and putting the analyzed node identification information into a queue, and acquiring the node data of the merkel directed acyclic graph according to the node identification information after taking out the element from the head of the queue.
Optionally, the node data packet includes root node identification information of the merkel directed acyclic graph and node serialization data of the merkel directed acyclic graph, and the sending of the node data packet to the first service node includes:
and sending the root node identification information of the Mercker directed acyclic graph and the node serialized data of the Mercker directed acyclic graph to the first service node according to a node data protocol, wherein the node data protocol is a one-way transmission protocol.
Optionally, the method comprises:
and if the node data of the Mercker directed acyclic graph is not obtained, sending a data error processing protocol to the service configuration where the first service node is located, wherein the data error processing protocol comprises root node identification information, node identification information and error information of the Mercker directed acyclic graph.
According to another aspect of the present application, there is further provided a first service node device for merkel directed acyclic graph synchronization, the first service node device including:
one or more processors; and
a memory having computer readable instructions stored thereon that, when executed, cause the processor to perform the operations of the method as described previously.
According to another aspect of the present application, there is also provided a second serving node device for merkel directed acyclic graph synchronization, the second serving node device including:
one or more processors; and
a memory storing computer readable instructions that, when executed, cause the processor to perform the operations of the method as previously described.
According to yet another aspect of the present application, there is also provided a computer readable medium having computer readable instructions stored thereon, the computer readable instructions being executable by a processor to implement the method as described above.
Compared with the prior art, the method and the device have the advantages that the protocol of the node identification information of the Mercker directed acyclic graph including the root node identification information is sent to the second service node which establishes the connection relation with the first service node by establishing the identification information synchronous set; acquiring a node data packet which is fed back after the second service node analyzes the protocol based on the received node identification information, deserializing the node data packet and storing the deserialized node data packet into a local node data storage library; recursively acquiring all acquirable child node identification information of the child Mercker directed acyclic graph, and filtering the acquired child node identification information based on the existing identification information of the local node data storage library; and solving a difference set of the filtered residual identification information of the nodes to be synchronized and the identification information synchronization set, storing the obtained difference set into the identification information synchronization set, and synchronizing a new protocol of the node identification information of the Mercker directed acyclic graph to the second service node, wherein the new protocol of the node identification information of the Mercker directed acyclic graph comprises the root node identification information and the difference set. Therefore, when the Merkle DAG nodes are synchronized in parallel, the requests of the subsequent nodes do not depend on the synchronization completion sequence of the current Merkle DAG nodes any more, and the request times of the nodes are also reduced.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 illustrates a process flow diagram of a Mercker directed acyclic graph synchronization provided in accordance with an aspect of the subject application;
FIG. 2 is a flow diagram illustrating a method for merkel directed acyclic graph synchronization according to yet another aspect of the present application;
FIG. 3 is a flow diagram illustrating a process for a service node M to synchronize DAG data to a service node N according to an embodiment of the present disclosure;
FIG. 4 is a diagram illustrating a first state change when a service node M synchronizes DAG data to a service node N in an example of the present application;
FIG. 5 is a diagram illustrating a second state change when service node M synchronizes DAG data to service node N in an example of the present application;
FIG. 6 is a diagram illustrating a third state change when a service node M synchronizes DAG data to a service node N in an example of the present application;
FIG. 7 is a diagram illustrating a fourth state change when service node M synchronizes DAG data to service node N in an example of the present application;
fig. 8 is a diagram illustrating a fifth state change when a service node M synchronizes DAG data to a service node N in an example of the present application.
The same or similar reference numbers in the drawings identify the same or similar elements.
Detailed Description
The present application is described in further detail below with reference to the attached figures.
In a typical configuration of the present application, the terminal, the device serving the network, and the trusted party each include one or more processors (e.g., Central Processing Units (CPUs)), input/output interfaces, network interfaces, and memory.
The Memory may include volatile Memory in a computer readable medium, Random Access Memory (RAM), and/or nonvolatile Memory such as Read Only Memory (ROM) or flash Memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, Phase-Change RAM (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 tape, magnetic tape storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.
Fig. 1 is a flowchart illustrating a method for merkel directed acyclic graph synchronization, applied to a first service node, according to an aspect of the present application, where the method includes: step S11 to step S14,
step S11, creating an identification information synchronization set, and sending a protocol of node identification information of the Merckel directed acyclic graph including root node identification information to a second service node establishing a connection relation with the first service node; here, the identification information is an identifier of each node, and may be obtained by performing hash processing on the content of the node using an encryption hash function such as SHA256, and the node identifier is named as cid (content identifier); and creating a CID synchronization set on the first service node, wherein the CID synchronization set is used for storing CID tasks of Merkle directed acyclic graph (Merkle DAG) nodes to be synchronized, and each task comprises a Merkle DAG node CID and a task creation timestamp. The connection between the first service node and the second service node is established through the communication between the service configuration where the first service node is located and the service configuration where the second service node is located, so that Merkle DAG node data which needs to be synchronized in a CID synchronization set created by the first service node can be synchronized to the second service node. After the CID synchronization set is created, the root node CID of the Merkle DAG which needs to be synchronized is sent to the second service node, the sending is carried out by using a protocol of node identification information of the Mercker directed acyclic graph, the node CID protocol is in one-way transmission, namely when the related data of the Merkle DAG is sent to the opposite side, the processing is carried out without waiting for the returned data.
Step S12, obtaining a node data packet fed back after the second service node analyzes the protocol based on the received node identification information, deserializing the node data packet and storing the deserialized node data packet into a local node data storage library; after the protocol of the node identification information of the merkel directed acyclic graph including the root node identification information is sent to the second service node, the second service node analyzes the protocol of the node identification information to obtain a node data packet, the node data packet is fed back to the first service node, and the first service node performs deserialization on the received node data packet and stores the node data packet in the local node data storage bank for caching.
Step S13, recursively acquiring all acquirable child node identification information of the child Merckel directed acyclic graph, and filtering the acquired child node identification information based on the existing identification information of the local node data repository; after the root node identification information is screened, all acquirable child node identification information under the root node identification information is traversed in sequence and recurrently, so that the root node identification information is compared with the existing identification information in the node data storage base in the local cache, and the node identification information to be synchronized is obtained through filtering.
Step S14, obtaining a difference set from the filtered identification information of the remaining nodes to be synchronized and the identification information synchronization set, storing the obtained difference set in the identification information synchronization set, and synchronizing a protocol of the new node identification information of the merkel directed acyclic graph to the second service node, where the protocol of the new node identification information of the merkel directed acyclic graph includes the root node identification information and the difference set. After filtering all the available child node identification information obtained by traversal, solving a difference set of the identification information of the remaining nodes to be synchronized and the CID synchronization set, so as to store elements in the obtained difference set into the CID synchronization set, that is, the node identification information which needs to be synchronized and is not synchronized is stored in the CID synchronization set, so as to perform subsequent synchronization. And during synchronization, the obtained difference set and the original root node identification information are sent to a second service node by a new CID protocol of the Mercker directed acyclic graph, and the second service node obtains DAG node data synchronized by the first service node. Therefore, when the Merkle DAG nodes are synchronized in parallel, the requests of the subsequent nodes do not depend on the synchronization completion sequence of the current Merkle DAG nodes any more, and the request times of the nodes are also reduced.
In some embodiments of the present application, the identification information of the node in the protocol of the new merkel directed acyclic graph node identification information is removed from the synchronization set of identification information. Here, after the DAG node corresponding to the current synchronized merkel directed acyclic graph node identification information is synchronized, the current synchronized merkel directed acyclic graph node identification information needs to be removed from the CID synchronization set, that is, after a new protocol of merkel directed acyclic graph node identification information is sent to the second service node, the CID carried in the protocol is removed from the CID synchronization set.
In some embodiments of the present application, the root node identification information of the mercker directed acyclic graph is stored in the identification information synchronization set, and the root node identification information and the node identification information array of the mercker directed acyclic graph are packaged into a protocol of the node identification information of the mercker directed acyclic graph. Here, the synchronization protocol adopted in the prior art is to send a request containing a DAG node CID to the other side, and then return DAG node data of the CID; in the embodiment of the application, a Merkle DAG node CID protocol is adopted, the protocol is one-way transmission, the root node CID of the Merkle DAG is firstly stored in the created CID synchronization set, then an array is formed according to the CIDs of all other nodes of the Merkle DAG, the array comprises the unique identification CID of each DAG node to be synchronized, the root CID is packaged to obtain a data packet comprising the root CID and the CID array, the data packet is sent to a second service node by the Merkle DAG node CID protocol, namely the Merkle DAG root CID and the DAG node CID array to be synchronized are sent to the second service node, and the processing of returned data is not needed.
In some embodiments of the present application, the node data packet is analyzed, and a child node identification information array obtained by the analysis is placed in the temporary identification information array. Then, judging whether the temporary identification information array is empty, if not, sequentially recursively acquiring all acquirable child node identification information of the child merkel directed acyclic graph from the temporary identification information array; and judging whether each sub-node identification information exists or not based on the existing identification information of the local node data storage library, if not, putting the sub-node identification information into the temporary synchronous identification information set, and if so, acquiring the node data obtained by analysis again.
After receiving the node data packet returned by the second service node, the first service node analyzes the node data packet, that is, analyzes DAG node data, and when analyzing, stores the node data into the local node data storage library, and simultaneously obtains the child node identification information array of the node and stores the child node identification information array into the temporary CID array of the DAG node. And if not, putting the extracted CID into a temporary synchronous CID set, if so, analyzing the sub-node identification information CID array of the DAG node and storing the sub-node identification information CID array into the temporary CID array, and circulating the steps until the temporary CID array is empty.
If the temporary identification information array is empty, judging whether the temporary synchronous identification information set is empty, and if not, solving a difference set between the temporary synchronous identification information set and the identification information synchronous set and putting elements in the identification information difference set into the identification information synchronous set; if yes, removing the previously received identification information from the identification information synchronization set, judging whether the identification information synchronization set is empty, if not, continuing to receive the node data packet returned by the second service node, and if yes, completing synchronization. If the temporary CID array is empty, determining whether the temporary synchronous CID set is empty, otherwise, performing difference set calculation on the temporary synchronous CID set and the previous CID synchronous set, sending the CID difference set to the second service node by using the Merkle DAG node CID protocol, putting CID difference set elements into the CID synchronous set, and removing the previously received CID from the CID synchronous set. If the temporary synchronous CID set is empty, removing the previously received CID from the CID synchronous set, judging whether the CID synchronous set is empty, if not, continuously receiving the node data, and if so, indicating that all the node data needing to be synchronized are synchronized.
In some embodiments of the present application, the method comprises: and if the data error processing protocol fed back by the second service node is received, processing error information according to the received data error processing protocol. Here, if the first service node receives the data error handling protocol, the data synchronization process is terminated in advance according to the received error information, for example, the error information is recorded in a log or the protocol is retransmitted. In the embodiment of the application, the data error processing protocol is bidirectional transmission, and after information is sent to an opposite side, the data needs to wait for returning for processing, and the sent information comprises a Merkle DAG root node, a CID of a DAG node with a synchronous error and error information.
Fig. 2 is a flowchart illustrating a method for merkel directed acyclic graph synchronization, applied to a second service node, according to yet another aspect of the present application, where the method includes: step S21 to step S24,
step S21, receiving a protocol of node identification information of a Mercker directed acyclic graph including root node identification information sent by a first service node establishing a connection relationship with a second service node; after the second service node establishes connection with the first service node, a protocol of node identification information of the merkel directed acyclic graph sent by the first service node is received, and the protocol carries a data packet of a Merkle DAG root node CID and a CID array.
Step S22, analyzing the protocol of the node identification information, and acquiring the node data of the Mercker directed acyclic graph according to the analysis result; here, the received packet is parsed to parse node data of the Merkle DAG, where the node data includes a CID array, and the CID array is placed in a queue, thereby entering a loop body and performing concurrent processing.
Step S23, packaging the acquired node data to obtain a node data packet, and sending the node data packet to the first service node to obtain a difference set of node identification information of the Mercker directed acyclic graph; here, during concurrent processing, the node data obtained by analysis is packaged, so that the packaged node data packet is fed back to the first service node, and the first service node obtains a difference set of Merkle DAG node CIDs required to be synchronized based on the node data packet.
Step S24, receiving a protocol of node identification information of a new merkel directed acyclic graph synchronized by the first service node based on the node data packet, where the protocol of the node identification information of the new merkel directed acyclic graph includes the root node identification information and the difference set. Here, a CID protocol synchronized by the first service node is received, and the protocol carries the obtained difference set information and the root CID information, so that the synchronization of node data can be completed.
In some embodiments of the present application, in step S22, the parsed node identification information is placed in a queue, and after an element is taken out from the head of the queue, node data of the merkel directed acyclic graph is obtained according to the node identification information. And taking out the element from the head of the data queue, acquiring DAG node data according to the CID, packaging the acquired DAG node, packaging into a data packet comprising the root CID and the DAG node data, and sending the data packet to the first service node. The specific process is as follows: the second service node receives and analyzes the CID array from the Merkle DAG node CID protocol, and assembles the service configuration and the CID where the first service node is located into a structure to be placed in a data sending queue; the transmit data queue asynchronously performs the following steps: continuously acquiring tasks from a data sending queue, wherein the tasks are to set a proper concurrent task number according to machine configuration, for example, the concurrent task number is set to be 2 times of the number of CPU cores; and acquiring Merkle DAG node data according to the CID, and then sending Merkle DAG node data protocol data to the first service node.
Receiving the above embodiment, the node data packet includes root node identification information of the merkel directed acyclic graph and node serialization data of the merkel directed acyclic graph, and in step S23, the root node identification information of the merkel directed acyclic graph and the node serialization data of the merkel directed acyclic graph are sent to the first service node according to a node data protocol, where the node data protocol is a one-way transmission protocol. When the second service node feeds back the node data, a Merkle DAG node data protocol is adopted, the protocol is unidirectional transmission, Merkle DAG root CID and Merkle DAG node serialized data are sent to the opposite side, and the processing of returning data is not required to be waited. It should be noted that, a DAG node mainly consists of a Payload (Payload) field and a child node CID array, and serialization of the Merkle DAG node is convenient for storage and transmission.
In some embodiments of the present application, the method comprises: and if the node data of the Merckel directed acyclic graph are acquired unsuccessfully, sending a data error processing protocol to the service configuration where the first service node is located, wherein the data error processing protocol comprises root node identification information, node identification information and error information of the Merckel directed acyclic graph. Here, if the acquisition of the Merkle DAG node data fails, data error handling protocol data including a Merkle DAG root CID, a DAG CID with a synchronization error, and error information is transmitted to the first service node.
In a specific embodiment of the present application, an example is taken to illustrate that the service node M synchronizes DAG data to the service node N:
step 1, a service node M establishes connection with a service node N;
step 2, a CID synchronous set is created, the CID synchronous set is scanned at regular time, and if a CID synchronous task is overtime, the data synchronization process is ended in advance;
step 3, the service node M sends Merkle DAG node CID protocol data containing Merkle DAG root CID and puts the root CID into a CID synchronous set;
and 4, the service node N receives and analyzes the CID array from the Merkle DAG node CID protocol, assembles the connection object and the CID into a structure and puts the structure into a data sending queue. The transmit data queue executes asynchronously: continuously acquiring tasks from the data sending queue, acquiring Merkle DAG node data according to CID, and then sending Merkle DAG node data protocol data to the connection object; if the acquisition of Merkle DAG node data fails, sending data error handling protocol data to the connection object, wherein the data error handling protocol data comprises Merkle DAG root CID, DACID and error information;
step 5, the service node M acquires Merkle DAG node data from the Merkle DAG node data protocol, stores the Merkle DAG node data into the local node data storage bank, recursively acquires all available sub DAG node CIDs of the sub Merkle DAG, filters out the existing node CIDs in the local node data storage bank, finds a difference set between the CID set of the remaining nodes to be synchronized and the CID synchronization set, puts the difference set into the CID synchronization set, and sends the Merkle DAG node CID protocol to the service node N, wherein the node CID protocol comprises a Merkle DAG root CID and the CID difference set obtained in the previous step, and removes the CID of the DAG node in the data packet from the CID synchronization set;
step 6, if the service node M receives the data error processing protocol, processing according to the error information, and ending the data synchronization process in advance;
and 7, repeating the steps 4-6 until the data to be synchronized is not in the CID synchronization set of the service node M, and completing data synchronization.
Specifically, as shown in fig. 3, steps S11 to S14, S21 to S24 and steps in the embodiments described above are executed in the service node M and the service node N, and after a CID synchronization set is created in the service node M, a packed data packet is sent to the service node N to perform concurrent processing on the service node N, and after the data is fed back to the service node M, the data is concurrently processed in the service node M, so that the service node M synchronizes DAG data from the service node N, and thus when parallel synchronizing DAG nodes, a request of a subsequent node does not depend on a synchronization completion sequence of a current Merkle DAG node, and at the same time, the number of requests is reduced.
The following example is used to describe the internal state change of the service node M from the service node N in synchronization with the Merkle DAGA, and it should be noted that this packet order is only one of the possibilities.
Wherein service node M, N represents two server process instances; the data packet is a data packet of the service node M, N for network communication; the CID synchronous set is a child node CID to be synchronized; merkle DAG A is the whole Merkle DAG to be synchronized, wherein nodes A-F are all nodes belonging to Merkle DAG A, the dotted line indicates not synchronized, and the solid line indicates synchronized.
Specifically, as shown in fig. 4, the service node M initiates a synchronization MerkleDAGA task to the service node N, first synchronizes the root node CIDA, sends merkles DAG node CID protocol data (root CIDA and CIDA in CID array), and puts the CIDA into a CID synchronization set.
As shown in fig. 5, the service node M receives the packet sent by the service node N, analyzes the packet to obtain data of the DAG node a, obtains child nodes (CIDB and CIDC) in the node a, and if the two child nodes cannot be found in the local node data repository, sends CID protocol data of the Merkle DAG node, where the root CIDA and CID arrays are CIDB and CIDC, puts the CIDB and CIDC into the CID synchronization set, and deletes the CIDA.
As shown in fig. 6, the service node M receives the data packet sent by the service node N, parses the data packet to obtain data of the DAG node C, obtains child nodes (CIDF and CID E) in the node C, and sends the CID protocol data of the Merkle DAG node if the two child nodes are not found in the local node data repository, where the root CIDA and CID arrays are CID F and CID E, places CID F and CID E in the CID synchronization set, and deletes CID C.
As shown in fig. 7, the service node M receives the data packet sent by the service node N, parses the data packet to obtain data of the DAG node B, obtains child nodes (CID D and CID) in the node B, and if the two child nodes are not found in the local node data repository but the CID is already in the synchronization set and no resynchronization is needed, sends CID protocol data of the Merkle DAG node (root CIDA and CID in the CID array are CIDD), puts CID D in the CID synchronization set, and deletes CID B.
As shown in fig. 8, the service node M receives the data packet sent by the service node N, analyzes the data packet to obtain data of the DAG node F, E, D, obtains child nodes in the node (at this time, the node F, E, D does not have child nodes), deletes the CIDF, E, and D from the CID synchronization set, and ends synchronization when the CID synchronization set is empty.
According to another aspect of the present application, there is further provided a first service node device for merkel directed acyclic graph synchronization, the first service node device including:
one or more processors; and
a memory storing computer readable instructions that, when executed, cause the processor to perform the operations of the method as previously described.
For example, the computer readable instructions, when executed, cause the one or more processors to:
creating an identification information synchronization set, and sending a protocol of node identification information of a Mercker directed acyclic graph including root node identification information to a second service node establishing a connection relation with the first service node;
acquiring a node data packet which is fed back after the second service node analyzes the protocol based on the received node identification information, deserializing the node data packet and storing the deserialized node data packet into a local node data storage library;
recursively acquiring all acquirable child node identification information of the child Mercker directed acyclic graph, and filtering the acquired child node identification information based on the existing identification information of the local node data storage library;
and solving a difference set of the filtered residual identification information of the nodes to be synchronized and the identification information synchronization set, storing the obtained difference set into the identification information synchronization set, and synchronizing a new protocol of the node identification information of the Mercker directed acyclic graph to the second service node, wherein the new protocol of the node identification information of the Mercker directed acyclic graph comprises the root node identification information and the difference set.
According to another aspect of the present application, there is also provided a second serving node device for merkel directed acyclic graph synchronization, the second serving node device including:
one or more processors; and
a memory storing computer readable instructions that, when executed, cause the processor to perform the operations of the method as previously described.
For example, the computer readable instructions, when executed, cause the one or more processors to:
receiving a protocol of node identification information of a Mercker directed acyclic graph including root node identification information, which is sent by a first service node establishing a connection relation with a second service node;
analyzing the protocol of the node identification information, and acquiring node data of the Mercker directed acyclic graph according to an analysis result;
the method comprises the steps of packaging obtained node data to obtain a node data packet, and sending the node data packet to a first service node to obtain a difference set of node identification information of a Mercker directed acyclic graph;
and receiving a protocol of node identification information of a new merkel directed acyclic graph, which is synchronized by the first service node based on the node data packet, wherein the protocol of the node identification information of the new merkel directed acyclic graph includes the root node identification information and the difference set.
Furthermore, an embodiment of the present application further provides a computer readable medium, on which computer readable instructions are stored, where the computer readable instructions are executable by a processor to implement the foregoing method for merkel directed acyclic graph synchronization.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, for example, implemented using Application Specific Integrated Circuits (ASICs), general purpose computers or any other similar hardware devices. In one embodiment, the software programs of the present application may be executed by a processor to implement the steps or functions described above. Likewise, the software programs (including associated data structures) of the present application may be stored in a computer readable recording medium, such as RAM memory, magnetic or optical drive or diskette and the like. Additionally, some of the steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
In addition, some of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application through the operation of the computer. Program instructions which invoke the methods of the present application may be stored on a fixed or removable recording medium and/or transmitted via a data stream on a broadcast or other signal-bearing medium and/or stored within a working memory of a computer device operating in accordance with the program instructions. An embodiment according to the present application comprises an apparatus comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to perform a method and/or a solution according to the aforementioned embodiments of the present application.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it will be obvious that the term "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. The terms first, second, etc. are used to denote names, but not to denote any particular order.

Claims (14)

1. A method for synchronization of a Mercker directed acyclic graph, applied to a first service node, the method comprising:
creating an identification information synchronization set, and sending a protocol of node identification information of a Mercker directed acyclic graph including root node identification information to a second service node establishing a connection relation with the first service node;
acquiring a node data packet which is fed back after the second service node analyzes the protocol based on the received node identification information, deserializing the node data packet and storing the deserialized node data packet into a local node data storage library;
recursively acquiring all acquirable child node identification information of the child Mercker directed acyclic graph, and filtering the acquired child node identification information based on the existing identification information of the local node data storage library;
and solving a difference set of the filtered residual identification information of the nodes to be synchronized and the identification information synchronization set, storing the obtained difference set into the identification information synchronization set, and synchronizing a new protocol of the node identification information of the Mercker directed acyclic graph to the second service node, wherein the new protocol of the node identification information of the Mercker directed acyclic graph comprises the root node identification information and the difference set.
2. The method of claim 1, wherein after synchronizing the protocol for the node identification information of the new merkel directed acyclic graph to the second serving node, comprising:
removing the identification information of the node in the protocol of the new merkel directed acyclic graph node identification information from the identification information synchronization set.
3. The method of claim 1, wherein before sending the protocol for node identification information of the merkel directed acyclic graph including root node identification information to the second service node establishing the connection relationship with the first service node, comprising:
and storing the root node identification information of the Merckel directed acyclic graph in the identification information synchronization set, and packaging the root node identification information and the node identification information array of the Merckel directed acyclic graph into the node identification information of the Merckel directed acyclic graph.
4. The method of claim 1, wherein deserializing the node data prior to storing the node data in the local node data store comprises:
and analyzing the node data packet, and putting the sub-node identification information array obtained by analysis into the temporary identification information array.
5. The method of claim 4, wherein recursively acquiring all available child node identification information of the child merkel directed acyclic graph, and filtering the acquired child node identification information based on existing identification information of the local node data store comprises:
judging whether the temporary identification information array is empty or not, and if not, sequentially and recursively acquiring all acquirable child node identification information of the child merkel directed acyclic graph from the temporary identification information array;
and judging whether each child node identification information exists or not based on the existing identification information of the local node data storage library, if not, putting the child node identification information into the temporary synchronous identification information set, and if so, acquiring the node data obtained by analysis again.
6. The method according to claim 5, wherein obtaining a difference set from the filtered identification information of the remaining nodes to be synchronized and the identification information synchronization set, and storing the obtained difference set in the identification information synchronization set, comprises:
if the temporary identification information array is empty, judging whether the temporary synchronous identification information set is empty, if not, calculating a difference set of the temporary synchronous identification information set and the identification information synchronous set, and putting elements in the identification information difference set into the identification information synchronous set;
if so, removing the previously received identification information from the identification information synchronization set, judging whether the identification information synchronization set is empty, if not, continuing to receive the node data packet returned by the second service node, and if so, completing synchronization.
7. The method according to claim 1, characterized in that it comprises:
and if the data error processing protocol fed back by the second service node is received, processing error information according to the received data error processing protocol.
8. A method for synchronization of a Mercker directed acyclic graph, applied to a second service node, the method comprising:
receiving a protocol of node identification information of a Mercker directed acyclic graph including root node identification information, which is sent by a first service node establishing a connection relation with a second service node;
analyzing the protocol of the node identification information, and acquiring node data of the Mercker directed acyclic graph according to an analysis result;
the method comprises the steps of packaging obtained node data to obtain a node data packet, and sending the node data packet to a first service node to obtain a difference set of node identification information of a Mercker directed acyclic graph;
and receiving a protocol of the node identification information of the new merkel directed acyclic graph, which is synchronized by the first service node based on the node data packet, wherein the protocol of the node identification information of the new merkel directed acyclic graph includes the root node identification information and the difference set.
9. The method according to claim 1, wherein obtaining node data of the merkel directed acyclic graph according to the parsing result comprises:
and putting the analyzed node identification information into a queue, and acquiring the node data of the merkel directed acyclic graph according to the node identification information after taking out the element from the head of the queue.
10. The method of claim 9, wherein the node data packet includes root node identification information of the merkel directed acyclic graph and node serialization data of the merkel directed acyclic graph, and wherein sending the node data packet to the first service node includes:
and sending the root node identification information of the Mercker directed acyclic graph and the node serialized data of the Mercker directed acyclic graph to the first service node according to a node data protocol, wherein the node data protocol is a one-way transmission protocol.
11. The method of claim 8, wherein the method comprises:
and if the node data of the Mercker directed acyclic graph is not obtained, sending a data error processing protocol to the service configuration where the first service node is located, wherein the data error processing protocol comprises root node identification information, node identification information and error information of the Mercker directed acyclic graph.
12. A first serving node device for merkel directed acyclic graph synchronization, the first serving node device comprising:
one or more processors; and
a memory storing computer readable instructions that, when executed, cause the processor to perform the operations of the method of any of claims 1 to 7.
13. A second serving node device for merkel directed acyclic graph synchronization, the second serving node device comprising:
one or more processors; and
memory storing computer readable instructions that, when executed, cause the processor to perform the operations of the method of any of claims 8 to 11.
14. A computer readable medium having computer readable instructions stored thereon which are executable by a processor to implement the method of any one of claims 1 to 11.
CN202210632582.XA 2022-05-27 2022-05-27 Method and equipment for synchronizing merkel directed acyclic graph Pending CN115080564A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210632582.XA CN115080564A (en) 2022-05-27 2022-05-27 Method and equipment for synchronizing merkel directed acyclic graph

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210632582.XA CN115080564A (en) 2022-05-27 2022-05-27 Method and equipment for synchronizing merkel directed acyclic graph

Publications (1)

Publication Number Publication Date
CN115080564A true CN115080564A (en) 2022-09-20

Family

ID=83249476

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210632582.XA Pending CN115080564A (en) 2022-05-27 2022-05-27 Method and equipment for synchronizing merkel directed acyclic graph

Country Status (1)

Country Link
CN (1) CN115080564A (en)

Similar Documents

Publication Publication Date Title
CN107122297B (en) Method and equipment for generating request message of test interface
CN111008246B (en) Database log synchronization method, device, computer equipment and readable storage medium
US11386061B2 (en) Telemetry request system
WO2017066115A1 (en) Telemetry response system
CN114547208B (en) Method and native distributed database for full link trace transactions
WO2016155492A1 (en) Remote data synchronization method and apparatus for database
CN112182104A (en) Data synchronization method, device, equipment and storage medium
CN111225012A (en) Transaction processing method, device and equipment
CN113626416A (en) Data verification method and device, computing equipment and storage medium
CN115811484A (en) Network detection method, device and storage medium
CN114490869A (en) Data synchronization method and device, data source end, target end and storage medium
CN115080564A (en) Method and equipment for synchronizing merkel directed acyclic graph
CN114640657A (en) Multi-registration center fusion method and device
CN116186082A (en) Data summarizing method based on distribution, first server and electronic equipment
CN112699000A (en) Data processing method and device, readable storage medium and electronic equipment
CN115422286A (en) Data synchronization method and device for distributed database
CN109389271B (en) Application performance management method and system
CN106557530A (en) Operation system, data recovery method and device
US20040111706A1 (en) Analysis of latencies in a multi-node system
CN116701452A (en) Data processing method, related device, storage medium and program product
CN115098587A (en) Method, device, equipment and medium for synchronizing remote database
CN113194129A (en) Data ferrying method, equipment and medium
CN114168445A (en) Log analysis method, device and system and readable storage medium
WO2016180167A1 (en) Method, device and system for associating events between computing devices
WO2019165573A1 (en) Docker-based image synchronization method, device and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination