Data synchronization method and device based on blockchain
By dynamically updating the routing table and weighted scores, the synchronization target nodes are solved, and the blockchain data synchronization problem is inefficient and unstable, achieving efficient and stable data synchronization effect.
Patent Information
- Application Number
- CN202110434093.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-20
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2041-04-20
AI Technical Summary
Data synchronization is inefficient and unstable in blockchain technology. As the amount of block data increases, existing data synchronization methods are difficult to meet the needs of efficient synchronization.
By dynamically updating the routing table between blockchain nodes, determining the optimal candidate nodes for block information synchronization, weighted scoring based on distance and trustworthiness, selecting synchronization target nodes to achieve a local optimal data synchronization scheme.
It improves the efficiency and stability of blockchain data synchronization, ensures that the data synchronization effect reaches local optimality, adapts to network changes, and improves overall synchronization performance.
Smart Images

Figure CN113064951B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of blockchain technology, and in particular to a blockchain-based data synchronization method and device. Background Art
[0002] Since blockchain technology has the characteristics of distributed network storage and a reliable underlying mechanism that does not require a third-party trusted institution, it has greatly expanded the application scenarios of blockchain technology. Each blockchain node in the blockchain platform stores the block data of the entire blockchain, so it is often necessary to synchronize data between different blockchain nodes in the blockchain platform.
[0003] In the process of implementing the technical solution disclosed in the present invention, the inventors found that with the increasing maturity of blockchain technology, the amount of block data has shown a rapid growth trend, and the data synchronization method in the related technology has the problems of low data synchronization efficiency and unstable synchronization process. Summary of the invention
[0004] One aspect of the present disclosure provides a blockchain-based data synchronization method, which is applied to a node to be synchronized, including: determining a first preset number of candidate nodes in a first routing table associated with the node to be synchronized, the first routing table including first routing information between the node to be synchronized and each of the candidate nodes; obtaining a second routing table associated with each of the candidate nodes, wherein the second routing table associated with any candidate node includes second routing information between the candidate node and other nodes; updating the first routing table according to each of the obtained second routing tables to obtain an updated first routing table; determining a second preset number of target nodes as synchronization targets among the first preset number of candidate nodes according to the updated first routing table; and performing a block information synchronization operation for each of the target nodes.
[0005] Optionally, the acquiring the second routing table associated with each of the candidate nodes includes: sending a routing table acquisition request to each of the candidate nodes; and receiving the second routing table returned by each of the candidate nodes based on the acquisition request.
[0006] Optionally, the first routing table is updated according to the acquired second routing tables to obtain an updated first routing table, including: according to the second routing information between the candidate nodes and other nodes in each second routing table, the first routing information between the node to be synchronized and each candidate node is updated to obtain the updated first routing table.
[0007] Optionally, the first routing information between the node to be synchronized and any candidate node indicates the distance from the node to be synchronized to the candidate node, and the second routing information between the candidate node and any other node indicates the distance from the candidate node to the other node; the first routing information between the node to be synchronized and each candidate node is updated according to the second routing information between the candidate node and other nodes in each second routing table to obtain the updated first routing table, including: according to the distance from the candidate node to other nodes indicated by each second routing information, the distance from the node to be synchronized to each candidate node is updated to obtain the updated first routing table.
[0008] Optionally, determining a second preset number of target nodes as synchronization targets from among the first preset number of candidate nodes according to the updated first routing table includes: determining a second preset number of candidate nodes closest to the node to be synchronized from among the first preset number of candidate nodes as the target nodes according to the updated distance from the node to be synchronized to each of the candidate nodes indicated by the updated first routing table; wherein the distance from the node to be synchronized to any candidate node is represented by the number of terminals with network receiving and sending capabilities that the node to be synchronized needs to pass through when sending block information to the candidate node.
[0009] Optionally, the method further includes: obtaining node information for each of the candidate nodes, the node information including the blockchain height, data throughput historical data, and synchronization success rate historical data associated with the candidate node; determining the credibility of each of the candidate nodes based on the obtained node information; determining a second preset number of target nodes as synchronization targets from the first preset number of candidate nodes based on the updated first routing table, including: taking a weighted sum of the distance and the credibility according to weight values pre-assigned to the distance and the credibility to obtain a joint credibility score associated with each of the candidate nodes; and selecting the second preset number of candidate nodes with the highest joint credibility score as the target nodes.
[0010] Optionally, the method also includes: receiving an active synchronization request from a synchronization request node; in response to the received active synchronization request, performing a block information synchronization operation on the synchronization request node, wherein the synchronization request node is a blockchain node that has not performed block information synchronization within a preset time period, and the distance between the synchronization request node and the node to be synchronized is less than a first preset threshold or greater than a second preset threshold.
[0011] Another aspect of the present disclosure provides a blockchain-based data synchronization device, including: a first processing module, used to determine a first preset number of candidate nodes in a first routing table associated with a node to be synchronized, the first routing table including first routing information between the node to be synchronized and each of the candidate nodes; a first acquisition module, used to acquire a second routing table associated with each of the candidate nodes, wherein the second routing table associated with any candidate node includes second routing information between the candidate node and other nodes; a second processing module, used to update the first routing table according to each of the acquired second routing tables to obtain an updated first routing table; a third processing module, used to determine a second preset number of target nodes as synchronization targets among the first preset number of candidate nodes according to the updated first routing table; and a fourth processing module, used to perform block information synchronization operations for each of the target nodes.
[0012] Optionally, the first acquisition module includes: a first processing submodule, configured to send a routing table acquisition request to each of the candidate nodes, and to receive the second routing table returned by each of the candidate nodes based on the acquisition request.
[0013] Optionally, the second processing module includes: a second processing submodule, used to update the first routing information between the node to be synchronized and each candidate node according to the second routing information between the candidate node and other nodes in each second routing table, to obtain the updated first routing table.
[0014] Optionally, the first routing information between the node to be synchronized and any candidate node indicates the distance from the node to be synchronized to the candidate node, and the second routing information between the candidate node and any other node indicates the distance from the candidate node to the other node; the second processing sub-module includes: a first processing unit, used to update the distance from the node to be synchronized to each candidate node according to the distance from the candidate node to other nodes indicated by each second routing information, so as to obtain the updated first routing table.
[0015] Optionally, the third processing module includes: a third processing sub-module, used to determine a second preset number of candidate nodes closest to the node to be synchronized as the target node among the first preset number of candidate nodes based on the updated distance from the node to be synchronized to each of the candidate nodes indicated by the updated first routing table; wherein the distance from the node to be synchronized to any candidate node is represented by the number of terminals with network receiving and sending capabilities that the node to be synchronized needs to pass through when sending block information to the candidate node.
[0016] Optionally, the device also includes: a second acquisition module, used to acquire node information for each of the candidate nodes, the node information including the blockchain height, data throughput historical data, and synchronization success rate historical data associated with the candidate node; a fifth processing module, used to determine the credibility of each of the candidate nodes based on the acquired node information; the third processing module includes: a fourth processing submodule, used to perform weighted summation of the distance and the credibility according to weight values pre-assigned to the distance and the credibility to obtain a joint trust score associated with each of the candidate nodes, and for selecting a second preset number of candidate nodes with the highest joint trust score as the target node.
[0017] Optionally, the device also includes: a sixth processing module, used to receive an active synchronization request from a synchronization request node, and to perform a block information synchronization operation on the synchronization request node in response to the received active synchronization request, wherein the synchronization request node is a blockchain node that has not performed block information synchronization within a preset time period, and the distance between the synchronization request node and the node to be synchronized is less than a first preset threshold or greater than a second preset threshold.
[0018] Another aspect of the present disclosure provides an electronic device, comprising one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method of an embodiment of the present disclosure.
[0019] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the method of the embodiment of the present disclosure when executed.
[0020] Another aspect of the present disclosure provides a computer program product, including computer-readable instructions, wherein the computer-readable instructions are used to execute the blockchain-based data synchronization method of an embodiment of the present disclosure when executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] For a more complete understanding of the present disclosure and its advantages, reference will now be made to the following description taken in conjunction with the accompanying drawings, in which:
[0022] Figure 1 The system architecture of the blockchain-based data synchronization method and device according to an embodiment of the present disclosure is schematically shown;
[0023] Figure 2 A flowchart of a blockchain-based data synchronization method according to an embodiment of the present disclosure is schematically shown;
[0024] Figure 3A flowchart of another blockchain-based data synchronization method according to an embodiment of the present disclosure is schematically shown;
[0025] Figure 4 A schematic diagram schematically shows a first routing table and a second routing table according to an embodiment of the present disclosure;
[0026] Figure 5 A schematic diagram schematically shows updating a first routing table according to an embodiment of the present disclosure;
[0027] Figure 6 A schematic diagram schematically shows a communication link between a node to be synchronized and candidate nodes according to an embodiment of the present disclosure;
[0028] Figure 7 A block diagram of a data synchronization device based on blockchain according to an embodiment of the present disclosure is schematically shown;
[0029] Figure 8 A block diagram of an electronic device according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0030] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0031] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "include", "comprising", etc. used herein indicate the existence of features, operations, operations and / or components, but do not exclude the existence or addition of one or more other features, operations, operations or components.
[0032] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0033] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0034] Some block diagrams and / or flow charts are shown in the accompanying drawings. It should be understood that some boxes or combinations thereof in the block diagrams and / or flow charts can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable blockchain-based data synchronization device, so that these instructions can create a device for implementing the functions / operations described in these block diagrams and / or flow charts when executed by the processor. The technology of the present disclosure can be implemented in the form of hardware and / or software (including firmware, microcode, etc.). In addition, the technology of the present disclosure can take the form of a computer program product on a computer-readable storage medium storing instructions, which can be used by an instruction execution system or in combination with an instruction execution system.
[0035] The embodiment of the present disclosure provides a data synchronization method based on blockchain and a synchronization device capable of applying the method. The method may specifically include the following operations: first, in a first routing table associated with a node to be synchronized, a first preset number of candidate nodes is determined, the first routing table includes first routing information between the node to be synchronized and each candidate node, then, a second routing table associated with each candidate node is obtained, wherein the second routing table associated with any candidate node includes second routing information between the candidate node and other nodes, then, according to each second routing table obtained, the first routing table is updated to obtain an updated first routing table, next, according to the updated first routing table, a second preset number of target nodes as synchronization targets are determined among the first preset number of candidate nodes, and finally, a block information synchronization operation is performed for each target node.
[0036] Figure 1 The system architecture of the blockchain-based data synchronization method and device according to the embodiment of the present disclosure is schematically shown. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0037] like Figure 1As shown, the system architecture 100 includes multiple blockchain nodes in a blockchain network, and the multiple blockchain nodes include nodes to be synchronized (such as node 101 to be synchronized) and other nodes except the nodes to be synchronized.
[0038] First, in the first routing table associated with the node 101 to be synchronized, a first preset number of candidate nodes (a plurality of candidate nodes are shown in the figure, such as candidate nodes 102, 103, 104, 105 and 106) are determined, and the first routing table includes first routing information between the node 101 to be synchronized and each candidate node. Then, a second routing table associated with each candidate node (such as candidate nodes 102, 103, 104, 105 and 106) is obtained, wherein the second routing table associated with any candidate node includes second routing information between the candidate node and other nodes. Then, according to the obtained second routing tables, the first routing table is updated to obtain an updated first routing table. Next, according to the updated first routing table, a second preset number of target nodes as synchronization targets are determined among the first preset number of candidate nodes (such as candidate nodes 102, 103, 104, 105 and 106), and finally a block information synchronization operation is performed on each target node.
[0039] It should be noted that the blockchain-based data synchronization method and device of the embodiment of the present disclosure can be used in the financial field, and can also be used in any field other than the financial field. The present disclosure will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0040] Figure 2 The flowchart of a data synchronization method based on blockchain according to an embodiment of the present disclosure is schematically shown as follows: Figure 2 As shown, method 200 may include operations S210 to S250.
[0041] In operation S210, a first preset number of candidate nodes are determined in a first routing table associated with the node to be synchronized, where the first routing table includes first routing information between the node to be synchronized and each candidate node.
[0042] In this embodiment, specifically, each blockchain node in the blockchain platform can maintain a small range routing table, which can be used for node data synchronization and data transmission. Exemplarily, in the Ethereum network, a blockchain node can maintain a routing table consisting of 17 buckets, each of which contains 16 blockchain nodes. Therefore, the number of nodes in the routing table maintained by the blockchain node is 16*17. In actual network applications, the number of nodes in the routing table maintained by the blockchain node can be set according to business needs, and this application does not limit this.
[0043] The first routing table associated with the node to be synchronized includes first routing information between the node to be synchronized and other nodes. The first routing information may indicate, for example, the distance between the node to be synchronized and other nodes. In the first routing table associated with the node to be synchronized, a first preset number of candidate nodes are determined. The candidate nodes may specifically be nodes in the first routing table that have a data synchronization history record with the node to be synchronized, or nodes whose distance from the node to be synchronized is less than a preset threshold, or nodes whose credibility score is higher than a preset threshold.
[0044] Next, in operation S220, a second routing table associated with each candidate node is acquired, wherein the second routing table associated with any candidate node includes second routing information between the candidate node and other nodes.
[0045] In this embodiment, specifically, after determining a first preset number of candidate nodes, a second routing table associated with each candidate node is obtained, and the second routing table associated with any candidate node includes second routing information between the candidate node and at least one other node. The at least one other node may include the aforementioned node to be synchronized, and may also include other candidate nodes determined by the aforementioned operation.
[0046] The method for obtaining the second routing table associated with each candidate node includes: sending a routing table acquisition request to each candidate node, and receiving the second routing table returned by each candidate node based on the acquisition request. Alternatively, a request may be made to obtain the second routing table associated with each candidate node from a preset node in the blockchain, for example, sending a routing table acquisition request for each candidate node to a root node in the blockchain, and receiving the second routing table associated with each candidate node returned by the root node.
[0047] Next, in operation S230, the first routing table is updated according to the acquired second routing tables to obtain an updated first routing table.
[0048] In this embodiment, specifically, after obtaining the second routing table associated with each candidate node, the first routing information between the node to be synchronized and each candidate node is updated according to the second routing information between the corresponding candidate node and at least one other node indicated by each second routing table, so as to update the first routing table associated with the node to be synchronized and obtain the updated first routing table.
[0049] Next, in operation S240, a second preset number of target nodes as synchronization targets are determined from among the first preset number of candidate nodes according to the updated first routing table.
[0050] In this embodiment, specifically, the updated first routing table indicates the updated first routing information between the node to be synchronized and each candidate node. According to the updated first routing table, among the first preset number of candidate nodes, a second preset number of candidate nodes whose updated first routing information meets the preset conditions are determined as the target nodes for block information synchronization.
[0051] Since the routing information can indicate the distance between different nodes, the aforementioned preset condition can specifically be a condition related to the distance between nodes. Exemplarily, based on the updated first routing information between the node to be synchronized and each candidate node, a second preset number of candidate nodes closest to the node to be synchronized is determined as the target nodes for block information synchronization.
[0052] Next, in operation S250, a block information synchronization operation is performed for each target node.
[0053] In this embodiment, specifically, the block information synchronization operation for each target node is performed through the node to be synchronized. Since the routing information can also indicate the communication links between different nodes, the block information to be synchronized can be sent to each target node through the communication link according to the communication link between the node to be synchronized and each target node indicated by the updated first routing information, so as to realize the block information synchronization of each target node.
[0054] According to the disclosed embodiment, in the first routing table associated with the node to be synchronized, a first preset number of candidate nodes is determined, and the first routing table includes the first routing information between the node to be synchronized and each candidate node; the second routing table associated with each candidate node is obtained, wherein the second routing table associated with any candidate node includes the second routing information between the candidate node and other nodes; according to each second routing table obtained, the first routing table is updated to obtain an updated first routing table; according to the updated first routing table, among the first preset number of candidate nodes, a second preset number of target nodes as synchronization targets are determined; and block information synchronization operations are performed for each target node. By obtaining the second routing table associated with each candidate node, the first routing table associated with the node to be synchronized is updated using the second routing information between the candidate node and other nodes in each second routing table, that is, the first routing information between the node to be synchronized and each candidate node in the first routing table is updated to obtain an updated first routing table, and finally, based on the updated first routing table, the target node as the synchronization target is determined, and block information synchronization operations are performed for each target node. This design dynamically updates the first routing table associated with the node to be synchronized, and determines the target node to be synchronized with the block information based on the updated first routing table, which is conducive to achieving local optimal selection of the target node, improving the data synchronization efficiency in the blockchain, and improving the stability and reliability of data synchronization in the blockchain, so that the data synchronization effect reaches the local optimal level.
[0055] Figure 3 A flowchart of another blockchain-based data synchronization method according to an embodiment of the present disclosure is schematically shown. Figure 3 As shown, method 300 may include operations S310 to S340 and S250.
[0056] In operation S310, a first preset number of candidate nodes is determined in a first routing table associated with the node to be synchronized, wherein the first routing table includes first routing information between the node to be synchronized and each candidate node, wherein the first routing information between the node to be synchronized and any candidate node indicates the distance from the node to be synchronized to the candidate node.
[0057] In this embodiment, specifically, the distance from the node to be synchronized to any candidate node can be characterized by the number of terminals with network transceiver capabilities that the node to be synchronized needs to pass through when sending block information to the candidate node, wherein the terminals with network transceiver capabilities may include, for example, servers, routers, user terminals and other devices.
[0058] In addition, the distance between the node to be synchronized and any candidate node can also be represented by the distance between the node ID of the node to be synchronized and the node ID of the candidate node. Blockchain nodes have node IDs used as global unique identifiers. When determining the distance between different node IDs, the XOR calculation method can be used to calculate the XOR value between different node IDs, convert the calculated XOR value into an unsigned integer, and use the unsigned integer to represent the distance between different node IDs.
[0059] Next, in operation S320, a second routing table associated with each candidate node is obtained, wherein the second routing table associated with any candidate node includes second routing information between the candidate node and other nodes, and the second routing information between the candidate node and any other node indicates the distance from the candidate node to the other node.
[0060] In this embodiment, specifically, the distance from the candidate node to any other node can be represented by the number of terminals with network receiving and sending capabilities that the candidate node needs to pass through when sending block information to the other node, or can also be represented by the distance between the node ID of the candidate node and the node ID of the other node.
[0061] The second routing table associated with any candidate node includes the second routing information between the candidate node and other nodes, that is, the distance information between the candidate node and other nodes. Since other nodes may include nodes to be synchronized, they may also include other candidate nodes that have been determined. Therefore, the obtained second routing table may include the distance information from the candidate node to the node to be synchronized, and may also include the distance information between the candidate node and other candidate nodes.
[0062] When the node to be synchronized transmits block information to any candidate node, it can complete the block information transmission through different communication links. The lengths of the information transmission paths corresponding to different communication links may be different. Specifically, the routing information indicates the shortest distance between different blockchain nodes, that is, the first routing information indicates the shortest distance from the node to be synchronized to each candidate node, and the second routing information associated with any candidate node indicates the shortest distance from the candidate node to other nodes.
[0063] The second routing information associated with any candidate node may indicate the distance from the candidate node to the node to be synchronized, or may indicate the distance from the candidate node to other candidate nodes. Therefore, in order to improve the data synchronization efficiency of the blockchain, the second routing table associated with each candidate node can be used, that is, the second routing information between each candidate node and other nodes can be used to update the first routing information between the node to be synchronized and each candidate node, and based on the real-time updated first routing table, the local optimal candidate node as the synchronization object is determined.
[0064] Next, in operation S330, the distance from the node to be synchronized to each candidate node is updated according to the distance from the candidate node to other nodes indicated by each second routing information, so as to obtain an updated first routing table.
[0065] In this embodiment, specifically, since the real-time status of the routing tables maintained by different blockchain nodes may be different, the distances between the same two blockchain nodes indicated by different routing tables may be different, that is, the number of terminals with network transceiver capabilities that need to be passed when transmitting block information between the same two blockchain nodes indicated by different routing tables may be different. Therefore, the distance from the node to be synchronized to a candidate node indicated by the first routing information may be different from the distance from the candidate node to the node to be synchronized indicated by the second routing information.
[0066] According to the distances from the candidate nodes to other nodes indicated by each second routing information, specifically according to the distances from each candidate node to the node to be synchronized, and according to the distances from each candidate node to other candidate nodes, the distances from the node to be synchronized to each candidate node are updated to obtain an updated first routing table. The goal of updating the distances from the node to be synchronized to each candidate node is to determine the shortest distance from the node to be synchronized to each candidate node, that is, to update the distances from the node to be synchronized to each candidate node in the first routing table to the minimum value of the corresponding distances indicated by the first routing table or the second routing table.
[0067] Figure 4 A schematic diagram schematically shows a first routing table and a second routing table according to an embodiment of the present disclosure, and
[0068] Figure 5 A schematic diagram schematically shows an update of the first routing table according to an embodiment of the present disclosure, and
[0069] Figure 6 A schematic diagram schematically shows a communication link between a node to be synchronized and candidate nodes according to an embodiment of the present disclosure.
[0070] like Figure 4 As shown, the left dotted box schematically shows the first routing table associated with the node A to be synchronized, and the first routing table includes the first routing information between the node A to be synchronized and the candidate nodes B, C, D, E, and F, which can be the distance between the node A to be synchronized and the candidate nodes B, C, D, E, and F. The distances from the node A to be synchronized to the candidate nodes B, C, D, E, and F indicated by the first routing table are 11, 12, 10, 21, and 17, respectively, where the distance from the node A to be synchronized to any of the candidate nodes can be characterized by the number of terminals with network transceiver capabilities that the node A to be synchronized needs to pass through when sending block information to the candidate node.
[0071] The second routing table associated with candidate nodes B, C, D, and E (F is not shown in the figure) is schematically shown in the dotted box on the right. The second routing table includes second routing information of the candidate node and other nodes, which may be the distance from the candidate node to other nodes. Among them, other nodes associated with any candidate node include the node A to be synchronized, and also include other candidate nodes except the candidate node.
[0072] Figure 5 A schematic diagram schematically shows a schematic diagram of updating the first routing table according to an embodiment of the present disclosure, such as Figure 5 As shown, the first routing table associated with the node to be synchronized A is updated by using the second routing tables associated with the candidate nodes B, C, D, and E, respectively, to obtain an updated first routing table. The goal of updating the first routing table is to determine the shortest distances from the node to be synchronized A to the candidate nodes B, C, D, E, and F, respectively, by combining the first routing table and each second routing table.
[0073] For example, Figure 6 As shown, the communication link between the node to be synchronized A and the candidate node B includes the node to be synchronized A directly pointing to the candidate node B, the node to be synchronized A pointing to the candidate node B via the candidate node C, etc. Taking the analysis of the node to be synchronized A directly pointing to the candidate node B as an example, Figure 5 As shown, the first routing table indicates that the distance from the node A to be synchronized to the candidate node B is 11, and the second routing table associated with the candidate node B indicates that the distance from the candidate node B to the node A to be synchronized is 9. At this time, the distance from the node A to be synchronized to the candidate node B needs to be updated to the minimum value of 9, but because the number of hops in the process of sending the routing table acquisition request to the candidate node B by the node A to be synchronized has changed to 6 (the number of hops refers to the number of routers passed from the source end to the destination end, and the number of hops can be used to measure the routing distance between the target IP addresses), therefore, the minimum distance from the node A to be synchronized to the candidate node B is recorded as 6. Comprehensively analyzing other communication links between the node A to be synchronized and the candidate node B, it can be determined that the shortest distance from the node A to be synchronized to the candidate node B is 6, so the corresponding distance value is recorded as 6 in the updated first routing table.
[0074] After the first routing table is updated using the second routing table associated with candidate node B, the first updated first routing table is obtained, and then the first updated first routing table is updated using the second routing table associated with candidate node C to obtain the second updated first routing table. Repeat the above operation until the second routing table associated with the last candidate node is updated to obtain the final updated first routing table. Figure 5 As shown, the first routing table finally updated indicates that the distances from the to-be-synchronized node A to the candidate nodes B, C, D, E, and F are 6, 9, 8, 19, and 7, respectively. Figure 6The values between the node A to be synchronized and the candidate nodes B, C, D, E, and F are the distances between the corresponding nodes indicated by the first routing table after the final update).
[0075] Next, in operation S340, according to the updated distances from the node to be synchronized to each candidate node indicated in the updated first routing table, a second preset number of candidate nodes closest to the node to be synchronized are determined from the first preset number of candidate nodes as target nodes.
[0076] In this embodiment, specifically, according to the updated distances from the node to be synchronized to each candidate node indicated in the updated first routing table, a second preset number of candidate nodes closest to the node to be synchronized are determined from the first preset number of candidate nodes as the target nodes for block information synchronization. Figure 6 As shown, the three candidate nodes (candidate nodes B, F, and D) closest to the node A to be synchronized are determined as the target nodes to be synchronized. By dynamically updating the first routing information associated with the node to be synchronized, the preset number of nodes closest to the node to be synchronized are determined as the target nodes using the updated first routing information. This design is conducive to selecting the best node for block information synchronization among many blockchain nodes, and is conducive to realizing the local optimal data synchronization solution in the blockchain. By realizing the local optimal data synchronization processing for each node to be synchronized, the data synchronization result with the best performance in the entire blockchain can be achieved.
[0077] Optionally, node information for each candidate node may also be obtained, the node information including the blockchain height, data throughput history data, synchronization success rate history data associated with the candidate node, and the credibility of each candidate node may be determined based on the obtained node information. When determining the target node to be synchronized with the block information, the distance and credibility are weighted and summed according to the weight values pre-assigned to the distance and credibility to obtain the joint credibility score associated with each candidate node, and then the second preset number of candidate nodes with the highest joint credibility score are selected as the target node.
[0078] According to the credibility of each candidate node and the distance from the node to be synchronized to each candidate node, the target node for block information synchronization is jointly determined. By selecting the target node with short distance and stable performance for data synchronization, it is conducive to realizing a fair and stable blockchain data synchronization solution that can adapt to network changes, and is conducive to improving the synchronization efficiency and network performance of the overall data synchronization in the blockchain network.
[0079] Next, in operation S250, a block information synchronization operation is performed for each target node.
[0080] In this embodiment, the node to be synchronized synchronizes its own block information to each target node. After receiving the block information of the node to be synchronized, each target node performs an information exchange operation with the node to be synchronized to achieve block information consistency with the node to be synchronized. In practical applications, the number of target nodes can be determined according to the maximum broadcast value allowed by the policy setting, and this value can vary according to the cluster status in a real network environment.
[0081] Optionally, the method further includes: receiving an active synchronization request from a synchronization request node, and in response to the received active synchronization request, performing a block information synchronization operation for the synchronization request node. The synchronization request node is a blockchain node that has not performed block information synchronization within a preset time period, and the distance between the synchronization request node and the node to be synchronized is less than a first preset threshold or greater than a second preset threshold. The node to be synchronized can specifically be one of a preset number of blockchain nodes closest to the synchronization request node, or can be one of a preset number of blockchain nodes farthest from the synchronization request node.
[0082] In order to ensure that every blockchain node in the cluster has the possibility to participate in the block information synchronization process, if any blockchain node does not receive the block information synchronization broadcast from other nodes to be synchronized within the preset time, the blockchain node can actively send a block information synchronization request to the preset number of nodes closest or farthest from itself. The node that receives the block information synchronization request performs the operation of assisting data synchronization to synchronize its own block information to the blockchain node, which is conducive to achieving a complete and stable blockchain data synchronization effect.
[0083] Figure 7 A block diagram of a blockchain-based data synchronization device according to an embodiment of the present disclosure is schematically shown.
[0084] like Figure 7 As shown, the apparatus 700 includes a first processing module 701 , a first acquisition module 702 , a second processing module 703 , a third processing module 704 and a fourth processing module 705 .
[0085] The first processing module 701 is used to determine a first preset number of candidate nodes in a first routing table associated with the node to be synchronized, the first routing table including first routing information between the node to be synchronized and each candidate node; the first acquisition module 702 is used to acquire a second routing table associated with each candidate node, wherein the second routing table associated with any candidate node includes second routing information between the candidate node and other nodes; the second processing module 703 is used to update the first routing table according to the acquired second routing tables to obtain an updated first routing table; the third processing module 704 is used to determine a second preset number of target nodes as synchronization targets among the first preset number of candidate nodes according to the updated first routing table; the fourth processing module 705 is used to perform block information synchronization operations for each target node.
[0086] According to the disclosed embodiment, in the first routing table associated with the node to be synchronized, a first preset number of candidate nodes is determined, and the first routing table includes the first routing information between the node to be synchronized and each candidate node; the second routing table associated with each candidate node is obtained, wherein the second routing table associated with any candidate node includes the second routing information between the candidate node and other nodes; according to each second routing table obtained, the first routing table is updated to obtain an updated first routing table; according to the updated first routing table, among the first preset number of candidate nodes, a second preset number of target nodes as synchronization targets are determined; and block information synchronization operations are performed for each target node. By obtaining the second routing table associated with each candidate node, the first routing table associated with the node to be synchronized is updated using the second routing information between the candidate node and other nodes in each second routing table, that is, the first routing information between the node to be synchronized and each candidate node in the first routing table is updated to obtain an updated first routing table, and finally, based on the updated first routing table, the target node as the synchronization target is determined, and block information synchronization operations are performed for each target node. This design dynamically updates the first routing table associated with the node to be synchronized, and determines the target node to be synchronized with the block information based on the updated first routing table, which is conducive to achieving local optimal selection of the target node, improving the data synchronization efficiency in the blockchain, and improving the stability and reliability of data synchronization in the blockchain, so that the data synchronization effect reaches the local optimal level.
[0087] As a feasible embodiment, the first acquisition module includes: a first processing submodule, configured to send a routing table acquisition request to each candidate node, and configured to receive a second routing table returned by each candidate node based on the acquisition request.
[0088] As a feasible embodiment, the second processing module includes: a second processing submodule, which is used to update the first routing information between the synchronization node and each candidate node according to the second routing information between the candidate node and other nodes in each second routing table to obtain an updated first routing table.
[0089] As a feasible embodiment, the first routing information between the node to be synchronized and any candidate node indicates the distance from the node to be synchronized to the candidate node, and the second routing information between the candidate node and any other node indicates the distance from the candidate node to the other node; the second processing submodule includes: a first processing unit, which is used to update the distance from the node to be synchronized to each candidate node according to the distance from the candidate node to other nodes indicated by each second routing information, so as to obtain an updated first routing table.
[0090] As a feasible embodiment, the third processing module includes: a third processing sub-module, used to determine a second preset number of candidate nodes that are closest to the node to be synchronized among the first preset number of candidate nodes as target nodes based on the updated distance from the node to be synchronized to each candidate node indicated by the updated first routing table; wherein the distance from the node to be synchronized to any candidate node is represented by the number of terminals with network receiving and sending capabilities that the node to be synchronized needs to pass through when sending block information to the candidate node.
[0091] As a feasible embodiment, the device also includes: a second acquisition module, used to obtain node information for each candidate node, the node information includes the blockchain height, data throughput historical data, and synchronization success rate historical data associated with the candidate node; a fifth processing module, used to determine the credibility of each candidate node based on the acquired node information; the third processing module includes: a fourth processing submodule, used to perform weighted summation of the distance and credibility according to the weight values pre-assigned to the distance and credibility, to obtain a joint credibility score associated with each candidate node, and for selecting a second preset number of candidate nodes with the highest joint credibility score as the target node.
[0092] As a feasible embodiment, the device also includes: a sixth processing module, used to receive an active synchronization request from a synchronization request node, and to perform a block information synchronization operation on the synchronization request node in response to the received active synchronization request, wherein the synchronization request node is a blockchain node that has not performed block information synchronization within a preset time period, and the distance between the synchronization request node and the node to be synchronized is less than a first preset threshold or greater than a second preset threshold.
[0093] It should be noted that in the embodiments of the present disclosure, the implementation of the device part is the same as or similar to the implementation of the method part, and will not be repeated here.
[0094] According to any one or more of the modules of the embodiments of the present disclosure, or at least part of the functions of any one of them, can be implemented in one module. According to any one or more of the modules of the embodiments of the present disclosure, it can be split into multiple modules for implementation. According to any one or more of the modules of the embodiments of the present disclosure, it can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware of any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Or according to one or more of the modules of the embodiments of the present disclosure, it can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be performed.
[0095] For example, any multiple of the first processing module 701, the first acquisition module 702, the second processing module 703, the third processing module 704, and the fourth processing module 705 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the first processing module 701, the first acquisition module 702, the second processing module 703, the third processing module 704, and the fourth processing module 705 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware, and firmware, or by a suitable combination of any of them. At least one of the first processing module 701 , the first acquisition module 702 , the second processing module 703 , the third processing module 704 and the fourth processing module 705 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be executed.
[0096] Figure 8 A block diagram of an electronic device according to an embodiment of the present disclosure is schematically shown. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0097] like Figure 8As shown, the electronic device 800 includes a processor 810 and a computer-readable storage medium 820. The electronic device 800 can execute the method according to the embodiment of the present disclosure.
[0098] Specifically, the processor 810 may include, for example, a general-purpose microprocessor, an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 810 may also include an onboard memory for cache purposes. The processor 810 may be a single processing module or multiple processing modules for executing different actions of the method flow according to an embodiment of the present disclosure.
[0099] The computer-readable storage medium 820 may be, for example, a non-volatile computer-readable storage medium, specific examples of which include but are not limited to: magnetic storage devices, such as magnetic tapes or hard disks (HDDs); optical storage devices, such as compact disks (CD-ROMs); memories, such as random access memories (RAMs) or flash memories; and the like.
[0100] The computer-readable storage medium 820 may include a computer program 821 , which may include code / computer-executable instructions that, when executed by the processor 810 , cause the processor 810 to perform a method according to an embodiment of the present disclosure or any variation thereof.
[0101] The computer program 821 may be configured to have, for example, a computer program code including a computer program module. For example, in an example embodiment, the code in the computer program 821 may include one or more program modules, for example, including module 821A, module 821B, ... It should be noted that the division method and number of modules are not fixed, and those skilled in the art may use appropriate program modules or program module combinations according to actual conditions, and when these program module combinations are executed by the processor 810, the processor 810 may execute the method according to the embodiment of the present disclosure or any variation thereof.
[0102] According to an embodiment of the present disclosure, at least one of the first processing module 701, the first acquisition module 702, the second processing module 703, the third processing module 704, and the fourth processing module 705 can be implemented as a reference. Figure 8 The computer program modules described herein, when executed by the processor 810, can implement the corresponding operations described above.
[0103] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0104] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0105] It will be appreciated by those skilled in the art that, although the present disclosure has been shown and described with reference to specific exemplary embodiments of the present disclosure, it will be appreciated by those skilled in the art that, without departing from the spirit and scope of the present disclosure as defined by the appended claims and their equivalents, various changes in form and detail may be made to the present disclosure. Therefore, the scope of the present disclosure should not be limited to the above-described embodiments, but should be determined not only by the appended claims, but also by the equivalents of the appended claims.
Claims
1. A data synchronization method based on blockchain, applied to a node to be synchronized, comprising: Determine a first preset number of candidate nodes in a first routing table associated with the node to be synchronized, wherein the first routing table includes first routing information between the node to be synchronized and each of the candidate nodes; Acquire a second routing table associated with each of the candidate nodes, wherein the second routing table associated with any candidate node includes second routing information between the candidate node and other nodes; According to each of the acquired second routing tables, the first routing table is updated to obtain an updated first routing table; Determining, according to the updated first routing table, a second preset number of target nodes as synchronization targets from among the first preset number of candidate nodes; Perform block information synchronization operations on each of the target nodes, The updating of the first routing table according to each of the acquired second routing tables to obtain an updated first routing table includes: According to the second routing information between the candidate node and other nodes in each of the second routing tables, the first routing information between the node to be synchronized and each of the candidate nodes is updated to obtain the updated first routing table, The first routing information between the node to be synchronized and any candidate node indicates the distance from the node to be synchronized to the candidate node, and the second routing information between the candidate node and any other node indicates the distance from the candidate node to the other node; The updating of the first routing information between the node to be synchronized and each of the candidate nodes according to the second routing information between the candidate node and other nodes in each of the second routing tables to obtain the updated first routing table includes: According to the distances from the candidate nodes to other nodes indicated by each of the second routing information, the distances from the node to be synchronized to each of the candidate nodes are updated to obtain the updated first routing table.
2. The method according to claim 1, wherein: The obtaining of the second routing table associated with each of the candidate nodes includes: Sending a routing table acquisition request to each of the candidate nodes; and Receive the second routing table returned by each of the candidate nodes based on the acquisition request.
3. The method according to claim 1, wherein: The step of determining, according to the updated first routing table, a second preset number of target nodes as synchronization targets from among the first preset number of candidate nodes comprises: According to the updated distances from the node to be synchronized to each of the candidate nodes indicated in the updated first routing table, a second preset number of candidate nodes closest to the node to be synchronized are determined from the first preset number of candidate nodes as the target nodes, The distance between the node to be synchronized and any candidate node is represented by the number of terminals with network transceiver capabilities that the node to be synchronized needs to pass through when sending block information to the candidate node.
4. The method according to claim 1, further comprising: Obtaining node information for each of the candidate nodes, the node information including the blockchain height, data throughput historical data, or synchronization success rate historical data associated with the candidate node; Determining the credibility of each of the candidate nodes according to the acquired node information; The step of determining, according to the updated first routing table, a second preset number of target nodes as synchronization targets from among the first preset number of candidate nodes comprises: According to the weight values pre-assigned to the distance and the credibility, weighted summation is performed on the distance and the credibility to obtain a joint credibility score associated with each of the candidate nodes; A second preset number of candidate nodes with the highest joint trustworthiness scores are selected as the target nodes.
5. The method according to claim 1, further comprising: Receiving active synchronization requests from synchronization request nodes; In response to the received active synchronization request, a block information synchronization operation is performed on the synchronization requesting node, Among them, the synchronization request node is a blockchain node that has not synchronized block information within a preset time period, and the distance between the synchronization request node and the node to be synchronized is less than a first preset threshold or greater than a second preset threshold.
6. A data synchronization device based on blockchain, comprising: A first processing module, configured to determine a first preset number of candidate nodes in a first routing table associated with the node to be synchronized, wherein the first routing table includes first routing information between the node to be synchronized and each of the candidate nodes; A first acquisition module is used to acquire a second routing table associated with each of the candidate nodes, wherein the second routing table associated with any candidate node includes second routing information between the candidate node and other nodes; A second processing module, configured to update the first routing table according to the acquired second routing tables to obtain an updated first routing table; A third processing module, configured to determine, according to the updated first routing table, a second preset number of target nodes as synchronization targets from among the first preset number of candidate nodes; The fourth processing module is used to perform a block information synchronization operation for each of the target nodes. The updating of the first routing table according to each of the acquired second routing tables to obtain an updated first routing table includes: According to the second routing information between the candidate node and other nodes in each of the second routing tables, the first routing information between the node to be synchronized and each of the candidate nodes is updated to obtain the updated first routing table, The first routing information between the node to be synchronized and any candidate node indicates the distance from the node to be synchronized to the candidate node, and the second routing information between the candidate node and any other node indicates the distance from the candidate node to the other node; The updating of the first routing information between the node to be synchronized and each of the candidate nodes according to the second routing information between the candidate node and other nodes in each of the second routing tables to obtain the updated first routing table includes: According to the distances from the candidate nodes to other nodes indicated by each of the second routing information, the distances from the node to be synchronized to each of the candidate nodes are updated to obtain the updated first routing table.
7. An electronic device comprising: one or more processors; as well as a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Node synchronization method and apparatus of blockchain
CN108924223A
Block chain network data synchronization method and system, electronic equipment and readable medium
CN112231415A