Block chain data synchronization method and device, electronic equipment, medium and product

By diversion of data to different receiving channels according to data type in the blockchain network, the problems of low transmission efficiency and high latency caused by competition in a single channel are solved, and more efficient and accurate data synchronization is achieved.

CN119071308AActive Publication Date: 2024-12-03MIDEA NETWORK INFORMATION SERVICE (SHENZHEN) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410996457.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2024-12-03
Estimated Expiration
2044-07-23

AI Technical Summary

Technical Problem

In blockchain networks, data synchronization through a single channel leads to low data transmission efficiency and high latency, serious competition, affecting data synchronization efficiency and accuracy.

Method used

The data is diverted to different receiving channels according to the data type, ensuring that synchronous data is sent directly to the target data processing module, avoiding competition from single channel, and improving transmission efficiency and accuracy.

Benefits of technology

Through data type diversion, the efficiency and accuracy of blockchain data synchronization is improved, transmission delay is reduced, and data can be delivered to the target processing module accurately.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119071308A_ABST
    Figure CN119071308A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of block chains, and provides a block chain data synchronization method and device, electronic equipment, a medium and a product. The method comprises the following steps: receiving synchronization data transmitted by a synchronization node in the block chain; based on a target data type of the synchronous data, sending the synchronous data to a target receiving channel corresponding to the target data type; different data types correspond to different receiving channels; sending the synchronous data in the target receiving channel to a target data processing module corresponding to the target receiving channel; the target data processing module is used for completing data synchronization processing; and different receiving channels correspond to different data processing modules. According to the invention, the data can be distributed to different receiving channels according to the data type, so that the competition condition of all data on a single channel is avoided, the synchronous data can be ensured to be directly sent to the target data processing module capable of processing the synchronous data, and the data synchronization efficiency of the block chain is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain data synchronization method, device, electronic device, medium and product. Background Art

[0002] As a distributed ledger system based on cryptographic principles and consensus mechanisms, blockchain provides support for building a decentralized trust network by ensuring the immutability and transparency of data. In the blockchain network, data is stored in multiple nodes, and each node holds a complete copy of the ledger, thus avoiding the risk of single point failure and improving data security; therefore, it is necessary to synchronize the data of each node in the blockchain to ensure data security.

[0003] Currently, data synchronization is achieved through a single channel. However, all synchronization data are transmitted on one channel, which will lead to competition between the synchronization data, thereby reducing the transmission efficiency and causing transmission delay, that is, reducing the data synchronization efficiency. Summary of the invention

[0004] The present invention aims to solve at least one of the technical problems existing in the related art. To this end, the present invention proposes a data synchronization method for blockchain, which can divert data to different receiving channels according to the data type, avoid the competition of all data on a single channel, and then ensure that the synchronized data is directly sent to the target data processing module that can process it, thereby improving the transmission efficiency and reducing the transmission delay, that is, improving the data synchronization efficiency of blockchain.

[0005] The present invention also proposes a data synchronization device for blockchain.

[0006] The invention also provides an electronic device.

[0007] The present invention also provides a storage medium.

[0008] The present invention also provides a computer program product.

[0009] The blockchain data synchronization method according to the first aspect of the present invention is applied to a node to be synchronized in the blockchain, and the method includes: Receiving synchronization data transmitted by a synchronization node in the blockchain; Based on the target data type of the synchronization data, the synchronization data is sent to a target receiving channel corresponding to the target data type; different data types correspond to different receiving channels; The synchronization data in the target receiving channel is sent to a target data processing module corresponding to the target receiving channel; the target data processing module is used to complete data synchronization processing; different receiving channels correspond to different data processing modules.

[0010] According to the data synchronization method of the blockchain of the embodiment of the present invention, the synchronization data transmitted by the synchronization node in the blockchain is received, and based on the target data type of the synchronization data, the synchronization data is sent to the target receiving channel corresponding to the target data type, so that the synchronization data in the target receiving channel is sent to the target data processing module corresponding to the target receiving channel, so that the data can be diverted to different receiving channels according to the data type, avoiding the competition of all data on a single channel, and further ensuring that the synchronization data is directly sent to the target data processing module that can process it, thereby improving the transmission efficiency and reducing the transmission delay, that is, improving the data synchronization efficiency of the blockchain; at the same time, the synchronization data is sent to the corresponding target receiving channel according to the target data type, thereby ensuring that the synchronization data can be accurately delivered to the target data processing module, thereby improving the data synchronization accuracy of the blockchain.

[0011] According to one embodiment of the present invention, the receiving synchronization data transmitted by the synchronization node in the blockchain includes: Receiving the synchronization data through a data receiving channel; the data receiving channel is used to receive transmission data of nodes in the blockchain other than the node to be synchronized; The sending the synchronization data to a target receiving channel corresponding to the target data type based on the target data type of the synchronization data includes: Based on the target data type of the synchronization data, the synchronization data in the data receiving channel is sent to a target receiving channel corresponding to the target data type.

[0012] According to one embodiment of the present invention, the receiving the synchronization data through a data receiving channel includes: Monitoring a first target data transmission channel between the node to be synchronized and the synchronization node; If it is monitored that the first target data transmission channel contains synchronization data, the synchronization data in the first target data transmission channel is received through a data receiving channel; The sending, based on the target data type of the synchronization data, the synchronization data in the data receiving channel to a target receiving channel corresponding to the target data type, comprises: monitoring the data receiving channel; If it is monitored that the data receiving channel contains synchronization data, based on the target data type, the synchronization data in the data receiving channel is sent to a target receiving channel corresponding to the target data type.

[0013] According to an embodiment of the present invention, the step of sending the synchronization data in the target receiving channel to a target data processing module corresponding to the target receiving channel includes: monitoring the target receiving channel; If it is monitored that synchronization data exists in the target receiving channel, the synchronization data in the target receiving channel is sent to the target data processing module.

[0014] According to one embodiment of the present invention, it also includes: Determine in sequence whether each node identified in the surviving node list is in a surviving state; the surviving node list is used to record the identification information of the surviving nodes in the blockchain except the node to be synchronized, and each node identified in the surviving node list establishes a connection with the node to be synchronized respectively; If it is determined that there is identification information of a target node that is not in a surviving state in the surviving node list, the identification information of the target node in the surviving node list is deleted, and the identification information of the target node is added to the dead node list, and the connection between the node to be synchronized and the target node is deleted; the dead node list is used to record the identification information of dead nodes in the blockchain except the node to be synchronized.

[0015] According to one embodiment of the present invention, it also includes: Determine in sequence whether each node identified in the dead node list is in a live state; the dead node list is used to record the identification information of the dead nodes in the blockchain except the node to be synchronized; If it is determined that there is identification information of an Easter node in a surviving state in the dead node list, the identification information of the Easter node in the dead node list is deleted, and the identification information of the Easter node is added to the surviving node list, and a connection is established between the node to be synchronized and the Easter node; the surviving node list is used to record the identification information of the surviving nodes in the blockchain except the node to be synchronized, and each node identified in the surviving node list establishes a connection with the node to be synchronized respectively.

[0016] According to an embodiment of the present invention, establishing a connection between the node to be synchronized and the Easter node includes: Establishing a second target data transmission channel between the node to be synchronized and the Easter node; Monitor the second target data transmission channel.

[0017] According to one embodiment of the present invention, it also includes: Determine the target data synchronization scenario for the data to be synchronized; Determine the target data transmission mode corresponding to the target data synchronization scenario based on the scenario-transmission mode mapping relationship, wherein the scenario-transmission mode mapping relationship includes multiple sub-mapping relationships, and any of the sub-mapping relationships represents a correspondence between a data synchronization scenario and a data transmission mode; Based on the target data transmission mode, determining a receiving node to which the to-be-synchronized data needs to be sent; the receiving node is a node in the blockchain; The data to be synchronized is sent to a third target data transmission channel between the node to be synchronized and the receiving node, so that the receiving node receives the data to be synchronized in the third target data transmission channel.

[0018] According to the second aspect of the present invention, the data synchronization device of the blockchain is deployed in the node to be synchronized in the blockchain, and the device includes: A data receiving module, used to receive synchronization data transmitted by a synchronization node in the blockchain; A first sending module, configured to send the synchronization data to a target receiving channel corresponding to the target data type based on the target data type of the synchronization data; different data types correspond to different receiving channels; The second sending module is used to send the synchronization data in the target receiving channel to the target data processing module corresponding to the target receiving channel; the target data processing module is used to complete data synchronization processing; different receiving channels correspond to different data processing modules.

[0019] According to an embodiment of the third aspect of the present invention, an electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the program, a blockchain data synchronization method as described in any one of the above is implemented.

[0020] According to the non-transitory computer-readable storage medium of the fourth aspect embodiment of the present invention, a computer program is stored thereon, and when the computer program is executed by a processor, a blockchain data synchronization method as described in any one of the above is implemented.

[0021] A computer program product according to an embodiment of the fifth aspect of the present invention includes a computer program, which, when executed by a processor, implements a blockchain data synchronization method as described in any one of the above.

[0022] The above one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects: Receive the synchronization data transmitted by the synchronization node in the blockchain, and based on the target data type of the synchronization data, send the synchronization data to the target receiving channel corresponding to the target data type, so as to send the synchronization data in the target receiving channel to the target data processing module corresponding to the target receiving channel, so that the data can be diverted to different receiving channels according to the data type, avoiding the competition of all data on a single channel, and then ensuring that the synchronization data is directly sent to the target data processing module that can process it, thereby improving the transmission efficiency and reducing the transmission delay, that is, improving the data synchronization efficiency of the blockchain; at the same time, send the synchronization data to the corresponding target receiving channel according to the target data type, so as to ensure that the synchronization data can be accurately delivered to the target data processing module, thereby improving the data synchronization accuracy of the blockchain.

[0023] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0025] Figure 1 This is one of the flow charts of the data synchronization method of the blockchain provided in an embodiment of the present invention.

[0026] Figure 2 This is the second flow chart of the data synchronization method of the blockchain provided in an embodiment of the present invention.

[0027] Figure 3 It is a schematic diagram of channel connection provided by an embodiment of the present invention.

[0028] Figure 4 It is a structural diagram of a data synchronization device for a blockchain provided in an embodiment of the present invention.

[0029] Figure 5 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0031] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiments of the present application. In addition, the terms "first", "second", and "third" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradicting each other.

[0032] The present invention proposes the following embodiments. Figure 1-Figure 3 The present invention describes a method for synchronizing blockchain data.

[0033] Figure 1 This is one of the flow charts of the data synchronization method of the blockchain provided by the present invention, such as Figure 1 As shown, the data synchronization method of the blockchain includes the following steps 110, 120 and 130. The method is applied to the node to be synchronized in the blockchain, and the method can be applied to any node in the blockchain, that is, the node to be synchronized can be any node in the blockchain.

[0034] Step 110: Receive synchronization data transmitted by the synchronization node in the blockchain.

[0035] Here, the synchronization node is any node in the blockchain except the node to be synchronized. The synchronization data is the data transmitted by the synchronization node, and it is the data that needs to be synchronized to the node to be synchronized.

[0036] In one embodiment, the synchronization data is received through a data receiving channel to send the synchronization data in the data receiving channel to a target receiving channel corresponding to the target data type. The data receiving channel is used to receive transmission data from nodes other than the node to be synchronized in the blockchain.

[0037] The data receiving channel is a receiving channel dedicated to the node to be synchronized, and is dedicated to receiving data transmitted from other nodes.

[0038] Furthermore, before the above step 110, the first node establishes its own communication server and registers a data receiving channel. Exemplarily, when the node to be synchronized is started, the communication server is started at the same time, and a data receiving channel for receiving blockchain data is created. For example, the communication server is a P2P (Peer-to-Peer Protocol) server.

[0039] In another embodiment, the synchronization data is received via a first target data transmission channel between the node to be synchronized and the synchronization node.

[0040] Further, the first target data transmission channel is monitored; if synchronization data is detected in the first target data transmission channel, the synchronization data in the first target data transmission channel is received to send the synchronization data in the first target data transmission channel to the target receiving channel corresponding to the target data type.

[0041] Furthermore, before the above step 110, a first target data transmission channel is established between the node to be synchronized and the synchronization node. Furthermore, a connection is established between the node to be synchronized and the synchronization node, specifically including the establishment of a client, the establishment of a stream connection, etc. In one example, a connection between nodes is established in advance with other surviving nodes in the blockchain except the node to be synchronized.

[0042] Furthermore, after establishing a data transmission channel between the node to be synchronized and other nodes, the data transmission channel is monitored, so as to immediately send synchronization data to the corresponding node when synchronization data exists in the data transmission channel.

[0043] Step 120: Based on the target data type of the synchronization data, send the synchronization data to a target receiving channel corresponding to the target data type.

[0044] Among them, different data types correspond to different receiving channels.

[0045] Here, the target data type may include but is not limited to: transaction data type, block data type, block height data type, etc.

[0046] One data type corresponds to one receiving channel, that is, each data type has a dedicated receiving channel, so that data can be diverted to different receiving channels according to the data type, avoiding the competition of all data on a single channel, thereby improving transmission efficiency and reducing transmission delay. Based on this, the receiving channel corresponding to each data type needs to be established in advance.

[0047] In one embodiment, based on the target data type, the target receiving channel corresponding to the target data type is registered in advance. Exemplarily, the target receiving channel corresponding to the target data type is registered with the node to be synchronized. For example, the transaction pool module, block pool module, etc. inside the node to be synchronized will register receiving channels corresponding to different data types with the node to be synchronized; the transaction pool module is responsible for the management of transactions, that is, for synchronizing transactions; the block pool module is responsible for the management of blocks, and is used to synchronize block height, block and other data.

[0048] Furthermore, after the receiving channels corresponding to the data types are established, the receiving channels are monitored so as to immediately send the synchronous data to the corresponding data processing module when there is synchronous data in the receiving channel.

[0049] Step 130: Send the synchronization data in the target receiving channel to a target data processing module corresponding to the target receiving channel.

[0050] The target data processing module is used to complete data synchronization processing, such as submission and disk processing; different receiving channels correspond to different data processing modules.

[0051] One receiving channel corresponds to one data processing module, that is, each data processing module has a dedicated receiving channel, so that data can be diverted to different receiving channels according to the data type, avoiding competition among all data on a single channel, and ensuring that the synchronous data is sent directly to the target data processing module that can process it, thereby improving transmission efficiency and reducing transmission delay; at the same time, the synchronous data is sent to the corresponding target receiving channel according to the target data type, thereby ensuring that the synchronous data can be accurately delivered to the target data processing module, thereby improving the accuracy of data synchronization.

[0052] The data synchronization method of the blockchain provided by the embodiment of the present invention receives the synchronization data transmitted by the synchronization node in the blockchain, and based on the target data type of the synchronization data, sends the synchronization data to the target receiving channel corresponding to the target data type, so as to send the synchronization data in the target receiving channel to the target data processing module corresponding to the target receiving channel, so that the data can be diverted to different receiving channels according to the data type, avoiding the competition of all data on a single channel, and further ensuring that the synchronization data is directly sent to the target data processing module that can process it, thereby improving the transmission efficiency and reducing the transmission delay, that is, improving the data synchronization efficiency of the blockchain; at the same time, the synchronization data is sent to the corresponding target receiving channel according to the target data type, thereby ensuring that the synchronization data can be accurately delivered to the target data processing module, thereby improving the data synchronization accuracy of the blockchain.

[0053] Based on any of the above embodiments, in the method, the above step 110 includes: receiving the synchronization data through a data receiving channel. The data receiving channel is used to receive transmission data from nodes in the blockchain other than the node to be synchronized.

[0054] Here, the data receiving channel is a receiving channel dedicated to the node to be synchronized, and is dedicated to receiving data transmitted from other nodes.

[0055] Furthermore, before the above step 110, the node to be synchronized establishes its own communication server and registers a data receiving channel. Exemplarily, when the node to be synchronized is started, the communication server is started at the same time, and a data receiving channel for receiving blockchain data is created. That is, when the node to be synchronized receives data, it will put the data into the data receiving channel.

[0056] Correspondingly, in the method, the above step 120 includes: based on the target data type of the synchronization data, sending the synchronization data in the data receiving channel to a target receiving channel corresponding to the target data type.

[0057] The blockchain data synchronization method provided by the embodiment of the present invention receives the synchronization data sent by other nodes through the data receiving channel dedicated to the node to be synchronized, thereby ensuring that the synchronization data in the data receiving channel is accurately sent to the target receiving channel corresponding to the target data type, and then accurately diverts the data to different receiving channels according to the data type, ultimately further improving the data synchronization efficiency and data synchronization accuracy of the blockchain

[0058] Based on any of the above embodiments, in the method, receiving the synchronization data through a data receiving channel includes: monitoring a first target data transmission channel between the node to be synchronized and the synchronization node; if it is monitored that there is synchronization data in the first target data transmission channel, receiving the synchronization data in the first target data transmission channel through a data receiving channel.

[0059] Here, the first target data transmission channel is used to transmit data of the node to be synchronized to the synchronization node, and is used to transmit data of the synchronization node to the node to be synchronized.

[0060] Furthermore, before the above step 110, a first target data transmission channel is established between the node to be synchronized and the synchronization node. Furthermore, a connection is established between the node to be synchronized and the synchronization node, specifically including the establishment of a client, the establishment of a stream connection, etc. In one example, a connection between nodes is established in advance with other surviving nodes in the blockchain except the node to be synchronized, that is, a stable stream connection and data transmission channel are established with all surviving nodes.

[0061] Further, after establishing the first target data transmission channel between the node to be synchronized and the synchronization node, the first target data transmission channel is monitored to immediately receive the synchronization data in the first target data transmission channel through the data receiving channel when there is synchronization data in the first target data transmission channel.

[0062] In one embodiment, a real-time listening thread is started for the first target data transmission channel to respond to changes in data in the first target data transmission channel in real time, that is, when new data arrives in the first target data transmission channel, the real-time listening thread will immediately push the data to the data receiving channel.

[0063] The data synchronization method of the blockchain provided by the embodiment of the present invention monitors the first target data transmission channel between the node to be synchronized and the synchronization node. If the synchronization data is monitored in the first target data transmission channel, the synchronization data in the first target data transmission channel can be immediately received through the data receiving channel, thereby improving the real-time performance of data transmission, thereby improving the real-time performance of blockchain data synchronization, and ultimately ensuring the reliability of the blockchain. In addition, monitoring the first target data transmission channel ensures rapid response and processing of data, thereby achieving data synchronization with nearly zero delay, which is crucial for blockchain applications that require real-time confirmation.

[0064] Based on any of the above embodiments, in the method, based on the target data type of the synchronization data, sending the synchronization data in the data receiving channel to the target receiving channel corresponding to the target data type includes: monitoring the data receiving channel; if it is monitored that there is synchronization data in the data receiving channel, based on the target data type, sending the synchronization data in the data receiving channel to the target receiving channel corresponding to the target data type.

[0065] Further, after the data receiving channel is established, the data receiving channel is monitored, so that when there is synchronization data in the data receiving channel, the synchronization data in the data receiving channel is immediately sent to the target receiving channel corresponding to the target data type.

[0066] In one embodiment, a real-time monitoring thread is started for the data receiving channel to respond to changes in data in the data receiving channel in real time, that is, when new data arrives in the data receiving channel, the real-time monitoring thread will immediately push the data to the target receiving channel.

[0067] The data synchronization method of the blockchain provided by the embodiment of the present invention monitors the data receiving channel. If the data receiving channel is monitored to have synchronization data, the synchronization data in the data receiving channel can be immediately sent to the target receiving channel corresponding to the target data type, thereby improving the real-time performance of data transmission, thereby improving the real-time performance of blockchain data synchronization, and ultimately ensuring the reliability of the blockchain. In addition, monitoring the data receiving channel ensures rapid response and processing of data, thereby achieving data synchronization with nearly zero delay, which is crucial for blockchain applications that require real-time confirmation.

[0068] Based on any of the above embodiments, in the method, the above step 130 includes: monitoring the target receiving channel; if synchronization data is detected in the target receiving channel, sending the synchronization data in the target receiving channel to the target data processing module.

[0069] Further, after the target receiving channel is established, the target receiving channel is monitored, so that when there is synchronization data in the target receiving channel, the synchronization data in the target receiving channel is immediately sent to the target data processing module.

[0070] In one embodiment, a real-time monitoring thread is started for the target receiving channel to respond to changes in data in the target receiving channel in real time, that is, when new data arrives in the target receiving channel, the real-time monitoring thread will immediately push the data to the target data processing module.

[0071] The data synchronization method of the blockchain provided by the embodiment of the present invention monitors the target receiving channel. If the target receiving channel is monitored to have synchronization data, the synchronization data in the target receiving channel can be immediately sent to the target data processing module, thereby improving the real-time performance of data transmission, thereby improving the real-time performance of blockchain data synchronization, and ultimately ensuring the reliability of the blockchain. In addition, monitoring the target receiving channel ensures rapid response and processing of data, thereby achieving data synchronization with nearly zero delay, which is crucial for blockchain applications that require real-time confirmation.

[0072] Based on any of the above embodiments, the method further includes: determining in turn whether each node identified in the surviving node list is in a surviving state; the surviving node list is used to record the identification information of the surviving nodes in the blockchain except the node to be synchronized, and each node identified in the surviving node list establishes a connection with the node to be synchronized respectively; if it is determined that there is identification information of a target node that is not in a surviving state in the surviving node list, deleting the identification information of the target node in the surviving node list, adding the identification information of the target node to the dead node list, and deleting the connection between the node to be synchronized and the target node; the dead node list is used to record the identification information of the dead nodes in the blockchain except the node to be synchronized.

[0073] Here, the surviving node list is a node list stored in the node to be synchronized. The surviving node list may include identification information of 0, 1 or more surviving nodes, and the identification information is used to uniquely identify the surviving nodes. In one embodiment, the surviving node is a node that joins the transaction.

[0074] In one embodiment, it is determined periodically and in turn whether each node identified in the surviving node list is in a surviving state, that is, the surviving state of each node in the blockchain is regularly detected to dynamically maintain the surviving node list.

[0075] In one embodiment, the node to be synchronized actively detects whether each node identified in the surviving node list is in a surviving state. For example, the node to be synchronized actively pings each node identified in the surviving node list, and if the ping is successful, the node is in a surviving state.

[0076] In another embodiment, it is determined whether a node exit event message is received. If a node exit event message is received and the node corresponding to the node exit event message is a node identified in a surviving node list, it is determined that the node is not in a surviving state.

[0077] Furthermore, when the node to be synchronized is started, it is determined whether other nodes in the blockchain except the node to be synchronized exist in a live state, the identification information of the nodes in a live state is added to the live node list, and each node identified in the live node list is connected to the node to be synchronized. In one embodiment, establishing a connection includes establishing a data transmission channel, stream, and client between the node and the node to be synchronized.

[0078] Here, the dead node list is a list of nodes stored in the node to be synchronized. The dead node list may include identification information of 0, 1 or more dead nodes, and the identification information is used to uniquely identify the dead node. In one embodiment, the dead node is a node that exits the transaction.

[0079] It should be noted that since each node identified in the surviving node list establishes a connection with the node to be synchronized in advance, when it is detected that the target node identified in the surviving node list is inactive, the identification information of the target node is removed from the surviving node list to the dead node list, and the connection between the node to be synchronized and the target node is deleted.

[0080] Furthermore, when a new node is detected in the blockchain, the identification information of the new node is added to the list of surviving nodes, and the new node is connected to the node to be synchronized. The new node is a surviving node. For example, the transaction message monitoring of the new node is started, and when the new node is detected to join the transaction, the connection between the new node and the node to be synchronized is established. Based on this, by quickly identifying and accepting new nodes, the blockchain can continue to expand and maintain vitality.

[0081] Furthermore, after establishing the connection between other nodes in the blockchain and the node to be synchronized, the data transmission channel between the other nodes and the node to be synchronized is monitored.

[0082] It should be understood that if it is determined that there is no identification information of the target node that is not in the surviving state in the surviving node list, no processing is required.

[0083] The blockchain data synchronization method provided by the embodiment of the present invention determines in turn whether each node identified in the surviving node list is in a surviving state, and each node identified in the surviving node list establishes a connection with the node to be synchronized respectively. If it is determined that there is identification information of a target node that is not in a surviving state in the surviving node list, the identification information of the target node in the surviving node list is deleted, and the identification information of the target node is added to the dead node list, and the connection between the node to be synchronized and the target node is deleted, so as to timely discover and remove the dead node, avoid the dead node still establishing a connection with the node to be synchronized, that is, the connection status between the nodes can be updated in time, thereby reducing the data transmission between the node to be synchronized and the dead node, thereby avoiding resource waste while improving the data synchronization efficiency of the blockchain.

[0084] Based on any of the above embodiments, the method further includes: determining in turn whether each node identified in the dead node list is in a surviving state; the dead node list is used to record the identification information of the dead nodes in the blockchain except the node to be synchronized; if it is determined that there is identification information of an Easter node in a surviving state in the dead node list, deleting the identification information of the Easter node in the dead node list, adding the identification information of the Easter node to the surviving node list, and establishing a connection between the node to be synchronized and the Easter node; the surviving node list is used to record the identification information of the surviving nodes in the blockchain except the node to be synchronized, and each node identified in the surviving node list establishes a connection with the node to be synchronized respectively.

[0085] Here, the dead node list is a list of nodes stored in the node to be synchronized. The dead node list may include identification information of 0, 1 or more dead nodes, and the identification information is used to uniquely identify the dead node. In one embodiment, the dead node is a node that exits the transaction.

[0086] In one embodiment, it is determined periodically and in turn whether each node identified in the dead node list is alive, that is, the alive status of each node in the blockchain is regularly detected to dynamically maintain the dead node list.

[0087] In one embodiment, the node to be synchronized actively detects whether each node identified in the dead node list is alive. For example, the node to be synchronized actively pings each node identified in the dead node list, and if the ping is successful, the node is alive.

[0088] In another embodiment, it is determined whether a node joining event message is received. If a node joining event message is received and the node corresponding to the node joining event message is a node identified in the dead node list, it is determined that the node is in a survival state.

[0089] Here, the surviving node list is a node list stored in the node to be synchronized. The surviving node list may include identification information of 0, 1 or more surviving nodes, and the identification information is used to uniquely identify the surviving nodes. In one embodiment, the surviving node is a node that joins the transaction.

[0090] It should be noted that since the nodes identified in the dead node list do not establish a connection with the node to be synchronized, when it is detected that the Easter node identified in the dead node list is alive, the identification information of the Easter node is removed from the dead node list to the surviving node list, and a connection is established between the node to be synchronized and the Easter node.

[0091] Furthermore, when an exit node is detected in the blockchain, the identification information of the exit node is added to the dead node list, and the connection between the exit node and the node to be synchronized is deleted. The exit node is a dead node. For example, the transaction message monitoring of the exit node is started, and when the node exit transaction is monitored, the connection between the exit node and the node to be synchronized is deleted.

[0092] It should be understood that if it is determined that there is no identification information of an Easter node in a surviving state in the dead node list, no processing is required.

[0093] The blockchain data synchronization method provided by the embodiment of the present invention determines in turn whether each node identified in the dead node list is in a surviving state. If it is determined that the dead node list contains identification information of an Easter node in a surviving state, the identification information of the Easter node in the dead node list is deleted, and the identification information of the Easter node is added to the surviving node list, and a connection is established between the node to be synchronized and the Easter node, so as to timely discover the Easter node and avoid the Easter node failing to establish a connection with the node to be synchronized, that is, the connection status between the nodes can be updated in time, so as to ensure the data transmission between the node to be synchronized and the Easter node, and then ensure the accuracy of blockchain data synchronization, and improve the reliability of the blockchain.

[0094] Based on any of the above embodiments, in the method, establishing a connection between the node to be synchronized and the Easter node includes: establishing a second target data transmission channel between the node to be synchronized and the Easter node; and monitoring the second target data transmission channel.

[0095] Here, the second target data transmission channel is used to transmit data of the node to be synchronized to the Easter node, and is used to transmit data of the Easter node to the node to be synchronized.

[0096] Furthermore, establishing a connection between the node to be synchronized and the Easter node also includes: establishing a client, establishing a stream connection, and the like.

[0097] In one embodiment, a real-time listening thread is started for the second target data transmission channel to respond to changes in data in the second target data transmission channel in real time, that is, when new data arrives in the second target data transmission channel, the real-time listening thread will immediately push the data to the data receiving channel.

[0098] The data synchronization method of the blockchain provided by the embodiment of the present invention monitors the second target data transmission channel after establishing the second target data transmission channel between the node to be synchronized and the Easter node, so as to immediately receive the synchronization data in the second target data transmission channel through the data receiving channel when the synchronization data exists in the second target data transmission channel, thereby improving the real-time performance of data transmission, and then improving the real-time performance of blockchain data synchronization, and finally ensuring the reliability of the blockchain. In addition, monitoring the second target data transmission channel ensures rapid response and processing of data, thereby achieving data synchronization with nearly zero delay, which is crucial for blockchain applications that require real-time confirmation.

[0099] Based on any of the above embodiments, considering that traditionally, data synchronization is mostly performed by randomly selecting nodes, when there are many nodes in the blockchain or the blockchain topology is complex, it is easy to reduce the efficiency of data synchronization; based on this, Figure 2 This is the second flow chart of the data synchronization method of the blockchain provided by the present invention, such as Figure 2 As shown, the blockchain data synchronization method also includes the following steps 140, 150, 160 and 170.

[0100] Step 140: Determine the target data synchronization scenario of the data to be synchronized.

[0101] Here, the data to be synchronized is data that the node to be synchronized needs to synchronize to other nodes in the blockchain except the node to be synchronized.

[0102] It should be understood that for the node to be synchronized, the data synchronization scenario of the data to be synchronized can be directly determined. For example, the data synchronization scenario may include but is not limited to: transaction broadcast scenario, transaction synchronization scenario, block broadcast scenario, block synchronization scenario, block height synchronization scenario, etc.

[0103] Step 150: Determine the target data transmission mode corresponding to the target data synchronization scenario based on the scenario-transmission mode mapping relationship.

[0104] The scenario-transmission mode mapping relationship includes a plurality of sub-mapping relationships, and any of the sub-mapping relationships represents a corresponding relationship between a data synchronization scenario and a data transmission mode. The scenario-transmission mode mapping relationship can be set in advance.

[0105] Here, the data transmission mode may include but is not limited to: unicast, random unicast, broadcast, etc. Unicast refers to sending data to a specified node; further, unicast refers to sending data to a specified live node. Random unicast refers to sending data to a node randomly; further, random unicast refers to sending data to a live node randomly, that is, sending data to any node in the live node list randomly. Broadcast refers to sending data to all nodes in the blockchain except its own node at the same time; further, broadcast refers to sending data to all live nodes in the blockchain except its own node at the same time, that is, sending data to all nodes in the live node list at the same time. This data transmission mode is used to determine the receiving node to which the data to be synchronized needs to be sent.

[0106] Exemplarily, the transaction broadcast scenario corresponds to the broadcast transmission method, such as sending the data to be synchronized to all nodes in the surviving node list; the transaction synchronization scenario corresponds to the random unicast transmission method, such as sending the data to be synchronized to any node in the surviving node list; the block broadcast scenario corresponds to the broadcast transmission method; the block synchronization scenario corresponds to the unicast transmission method, such as sending the data to be synchronized to a node in the surviving node list whose block height is higher than its own node; the block height synchronization scenario corresponds to the broadcast transmission method.

[0107] Step 160: Based on the target data transmission mode, determine a receiving node to which the data to be synchronized needs to be sent.

[0108] The receiving node is a node in the blockchain. The receiving node is a node whose data to be synchronized needs to be synchronized, and the receiving node is a node in the blockchain other than the node to be synchronized.

[0109] Step 170: Send the data to be synchronized to a third target data transmission channel between the node to be synchronized and the receiving node, so that the receiving node receives the data to be synchronized in the third target data transmission channel.

[0110] Here, the third target data transmission channel is used to transmit data of the node to be synchronized to the receiving node, and is used to transmit data of the receiving node to the node to be synchronized.

[0111] It should be understood that after sending the data to be synchronized to the third target data transmission channel between the node to be synchronized and the receiving node, the receiving node will execute the execution steps of the node to be synchronized to enable the receiving node to complete data synchronization.

[0112] The data synchronization method of the blockchain provided by the embodiment of the present invention determines the target data synchronization scenario of the data to be synchronized, and determines the target data transmission method corresponding to the target data synchronization scenario based on the scenario-transmission method mapping relationship, so that the embodiment of the present invention provides a flexible data transmission strategy, thereby improving the data transmission efficiency, and ultimately improving the data synchronization efficiency of the blockchain; and based on the target data synchronization scenario of the data to be synchronized, the corresponding data transmission method is selected to ensure that a better data transmission method can be selected, thereby ensuring the stability and reliability of data transmission, and ultimately improving the data synchronization accuracy of the blockchain to improve the stability of the blockchain.

[0113] To facilitate understanding of the above channels, Figure 3 As shown, node 1, node 2, and node 3 are all surviving nodes, a data transmission channel 12 is established between node 1 and node 2, a data transmission channel 23 is established between node 2 and node 3, and a data transmission channel 13 is established between node 1 and node 3; each data processing module in each node also establishes a receiving channel with the communication server module, and a data receiving channel dedicated to receiving data transmitted by other nodes is established in the communication server.

[0114] The data synchronization device of the blockchain provided by the present invention is described below. The data synchronization device of the blockchain described below and the data synchronization method of the blockchain described above can be referenced to each other.

[0115] Figure 4 It is a structural diagram of the data synchronization device of the blockchain provided by the present invention, such as Figure 4As shown, the data synchronization device of the blockchain includes a data receiving module 410, a first sending module 420, and a second sending module 430.

[0116] The data receiving module 410 is used to receive synchronization data transmitted by the synchronization node in the blockchain.

[0117] The first sending module 420 is used to send the synchronization data to a target receiving channel corresponding to the target data type based on the target data type of the synchronization data; different data types correspond to different receiving channels.

[0118] The second sending module 430 is used to send the synchronization data in the target receiving channel to the target data processing module corresponding to the target receiving channel; the target data processing module is used to complete data synchronization processing; different receiving channels correspond to different data processing modules.

[0119] The data synchronization device of the blockchain provided by the embodiment of the present invention receives the synchronization data transmitted by the synchronization node in the blockchain, and based on the target data type of the synchronization data, sends the synchronization data to the target receiving channel corresponding to the target data type, so as to send the synchronization data in the target receiving channel to the target data processing module corresponding to the target receiving channel, so that the data can be diverted to different receiving channels according to the data type, avoiding the competition of all data on a single channel, and further ensuring that the synchronization data is directly sent to the target data processing module that can process it, thereby improving the transmission efficiency and reducing the transmission delay, that is, improving the data synchronization efficiency of the blockchain; at the same time, the synchronization data is sent to the corresponding target receiving channel according to the target data type, thereby ensuring that the synchronization data can be accurately delivered to the target data processing module, thereby improving the data synchronization accuracy of the blockchain.

[0120] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the data synchronization method of the blockchain, which includes: receiving synchronization data transmitted by the synchronization node in the blockchain; based on the target data type of the synchronization data, sending the synchronization data to the target receiving channel corresponding to the target data type; different data types correspond to different receiving channels; sending the synchronization data in the target receiving channel to the target data processing module corresponding to the target receiving channel; the target data processing module is used to complete data synchronization processing; different receiving channels correspond to different data processing modules.

[0121] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0122] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the blockchain data synchronization method provided by the above methods, which includes: receiving synchronization data transmitted by a synchronization node in the blockchain; based on a target data type of the synchronization data, sending the synchronization data to a target receiving channel corresponding to the target data type; different data types correspond to different receiving channels; sending the synchronization data in the target receiving channel to a target data processing module corresponding to the target receiving channel; the target data processing module is used to complete data synchronization processing; different receiving channels correspond to different data processing modules.

[0123] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the blockchain data synchronization method provided by the above-mentioned methods, the method comprising: receiving synchronization data transmitted by a synchronization node in the blockchain; based on a target data type of the synchronization data, sending the synchronization data to a target receiving channel corresponding to the target data type; different data types correspond to different receiving channels; sending the synchronization data in the target receiving channel to a target data processing module corresponding to the target receiving channel; the target data processing module is used to complete data synchronization processing; different receiving channels correspond to different data processing modules.

[0124] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0125] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0126] Finally, it should be noted that the above embodiments are only used to illustrate the present invention, rather than to limit the present invention. Although the present invention is described in detail with reference to the embodiments, it should be understood by those skilled in the art that various combinations, modifications or equivalent substitutions of the technical solutions of the present invention do not depart from the spirit and scope of the technical solutions of the present invention, and should be included in the scope of the claims of the present invention.

Claims

1. A data synchronization method for blockchain, It is characterized in that Applied to a node to be synchronized in a blockchain, the method comprises: Receiving synchronization data transmitted by a synchronization node in the blockchain; Based on the target data type of the synchronization data, the synchronization data is sent to a target receiving channel corresponding to the target data type; different data types correspond to different receiving channels; The synchronization data in the target receiving channel is sent to a target data processing module corresponding to the target receiving channel; the target data processing module is used to complete data synchronization processing; different receiving channels correspond to different data processing modules.

2. The data synchronization method of the blockchain according to claim 1, It is characterized in that The receiving synchronization data transmitted by the synchronization node in the blockchain includes: The synchronization data is received through a data receiving channel; the data receiving channel is used to receive transmission data of nodes in the blockchain other than the node to be synchronized. The step of sending the synchronization data to a target receiving channel corresponding to the target data type based on the target data type of the synchronization data includes: Based on the target data type of the synchronization data, the synchronization data in the data receiving channel is sent to a target receiving channel corresponding to the target data type.

3. The data synchronization method of the blockchain according to claim 2, It is characterized in that The receiving the synchronization data through the data receiving channel comprises: Monitoring a first target data transmission channel between the node to be synchronized and the synchronization node; If it is monitored that the first target data transmission channel contains synchronization data, the synchronization data in the first target data transmission channel is received through a data receiving channel; The sending, based on the target data type of the synchronization data, the synchronization data in the data receiving channel to a target receiving channel corresponding to the target data type, comprises: monitoring the data receiving channel; If it is monitored that the data receiving channel contains synchronization data, based on the target data type, the synchronization data in the data receiving channel is sent to a target receiving channel corresponding to the target data type.

4. The data synchronization method of the blockchain according to claim 1, It is characterized in that The step of sending the synchronization data in the target receiving channel to a target data processing module corresponding to the target receiving channel includes: monitoring the target receiving channel; If it is monitored that synchronization data exists in the target receiving channel, the synchronization data in the target receiving channel is sent to the target data processing module.

5. The blockchain data synchronization method according to any one of claims 1 to 4, It is characterized in that Also includes: Determine in turn whether each node identified in the surviving node list is in a surviving state; The surviving node list is used to record the identification information of the surviving nodes in the blockchain except the node to be synchronized, and each node identified in the surviving node list establishes a connection with the node to be synchronized respectively; If it is determined that there is identification information of a target node that is not in a surviving state in the surviving node list, the identification information of the target node in the surviving node list is deleted, the identification information of the target node is added to the dead node list, and the connection between the node to be synchronized and the target node is deleted; The dead node list is used to record the identification information of the dead nodes in the blockchain except the node to be synchronized.

6. The data synchronization method of the blockchain according to any one of claims 1 to 4, It is characterized in that Also includes: Determine in turn whether each node identified in the dead node list is in a live state; The dead node list is used to record the identification information of the dead nodes in the blockchain except the node to be synchronized; If it is determined that there is identification information of an Easter node in a surviving state in the dead node list, deleting the identification information of the Easter node in the dead node list, adding the identification information of the Easter node to the surviving node list, and establishing a connection between the node to be synchronized and the Easter node; The surviving node list is used to record the identification information of the surviving nodes in the blockchain except the node to be synchronized, and each node identified in the surviving node list establishes a connection with the node to be synchronized respectively.

7. The data synchronization method of the blockchain according to claim 6, It is characterized in that The establishing of a connection between the node to be synchronized and the Easter node comprises: Establishing a second target data transmission channel between the node to be synchronized and the Easter node; Monitor the second target data transmission channel.

8. The method for synchronizing blockchain data according to any one of claims 1 to 4, It is characterized in that Also includes: Determine the target data synchronization scenario for the data to be synchronized; Determine the target data transmission mode corresponding to the target data synchronization scenario based on the scenario-transmission mode mapping relationship, wherein the scenario-transmission mode mapping relationship includes multiple sub-mapping relationships, and any of the sub-mapping relationships represents a correspondence between a data synchronization scenario and a data transmission mode; Based on the target data transmission mode, determining a receiving node to which the data to be synchronized needs to be sent; The receiving node is a node in the blockchain; The data to be synchronized is sent to a third target data transmission channel between the node to be synchronized and the receiving node, so that the receiving node receives the data to be synchronized in the third target data transmission channel.

9. A data synchronization device for blockchain, It is characterized in that A node to be synchronized deployed in a blockchain, the device comprising: A data receiving module, used to receive synchronization data transmitted by a synchronization node in the blockchain; A first sending module, configured to send the synchronization data to a target receiving channel corresponding to the target data type based on the target data type of the synchronization data; different data types correspond to different receiving channels; The second sending module is used to send the synchronization data in the target receiving channel to the target data processing module corresponding to the target receiving channel; the target data processing module is used to complete data synchronization processing; different receiving channels correspond to different data processing modules.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the data synchronization method of the blockchain as described in any one of claims 1 to 8 is implemented.

11. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the data synchronization method of the blockchain as described in any one of claims 1 to 8 is implemented.

12. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the data synchronization method of the blockchain as described in any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Service processing method and information processing method of block chain network, and node equipment

    CN112200681A

  • Data synchronization script generation method and system, terminal and storage medium

    CN112364049A

  • Block chain data synchronization method and device, electronic equipment and readable storage medium

    CN116028578A

  • Block chain-based operation and maintenance data management method and apparatus, and electronic device

    CN116866341A

  • Database synchronization system in high security zones using blockchain

    US20210400025A1