Blockchain data synchronization method and device, electronic equipment, medium and product
By routing data to different receiving channels based on data type within the blockchain network, the inefficiency and latency issues caused by single-channel synchronization are resolved, achieving efficient and accurate data synchronization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2026-04-07
AI Technical Summary
In blockchain networks, achieving data synchronization through a single channel leads to problems such as low data transmission efficiency and increased latency.
Data is distributed to different receiving channels based on its data type, ensuring that synchronous data is sent directly to the target data processing module that can handle it. Through the mapping of data receiving channels, target receiving channels, and target data processing modules, data competition on a single channel is avoided.
It improves the efficiency and accuracy of blockchain data synchronization, reduces transmission latency, and ensures that synchronized data is delivered to the target data processing module accurately.
Smart Images

Figure CN119071308B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, and in particular to a data synchronization method, apparatus, electronic device, medium, and product for blockchain. Background Technology
[0002] Blockchain, as a distributed ledger system built on cryptographic principles and consensus mechanisms, supports the construction of decentralized trust networks by ensuring the immutability and transparency of data. In a blockchain network, data is distributed and stored across multiple nodes, each holding a complete copy of the ledger, thus avoiding the risk of single points of failure and improving data security. Therefore, it is necessary to synchronize the data across all nodes in the blockchain to ensure data security.
[0003] Currently, data synchronization is achieved through a single channel. However, transmitting all synchronization data on a single channel leads to contention among the data, resulting in reduced transmission efficiency and latency, thus reducing data synchronization efficiency. Summary of the Invention
[0004] This invention aims to at least solve one of the technical problems existing in related technologies. To this end, this invention proposes a data synchronization method for blockchain, which can divert data to different receiving channels according to data type, avoiding competition for all data on a single channel. This ensures that synchronized data is directly sent to the target data processing module capable of processing it, thereby improving transmission efficiency and reducing transmission latency, i.e., improving the data synchronization efficiency of the blockchain.
[0005] The present invention also proposes a data synchronization device for blockchain.
[0006] The present invention also proposes an electronic device.
[0007] The present invention also proposes a storage medium.
[0008] The present invention also proposes a computer program product.
[0009] According to a first aspect of the present invention, a blockchain data synchronization method is applied to nodes to be synchronized in a blockchain, the method comprising:
[0010] Receive synchronization data transmitted by the synchronization nodes in the blockchain;
[0011] 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; different data types correspond to different receiving channels;
[0012] The synchronization data in the target receiving channel is sent to the target data processing module corresponding to the target receiving channel; the target data processing module is used to complete the data synchronization processing; different receiving channels correspond to different data processing modules.
[0013] According to the blockchain data synchronization method of the present invention, synchronization data transmitted by synchronization nodes in the blockchain is received. 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. The synchronization data in the target receiving channel is then sent to the target data processing module corresponding to the target receiving channel. This allows data to be distributed to different receiving channels according to the data type, avoiding competition for all data on a single channel. This ensures that the synchronization data is directly sent to the target data processing module capable of processing it, thereby improving transmission efficiency and reducing transmission latency, thus improving the data synchronization efficiency of the blockchain. Simultaneously, by sending the synchronization data to the corresponding target receiving channel according to the target data type, the synchronization data is ensured to be accurately delivered to the target data processing module, thereby improving the data synchronization accuracy of the blockchain.
[0014] According to one embodiment of the present invention, receiving synchronization data transmitted by the synchronization node in the blockchain includes:
[0015] The synchronization data is received 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.
[0016] The step of sending the synchronization data to the target receiving channel corresponding to the target data type based on the synchronization data includes:
[0017] Based on the target data type of the synchronization data, the synchronization data in the data receiving channel is sent to the target receiving channel corresponding to the target data type.
[0018] According to one embodiment of the present invention, receiving the synchronization data through a data receiving channel includes:
[0019] Monitor the first target data transmission channel between the node to be synchronized and the synchronization node;
[0020] If synchronization data is detected in the first target data transmission channel, the synchronization data in the first target data transmission channel is received through the data receiving channel.
[0021] The step of sending the synchronization data from the data receiving channel to the target receiving channel corresponding to the target data type based on the target data synchronization data includes:
[0022] Monitor the data receiving channel;
[0023] If synchronization data is detected in the data receiving channel, the synchronization data in the data receiving channel is sent to the target receiving channel corresponding to the target data type, based on the target data type.
[0024] According to an embodiment of the present invention, the step of sending the synchronization data in the target receiving channel to the target data processing module corresponding to the target receiving channel includes:
[0025] Monitor the target's receiving channel;
[0026] If synchronization data is detected in the target receiving channel, the synchronization data in the target receiving channel is sent to the target data processing module.
[0027] According to one embodiment of the present invention, it further includes:
[0028] The system sequentially determines whether each node in the list of live nodes is alive; the list of live nodes is used to record the identification information of live nodes in the blockchain other than the node to be synchronized, and each node in the list of live nodes establishes a connection with the node to be synchronized.
[0029] If it is determined that there is an identifier information of a target node that is not alive in the list of live nodes, the identifier information of the target node is deleted from the list of live nodes, and the identifier information of the target node is added to the list of dead nodes, and the connection between the node to be synchronized and the target node is deleted; the list of dead nodes is used to record the identifier information of dead nodes in the blockchain other than the node to be synchronized.
[0030] According to one embodiment of the present invention, it further includes:
[0031] The status of each node identified in the list of dead nodes is determined sequentially; the list of dead nodes is used to record the identification information of dead nodes in the blockchain, excluding the node to be synchronized.
[0032] If it is determined that there is an identification information of an Easter point that is alive in the list of dead nodes, the identification information of the Easter point is deleted from the list of dead nodes, and the identification information of the Easter point is added to the list of alive nodes, and a connection is established between the node to be synchronized and the Easter point; the list of alive nodes is used to record the identification information of the alive nodes in the blockchain other than the node to be synchronized, and each node identified in the list of alive nodes establishes a connection with the node to be synchronized.
[0033] According to one embodiment of the present invention, establishing a connection between the node to be synchronized and the Easter point includes:
[0034] Establish a second target data transmission channel between the node to be synchronized and the Easter point;
[0035] Monitor the second target data transmission channel.
[0036] According to one embodiment of the present invention, it further includes:
[0037] Determine the target data synchronization scenario for the data to be synchronized;
[0038] Based on the scenario-transmission mode mapping relationship, the target data transmission mode corresponding to the target data synchronization scenario is determined. The scenario-transmission mode mapping relationship includes multiple sub-mapping relationships, and any one of the sub-mapping relationships represents the correspondence between a data synchronization scenario and a data transmission mode.
[0039] Based on the target data transmission method, the receiving node to which the data to be synchronized needs to be sent is determined; the receiving node is a node in the blockchain.
[0040] 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.
[0041] According to a second aspect of the present invention, a blockchain data synchronization device is deployed on a node to be synchronized in the blockchain, the device comprising:
[0042] The data receiving module is used to receive synchronization data transmitted by the synchronization nodes in the blockchain;
[0043] The first sending module is used to send the synchronization data to the 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;
[0044] The second transmitting module is used to transmit 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 the data synchronization processing; different receiving channels correspond to different data processing modules.
[0045] An electronic device according to a third aspect of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements a data synchronization method for blockchain as described above.
[0046] According to a fourth aspect of the present invention, a non-transitory computer-readable storage medium is provided thereon storing a computer program that, when executed by a processor, implements the blockchain data synchronization method as described above.
[0047] A computer program product according to a fifth aspect of the present invention includes a computer program that, when executed by a processor, implements a blockchain data synchronization method as described above.
[0048] The above-described one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects:
[0049] The system receives synchronization data transmitted by synchronization nodes in the blockchain. Based on the target data type, it sends the synchronization data to the target receiving channel corresponding to the target data type. This allows the synchronization data in the target receiving channel to be sent to the target data processing module corresponding to the target receiving channel. This method distributes data to different receiving channels according to data type, avoiding contention for all data on a single channel. This ensures that the synchronization data is directly sent to the target data processing module capable of processing it, thereby improving transmission efficiency and reducing latency, thus improving the data synchronization efficiency of the blockchain. Simultaneously, by sending the synchronization data to the corresponding target receiving channel according to the target data type, it ensures that the synchronization data is accurately delivered to the target data processing module, thereby improving the data synchronization accuracy of the blockchain.
[0050] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0052] Figure 1 This is one of the flowcharts illustrating the blockchain data synchronization method provided in this embodiment of the invention.
[0053] Figure 2 This is the second flowchart illustrating the blockchain data synchronization method provided in this embodiment of the invention.
[0054] Figure 3 This is a schematic diagram of the channel connection provided in an embodiment of the present invention.
[0055] Figure 4This is a schematic diagram of the structure of the blockchain data synchronization device provided in an embodiment of the present invention.
[0056] Figure 5 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0057] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0058] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the embodiments of this application. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance. In this specification, the illustrative expressions 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 suitable manner in one or more embodiments or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0059] The present invention proposes the following embodiments. The following is a detailed description in conjunction with... Figures 1-3 The present invention describes a blockchain data synchronization method.
[0060] Figure 1 This is one of the flowcharts illustrating the blockchain data synchronization method provided by the present invention, such as... Figure 1 As shown, the data synchronization method for this blockchain includes the following steps 110, 120, and 130. This method is applied to the nodes to be synchronized in the blockchain, and can be applied to any node in the blockchain; that is, the node to be synchronized can be any node in the blockchain.
[0061] Step 110: Receive synchronization data transmitted by the synchronization node in the blockchain.
[0062] Here, a synchronization node is any node in the blockchain other than the node to be synchronized. Synchronization data is data transmitted from the synchronization node, and it is data that needs to be synchronized to the node to be synchronized.
[0063] In one embodiment, the synchronization data is received via a data receiving channel, and then the synchronization data in the data receiving channel is sent to a target receiving channel corresponding to the target data type. The data receiving channel is used to receive transmission data from nodes in the blockchain other than the node to be synchronized.
[0064] The data receiving channel is a dedicated receiving channel for the node to be synchronized, which is used exclusively to receive data transmitted from other nodes.
[0065] Furthermore, prior to step 110 above, the first node establishes its own communication server and registers a data receiving channel. For example, when starting the node to be synchronized, the communication server is started simultaneously, and a data receiving channel for receiving blockchain data is created. For instance, the communication server is a P2P (Peer-to-Peer Protocol) server.
[0066] In another embodiment, the synchronization data is received via a first target data transmission channel between the node to be synchronized and the synchronizing node.
[0067] Furthermore, the system monitors the first target data transmission channel; if synchronization data is detected in the first target data transmission channel, the system receives the synchronization data in the first target data transmission channel and sends the synchronization data in the first target data transmission channel to the target receiving channel corresponding to the target data type.
[0068] Furthermore, prior to step 110 above, a first target data transmission channel is established between the node to be synchronized and the synchronization node. Even further, a connection is established between the node to be synchronized and the synchronization node, specifically including client establishment, stream connection establishment, etc. In one example, connections are established in advance with other live nodes in the blockchain besides the node to be synchronized.
[0069] Furthermore, after establishing a data transmission channel between the node to be synchronized and other nodes, the data transmission channel is monitored so that if synchronization data exists in the data transmission channel, the synchronization data is immediately sent to the corresponding node.
[0070] Step 120: 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.
[0071] Different data types correspond to different receiving channels.
[0072] Here, the target data type may include, but is not limited to: transaction data type, block data type, block height data type, etc.
[0073] Each data type corresponds to a dedicated receiving channel, meaning each data type has its own dedicated receiving channel. This allows data to be distributed across different receiving channels based on its data type, avoiding contention for data on a single channel and thus improving transmission efficiency and reducing latency. Therefore, it is necessary to establish the corresponding receiving channels for each data type in advance.
[0074] In one embodiment, a target receiving channel corresponding to the target data type is registered in advance. For example, the target receiving channel corresponding to the target data type is registered with the node to be synchronized. For instance, the transaction pool module and block pool module within 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 transaction management, i.e., for synchronizing transactions; the block pool module is responsible for block management, i.e., for synchronizing block height, block data, etc.
[0075] Furthermore, after establishing receiving channels corresponding to each data type, each receiving channel is monitored so that when synchronization data is present in the receiving channel, the synchronization data is immediately sent to the corresponding data processing module.
[0076] Step 130: Send the synchronization data in the target receiving channel to the target data processing module corresponding to the target receiving channel.
[0077] The target data processing module is used to complete data synchronization processing, such as submission and disk write processing; different receiving channels correspond to different data processing modules.
[0078] One receiving channel corresponds to one data processing module, meaning each data processing module has a dedicated receiving channel. This allows data to be distributed to different receiving channels based on its data type, avoiding contention for all data on a single channel. It also ensures that synchronization data is directly sent to the target data processing module capable of processing it, thereby improving transmission efficiency and reducing transmission latency. Simultaneously, synchronization data is sent to the corresponding target receiving channel based on the target data type, ensuring that the synchronization data is accurately delivered to the target data processing module, thus improving the accuracy of data synchronization.
[0079] The blockchain data synchronization method provided in this invention receives synchronization data transmitted by synchronization nodes in the blockchain. Based on the target data type of the synchronization data, it sends the synchronization data to the target receiving channel corresponding to the target data type. This allows the synchronization data in the target receiving channel to be sent to the target data processing module corresponding to the target receiving channel. This method distributes data to different receiving channels according to data type, avoiding contention for all data on a single channel. This ensures that the synchronization data is directly sent to the target data processing module capable of processing it, thereby improving transmission efficiency and reducing transmission latency, thus improving the data synchronization efficiency of the blockchain. Simultaneously, by sending the synchronization data to the corresponding target receiving channel according to the target data type, it ensures that the synchronization data is accurately delivered to the target data processing module, thereby improving the data synchronization accuracy of the blockchain.
[0080] Based on any of the above embodiments, in this method, 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.
[0081] Here, the data receiving channel is a dedicated receiving channel for the node to be synchronized, which is used exclusively to receive data transmitted from other nodes.
[0082] Furthermore, prior to step 110 above, the node to be synchronized establishes its own communication server and registers a data receiving channel. For example, when the node to be synchronized starts, the communication server is started simultaneously, and a data receiving channel for receiving blockchain data is created. That is, when the node to be synchronized receives data, it will place the data into the data receiving channel.
[0083] Accordingly, in this method, step 120 includes: 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.
[0084] The blockchain data synchronization method provided in this invention, through the aforementioned approach, receives synchronization data sent by other nodes via a dedicated data receiving channel for the node to be synchronized. This ensures that the synchronization data in the data receiving channel is accurately sent to the target receiving channel corresponding to the target data type. Furthermore, it accurately distributes data to different receiving channels according to data type, ultimately improving the data synchronization efficiency and accuracy of the blockchain.
[0085] Based on any of the above embodiments, in this 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 node to be synchronized; if synchronization data is detected in the first target data transmission channel, receiving the synchronization data in the first target data transmission channel through a data receiving channel.
[0086] Here, the first target data transmission channel is used to transmit data from the node to be synchronized to the synchronization node, and to transmit data from the synchronization node to the node to be synchronized.
[0087] Furthermore, prior to step 110 above, a first target data transmission channel is established between the node to be synchronized and the synchronization node. Even further, a connection is established between the node to be synchronized and the synchronization node, specifically including client establishment, stream connection establishment, etc. In one example, connections are established in advance with all other surviving nodes in the blockchain besides the node to be synchronized, i.e., stable stream connections and data transmission channels are established with all surviving nodes.
[0088] Furthermore, 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 so that if synchronization data exists in the first target data transmission channel, the synchronization data in the first target data transmission channel can be received immediately through the data receiving channel.
[0089] In one embodiment, a real-time monitoring thread is started for the first target data transmission channel to respond in real time to changes in the data in the first target data transmission channel. That is, when new data arrives in the first target data transmission channel, the real-time monitoring thread will immediately push the data to the data receiving channel.
[0090] The blockchain data synchronization method provided in this invention monitors a first target data transmission channel between the node to be synchronized and the node synchronizing. If synchronization data is detected in the first target data transmission channel, the synchronized data can be immediately received through a data receiving channel, thereby improving the real-time performance of data transmission and thus the real-time performance of blockchain data synchronization, ultimately ensuring the reliability of the blockchain. Furthermore, monitoring the first target data transmission channel ensures rapid data response and processing, achieving near-zero latency data synchronization, which is crucial for blockchain applications requiring real-time confirmation.
[0091] Based on any of the above embodiments, in this method, the step of sending the synchronization data in the data receiving channel to the target receiving channel corresponding to the target data type based on the target data type includes: monitoring the data receiving channel; if synchronization data is detected in the data receiving channel, sending the synchronization data in the data receiving channel to the target receiving channel corresponding to the target data type based on the target data type.
[0092] Furthermore, after establishing the data receiving channel, the data receiving channel is monitored so that if synchronization data exists 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.
[0093] In one embodiment, a real-time monitoring thread is started for the data receiving channel to respond in real time to changes in the data in the data receiving channel. 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.
[0094] The blockchain data synchronization method provided in this invention monitors the data receiving channel. If synchronized data is detected in the data receiving channel, it immediately sends the synchronized data to the target receiving channel corresponding to the target data type, thereby improving the real-time performance of data transmission and thus the real-time performance of blockchain data synchronization, ultimately ensuring the reliability of the blockchain. Furthermore, monitoring the data receiving channel ensures rapid data response and processing, achieving near-zero latency data synchronization, which is crucial for blockchain applications requiring real-time confirmation.
[0095] Based on any of the above embodiments, in this method, 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.
[0096] Furthermore, after establishing the target receiving channel, the target receiving channel is monitored so that if synchronization data exists in the target receiving channel, the synchronization data in the target receiving channel is immediately sent to the target data processing module.
[0097] In one embodiment, a real-time monitoring thread is started for the target receiving channel to respond in real time to changes in the data in the target receiving channel. 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.
[0098] The blockchain data synchronization method provided in this invention monitors a target receiving channel. If synchronization data is detected on the target receiving channel, it can immediately send the synchronization data to the target data processing module, thereby improving the real-time performance of data transmission and thus the real-time performance of blockchain data synchronization, ultimately ensuring the reliability of the blockchain. Furthermore, monitoring the target receiving channel ensures rapid data response and processing, achieving near-zero latency data synchronization, which is crucial for blockchain applications requiring real-time confirmation.
[0099] Based on any of the above embodiments, the method further includes: sequentially determining whether each node identified in the list of surviving nodes is in a surviving state; the list of surviving nodes is used to record the identification information of surviving nodes in the blockchain other than the node to be synchronized, and each node identified in the list of surviving nodes establishes a connection with the node to be synchronized; if it is determined that there is identification information of a target node that is not in a surviving state in the list of surviving nodes, the identification information of the target node is deleted from the list of surviving nodes, and the identification information of the target node is added to the list of dead nodes, and the connection between the node to be synchronized and the target node is deleted; the list of dead nodes is used to record the identification information of dead nodes in the blockchain other than the node to be synchronized.
[0100] Here, the list of surviving nodes is the list of nodes stored in the node synchronization database. This list may include identification information for 0, 1, or more surviving nodes, which is used to uniquely identify each surviving node. In one embodiment, surviving nodes are nodes that have joined a transaction.
[0101] In one embodiment, it is periodically determined whether each node identified in the list of live nodes is alive. That is, the liveness status of each node in the blockchain is checked periodically to dynamically maintain the list of live nodes.
[0102] In one embodiment, the node to be synchronized actively probes whether each node in the list of live nodes is alive. For example, the node to be synchronized actively pings each node in the list of live nodes; if the ping is successful, the node is considered to be alive.
[0103] In another embodiment, it is determined whether a node exit event message has been received. If a node exit event message is received, and the node corresponding to the node exit event message is a node identified in the list of live nodes, then it is determined that the node is not in a live state.
[0104] Furthermore, when the node to be synchronized starts, it is determined whether other nodes in the blockchain besides the node to be synchronized are alive. The identification information of the nodes in the alive state is added to the list of alive nodes, and each node identified in the list of alive nodes establishes a connection with 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.
[0105] Here, the list of dead nodes is a list of nodes stored in the node synchronization database. This list may include identification information for 0, 1, or more dead nodes, which is used to uniquely identify each dead node. In one embodiment, a dead node is a node that has exited a transaction.
[0106] It should be noted that since each node in the list of surviving nodes has established a connection with the node to be synchronized in advance, when the target node in the list of surviving nodes is detected to be inactive, the identification information of the target node is removed from the list of surviving nodes and moved to the list of dead nodes, and the connection between the node to be synchronized and the target node is deleted.
[0107] Furthermore, when a new node is detected joining the blockchain, its identifier is added to the list of live nodes, and a connection is established between the new node and the node to be synchronized. The new node is considered a live node. For example, transaction message listening for the new node is initiated; when the new node joins a transaction, a connection is established between the new node and the node to be synchronized. Based on this, by quickly identifying and accepting new nodes, the blockchain can continuously expand and remain active.
[0108] Furthermore, after establishing connections between other nodes in the blockchain and the node to be synchronized, the data transmission channel between these other nodes and the node to be synchronized is monitored.
[0109] It should be understood that if it is determined that there is no identification information for a target node that is not in a live state in the list of live nodes, then no processing is required.
[0110] The blockchain data synchronization method provided in this invention sequentially determines whether each node in the list of live nodes is alive, and each node in the list of live nodes establishes a connection with the node to be synchronized. If it is determined that there is a target node in the list of live nodes that is not alive, the target node's identification information is deleted from the list of live nodes, and the target node's identification information is added to the list of dead nodes. The connection between the node to be synchronized and the target node is also deleted. This allows for the timely detection and removal of dead nodes, preventing dead nodes from still establishing connections with the node to be synchronized. In other words, it enables timely updates to the connection status between nodes, thereby reducing data transmission between the node to be synchronized and the dead node, thus avoiding resource waste and improving the data synchronization efficiency of the blockchain.
[0111] Based on any of the above embodiments, the method further includes: sequentially determining 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 dead nodes in the blockchain other than the node to be synchronized; if it is determined that there is identification information of an Easter node in a live state in the dead node list, the identification information of the Easter node is deleted from the dead node list, and the identification information of the Easter node is added to the live node list, and a connection is established between the node to be synchronized and the Easter node; the live node list is used to record the identification information of live nodes in the blockchain other than the node to be synchronized, and each node identified in the live node list establishes a connection with the node to be synchronized.
[0112] Here, the list of dead nodes is a list of nodes stored in the node synchronization database. This list may include identification information for 0, 1, or more dead nodes, which is used to uniquely identify each dead node. In one embodiment, a dead node is a node that has exited a transaction.
[0113] In one embodiment, it is periodically determined whether each node identified in the list of dead nodes is still alive. That is, the liveness status of each node in the blockchain is periodically checked to dynamically maintain the list of dead nodes.
[0114] In one embodiment, the node to be synchronized actively probes whether each node in the list of dead nodes is alive. For example, the node to be synchronized actively pings each node in the list of dead nodes; if the ping is successful, the node is considered alive.
[0115] In another embodiment, it is determined whether a node joining event message has been 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 list of dead nodes, then it is determined that the node is in a live state.
[0116] Here, the list of surviving nodes is the list of nodes stored in the node synchronization database. This list may include identification information for 0, 1, or more surviving nodes, which is used to uniquely identify each surviving node. In one embodiment, surviving nodes are nodes that have joined a transaction.
[0117] It should be noted that since the nodes marked in the list of dead nodes do not establish a connection with the node to be synchronized, when an Easter point marked in the list of dead nodes is detected to be alive, the Easter point's identification information is removed from the list of dead nodes and added to the list of alive nodes, while a connection is established between the node to be synchronized and the Easter point.
[0118] Furthermore, when a delisted node is detected in the blockchain, its identifier is added to the list of dead nodes, and the connection between the delisted node and the node to be synchronized is removed. A delisted node is considered a dead node. For example, a transaction message listener is started for delisted nodes; when a node is detected to have exited a transaction, the connection between the delisted node and the node to be synchronized is removed.
[0119] It should be understood that if it is determined that there is no identification information for an Easter node that is alive in the list of dead nodes, then no action needs to be taken.
[0120] The blockchain data synchronization method provided in this invention sequentially determines whether each node identified in the list of dead nodes is in a live state. If it is determined that there is an Easter node identification information in the list of dead nodes that is in a live state, the Easter node identification information is deleted from the list of dead nodes and added to the list of live nodes. A connection is also established between the node to be synchronized and the Easter node. This allows for timely detection of Easter nodes, preventing Easter nodes from failing to establish a connection with the node to be synchronized. In other words, it enables timely updates to the connection status between nodes, thereby ensuring data transmission between the node to be synchronized and the Easter node, and thus ensuring the accuracy of blockchain data synchronization and improving the reliability of the blockchain.
[0121] Based on any of the above embodiments, in this method, establishing the connection between the node to be synchronized and the Easter point includes: establishing a second target data transmission channel between the node to be synchronized and the Easter point; and monitoring the second target data transmission channel.
[0122] Here, the second target data transmission channel is used to transmit data from the node to be synchronized to the Easter point, and to transmit data from the Easter point to the node to be synchronized.
[0123] Furthermore, establishing a connection between the node to be synchronized and the re-emergence node also includes: establishing the client, establishing streaming connections, and so on.
[0124] In one embodiment, a real-time monitoring thread is started for the second target data transmission channel to respond in real time to changes in the data in the second target data transmission channel. That is, when new data arrives in the second target data transmission channel, the real-time monitoring thread will immediately push the data to the data receiving channel.
[0125] The blockchain data synchronization method provided in this invention establishes a second target data transmission channel between the node to be synchronized and the redo node. It then monitors this second target data transmission channel to immediately receive synchronized data from it via a data receiving channel when such data is present. This improves the real-time performance of data transmission, thereby enhancing the real-time performance of blockchain data synchronization and ultimately ensuring the reliability of the blockchain. Furthermore, monitoring the second target data transmission channel ensures rapid data response and processing, achieving near-zero latency data synchronization, which is crucial for blockchain applications requiring real-time confirmation.
[0126] Based on any of the above embodiments, considering that traditional methods mostly use random node selection for data synchronization, this can easily lead to reduced data synchronization efficiency when there are many nodes or a complex blockchain topology; therefore, Figure 2 This is the second flowchart illustrating the blockchain data synchronization method provided by this invention, as shown below. Figure 2 As shown, the data synchronization method of the blockchain also includes the following steps 140, 150, 160 and 170.
[0127] Step 140: Determine the target data synchronization scenario for the data to be synchronized.
[0128] Here, the data to be synchronized refers to the data that the node to be synchronized needs to synchronize with other nodes in the blockchain besides the node to be synchronized.
[0129] It should be understood that for a node to be synchronized, the data synchronization scenario can be directly determined. For example, data synchronization scenarios may include, but are not limited to: transaction broadcast scenario, transaction synchronization scenario, block broadcast scenario, block synchronization scenario, block height synchronization scenario, etc.
[0130] Step 150: Based on the scenario-transmission method mapping relationship, determine the target data transmission method corresponding to the target data synchronization scenario.
[0131] The scenario-transmission mode mapping relationship includes multiple sub-mapping relationships, whereby each sub-mapping relationship represents the correspondence between a data synchronization scenario and a data transmission mode. The scenario-transmission mode mapping relationship can be pre-defined.
[0132] Here, data transmission methods can include, but are not limited to: unicast, random unicast, broadcast, etc. Unicast refers to sending data to a specified node; more specifically, unicast refers to sending data to a specific live node. Random unicast refers to sending data to a node randomly; more specifically, random unicast refers to sending data to any live node randomly, that is, sending data randomly to any node in the list of live nodes. Broadcast refers to sending data simultaneously to all nodes in the blockchain except for the node itself; more specifically, broadcast refers to sending data simultaneously to all live nodes in the blockchain except for the node itself, that is, sending data simultaneously to all nodes in the list of live nodes. This data transmission method is used to determine the receiving node to which the data to be synchronized should be sent.
[0133] For example, the transaction broadcast scenario corresponds to the broadcast transmission method, such as sending the data to be synchronized to all nodes in the list of live nodes; the transaction synchronization scenario corresponds to the random unicast transmission method, such as sending the data to be synchronized to any node in the list of live nodes; 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 nodes in the list of live nodes whose block height is higher than its own node; and the block height synchronization scenario corresponds to the broadcast transmission method.
[0134] Step 160: Based on the target data transmission method, determine the receiving node to which the data to be synchronized needs to be sent.
[0135] The receiving node is a node in the blockchain. The receiving node is the node whose data needs to be synchronized, and it is a node in the blockchain other than the node to be synchronized.
[0136] 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.
[0137] Here, the third target data transmission channel is used to transmit data from the node to be synchronized to the receiving node, and to transmit data from the receiving node to the node to be synchronized.
[0138] It should be understood that after the data to be synchronized is sent 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 described above, so that the receiving node can complete the data synchronization.
[0139] The blockchain data synchronization method provided in this 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. This invention provides a flexible data transmission strategy, thereby improving data transmission efficiency and ultimately enhancing the data synchronization efficiency of the blockchain. Furthermore, by selecting the corresponding data transmission method based on the target data synchronization scenario of the data to be synchronized, a superior data transmission method can be selected, ensuring the stability and reliability of data transmission and ultimately improving the accuracy of blockchain data synchronization, thus enhancing the stability of the blockchain.
[0140] To facilitate understanding of the above channels, such as Figure 3 As shown, nodes 1, 2, and 3 are all live 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. The communication server has a dedicated data receiving channel for receiving data transmitted from other nodes.
[0141] The blockchain data synchronization device provided by the present invention is described below. The blockchain data synchronization device described below and the blockchain data synchronization method described above can be referred to in correspondence.
[0142] Figure 4 This is a schematic diagram of the structure of the blockchain data synchronization device provided by the present invention, as shown below. Figure 4 As shown, the blockchain data synchronization device includes a data receiving module 410, a first sending module 420, and a second sending module 430.
[0143] The data receiving module 410 is used to receive synchronization data transmitted by the synchronization nodes in the blockchain.
[0144] The first sending module 420 is used to send the synchronization data to the 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.
[0145] The second transmitting module 430 is used to transmit 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 the data synchronization processing; different receiving channels correspond to different data processing modules.
[0146] The blockchain data synchronization device provided in this invention receives synchronization data transmitted by synchronization nodes in the blockchain. Based on the target data type of the synchronization data, it sends the synchronization data to the target receiving channel corresponding to the target data type. This allows the synchronization data in the target receiving channel to be sent to the target data processing module corresponding to the target receiving channel. This way, data can be distributed to different receiving channels according to the data type, avoiding contention for all data on a single channel. This ensures that the synchronization data is directly sent to the target data processing module capable of processing it, thereby improving transmission efficiency and reducing transmission latency, thus improving the data synchronization efficiency of the blockchain. Simultaneously, by sending the synchronization data to the corresponding target receiving channel according to the target data type, it ensures that the synchronization data can be accurately delivered to the target data processing module, thereby improving the data synchronization accuracy of the blockchain.
[0147] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, communications interface 520, and memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a blockchain data synchronization method. This method includes: receiving synchronization data transmitted by synchronization nodes in the blockchain; based on the 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.
[0148] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0149] On the other hand, the present invention also provides a computer program product, which includes a computer program that 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. The method includes: receiving synchronization data transmitted by synchronization nodes in the blockchain; sending the synchronization data to a target receiving channel corresponding to the target data type based on 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.
[0150] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a blockchain data synchronization method provided by the methods described above. The method includes: receiving synchronization data transmitted by synchronization nodes in the blockchain; 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; 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.
[0151] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0152] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0153] Finally, it should be noted that the above embodiments are only for illustrating the present invention and not for limiting the present invention. Although the present invention has been described in detail with reference to the embodiments, those skilled in the art should understand 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 covered within the scope of the claims of the present invention.
Claims
1. A data synchronization method for blockchain, characterized in that, The method, applied to nodes to be synchronized in a blockchain, includes: Receive synchronization data transmitted by the synchronization nodes in the blockchain; 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; different data types correspond to different receiving channels; The synchronization data in the target receiving channel is sent to the target data processing module corresponding to the target receiving channel; the target data processing module is used to complete the data synchronization processing; different receiving channels correspond to different data processing modules; Also includes: The system sequentially determines whether each node in the list of live nodes is alive; the list of live nodes is used to record the identification information of live nodes in the blockchain other than the node to be synchronized, and each node in the list of live nodes establishes a connection with the node to be synchronized. If it is determined that there is an identifier information of a target node that is not alive in the list of live nodes, the identifier information of the target node is deleted from the list of live nodes, and the identifier information of the target node is added to the list of dead nodes, and the connection between the node to be synchronized and the target node is deleted; the list of dead nodes is used to record the identifier information of dead nodes in the blockchain other than the node to be synchronized.
2. The blockchain data synchronization method according to claim 1, characterized in that, The receiving of synchronization data transmitted by the synchronization nodes in the blockchain includes: The synchronization data is received 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. The step of sending the synchronization data to the target receiving channel corresponding to the target data type based on 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 the target receiving channel corresponding to the target data type.
3. The blockchain data synchronization method according to claim 2, characterized in that, Receiving the synchronization data through the data receiving channel includes: Monitor the first target data transmission channel between the node to be synchronized and the synchronization node; If synchronization data is detected in the first target data transmission channel, the synchronization data in the first target data transmission channel is received through the data receiving channel. The step of sending the synchronization data from the data receiving channel to the target receiving channel corresponding to the target data type based on the target data synchronization data includes: Monitor the data receiving channel; If synchronization data is detected in the data receiving channel, the synchronization data in the data receiving channel is sent to the target receiving channel corresponding to the target data type, based on the target data type.
4. The blockchain data synchronization method according to claim 1, characterized in that, The step of sending the synchronization data in the target receiving channel to the target data processing module corresponding to the target receiving channel includes: Monitor the target's receiving channel; If synchronization data is detected 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, characterized in that, Also includes: Check in turn whether each node marked in the list of dead nodes is alive; The list of dead nodes is used to record the identification information of dead nodes in the blockchain, excluding the node to be synchronized. If it is determined that there is an identification information of an Easter point that is alive in the list of dead nodes, delete the identification information of the Easter point from the list of dead nodes, add the identification information of the Easter point to the list of alive nodes, and establish a connection between the node to be synchronized and the Easter point; The list of surviving nodes is used to record the identification information of surviving nodes in the blockchain other than the node to be synchronized. Each node identified in the list of surviving nodes establishes a connection with the node to be synchronized.
6. The blockchain data synchronization method according to claim 5, characterized in that, Establishing the connection between the node to be synchronized and the Easter point includes: Establish a second target data transmission channel between the node to be synchronized and the Easter point; Monitor the second target data transmission channel.
7. The blockchain data synchronization method according to any one of claims 1 to 4, characterized in that, Also includes: Determine the target data synchronization scenario for the data to be synchronized; Based on the scenario-transmission mode mapping relationship, the target data transmission mode corresponding to the target data synchronization scenario is determined. The scenario-transmission mode mapping relationship includes multiple sub-mapping relationships, and any one of the sub-mapping relationships represents the correspondence between a data synchronization scenario and a data transmission mode. Based on the target data transmission method, determine the 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.
8. A data synchronization device for blockchain, characterized in that, A node to be synchronized in a blockchain, the device comprising: The data receiving module is used to receive synchronization data transmitted by the synchronization nodes in the blockchain; The first sending module is used to send the synchronization data to the 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 transmitting module is used to transmit 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 the data synchronization processing; different receiving channels correspond to different data processing modules; Also includes: The status determination module is used to sequentially determine whether each node identified in the list of live nodes is in a live state; the list of live nodes is used to record the identification information of live nodes in the blockchain other than the node to be synchronized, and each node identified in the list of live nodes establishes a connection with the node to be synchronized. The information deletion module is used to delete the identification information of the target node from the list of live nodes if it is determined that there is an identification information of the target node that is not in a live state in the list of live nodes, and to add the identification information of the target node to the list of dead nodes, and to delete the connection between the node to be synchronized and the target node; the list of dead nodes is used to record the identification information of dead nodes in the blockchain other than the node to be synchronized.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the blockchain data synchronization method as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the blockchain data synchronization method as described in any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the blockchain data synchronization method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Block chain-based operation and maintenance data management method and apparatus, and electronic device
CN116866341A