Data synchronization method and apparatus, storage medium, and electronic device

By using blockchain technology to achieve multi-node data consistency in fund data synchronization, the problems of synchronization delay and single-node loss in existing technologies are solved, thereby improving the reliability and stability of data synchronization.

CN115794947BActive Publication Date: 2026-01-09ANT WEALTH (SHANGHAI) FINANCIAL INFORMATION SERVICES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211510422.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-29
Publication Date
2026-01-09
Estimated Expiration
2042-11-29

AI Technical Summary

Technical Problem

The existing fund data synchronization method relies on manual monitoring, which leads to time delays, reduces the real-time performance of data sharing and synchronization, and prevents other nodes from synchronizing when data is lost on a single node.

Method used

By employing blockchain technology, data synchronization between multiple nodes is achieved through data consensus and encryption mechanisms among consortium blockchain nodes, ensuring data consistency and reliability, and leveraging the immutability of blockchain to guarantee the authority of the data.

Benefits of technology

It achieves eventual consistency of data across multiple nodes, avoids data volume expansion, improves disaster recovery capabilities, and ensures the reliability and stability of data synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115794947B_ABST
    Figure CN115794947B_ABST
Patent Text Reader

Abstract

The embodiment of the specification discloses a method and device for synchronizing data between multiple nodes based on a blockchain, a storage medium and an electronic device. When a target node on the blockchain receives block data sent by a first node, the stored data of the target node is updated first, and then compared with other adjacent nodes to synchronize the data of the adjacent nodes to be consistent with the data of the target node, and even the data of other nodes of the blockchain is synchronized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present specification relates to the technical field of blockchains, and particularly relates to a data synchronization method and device, a storage medium and an electronic device. BACKGROUND

[0002] With the increasingly active financial investment market, the updating speed of fund data is also accelerating in frequent transaction activities. Therefore, in order to ensure that the transaction participants can follow the changes of the fund data, it is necessary to synchronize the constantly changing fund data among multiple transaction participants in time.

[0003] In the existing fund management system, the fund data sharing and synchronization among various transaction participants is mainly realized through files or data sharing tools and the like. However, it is found in practice that this fund data synchronization method largely depends on manual monitoring and management, and there is usually a large time delay in sharing and synchronizing the fund data, thus greatly reducing the real-time performance of fund data sharing and synchronization. SUMMARY

[0004] The embodiments of the present specification provide a data synchronization method, device, storage medium and electronic device, which can avoid the influence of a single node on the data synchronization of other nodes in the blockchain, and improve the success rate of data synchronization. The technical solution is as follows:

[0005] In a first aspect, the embodiments of the present specification provide a data synchronization method, which comprises:

[0006] receiving block data sent from a first node, wherein the blockchain comprises the first node;

[0007] updating the stored first data based on the block data to obtain second data;

[0008] comparing the second data with the data stored by at least one second adjacent node respectively, and updating the second data according to the comparison result until target data is obtained, wherein the target data is consistent with the data stored by each second node.

[0009] In a second aspect, the embodiments of the present specification provide a data synchronization device, which comprises:

[0010] a data receiving module configured to receive block data sent from a first node, wherein the blockchain comprises the first node;

[0011] a data updating module configured to update the stored first data based on the block data to obtain second data;

[0012] The data synchronization module is configured to compare the data stored by each of the at least one second node respectively, and update the second data according to the comparison result until target data is obtained, wherein the target data is consistent with the data stored by each of the second nodes.

[0013] In a third aspect, a computer storage medium is provided, which stores a plurality of instructions. The instructions are adapted to be loaded by a processor and execute the method steps described above.

[0014] In a fourth aspect, a computer program product is provided, which stores a plurality of instructions. The instructions are adapted to be loaded by a processor and execute the method steps described above.

[0015] In a fifth aspect, an electronic device is provided, which can include a processor and a memory. The memory stores a computer program, which is adapted to be loaded by the processor and execute the method steps described above.

[0016] The technical solutions provided by some embodiments of the present specification have at least the following beneficial effects:

[0017] The present specification provides a method for synchronizing data between multiple nodes based on a blockchain. When a target node on the blockchain receives block data sent by a first node, the stored data of the target node is updated, and then compared with other adjacent nodes to synchronize the data of the adjacent nodes to be consistent with the data of the target node, and even synchronize the data of other nodes on the blockchain. The method can achieve the final consistency of data in multiple nodes while avoiding the exponential expansion of data caused by mutual data exchange between multiple nodes, and solve the problem that other nodes cannot synchronize data when a single node loses data, thereby improving the disaster recovery capability of a single node. Since the blockchain has the feature of being tamper-proof, the authority of the block data from the first node is guaranteed, thereby making the data synchronization method of synchronizing the block data of the first node from the target node to other nodes have high reliability and stability. BRIEF DESCRIPTION OF DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present specification or the prior art, the drawings needed in the embodiment or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present specification, and those skilled in the art can obtain other drawings according to these drawings without creative labor.

[0019] Figure 1 is a schematic diagram of the architecture of a data synchronization method provided by an embodiment of the present specification;

[0020] Figure 2 is a schematic diagram of an architecture of another data synchronization method provided by an embodiment of the present specification;

[0021] Figure 3 is a schematic diagram of an architecture of another data synchronization method provided by an embodiment of the present specification;

[0022] Figure 4 is a schematic diagram of a flow of a data synchronization method provided by an embodiment of the present specification;

[0023] Figure 5 is a schematic diagram of a flow of receiving block data sent by a first node provided by an embodiment of the present specification;

[0024] Figure 6 is a schematic diagram of a structure of block data provided by an embodiment of the present specification;

[0025] Figure 7 is a schematic diagram of a structure of a target node including a plurality of block data provided by an embodiment of the present specification;

[0026] Figure 8 is a schematic diagram of a flow of another data synchronization method provided by an embodiment of the present specification;

[0027] Figure 9 is a schematic diagram of a flow of data comparison provided by an embodiment of the present specification;

[0028] Figure 10 is a schematic diagram of a structure of a data synchronization apparatus provided by an embodiment of the present specification;

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

[0030] The technical solutions in the embodiments of the present specification will be described clearly and completely below with reference to the drawings in the embodiments of the present specification. Obviously, the described embodiments are only part of the embodiments of the present specification, rather than all the embodiments. Based on the embodiments in the present specification, all other embodiments obtained by a person of ordinary skill in the art without creative labor fall within the scope of protection of the present specification.

[0031] In the description of the specification, it is understood that the terms "first", "second" and the like are used only for the purpose of description, and cannot be understood as indicating or implying relative importance. In the description of the specification, it should be noted that, unless otherwise explicitly specified and limited, "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, product or device. The specific meaning of the above terms in the specification can be understood by the person skilled in the art. In addition, in the description of the specification, "a plurality of" means two or more, unless otherwise specified. The association relationship of the associated objects is described as "and / or", which means that there can be three relationships, for example, A and / or B can represent the following three cases: A exists alone, A and B exist together, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after it.

[0032] The specification will be described in detail below in conjunction with specific embodiments.

[0033] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data for analysis, stored data, displayed data, etc.) and signals involved in the embodiments of the specification are authorized by the user or fully authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions. For example, the object features, interaction behavior features and user information involved in the specification are obtained under sufficient authorization.

[0034] Data synchronization can be understood as the data stored by multiple nodes in the same system or structure reaching final consistency. For example, as shown in Figure 1 , an architecture schematic diagram of a data synchronization method provided by the embodiments of the specification is shown, which includes a total transaction end 101 and multiple sub-transaction ends 102. The multiple sub-transaction ends 102 include a sub-transaction end 1021, a sub-transaction end 1022, a sub-transaction end 1023, a sub-transaction end 1024, a sub-transaction end 1025 and a sub-transaction end 1026. It can be understood that Figure 1 The number of sub-transaction ends shown is only for illustration, and the embodiments of the specification do not make any limitation thereto.

[0035] Taking the transaction participation corresponding to a plurality of nodes as an example of a fund-related institution, specifically, can include a sales system (for example, a sales outlet, a personal user, and other third-party sales systems), a fund system, and a share registration system (for example, an open-end fund registration and transfer system), and the like. For example, the following is introduced taking the total transaction end as a fund institution, the sub-transaction end as a fund selling agent, and the transaction data as fund data.

[0036] The fund data can include user data, transaction data, asset data, and fund product data, and the like, wherein the user data includes account opening, account closing, customer information change, and account registration data, and the like; the transaction data includes subscription, purchase, redemption, transfer of custody, fund conversion, non-transaction transfer, share freezing / thawing, and share strong increase / strong decrease data, and the like; the asset data includes custody fund assets and user asset data, and the like; and the fund product data includes product establishment, product issuance, product temporary opening, product liquidation, and product dividend data, and the like.

[0037] As of 2021, the number of domestic fund management companies has reached 137, the number of public funds has reached 9152, and the number of fund selling agents has exceeded 400. With the rapid growth of the number of funds and the number of related institutions, the demand for efficient synchronization of fund information between fund companies and fund selling agents is also increasing. Users want to see more timely and authoritative fund net worth data through fund selling agents, and fund selling agents also want to quickly synchronize fund data to perform subsequent calculation and display processing based on fund data.

[0038] Therefore, the CSRC formulated an open-end fund business data exchange agreement in 2004, which determined the data exchange specification between various fund sellers and fund institutions based on the TXT interface specified by the CSRC. The 07 file is a file based on this specification, and the 07 file mainly contains fund dynamic information and fund data. When the fund institution 101 publishes the 07 file, a plurality of fund selling agents 102 receive the 07 file including fund data through respective corresponding links, and parse the fund data according to the 07 file, and then store the fund data into the databases of the respective fund selling agents 102, to realize the synchronization of fund data between a plurality of nodes.

[0039] and based on the fact that the 07 file is a file based on the specification of the CSRC, the 07 file is parsed to obtain fund data, and the fund data is stored into the databases of the respective fund selling agents 102, to realize the synchronization of fund data between a plurality of nodes. Figure 1The architecture of the data synchronization shown, the current sub-transaction end 102 acquires the transaction data mainly by relying on the 07 file transmitted by the total transaction end 101, and as a whole, it is a centralized system. Centered on the total transaction end 101, the 07 file is transmitted to each sub-transaction end 102, and each sub-transaction end 102 needs a set of systems to parse the 07 file. But the repeated construction of the parsing system needs to spend a lot of cost, and under the centralized transmission architecture, it is also easy to cause problems in some receiving nodes, resulting in no update or incorrect update of transaction data. This will cause the transaction data displayed on different sub-transaction ends 102 to be inconsistent, that is, data synchronization fails.

[0040] Therefore, the embodiment of the present specification proposes Figure 2 The data synchronization structure shown, to solve the problems brought by the centralized data synchronization structure.

[0041] As Figure 2 The architecture of a data synchronization method proposed by the embodiment of the present specification is shown, including a plurality of nodes, and the plurality of nodes at least include nodes 201, 202, 203, 204, 205, 206, 207 and 208. It can be understood that the number of nodes and the adjacent relationship shown in the embodiment are only for illustration, and the present specification does not make any limitation thereon, and also includes any number of nodes and the adjacent relationship between the plurality of nodes.

[0042] In the embodiment, the plurality of nodes are arranged on the blockchain, and the blockchain is a decentralized distributed database, which embodies the characteristics of being collectively maintained by the plurality of nodes joining the blockchain. Each node stores data blocks arranged in chronological order, and each block stores a plurality of data. The method of cryptography is used to ensure the non-tamperability, non-falsifiability and verifiability of the data in the block, and the consensus algorithm is used to make all nodes (theoretically all nodes) on the blockchain complete the recognition of the block, and the different nodes exchange data through the peer-to-peer network (Peer to Peer, P2P).

[0043] Specifically, as Figure 3 shown, Figure 3is a schematic diagram of another data synchronization method provided by the embodiments of the present specification. Taking a node as a transaction participant and data as transaction data as an example, the nodes correspond to total transaction ends or sub-transaction ends respectively. Node 201 corresponds to total transaction end 3011, node 203 corresponds to sub-transaction end 301, node 204 corresponds to sub-transaction end 3022, node 205 corresponds to total transaction end 3012, and node 206 corresponds to sub-transaction end 3023. Node 201 is adjacent to node 202 and node 207 respectively, node 202 is adjacent to node 203 and node 204 respectively, node 204 is adjacent to node 205, node 205 is adjacent to node 206, node 206 is adjacent to node 207, and node 207 is adjacent to node 208.

[0044] When total transaction end 3011 as node 201 needs to issue transaction data, the transaction data is sent to node 202, node 204, node 205 and node 207 which sign an agreement with node 201, and the transaction data is further synchronized to other nodes in the blockchain through node 202, node 204, node 205 and node 207.

[0045] Specifically, as shown in Figure 4 , a flowchart of a data synchronization method proposed by the embodiments of the present specification is shown. The method can be implemented by relying on a computer program and can run on a data synchronization device based on the von Neumann system. The computer program can be integrated in an application or run as an independent tool application.

[0046] Specifically, the data synchronization method includes:

[0047] S102, receiving block data sent from a first node.

[0048] A number of specific nodes can be selected in the blockchain to form a consortium chain; wherein the consortium chain refers to a blockchain whose consensus process is controlled by pre-selected nodes, only transaction member nodes within the consortium have access rights, when the nodes forming the consortium chain change data, the change data is broadcast to the entire consortium chain. For example, Figure 3 Nodes 201 to 208 shown in

[0049] The nodes forming the consortium chain can negotiate and confirm the rules for joining the consortium chain, for example, Figure 3 Multiple total transaction ends and sub-transaction ends join the consortium chain through negotiation and confirmation. Optionally, a specified consortium chain node identifier can be attached to each node in the consortium chain, or a digital certificate for verifying the identity of the consortium chain node can be generated.

[0050] In one embodiment, before receiving block data from the first node, the following steps may be included: An institution joins the consortium blockchain via a protocol, becoming a node in the consortium blockchain, and this node carries consortium blockchain node identification information and / or digital certificate information. When the first node sends block data, and the target node receives the block data, the target node determines whether the consortium blockchain node identification information and / or digital certificate information of the first node (as the node to be verified) matches the consortium blockchain node identification information and / or digital certificate information of the target node. If they match, the first node (as the node to be verified) is determined to be a consortium blockchain node, and verification or recording operations on updated data and even synchronized data are performed. If they do not match, the first node (as the node to be verified) is determined not to be a consortium blockchain node, and no further processing operations on updated data and even synchronized data are performed.

[0051] In this embodiment, by using a consortium blockchain jointly operated by several specific nodes, it is possible to ensure that only authorized nodes in the consortium blockchain can access the shared data in the consortium blockchain, thereby avoiding the privacy leakage problem of nodes and improving the efficiency of data processing.

[0052] In another embodiment, after receiving block data sent from the first node, the following steps may be included: verifying whether the first node is the node corresponding to the target organization; if the first node is the node corresponding to the target organization, updating the stored first data based on the block data to obtain the second data.

[0053] like Figure 5 As shown, Figure 5 This is a schematic diagram illustrating a process for receiving block data sent by a first node, as provided in an embodiment of this specification. The target institution can be an authoritative organization sending the data, such as the main transaction data publishing agency. Specifically, taking the main transaction data publishing agency as the first node 501 as an example, the main transaction data publishing agency 501 encrypts the transaction data using the first encryption parameter corresponding to the stored transaction data type, signs the encrypted transaction data using the node identifier of the reporting node 501, and writes it into the block data. The first node 501 broadcasts the encrypted and signed block data to the target node 502 in the blockchain.

[0054] The target node 502 receives the encrypted and signed block data by the first node, obtains the node identifier in the encrypted and signed block data, and determines whether the first node 501 corresponding to the block data is the node corresponding to the target organization based on the node identifier. If so, it decrypts the encrypted and signed block data by the first node 501 using the stored first decryption parameter.

[0055] In the embodiment, the method for determining whether the first node 501 corresponding to the block data is the node corresponding to the target institution according to the node identifier is as follows: the target node determines whether the first node corresponding to the node identifier can be searched in the stored white list according to the node identifier; if yes, it is determined that the first node is the node corresponding to the target institution; if no, it is determined that the first node is not the node corresponding to the target institution.

[0056] In the embodiment, in addition to limiting the nodes in the block chain to process data by using the encryption / decryption parameter, the node identifier can also be used to identify whether the source node of any data or block data is the node corresponding to the target institution.

[0057] In another embodiment, as shown in Figure 5 Each node in the block chain pre-stores a pair of public key and secret key in the embodiment. The secret key is used to encrypt the node identifier from plaintext to ciphertext, and the public key is used to decrypt the ciphertext to plaintext, so as to obtain the node identifier.

[0058] In the embodiment, the first node 501 can also broadcast the block data encrypted and signed by the node to the block chain in the following manner: the first node 501 encrypts the node identifier by using the stored secret key to obtain the encrypted node identifier; the first node 501 broadcasts the encrypted node identifier and the fund transaction data encrypted and signed by the first node to the block chain. The target node 502 receives the encrypted node identifier and the block data encrypted and signed by the first node, identifies the node identifier in the block data signed by the first node; the target node 502 decrypts the encrypted node identifier by using the stored private key, and determines whether the decrypted node identifier is consistent with the identified node identifier; if yes, it is determined that the first node 501 corresponding to the node identifier is the node corresponding to the target institution. Further, the target node 502 obtains the plaintext corresponding to the block data by hash verification, and writes the block data into the node block data stored in the target node 502.

[0059] In the embodiment, the block data and the node identifier are encrypted by using the public key and the private key, which can prevent the node identifier from being tampered maliciously, thereby ensuring the integrity of the verification information.

[0060] S104, updating the stored first data based on the block data to obtain second data.

[0061] After the target node obtains the block data sent by the first node and verifies that the operation on the block data is to update the stored first data and perform data synchronization, the target node updates the stored first data by using the block data to obtain the updated second data.

[0062] The ledger maintained by any node in the blockchain stores data in a connected data block structure. Each data block includes a block header and a block body. The block body stores a number of data records and a binary Merkle tree composed of hash values of each record, and the block header generally includes a version number and a hash value (hash pointer) of the previous data block connected to the data block. As shown in Figure 6 Figure 6 is a structure diagram of block data provided by an embodiment of the present specification, including at least a hash value, data, a timestamp of generating data, a timestamp of generating a block (block version), and a hash pointer (address of the previous block).

[0063] It can be understood that the data items of the block header / body and the blockchain structure (such as single-chain and double-chain structure) will be different according to different application requirements, and the present embodiment does not make any limitation to this, Figure 6 The structure of the block data shown is only illustrative.

[0064] As shown in Figure 7 Figure 7 is a structure diagram of a target node including a plurality of block data provided by an embodiment of the present specification. In the first data stored by the target node 600, two block data chains composed of a plurality of block data are included, that is, the plurality of block data are connected to the corresponding block data through the hash pointer corresponding to each block data. As shown in Figure 7 The first data stored by the target node 600 includes a first block data chain composed of block data 6011, block data 6012, block data 6013, block data 6014, block data 6015, and block data 6016, and a second block data chain composed of block data 6021, block data 6022, block data 6023, and block data 6024. After the target node 700 obtains the block data sent by the first node, the first block data chain composed of block data 6011, block data 6012, block data 6013, block data 6014, block data 6015, and block data 6016 is updated according to the hash pointer included in the block data, thereby obtaining the updated second data.

[0065] S106, compare the data stored by at least one second node adjacent to the target node respectively, and update the second data according to the comparison result until the target data is obtained.

[0066] ​​In a blockchain, the target node is adjacent to at least one second node. Based on the strategy of modifying first and then reaching consensus, after the target node updates its stored data, it compares it with the data stored by at least one adjacent second node. The comparison determines whether the data stored by the two nodes is the same, and the second node's data is updated based on the comparison result until the target data is obtained. The target data is the data stored in the target node after data synchronization in the blockchain is complete.

[0067] For example, such as Figure 3 In the architecture diagram shown, the first node 201, which sends block data, sends block data to nodes 202, 204, 205, and 207, which are the target nodes. After updating the first data stored in node 202 according to the block data, node 202 compares the data with the adjacent second nodes 203 and 204. It compares whether the data stored in node 202 and node 203 are the same. If not, it obtains the data stored in node 203. It also compares whether the data stored in node 202 and node 204 are the same. If not, it obtains the data stored in node 204. Nodes 204, 205, and 207 compare the data stored in at least one adjacent second node. They compare whether the data stored in two nodes are the same and update the data stored in each node according to the comparison results until the target data corresponding to each node is obtained. That is, the data of each node in the blockchain reaches final consistency.

[0068] This specification proposes a method for data synchronization between multiple nodes based on blockchain. When a target node on the blockchain receives block data sent by the first node, it first updates the data stored in the target node, and then compares the data with other adjacent nodes to synchronize the data of adjacent nodes to be consistent with the data of the target node, and even to synchronize the data of other nodes in the blockchain. This method can achieve eventual consistency of data under multiple nodes without causing exponential expansion of data volume due to data exchange between multiple nodes, and solves the problem that other nodes cannot synchronize data when a single node loses data, thus improving the disaster recovery capability of a single node. Due to the immutable nature of blockchain, the authority of block data from the first node is guaranteed, thereby making the data synchronization method of synchronizing the block data of the first node from the target node to other nodes highly reliable and stable.

[0069] In one embodiment, such as Figure 8 The diagram shown is a flowchart illustrating a data synchronization method proposed in an embodiment of this specification. This method can be implemented using a computer program and can run on a data synchronization device based on the von Neumann architecture. The computer program can be integrated into an application or run as a standalone utility application.

[0070] Specifically, the data synchronization method comprises:

[0071] S202, receiving block data sent by the first node.

[0072] Referring to S102, details are not repeated here.

[0073] S204, updating the stored first data based on the block data to obtain second data.

[0074] Referring to S104, details are not repeated here.

[0075] S206, obtaining data stored by at least one second node respectively.

[0076] The target node and the at least one second node exchange data through a peer-to-peer (P2P) network of the blockchain. Specifically, the target node sends a query request to the at least one second node to obtain block data or data corresponding to the query request, or the target node broadcasts the second data stored by the target node to the at least one second node in a broadcast manner.

[0077] In an embodiment, the target node obtains the block data encrypted and signed by the second node, and obtains a node identifier in the block data encrypted and signed by the second node. The target node determines whether the second node corresponding to the node identifier is a trusted node in the blockchain according to the node identifier. If yes, the target node decrypts the block data encrypted and signed by the second node by using the stored first decryption parameter or private key.

[0078] In the embodiment, the target node determines whether the block data obtained from the second node is from a trusted node according to the node identifier. Specifically, the target node determines whether the second node corresponding to the node identifier can be searched in the stored whitelist according to the node identifier. If yes, the target node determines that the second node is a trusted node. If no, the target node determines that the second node is not a trusted node.

[0079] In the embodiment, in addition to using the encryption / decryption parameter to limit the nodes in the blockchain to process data, the node identifier can also be used to identify whether the source node of any data or block data is a trusted node.

[0080] S208, determining whether the data stored by each second node is consistent with the second data.

[0081] After the target node obtains the data stored by the second node, it is determined whether the data stored by each second node is consistent with the second data stored by the target node. The account book maintained by any node in the blockchain stores data in a connected data block structure. Each data block includes a block header and a block body. The block body stores a plurality of data records and a binary Merkle tree composed of hash values of each record, and the block header generally includes a version number and a hash value (hash pointer) of the previous data block connected to the data block.

[0082] In one embodiment, the method of determining whether the data stored by each second node is consistent with the second data is: obtaining the timestamp of the latest block data in the data stored by the second node, and determining whether the timestamp of the latest block data in the second data stored by the first node is consistent with the timestamp of the latest block data in the data stored by the second node.

[0083] The timestamp is the timestamp of the transaction data in the generated block data. For example, taking transaction data as an example, when the first node generates block data from transaction data, it writes the timestamp T of obtaining the transaction data or the settlement of the transaction data in the block data; the target node updates the first data corresponding to the target node based on the block data generated by the first node, and the timestamp corresponding to the latest block data in the first data is timestamp T, and it is further determined whether the timestamp of the latest block data in the data stored by the second node is consistent with the timestamp T.

[0084] In another embodiment, the method of determining whether the data stored by each second node is consistent with the second data is: determining whether the hash value of the latest block data in the data stored by each second node is consistent with the hash value of the latest block data in the second data. As shown in Figure 7 When the target node 600 updates the stored first data based on the newly obtained block data 6017, the block data 6017 in the second data includes the merkle root hash value corresponding to the block data; the hash value of the latest block data in the data stored by the second node is obtained, and it is determined whether the hash value of the latest block data in the second data stored by the first node is consistent with the hash value of the latest block data in the data stored by the second node.

[0085] S210, broadcast the second data to the second target node or obtain the data stored by the second target node, until the target data is obtained.

[0086] If the data of the second target node is inconsistent with the second data, and the timestamp of the latest block data in the second data is later than the timestamp of the latest block data stored in the second target node, at least one block data obtained after the target block data in the second data is sent to the second target node, and the timestamp of the target block data in the second data is the same as the timestamp of the latest block data stored in the second target node.

[0087] If the data of the second target node is inconsistent with the second data, and the timestamp of the latest block data in the second data is earlier than the timestamp of the latest block data stored in the second target node, at least one block data obtained after the target block data stored in the data of the second target node is obtained, and the timestamp of the target block data stored in the data of the second target node is the same as the timestamp of the latest block data stored in the second target node.

[0088] Specifically, as shown in Figure 9 , Figure 9 A flowchart of data comparison provided by an embodiment of the present specification is shown, in which a target node 600 and a second node 700 adjacent thereto perform data comparison. The second data stored in the target node 600 includes the latest block data 6017, which is compared with the corresponding block data 7017 in the second node 700. If the data is consistent, no operation is needed. Meanwhile, the block data 6024 obtained at the same time is compared with the latest block data 7023 obtained in the second node 700, and the hash value or the timestamp of the two block data is compared. Figure 9 As shown in the figure, the timestamp of the block data 6024 in the target node 600 is obviously later than the timestamp of the block data 7023 in the second node 700, that is, the second node 700 lacks the block data 6024 included in the target node 600. The target node 600 broadcasts the block data 6024 to the second node 700, and the second node 700 updates the block data chain composed of the block data 7021, the block data 7022 and the block data 7023 based on the block data 6024, that is, the second node 700 obtains the target data.

[0089] In one embodiment, the data stored in the at least one second node adjacent thereto is compared based on a preset time frequency, and the target data is updated according to the comparison result until the updated target data is consistent with the data stored in each second node. In other words, the nodes in the block chain perform exchange and verification of block data at regular intervals, that is, data comparison is performed between the nodes, so as to ensure that the data between each node is consistent. When the comparison between two nodes finds that one of the nodes has data missing, the data saved in the other node is obtained. The method of data comparison can be comparison of the hash value or the timestamp of the block data.

[0090] In another embodiment, when a new node joins the alliance chain composed of multiple nodes, data comparison is also performed with adjacent nodes until the data of the newly added node is consistent with the data of adjacent nodes, that is, data synchronization is achieved.

[0091] In this embodiment, data exchange between nodes is performed at regular intervals or triggered by preset conditions, so that the multiple nodes in the block chain can stably achieve data synchronization, and the synchronization rate is high.

[0092] The present specification proposes a method for realizing data synchronization between multiple nodes based on a block chain. When a target node on the block chain receives block data sent by a first node, the stored data stored by the target node is updated first, and then data comparison is performed with other adjacent nodes to synchronize the data of adjacent nodes to be consistent with the data of the target node, and even the data of other nodes in the block chain is synchronized to be consistent. Under the premise of avoiding exponential expansion of data caused by mutual data exchange between multiple nodes, the final consistency of data in multiple nodes is realized, and the problem that other nodes cannot synchronize data when a single node data is lost is solved, and the disaster recovery capability of a single node is improved. Because the block chain has the characteristics of non-tamperability, the authority of the block data from the first node is guaranteed, so that the data synchronization method of synchronizing the block data of the first node from the target node to other nodes has high reliability and stability.

[0093] The following is an apparatus embodiment of the present specification, which can be used to execute the method embodiments of the present specification. For details not disclosed in the apparatus embodiments of the present specification, please refer to the method embodiments of the present specification.

[0094] Please refer to Figure 10 which shows a structural schematic diagram of a data synchronization apparatus provided by an example embodiment of the present specification. The data synchronization apparatus can be realized by software, hardware or a combination of both to become all or part of the apparatus, and is suitable for a target node in multiple nodes on a block chain. The data synchronization apparatus includes a data receiving module 1001, a data updating module 1002 and a data synchronization module 1003.

[0095] The data receiving module 1001 is configured to receive block data sent by a first node, and the block chain includes the first node.

[0096] The data updating module 1002 is configured to update the first data stored based on the block data to obtain second data.

[0097] The data synchronization module 1003 is configured to compare the data stored by each of the at least one second node respectively with the second data, and update the second data according to a comparison result until target data is obtained, the target data being consistent with the data stored by each of the second nodes.

[0098] In one embodiment, the data synchronization module 1003 comprises:

[0099] a data acquisition unit configured to acquire the data stored by each of the at least one second node respectively;

[0100] a data judgment unit configured to judge whether the data stored by each of the second nodes is consistent with the second data;

[0101] a data synchronization unit configured to, if the data of the second target node is inconsistent with the second data, broadcast the second data to the second target node or acquire the data stored by the second target node until the target node obtains the target data.

[0102] In one embodiment, the data judgment unit is specifically configured to judge whether a timestamp of the latest block data in the data stored by the target node is consistent with a timestamp of the latest block data in the second data.

[0103] In one embodiment, the data synchronization unit is specifically configured to, if the data of the second target node is inconsistent with the second data, and the timestamp of the latest block data in the second data is later than a timestamp of the latest block data in the data stored by the second target node, send at least one block data acquired after target block data in the second data to the second target node, the target block data in the second data having the same timestamp as the latest block data in the data stored by the second target node.

[0104] In one embodiment, the data synchronization unit is specifically configured to, if the data of the second target node is inconsistent with the second data, and the timestamp of the latest block data in the second data is earlier than a timestamp of the latest block data in the data stored by the second target node, acquire at least one block data acquired after target block data in the data stored by the second target node, the target block data in the data stored by the second target node having the same timestamp as the latest block data in the data stored by the second target node.

[0105] In one embodiment, the data judgment unit is specifically configured to judge whether a hash value of the latest block data in the data stored by each of the second nodes is consistent with a hash value of the latest block data in the second data.

[0106] In one embodiment, the data synchronization apparatus comprises:

[0107] The verification node module is configured to verify whether the first node is a node corresponding to a target organization.

[0108] The data updating module 1002 comprises:

[0109] The verification updating unit is configured to, if the first node is a node corresponding to a target organization, update the stored first data based on the block data to obtain second data.

[0110] In one embodiment, the data synchronization device comprises:

[0111] The timing updating module is configured to compare the target data with data stored by at least one second adjacent node based on a preset time frequency, and update the target data according to a comparison result until the updated target data is consistent with the data stored by each second node.

[0112] The present specification provides a method for synchronizing data among multiple nodes based on a blockchain. When a target node on the blockchain receives block data sent by a first node, the stored data stored by the target node is updated, and then compared with data of other adjacent nodes, so that the data of the adjacent nodes is synchronized to be consistent with the data of the target node, and even the data of other nodes on the blockchain is synchronized to be consistent. The method can realize the final consistency of data in multiple nodes while avoiding the exponential expansion of data caused by mutual data exchange among multiple nodes, solve the problem that other nodes cannot synchronize data when a single node loses data, and improve the disaster recovery capability of a single node. Since the blockchain has the feature of being tamper-proof, the authority of the block data from the first node is guaranteed, so that the data synchronization method of synchronizing the block data of the first node from the target node to other nodes has high reliability and stability.

[0113] It should be noted that the data synchronization device provided in the above embodiments is only used to illustrate the division of the above functional modules when the data synchronization method is executed. In actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above described functions. In addition, the data synchronization device and the data synchronization method provided in the above embodiments belong to the same concept, and the implementation process is described in detail in the method embodiments, which will not be repeated here.

[0114] The above sequence numbers of the embodiments of the present specification are only for description, and do not represent the advantages or disadvantages of the embodiments.

[0115] The embodiments of the present specification also provide a computer storage medium, which can store a plurality of instructions, the instructions being suitable for being loaded and executed by a processor to perform the above Figures 1-9The data synchronization method of the embodiment can refer to the specific implementation process Figures 1-9 The specific description of the embodiment is not described here.

[0116] The present specification also provides a computer program product, which stores at least one instruction, the at least one instruction is loaded and executed by the processor to perform the above Figures 1-9 The data synchronization method of the embodiment can refer to the specific implementation process Figures 1-9 The specific description of the embodiment is not described here.

[0117] Please refer to Figure 11 The present specification provides a structural schematic diagram of an electronic device. As shown in Figure 11 The electronic device 1100 can include at least one processor 1101, at least one network interface 1104, a user interface 1103, a memory 1105, and at least one communication bus 1102.

[0118] The communication bus 1102 is used to realize the connection communication between the components.

[0119] The user interface 1103 can include a display screen (Display), a camera (Camera), and can also include a standard wired interface, a wireless interface.

[0120] The network interface 1104 can optionally include a standard wired interface, a wireless interface (such as a WI-FI interface).

[0121] The processor 1101 can include one or more processing cores. The processor 1101 connects various parts within the server 1100 through various interfaces and lines, and performs various functions of the server 1100 and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 1105, and calling data stored in the memory 1105. Alternatively, the processor 1101 can be implemented in at least one of a hardware form of a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 1101 can be a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU is mainly used to process the operating system, user interface, and application programs; the GPU is used to render and draw the content to be displayed on the display screen; and the modem is used to process wireless communication. It can be understood that the above-mentioned modem can also not be integrated into the processor 1101, but can be realized by a separate chip.

[0122] The memory 1105 can include a random access memory (RAM) and a read-only memory (ROM). Alternatively, the memory 1105 includes a non-transitory computer-readable storage medium. The memory 1105 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 1105 can include a program storage area and a data storage area, wherein the program storage area can store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area can store data involved in the above-mentioned various method embodiments, etc. The memory 1105 can alternatively be at least one storage device located away from the aforementioned processor 1101. As shown in the figure, the memory 1105 as a computer storage medium can include an operating system, a network communication module, a user interface module, and a data synchronization application program. Figure 11 As shown in the figure, the memory 1105 as a computer storage medium can include an operating system, a network communication module, a user interface module, and a data synchronization application program.

[0123] In Figure 11In the electronic device 1100 shown, the user interface 1103 is mainly used to provide an interface for user input, and obtain data input by the user; and the processor 1101 can be used to call a data synchronization application stored in the memory 1105, which is suitable for a target node in a plurality of nodes on a blockchain, and specifically performs the following operations:

[0124] receiving block data sent by a first node, the blockchain including the first node;

[0125] updating the stored first data based on the block data to obtain second data;

[0126] comparing the second data with data stored by at least one second adjacent node respectively, and updating the second data according to the comparison result until target data is obtained, the target data being consistent with the data stored by each second node.

[0127] In one embodiment, the processor 1101 performs the comparison of the second data with data stored by at least one second adjacent node respectively, and updates the second data according to the comparison result until target data is obtained, and specifically performs:

[0128] obtaining data stored by at least one second adjacent node respectively;

[0129] judging whether the data stored by each second node is consistent with the second data;

[0130] if there is a second target node whose data is inconsistent with the second data, broadcasting the second data to the second target node or obtaining data stored by the second target node until the target node obtains target data.

[0131] In one embodiment, the processor 1101 performs the judgment of whether the data stored by each second node is consistent with the second data, and specifically performs:

[0132] judging whether a timestamp of the latest block data in the data stored by the target node is consistent with a timestamp of the latest block data in the second data.

[0133] In one embodiment, the processor 1101 performs the operation of broadcasting the second data to the second target node or obtaining data stored by the second target node if there is a second target node whose data is inconsistent with the second data, until the target node obtains target data, and specifically performs:

[0134] If the data of the second target node is inconsistent with the second data, and the timestamp of the latest block data in the second data is later than the timestamp of the latest block data stored in the second target node, at least one block data obtained after the target block data in the second data is sent to the second target node, the timestamp of the target block data in the second data is the same as the timestamp of the latest block data stored in the second target node.

[0135] In one embodiment, the processor 1101 performs the above-mentioned if the data of the second target node is inconsistent with the second data, the second data is broadcast to the second target node or the data stored in the second target node is obtained, until the target data is obtained by the target node, and specifically performs:

[0136] If the data of the second target node is inconsistent with the second data, and the timestamp of the latest block data in the second data is earlier than the timestamp of the latest block data stored in the second target node, at least one block data obtained after the target block data in the second data is obtained, the timestamp of the target block data in the second target node is the same as the timestamp of the latest block data stored in the second target node.

[0137] In one embodiment, the processor 1101 performs the above-mentioned judging whether the data stored in each second node is consistent with the second data, and specifically performs:

[0138] Judging whether the hash value of the latest block data in the data stored in each second node is consistent with the hash value of the latest block data in the second data.

[0139] In one embodiment, the processor 1101 performs the above-mentioned after the target node receives the block data sent from the first node, before the second data is obtained based on the update of the stored first data based on the block data, and further performs:

[0140] Verifying whether the first node is the node corresponding to the target organization;

[0141] The processor 1101 performs the above-mentioned based on the update of the stored first data based on the block data, to obtain the second data, and specifically performs:

[0142] If the first node is the node corresponding to the target organization, the second data is obtained based on the update of the stored first data based on the block data.

[0143] In one embodiment, the processor 1101 performs the above-mentioned comparing the data stored in at least one second adjacent node respectively, and updating the second data according to the comparison result, until the target data is obtained, and further performs:

[0144] Compare the preset time frequency with the data stored by the at least one second adjacent node respectively, and update the target data according to the comparison result until the updated target data is consistent with the data stored by each second node.

[0145] The present specification provides a method for synchronizing data between multiple nodes based on a blockchain. When a target node on the blockchain receives block data sent by a first node, the stored data of the target node is updated first, and then compared with other adjacent nodes to synchronize the data of the adjacent nodes to be consistent with the data of the target node, and even synchronize the data of other nodes on the blockchain. Under the premise of avoiding exponential expansion of data caused by mutual data exchange between multiple nodes, the final consistency of data in multiple nodes is realized, and the problem of data synchronization of other nodes when a single node data is lost is solved, the disaster recovery capability of a single node is improved. Due to the tamper-proof feature of the blockchain, the authority of the block data from the first node is guaranteed, so that the data synchronization method of synchronizing the block data of the first node from the target node to other nodes has high reliability and stability.

[0146] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing related hardware. The program can be stored in a computer readable storage medium, and when the program is executed, it can include the processes of the above-mentioned embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory, or a random access memory.

[0147] The above only discloses the preferred embodiments of the present specification, and of course cannot limit the scope of the rights of the present specification, so equivalent changes made according to the claims of the present specification still fall within the scope of the present specification.

Claims

1. A data synchronization method suitable for a target node among a plurality of nodes on a blockchain, the method comprising: receiving block data sent from a first node, the blockchain comprising the first node; updating stored first data based on the block data to obtain second data; comparing the second data with data stored by at least one second adjacent node respectively, and updating the second data according to a comparison result until target data is obtained, the target data being consistent with the data stored by each second node; wherein the comparing the second data with data stored by at least one second adjacent node respectively, and updating the second data according to a comparison result until target data is obtained comprises: obtaining data stored by at least one second adjacent node respectively; determining whether the data stored by each second node is consistent with the second data; if the data of a second target node is inconsistent with the second data, broadcasting the second data to the second target node or obtaining data stored by the second target node until the target node obtains target data. 2.The method of claim 1, wherein the determining whether the data stored by each second node is consistent with the second data comprises: determining whether a timestamp of latest block data in the data stored by the target node is consistent with a timestamp of latest block data in the second data. 3.The method of claim 2, wherein the if the data of a second target node is inconsistent with the second data, broadcasting the second data to the second target node or obtaining data stored by the second target node until the target node obtains target data comprises: if the data of a second target node is inconsistent with the second data, and a timestamp of latest block data in the second data is later than a timestamp of latest block data in the data stored by the second target node, sending at least one block data obtained after target block data in the second data to the second target node, the target block data in the second data having a same timestamp as the timestamp of latest block data in the data stored by the second target node. 4.The method of claim 2, wherein the if the data of a second target node is inconsistent with the second data, broadcasting the second data to the second target node or obtaining data stored by the second target node until the target node obtains target data comprises: if the data of a second target node is inconsistent with the second data, and a timestamp of latest block data in the second data is earlier than a timestamp of latest block data in the data stored by the second target node, obtaining at least one block data obtained after target block data in the data stored by the second target node, the target block data in the data stored by the second target node having a same timestamp as the timestamp of latest block data in the data stored by the second target node. 5.The method of claim 1, wherein the determining whether the data stored by each second node is consistent with the second data comprises: determining whether the hash value of the latest block data stored in each of the second nodes is consistent with the hash value of the latest block data in the second data. 6.The method of claim 1, wherein after the target node receives the block data sent by the first node, and before the updating the stored first data based on the block data to obtain the second data, the method comprises: verifying whether the first node is a node corresponding to a target organization; the updating the stored first data based on the block data to obtain the second data comprises: if the first node is the node corresponding to the target organization, updating the stored first data based on the block data to obtain the second data. 7.The method of claim 1, wherein after the comparing the data stored in each of the at least one second adjacent node respectively and updating the second data based on the comparison result until the target data is obtained, the method further comprises: comparing the data stored in each of the at least one second adjacent node based on a preset time frequency respectively and updating the target data based on the comparison result until the updated target data is consistent with the data stored in each of the second nodes. 8.A data synchronization apparatus, comprising: a data receiving module configured to receive block data sent by a first node, wherein the block chain comprises the first node; a data updating module configured to update stored first data based on the block data to obtain second data; a data synchronization module configured to compare data stored in each of at least one second adjacent node respectively and update the second data based on the comparison result until target data is obtained, wherein the target data is consistent with the data stored in each of the second nodes; wherein the data synchronization module comprises: a data obtaining unit configured to obtain data stored in each of at least one second adjacent node respectively; a data judging unit configured to determine whether the data stored in each of the second nodes is consistent with the second data; a data synchronization unit configured to, if the data stored in a second target node is not consistent with the second data, broadcast the second data to the second target node or obtain the data stored in the second target node until the target node obtains the target data. 9.A computer storage medium storing a plurality of instructions, wherein the instructions are adapted to be loaded and executed by a processor to perform the steps of the method of any one of claims 1-7. 10.A computer program product storing a plurality of instructions, wherein the instructions are adapted to be loaded and executed by a processor to perform the steps of the method of any one of claims 1-7.

11. An electronic device comprising: a processor and a memory;wherein the memory stores a computer program, and the computer program is adapted to be loaded and executed by the processor to perform the steps of the method of any one of claims 1-7.

Citation Information

Patent Citations

  • Node data synchronization method, device and equipment and storage medium

    CN111209343A

  • Data synchronization method, block chain system, terminal equipment and storage medium

    CN114338715A