Method for block synchronization of fabric peer node based on network delay

By optimizing peer node synchronization in Fabric through network delay-based grouping and leader selection, the method addresses redundant synchronization messages and low efficiency, enhancing synchronization efficiency.

CN119094069APending Publication Date: 2024-12-06SHANGHAI INSPUR CLOUD COMPUTING SERVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411049408.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

Fabric peer nodes experience redundant synchronization block messages and low efficiency when the number of nodes is large due to inefficient network synchronization.

Method used

A method that selects a computing node to collect network delay data, calculates temporary and new leader nodes based on the sum of square delays, and groups peer nodes to optimize synchronization by using leader and deputy leader nodes for efficient block synchronization.

Benefits of technology

This method reduces network message redundancy and improves synchronization efficiency by grouping peer nodes based on the latest statistical network delay, ensuring efficient block synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119094069A_ABST
    Figure CN119094069A_ABST
Patent Text Reader

Abstract

The invention discloses a method for synchronizing blocks by fabric peer nodes based on network delay, and relates to the technical field of block chains. Comprising the following steps: step 1, selecting a computing node from peer nodes of an alliance chain Fabric, and initiating data collection by the computing node, step 2, performing data calculation by the computing node: obtaining a leader node and a group with the minimum delay quadratic sum as an optimal group, selecting two auxiliary leader nodes in each group, and performing data collection by the two auxiliary leader nodes; and step 3, carrying out block synchronization according to the grouping: the peer-to-peer node obtains the distributed blocks, confirms roles in the group to the leader node according to the grouping information in the blocks and the leader node information, and executes operations corresponding to the roles in the group. And if the peer-to-peer node is in a common node role and a leader node failure request reaches a preset number of times after the leader node failure is requested, sending a leader node failure request to the computing node, and 4, reselecting the leader node by the computing node.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention discloses a method, which relates to the technical field of blockchain, and specifically to a method for synchronizing blocks of fabric peer nodes based on network delay. Background Art

[0002] Blockchain is a distributed shared ledger. In blockchain, data is stored by multiple parties, and multiple parties use consensus algorithms to achieve consistency of multi-node data. In blockchain, data can only be appended and cannot be deleted or modified. The new blockchain is programmable. Users can use smart contracts to encode business rules into the blockchain. Rules cannot be deleted or modified like data. They are automatically executed when called and cannot be skipped. The results of the execution are also written into the blockchain. Since data is stored by multiple parties and the data on the chain cannot be tampered with, blockchain can be used to achieve trusted data sharing among multiple parties.

[0003] Fabric is a type of blockchain alliance chain, which includes sorting nodes, peer nodes, certificate issuing nodes, etc. The sorting nodes are responsible for packaging transactions and generating blocks, the peer nodes have functions such as transaction endorsement, contract deployment and execution, and the certificate issuing nodes implement identity management for each node. However, when there are too many peer nodes, fabric is prone to redundant synchronization block messages and low efficiency. Summary of the invention

[0004] In view of the problems of the prior art, the present invention provides a method for fabric peer node synchronization blocks based on network delay, which solves the problems of redundant synchronization block messages and low efficiency when the number of fabric peer nodes is too large.

[0005] The specific scheme proposed by the present invention is:

[0006] The present invention provides a method for fabric peer node synchronization block based on network delay, comprising: step 1: selecting a computing node from the peer nodes of the alliance chain fabric, the computing node initiating data collection: the computing node obtains information of all peer nodes in the organization through the certificate issuing node, notifies all peer nodes in the organization to count the average network delay between the peer node and the sorting node, and between the peer nodes, and the computing node saves the average network delay counted by each peer node,

[0007] Step 2: The computing node performs data calculation: The computing node reads the pre-configured number of groups, first calculates the temporary leader node and group of the peer node, and the sum of square delays within the group; then tries to replace the temporary leader node in the group with other peer nodes in the group. If a smaller sum of square delays is obtained after replacement, a new leader node and new group are used. This iteration continues until the leader node and group with the smallest sum of square delays are obtained as the best group, and then two deputy leader nodes in each group are selected.

[0008] Step 3: Block synchronization based on grouping: Encapsulate the grouping information into transactions and pack them into blocks. The peer node obtains the distributed blocks. According to the grouping information and leader node information in the block, it confirms the role in the group with the leader node and performs the operations corresponding to the role in the group. If the peer node is a common node role and fails to request the leader node for a preset number of times, it sends a leader node failure request to the computing node.

[0009] Step 4: The computing node re-elects the leader node: When the computing node receives a preset number of leader node failure requests, the computing node first notifies the peer nodes in the group to count the average network delay between the peer nodes and the sorting nodes and between the peer nodes in the group, and then calculates the square sum of the delays of each peer node in the group based on the average network delay information, and confirms the new leader node and two deputy leader nodes in the group based on the square sum of the delays. Finally, the new leader node and deputy leader node information are encapsulated into transactions and packaged into blocks, which are synchronized to each peer node, so that the peer nodes in the group confirm the roles in the group based on the new leader node information and perform operations corresponding to the roles in the group.

[0010] Furthermore, step 1 of the method for synchronizing blocks of fabric peer nodes based on network delay specifically includes:

[0011] Step 1.1: The computing node sends a request to the certificate issuing node, requesting the identity and address information of all peer nodes of the organization.

[0012] Step 1.2: After the computing node obtains the address information of the peer node, it sends a data collection request to the peer node.

[0013] Step 1.3: Each peer node P i , 1<=i<=n, n is the number of peer nodes in the organization. After receiving the data collection request, it sends three block requests to the sorting node and calculates the average delay of the three requests To i , 1<=i<=n, and save temporarily,

[0014] Step 1.4: Each peer node P i To the rest of the peer nodes P j Send three test requests and calculate the average delay Tp of the three requestsij , 1<=i<=n, 1<=j<=n, i and j are not equal and are temporarily saved,

[0015] Step 1.5: Each peer node P i To temporarily save i and Tp ij After the computing node collects the average delay data of all peer nodes, it proceeds to step 2.

[0016] Further, step 2 of the method for synchronizing blocks of fabric peer nodes based on network delay specifically includes:

[0017] Step 2.1: The computing node reads the pre-configured peer node cluster grouping number g,

[0018] Step 2.2: The computing node randomly selects g temporary leaders from among the peer nodes

[0019] Step 2.3: For each non-temporary leader node's peer node P j , computing node computing group number At this time, the peer node P j In group G i In, P j ∈G i ,

[0020] Step 2.4: For each group G i , 1≤i≤g, the computing node is Calculate the peer nodes P in the group j The sum of squares of the delays to the temporary leader node And calculate the delay and

[0021] Step 2.5: The computing node calculates the sum of squares of delays of all packets, ST = ST1 + ST2 + ... + ST g ,

[0022] Step 2.6: The computing node converts the temporary minimum delay square sum ST tmp Set to ST,

[0023] Step 2.7: Calculate the node for each group G i , and each node P in the group j , perform steps 2.8-2.10,

[0024] Step 2.8: The computing node saves the leader node and group information of the current group and sets a new leader node Calculate the remaining peer nodes P kNew group number At this time, the peer node P k In group G i′ In, P k ∈G i′ ,

[0025] Step 2.9: Calculate the nodes according to the new grouping G i′ , 1≤i′≤g, calculate the delay square sum ST′ of all new packets in the same way as steps 2.4-2.5,

[0026] Step 2.10: If ST′ <ST tmp , then ST tmp Update to ST′, update the leader node and group information of the current group, and continue to traverse the peer nodes in step 2.7; otherwise, restore the group leader node and group information saved in step 2.8, and continue to traverse the peer nodes in step 2.7.

[0027] Step 2.11: After the traversal in step 2.7 is completed, the grouping information of the current leader node is the best grouping information, and the computing node calculates the best grouping information for each group G. i , let the leader node of the current group confirmation be exist Find the index v1 corresponding to the smallest value and the index v2 corresponding to the second smallest value in the collection, and set and There are two deputy leader nodes for the group, and the deputy leader node information is saved in the best grouping information.

[0028] Further, step 3 of the method for synchronizing blocks of fabric peer nodes based on network delay specifically includes:

[0029] Step 3.1: The computing node encapsulates the best grouping information into transactions and sends them to the fabric’s sorting node, which packages the transactions into blocks.

[0030] Step 3.2: After the peer node obtains the distributed block in the original way, it obtains the transaction grouping information in the block.

[0031] Step 3.3: If the peer node finds that it is the leader node in the group in the block grouping information, it starts to request blocks from the sorting node; if the peer node finds that it is the deputy leader node in the group in the block grouping information, it monitors the status of the leader node in the group, and after finding that the leader node is in a state of being unable to connect, it actively requests blocks from the sorting node; if the peer node finds that it is an ordinary node in the group in the block grouping information, it starts to request blocks from the leader node in the group.

[0032] Step 3.4: If the peer node fails to request a block from the leader node in the group for more than the preset number of times, it requests a block from the surviving deputy leader node in the group and sends a leader node failure request to the computing node.

[0033] Further, step 4 of the method for synchronizing blocks of fabric peer nodes based on network delay specifically includes:

[0034] Step 4.1: If the computing node receives a preset number of failure requests from the leader nodes, it sends a fault message to group G. k The peer nodes in the same group send a request to re-elect the leader.

[0035] Step 4.2: Peer node P in the corresponding group i After receiving the re-election request, it sends three block requests to the sorting node and calculates the average delay T′o of the three requests. i (1≤i≤n∧P i ∈G k ), and save it temporarily,

[0036] Step 4.3: Peer node P in the corresponding group i To the rest of the peer nodes P in the group j Send three test requests and calculate the average delay T′p of the three requests ij ((1≤i≤n,1≤j≤n∧P i ∈G k ∧P j ∈G k )) and save it temporarily.

[0037] Step 4.4: Group peer nodes P i The temporarily stored T′o i and T′p ij Send it to the computing node. After the computing node collects the average delay data of all peer nodes, it calculates the sum of squares of the delay within the group. The index node corresponding to the smallest sum of squared delays within the group is selected as the leader node of the group, and the index nodes corresponding to the second smallest and third smallest sum of squared delays within the group are selected as the two deputy leaders of the group.

[0038] Step 4.5: Compute nodes will group G k The new leader node information and deputy leader node information are packaged into transactions and sent to the sorting node. The sorting node packages the transactions into blocks.

[0039] Step 4.6: Group G k After the peer nodes in the group are synchronized to the block through the current deputy leader node, the leader node and deputy leader node are updated according to the information of the corresponding transaction in the block, and the roles in this node group are confirmed, and the corresponding operations in step 3.3 are performed.

[0040] The present invention also provides a device for synchronizing blocks of fabric peer nodes based on network delay, comprising a computing node management module, a peer node management module and a block management module.

[0041] The computing node management module selects computing nodes from the peer nodes of the alliance chain fabric, and the computing nodes initiate data collection through the computing node management module: the computing node management module obtains the information of all peer nodes in the organization through the certificate issuing node, and notifies all peer nodes in the organization to count the average network delay between the peer nodes and the sorting nodes, and between the peer nodes. The computing nodes save the average network delay counted by each peer node.

[0042] The computing node performs data calculation through the computing node management module: the computing node management module reads the pre-configured number of groups, first calculates the temporary leader node and group of the peer node, and the sum of square delays in the group; then tries to replace the temporary leader node in the group with other peer nodes in the group. If a smaller sum of square delay is obtained after replacement, the new leader node and new group are adopted. This iteration is repeated until the leader node and group with the smallest sum of square delay are obtained as the best group, and then two deputy leader nodes in each group are selected.

[0043] The block management module synchronizes blocks according to groups: it encapsulates group information into transactions and packs them into blocks.

[0044] The peer node obtains the distributed blocks through the peer node management module. According to the grouping information and leader node information in the block, the peer node confirms the role in the group with the leader node and performs the operations corresponding to the role in the group. If the peer node is a common node role and the request to the leader node fails for a preset number of times, the peer node management module sends a leader node failure request to the computing node.

[0045] The computing node re-elects the leader node through the computing node management module: when the computing node management module receives a preset number of leader node failure requests, the computing node management module first notifies the peer nodes in the group to count the average network delay between the peer nodes and the sorting nodes and between the peer nodes in the group, and then calculates the square sum of the delays of each peer node in the group based on the average network delay information, and confirms the new leader node and two deputy leader nodes in the group based on the square sum of the delays. Finally, the block management module encapsulates the new leader node and deputy leader node information into transactions and packages them into blocks, which are synchronized to each peer node, so that the peer nodes in the group confirm the roles in the group based on the new leader node information through the peer node management module and perform operations corresponding to the roles in the group.

[0046] The present invention also provides a computer-readable medium for fabric peer node synchronization blocks based on network delay, wherein the computer-readable medium stores computer instructions, and when the computer instructions are executed by a processor, the processor executes the method for fabric peer node synchronization blocks based on network delay.

[0047] The present invention also provides an electronic device for fabric peer node synchronization blocks based on network delay, comprising: at least one memory and at least one processor;

[0048] The at least one memory is used to store a machine-readable program;

[0049] The at least one processor is used to call the machine-readable program to execute the method of synchronizing blocks of fabric peer nodes based on network delay.

[0050] The benefits of the present invention are:

[0051] The present invention realizes synchronization of blocks between peer nodes based on statistical network delay. Compared with the original method of using gossip protocol to synchronize blocks between fabric peer nodes, the present method groups fabric peer nodes and the leader node in the group is mainly responsible for block synchronization, which solves the problems of network message redundancy and low synchronization efficiency when the scale of peer nodes is large. In addition, the grouping and confirmation of the leader node in the present method are the better choices calculated based on the latest statistical network delay iteration, which also greatly guarantees the synchronization efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION

[0053] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.

[0054] Example 1

[0055] The present invention provides a method for synchronizing blocks of fabric peer nodes based on network delay, combined with Figure 1 ,include:

[0056] Step 1: Select a computing node from the peer nodes of the alliance chain fabric, and the computing node initiates data collection: the computing node obtains the information of all peer nodes in the organization through the certificate issuing node, notifies all peer nodes in the organization to count the average network delay between the peer node and the sorting node, and between the peer nodes, and the computing node saves the average network delay counted by each peer node. The computing node can query the certificate issuing node to obtain the identity of all peer nodes in the organization, and then communicate with the peer nodes. In addition, the computing node also has the function of sending transactions to the consensus node. One or more computing nodes can exist at the same time.

[0057] Step 1 specifically includes:

[0058] Step 1.1: The computing node sends a request to the certificate issuing node, requesting the identity and address information of all peer nodes of the organization.

[0059] Step 1.2: After the computing node obtains the address information of the peer node, it sends a data collection request to the peer node.

[0060] Step 1.3: Each peer node P i , 1<=i<=n, n is the number of peer nodes in the organization. After receiving the data collection request, it sends three block requests to the sorting node and calculates the average delay of the three requests To i , 1<=i<=n, and save temporarily,

[0061] Step 1.4: Each peer node P i To the rest of the peer nodes P j Send three test requests and calculate the average delay Tp of the three requests ij , 1<=i<=n, 1<=j<=n, i and j are not equal and are temporarily saved,

[0062] Step 1.5: Each peer node P i To temporarily save i and Tp ij After the computing node collects the average delay data of all peer nodes, it proceeds to step 2.

[0063] Step 2: The computing node performs data calculation: The computing node reads the pre-configured number of groups, first calculates the temporary leader node and group of the peer node, and the sum of square delays within the group; then tries to replace the temporary leader node in the group with other peer nodes in the group. If a smaller sum of square delays is obtained after replacement, a new leader node and new group are used. This iteration is repeated until the leader node and group with the smallest sum of square delays are obtained as the best group, and then two deputy leader nodes are selected in each group.

[0064] Specifically, they include:

[0065] Step 2.1: The computing node reads the pre-configured peer node cluster grouping number g,

[0066] Step 2.2: The computing node randomly selects g temporary leaders from among the peer nodes

[0067] Step 2.3: For each non-temporary leader node's peer node P j , computing node computing group number At this time, the peer node P j In group G i In, P j ∈G i ,

[0068] Step 2.4: For each group G i , 1≤i≤g, the computing node is Calculate the peer nodes P in the group j The sum of squares of the delays to the temporary leader node And calculate the delay and

[0069] Step 2.5: The computing node calculates the sum of squares of delays of all packets, ST = ST1 + ST2 + ... + ST g ,

[0070] Step 2.6: The computing node converts the temporary minimum delay square sum ST tmp Set to ST,

[0071] Step 2.7: Calculate the node for each group G i , and each node P in the group j , perform steps 2.8-2.10,

[0072] Step 2.8: The computing node saves the leader node and group information of the current group and sets a new leader node Calculate the remaining peer nodes P k New group number At this time, the peer node P k In group G i′ In, P k ∈G i′ ,

[0073] Step 2.9: Calculate the nodes according to the new grouping G i′ , 1≤i′≤g, calculate the delay square sum ST′ of all new packets in the same way as steps 2.4-2.5,

[0074] Step 2.10: If ST′ <STtmp , then ST tmp Update to ST′, update the leader node and group information of the current group, and continue to traverse the peer nodes in step 2.7; otherwise, restore the group leader node and group information saved in step 2.8, and continue to traverse the peer nodes in step 2.7.

[0075] Step 2.11: After the traversal in step 2.7 is completed, the grouping information of the current leader node is the best grouping information, and the computing node calculates the best grouping information for each group G. i , let the leader node of the current group confirmation be exist Find the index v1 corresponding to the smallest value and the index v2 corresponding to the second smallest value in the collection, and set and There are two deputy leader nodes for the group, and the deputy leader node information is saved in the best grouping information.

[0076] Step 3: Block synchronization based on grouping: Encapsulate the grouping information into transactions and pack them into blocks. The peer node obtains the distributed blocks. According to the grouping information and leader node information in the block, it confirms the role in the group with the leader node and performs operations corresponding to the role in the group. If the peer node is a normal node role and fails to request the leader node for a preset number of times, it sends a leader node failure request to the computing node.

[0077] Specifically include:

[0078] Step 3.1: The computing node encapsulates the best grouping information into transactions and sends them to the fabric’s sorting node, which packages the transactions into blocks.

[0079] Step 3.2: After the peer node obtains the distributed block in the original way, it obtains the transaction grouping information in the block.

[0080] Step 3.3: If the peer node finds that it is the leader node in the group in the block grouping information, it starts to request blocks from the sorting node; if the peer node finds that it is the deputy leader node in the group in the block grouping information, it monitors the status of the leader node in the group, and after finding that the leader node is in a state of being unable to connect, it actively requests blocks from the sorting node; if the peer node finds that it is an ordinary node in the group in the block grouping information, it starts to request blocks from the leader node in the group.

[0081] Step 3.4: If the peer node fails to request a block from the leader node in the group for more than the preset number of times, it requests a block from the surviving deputy leader node in the group and sends a leader node failure request to the computing node.

[0082] Step 4: The computing node re-elects the leader node: When the computing node receives a preset number of leader node failure requests, the computing node first notifies the peer nodes in the group to count the average network delay between the peer nodes and the sorting nodes and between the peer nodes in the group, and then calculates the square sum of the delays of each peer node in the group based on the average network delay information, and confirms the new leader node and two deputy leader nodes in the group based on the square sum of the delays. Finally, the new leader node and deputy leader node information are encapsulated into transactions and packaged into blocks, which are synchronized to each peer node, so that the peer nodes in the group confirm the roles in the group based on the new leader node information and perform operations corresponding to the roles in the group.

[0083] Specifically include:

[0084] Step 4.1: If the computing node receives a preset number of failure requests from the leader nodes, it sends a fault message to group G. k The peer nodes in the same group send a request to re-elect the leader.

[0085] Step 4.2: Peer node P in the corresponding group i After receiving the re-election request, it sends three block requests to the sorting node and calculates the average delay T′o of the three requests. i (1≤i≤n∧P i ∈G k ), and save it temporarily,

[0086] Step 4.3: Peer node P in the corresponding group i To the rest of the peer nodes P in the group j Send three test requests and calculate the average delay T′p of the three requests ij ((1≤i≤n,1≤j≤n∧P i ∈G k ∧P j ∈G k )) and save it temporarily.

[0087] Step 4.4: Group peer nodes P i The temporarily stored T′o i and T′p ij Send it to the computing node. After the computing node collects the average delay data of all peer nodes, it calculates the sum of squares of the delay within the group. The index node corresponding to the smallest sum of squared delays within the group is selected as the leader node of the group, and the index nodes corresponding to the second smallest and third smallest sum of squared delays within the group are selected as the two deputy leaders of the group.

[0088] Step 4.5: Compute nodes will group G k The new leader node information and deputy leader node information are packaged into transactions and sent to the sorting node. The sorting node packages the transactions into blocks.

[0089] Step 4.6: Group G k After the peer nodes in the group are synchronized to the block through the current deputy leader node, the leader node and deputy leader node are updated according to the information of the corresponding transaction in the block, and the roles in this node group are confirmed, and the corresponding operations in step 3.3 are performed.

[0090] Example 2

[0091] The present invention also provides a device for synchronizing blocks of fabric peer nodes based on network delay, comprising a computing node management module, a peer node management module and a block management module.

[0092] The computing node management module selects computing nodes from the peer nodes of the alliance chain fabric, and the computing nodes initiate data collection through the computing node management module: the computing node management module obtains the information of all peer nodes in the organization through the certificate issuing node, and notifies all peer nodes in the organization to count the average network delay between the peer nodes and the sorting nodes, and between the peer nodes. The computing nodes save the average network delay counted by each peer node.

[0093] The computing node performs data calculation through the computing node management module: the computing node management module reads the pre-configured number of groups, first calculates the temporary leader node and group of the peer node, and the sum of square delays in the group; then tries to replace the temporary leader node in the group with other peer nodes in the group. If a smaller sum of square delay is obtained after replacement, the new leader node and new group are adopted. This iteration is repeated until the leader node and group with the smallest sum of square delay are obtained as the best group, and then two deputy leader nodes in each group are selected.

[0094] The block management module synchronizes blocks according to groups: it encapsulates group information into transactions and packs them into blocks.

[0095] The peer node obtains the distributed blocks through the peer node management module. According to the grouping information and leader node information in the block, the peer node confirms the role in the group with the leader node and performs the operations corresponding to the role in the group. If the peer node is a common node role and the request to the leader node fails for a preset number of times, the peer node management module sends a leader node failure request to the computing node.

[0096] The computing node re-elects the leader node through the computing node management module: when the computing node management module receives a preset number of leader node failure requests, the computing node management module first notifies the peer nodes in the group to count the average network delay between the peer nodes and the sorting nodes and between the peer nodes in the group, and then calculates the square sum of the delays of each peer node in the group based on the average network delay information, and confirms the new leader node and two deputy leader nodes in the group based on the square sum of the delays. Finally, the block management module encapsulates the new leader node and deputy leader node information into transactions and packages them into blocks, which are synchronized to each peer node, so that the peer nodes in the group confirm the roles in the group based on the new leader node information through the peer node management module and perform operations corresponding to the roles in the group.

[0097] As the information interaction and execution process between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention, the specific contents can be found in the description of the embodiment of the method of the present invention and will not be repeated here.

[0098] Similarly, the device of the present invention realizes synchronization of blocks between peer nodes based on statistical network delay. Compared with the original method of using gossip protocol to synchronize blocks between fabric peer nodes, the present invention groups fabric peer nodes and the leader node in the group is mainly responsible for block synchronization, which solves the problems of network message redundancy and low synchronization efficiency when the scale of peer nodes is large. In addition, the grouping of the device of the present invention and the confirmation of the leader node are the better choices calculated based on the latest statistical network delay iteration, which also greatly guarantees the synchronization efficiency.

[0099] Example 3

[0100] The present invention also provides a computer-readable medium for fabric peer node synchronization blocks based on network delay, wherein the computer-readable medium stores computer instructions, and when the computer instructions are executed by a processor, the processor executes the method for fabric peer node synchronization blocks based on network delay. Specifically, a system or device equipped with a storage medium can be provided, on which a software program code for implementing the functions of any of the above embodiments is stored, and a computer (or CPU or MPU) of the system or device reads and executes the program code stored in the storage medium.

[0101] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.

[0102] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.

[0103] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.

[0104] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or written to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.

[0105] It should be noted that not all steps and modules in the above-mentioned processes and device structures are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.

[0106] Example 4

[0107] The present invention also provides an electronic device for fabric peer node synchronization blocks based on network delay, comprising: at least one memory and at least one processor;

[0108] The at least one memory is used to store a machine-readable program;

[0109] The at least one processor is used to call the machine-readable program to execute the method of synchronizing blocks of fabric peer nodes based on network delay.

[0110] The contents of information interaction and execution of readable program processes by the internal processor in the above-mentioned electronic device are based on the same concept as the embodiment of the method of the present invention. For specific contents, please refer to the description in the embodiment of the method of the present invention, and will not be repeated here.

[0111] Similarly, the device of the present invention realizes synchronization of blocks between peer nodes based on statistical network delay. Compared with the original method of using gossip protocol to synchronize blocks between fabric peer nodes, the present invention groups fabric peer nodes and the leader node in the group is mainly responsible for block synchronization, which solves the problems of network message redundancy and low synchronization efficiency when the scale of peer nodes is large. In addition, the grouping of the device of the present invention and the confirmation of the leader node are the better choices calculated based on the latest statistical network delay iteration, which also greatly guarantees the synchronization efficiency.

[0112] The above-described embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or changes made by those skilled in the art based on the present invention are within the protection scope of the present invention. The protection scope of the present invention shall be subject to the claims.

Claims

1. A method for synchronizing blocks among fabric peer nodes based on network delay, Its characteristics are include: Step 1: Select a computing node from the peer nodes of the alliance chain fabric, and the computing node initiates data collection: the computing node obtains the information of all peer nodes in the organization through the certificate issuing node, notifies all peer nodes in the organization to count the average network delay between the peer node and the sorting node, and between the peer nodes. The computing node saves the average network delay counted by each peer node. Step 2: The computing node performs data calculation: The computing node reads the pre-configured number of groups, first calculates the temporary leader node and group of the peer node, and the sum of square delays within the group; then tries to replace the temporary leader node in the group with other peer nodes in the group. If a smaller sum of square delays is obtained after replacement, a new leader node and new group are used. This iteration continues until the leader node and group with the smallest sum of square delays are obtained as the best group, and then two deputy leader nodes in each group are selected. Step 3: Block synchronization based on grouping: Encapsulate the grouping information into transactions and pack them into blocks. The peer node obtains the distributed blocks. According to the grouping information and leader node information in the block, it confirms the role in the group with the leader node and performs the operations corresponding to the role in the group. If the peer node is a common node role and fails to request the leader node for a preset number of times, it sends a leader node failure request to the computing node. Step 4: The computing node re-elects the leader node: When the computing node receives a preset number of leader node failure requests, the computing node first notifies the peer nodes in the group to count the average network delay between the peer nodes and the sorting nodes and between the peer nodes in the group, and then calculates the square sum of the delays of each peer node in the group based on the average network delay information, and confirms the new leader node and two deputy leader nodes in the group based on the square sum of the delays. Finally, the new leader node and deputy leader node information are encapsulated into transactions and packaged into blocks, which are synchronized to each peer node, so that the peer nodes in the group confirm the roles in the group based on the new leader node information and perform operations corresponding to the roles in the group.

2. According to claim 1, a method for synchronizing blocks among fabric peer nodes based on network delay, Its characteristics are Step 1 specifically includes: Step 1.1: The computing node sends a request to the certificate issuing node, requesting the identity and address information of all peer nodes of the organization. Step 1.2: After the computing node obtains the address information of the peer node, it sends a data collection request to the peer node. Step 1.3: Each peer node P i , 1<=i<=n, n is the number of peer nodes in the organization. After receiving the data collection request, three block requests are sent to the sorting node, and the average delay of the three requests is calculated. i , 1<=i<=n, and save temporarily, Step 1.4: Each peer node P i To the rest of the peer nodes P j Send three test requests and calculate the average delay Tp of the three requests ij , 1<=i<=n, 1<=j<=n, i and j are not equal and are temporarily saved, Step 1.5: Each peer node P i To temporarily save i and Tp ij After the computing node collects the average delay data of all peer nodes, it proceeds to step 2.

3. According to claim 1, a method for synchronizing blocks among fabric peer nodes based on network delay, Its characteristics are Step 2 specifically includes: Step 2.1: The computing node reads the pre-configured peer node cluster grouping number g, Step 2.2: The computing node randomly selects g temporary leader nodes {P Li ,(1≤L i ≤n,1≤i≤g)}, Step 2.3: For each non-temporary leader node's peer node P j , computing node computing group number At this time, the peer node P j In group G i In, P j ∈G i , Step 2.4: For each group G i , 1≤i≤g, the computing node is Calculate the peer nodes P in the group j The sum of squares of the delays to the temporary leader node And calculate the delay and Step 2.5: The computing node calculates the delay square sum of all packets ST = ST 1 +ST 2 +…+ST g , Step 2.6: The computing node converts the temporary minimum delay square sum ST tmp Set to ST, Step 2.7: Calculate the node for each group G i , and each node P in the group j , perform steps 2.8-2.10, Step 2.8: The computing node saves the leader node and group information of the current group and sets a new leader node Calculate the remaining peer nodes P k New group number At this time, the peer node P k In group G i′ In, P k ∈G i′ , Step 2.9: Calculate the nodes according to the new grouping G i′ , 1≤i′≤g, calculate the delay square sum ST′ of all new packets in the same way as steps 2.4-2.5, Step 2.10: If ST′ <ST tmp , then ST tmp Update to ST′, update the leader node and group information of the current group, and continue to traverse the peer nodes in step 2.7; otherwise, restore the group leader node and group information saved in step 2.8, and continue to traverse the peer nodes in step 2.

7. Step 2.11: After the traversal in step 2.7 is completed, the grouping information of the current leader node is the best grouping information, and the computing node calculates the best grouping information for each group G. i , let the leader node of the current group confirmation be exist Find the index v corresponding to the minimum value in the collection 1 The index v corresponding to the hour of the sum value 2 ,set up and There are two deputy leader nodes for the group, and the deputy leader node information is saved in the best grouping information.

4. According to claim 1, a method for synchronizing blocks among fabric peer nodes based on network delay, Its characteristics are Step 3 specifically includes: Step 3.1: The computing node encapsulates the best grouping information into transactions and sends them to the fabric’s sorting node, which packages the transactions into blocks. Step 3.2: After the peer node obtains the distributed block in the original way, it obtains the transaction grouping information in the block. Step 3.3: If the peer node finds that it is the leader node in the group in the block grouping information, it starts to request blocks from the sorting node; if the peer node finds that it is the deputy leader node in the group in the block grouping information, it monitors the status of the leader node in the group, and after finding that the leader node is in a state of being unable to connect, it actively requests blocks from the sorting node; if the peer node finds that it is an ordinary node in the group in the block grouping information, it starts to request blocks from the leader node in the group. Step 3.4: If the peer node fails to request a block from the leader node in the group for more than the preset number of times, it requests a block from the surviving deputy leader node in the group and sends a leader node failure request to the computing node.

5. A method for synchronizing blocks among fabric peer nodes based on network delay according to claim 1 or 4, Its characteristics are Step 4 specifically includes: Step 4.1: If the computing node receives a preset number of failure requests from the leader nodes, it sends a fault message to group G. k The peer nodes in the same group send a request to re-elect the leader. Step 4.2: Peer node P in the corresponding group i After receiving the re-election request, it sends three block requests to the sorting node and calculates the average delay T′o of the three requests. i (1≤i≤n∧P i ∈G k ), and save it temporarily, Step 4.3: Peer node P in the corresponding group i To the rest of the peer nodes P in the group j Send three test requests and calculate the average delay T′p of the three requests ij ((1≤i≤n,1≤j≤n∧P i ∈G k ∧P j ∈G k )) and save it temporarily. Step 4.4: Group peer nodes P i The temporarily stored T′o i and T′p ij Send it to the computing node. After the computing node collects the average delay data of all peer nodes, it calculates the sum of squares of the delay within the group. The index node corresponding to the smallest sum of squared delays within the group is selected as the leader node of the group, and the index nodes corresponding to the second smallest and third smallest sum of squared delays within the group are selected as the two deputy leaders of the group. Step 4.5: Compute nodes will group G k The new leader node information and deputy leader node information are packaged into transactions and sent to the sorting node. The sorting node packages the transactions into blocks. Step 4.6: Group G k After the peer nodes in the group are synchronized to the block through the current deputy leader node, the leader node and deputy leader node are updated according to the information of the corresponding transaction in the block, and the roles in this node group are confirmed, and the corresponding operations in step 3.3 are performed.

6. A device for synchronizing blocks among fabric peer nodes based on network delay, Its characteristics are Including computing node management module, peer node management module and block management module, The computing node management module selects computing nodes from the peer nodes of the alliance chain fabric, and the computing nodes initiate data collection through the computing node management module: the computing node management module obtains the information of all peer nodes in the organization through the certificate issuing node, and notifies all peer nodes in the organization to count the average network delay between the peer nodes and the sorting nodes, and between the peer nodes. The computing nodes save the average network delay counted by each peer node. The computing node performs data calculation through the computing node management module: the computing node management module reads the pre-configured number of groups, first calculates the temporary leader node and group of the peer node, and the sum of square delays in the group; then tries to replace the temporary leader node in the group with other peer nodes in the group. If a smaller sum of square delay is obtained after replacement, the new leader node and new group are adopted. This iteration is repeated until the leader node and group with the smallest sum of square delay are obtained as the best group, and then two deputy leader nodes in each group are selected. The block management module synchronizes blocks according to groups: it encapsulates group information into transactions and packs them into blocks. The peer node obtains the distributed blocks through the peer node management module. According to the grouping information and leader node information in the block, the peer node confirms the role in the group with the leader node and performs the operations corresponding to the role in the group. If the peer node is a common node role and the request to the leader node fails for a preset number of times, the peer node management module sends a leader node failure request to the computing node. The computing node re-elects the leader node through the computing node management module: when the computing node management module receives a preset number of leader node failure requests, the computing node management module first notifies the peer nodes in the group to count the average network delay between the peer nodes and the sorting nodes and between the peer nodes in the group, and then calculates the square sum of the delays of each peer node in the group based on the average network delay information, and confirms the new leader node and two deputy leader nodes in the group based on the square sum of the delays. Finally, the block management module encapsulates the new leader node and deputy leader node information into transactions and packages them into blocks, which are synchronized to each peer node, so that the peer nodes in the group confirm the roles in the group based on the new leader node information through the peer node management module and perform operations corresponding to the roles in the group.

7. A computer-readable medium for synchronizing blocks of fabric peer nodes based on network delay, Its characteristics are The computer-readable medium stores computer instructions, and when the computer instructions are executed by a processor, the processor executes a method for synchronizing blocks of fabric peer nodes based on network delay as described in any one of claims 1 to 5.

8. An electronic device for synchronizing blocks of fabric peer nodes based on network delay, Its characteristics are include: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to execute a method for synchronizing blocks of fabric peer nodes based on network delay according to any one of claims 1 to 5.