Data synchronization method and device based on block chain, equipment and storage medium

By using the rule string of the target blockchain node in the blockchain system to generate logical matching functions, the problem of changes in node access rights affecting data synchronization efficiency and security is solved, and efficient and secure data sharing is achieved.

CN119938779APending Publication Date: 2025-05-06TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311466178.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-03
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

Data sharing efficiency and security in blockchain systems are affected by changes in node access rights, resulting in inefficient data synchronization and insufficient security.

Method used

By obtaining the rule string corresponding to the node identification of the target blockchain node, a logical matching function is generated, and the function is executed to obtain the target transaction data that meets the transaction data conditions from the block to be synchronized, and synchronize it to the target blockchain node.

Benefits of technology

It improves the efficiency and security of data sharing in blockchain systems, simplifies rule management and adjustment, and reduces the complexity and possibility of system code adjustment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119938779A_ABST
    Figure CN119938779A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the technical field of block chains, in particular to a block chain-based data synchronization method and device, equipment and a storage medium. The method is applied to a synchronization node in a block chain system, and comprises the following steps: if data synchronization needs to be performed on a target block chain node, obtaining a rule character string corresponding to a node identifier of the target block chain node; the rule character string is used for limiting a transaction data condition that the target block chain node has access permission; generating a logic matching function based on the rule character string; executing the logic matching function to obtain target transaction data meeting the transaction data condition from a to-be-synchronized block; and synchronizing the target transaction data to the target block chain node. By adopting the method provided by the invention, the efficiency and security of data sharing in the block chain system can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and more specifically, to a blockchain-based data synchronization method, device, equipment and storage medium. Background Art

[0002] With the development of Internet technology, blockchain has received more and more attention; blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc., and its essence is a decentralized database.

[0003] In related technologies, there is data with complex structure and large amount of data in the blockchain system. As people's requirements for data sharing become higher and higher, how to share data between blockchain nodes has become a problem.

[0004] For example, as data accumulates in the blockchain system, the scale of data will become larger and larger, and different blockchain nodes often have different data access permissions. As time goes by and the amount of data increases, user permissions may change, and the corresponding blockchain node access permissions may also change. When the access permissions of blockchain nodes change, it will seriously affect the efficiency and security of data sharing in the blockchain system. Summary of the invention

[0005] In view of this, the embodiments of the present application propose a blockchain-based data synchronization method, device, equipment and storage medium to improve the efficiency of data synchronization.

[0006] In a first aspect, an embodiment of the present application provides a blockchain-based data synchronization method, which is applied to a synchronization node in a blockchain system, and the method includes: if data synchronization to a target blockchain node is required, obtaining a rule string corresponding to a node identifier of the target blockchain node; the rule string is used to limit transaction data conditions for which the target blockchain node has access rights; generating a logical matching function based on the rule string; executing the logical matching function to obtain target transaction data that meets the transaction data conditions from the block to be synchronized; and synchronizing the target transaction data to the target blockchain node.

[0007] In the second aspect, an embodiment of the present application provides a blockchain-based data synchronization device, which is applied to a synchronization node in a blockchain system, and the device includes: a string acquisition module, which is used to obtain a rule string corresponding to the node identifier of the target blockchain node when data synchronization to the target blockchain node is required; the rule string is used to limit the transaction data conditions for which the target blockchain node has access rights; a function generation module, which is used to generate a logical matching function based on the rule string; a function execution module, which is used to execute the logical matching function to obtain target transaction data that meets the transaction data conditions from the block to be synchronized; and a data synchronization module, which is used to synchronize the target transaction data to the target blockchain node.

[0008] In one possible implementation, the function generation module includes a parsing module and a function generation submodule. The parsing module is used to parse the rule string and generate a syntax tree corresponding to the rule string, wherein the syntax tree includes at least one of an identifier node representing an identifier, a value node representing a value of the identifier, an operation node representing an operator, and a function type node representing a built-in function, wherein the identifier is used to represent a property of a transaction, and the built-in function includes an identifier and its corresponding value; and the function generation submodule is used to traverse the syntax tree and generate a logic matching function based on the node information of each node obtained through the traversal.

[0009] In one possible implementation, the syntax tree is a binary tree, each parent node of the binary tree has two corresponding child nodes connected, the parent node of the syntax tree is an operation node, and the leaf nodes of the syntax tree are identifier nodes, value nodes or function type nodes; the function generation submodule is also used to traverse from the root node to determine the currently traversed node as the target node; if it is determined according to the target node that there is a target syntax subtree including the target node, a logical matching function corresponding to the target syntax subtree is generated according to the node information of each node in the target syntax subtree; wherein the target syntax subtree is formed by the target node and two child nodes connected to the target node as leaf nodes, or the target syntax subtree is formed by the target node as a function type node.

[0010] In one possible implementation, the function generation submodule is also used to, when both child nodes connected to the target node are not leaf nodes, use the left child node and the right child node connected to the target node as new target nodes respectively, until the logical matching functions corresponding to all target grammar subtrees under the left child node and the logical matching functions corresponding to all target grammar subtrees under the right child node are obtained; based on the operators represented by the upper nodes of each target grammar subtree, the logical matching functions corresponding to the multiple target grammar subtrees are connected to obtain the logical matching functions corresponding to the grammar trees.

[0011] In one possible implementation, the device also includes a data receiving module and a storage module, the data receiving module is used to receive the data broadcast by the target blockchain node when joining the blockchain system where the synchronization node is located, the data including the node identifier of the target blockchain node and the rule string; the storage module is used to store the node identifier of the target blockchain node in association with the rule string.

[0012] In one possible implementation, the function execution module is also used to execute the logic matching function for each transaction data in the block to be synchronized to determine the matching result between the transaction data and the transaction data condition; if the matching result indicates that the transaction data meets the transaction data condition, the transaction data is determined as the target transaction data.

[0013] In one possible implementation, the device also includes a block determination module, which is used to determine at least one block to be synchronized based on the target block height and the block height of the blockchain on the target blockchain node, and the block height of the block to be synchronized is between the block height of the blockchain on the target blockchain node and the target block height.

[0014] In one possible implementation, the synchronization node is a full node, and the full node has access rights to all transaction data.

[0015] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory; one or more programs are stored in the memory and configured to be executed by the processor to implement the above method.

[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, wherein the above method is executed when the program code is executed by a processor.

[0017] In a fifth aspect, an embodiment of the present application provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device obtains the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the above method.

[0018] The embodiment of the present application provides a data synchronization method, device, equipment and storage medium based on blockchain, which is used for synchronization nodes in blockchain systems. When data synchronization needs to be performed to a target blockchain node, a rule string corresponding to the node identifier of the target blockchain node is obtained; the rule string is used to limit the transaction data conditions for which the target blockchain node has access rights; a logic matching function is generated based on the rule string; the logic matching function is executed to obtain target transaction data that meets the transaction data conditions from the block to be synchronized; and the target transaction data is synchronized to the target blockchain node. When data synchronization needs to be performed to the target blockchain node, it is only necessary to generate a logic matching function based on the rule string of the target blockchain node, so as to use the logic matching function to filter and screen the transaction data in the block to be synchronized in the synchronization node, and the rule string is pre-configured, and the pre-configured rule strings for target blockchain nodes of different roles or purposes are different, so that the synchronization node can provide different transaction data to the target blockchain node based on the rule string during the data synchronization process. In addition, when the transaction data conditions of the target blockchain node change, it is only necessary to adjust the rule string corresponding to the target blockchain node, so that when the logic matching function generated based on the adjusted rule string obtains the target transaction data from the block to be synchronized, the acquired transaction data meets the changed transaction data conditions, and the content of adjusting the rule string is less than that of adjusting the system code, the adjustment efficiency is high, and the possibility of error is low. Therefore, by adopting the above method of the present application, the efficiency and security of data sharing in the blockchain system can be effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0020] Figure 1 A schematic diagram of a blockchain provided by an embodiment of the present application is shown;

[0021] Figure 2 A schematic diagram of a blockchain system proposed in an embodiment of the present application is shown;

[0022] Figure 3 A flowchart of a blockchain-based data synchronization method proposed in an embodiment of the present application is shown;

[0023] Figure 4 Another flowchart of a blockchain-based data synchronization method proposed in an embodiment of the present application is shown;

[0024] Figure 5 A schematic diagram of a syntax tree proposed in an embodiment of the present application is shown;

[0025] Figure 6 Another schematic diagram of a syntax tree proposed in an embodiment of the present application is shown;

[0026] Figure 7 for Figure 5 Schematic diagram of the process of step S230;

[0027] Figure 8 Another schematic diagram of a syntax tree proposed in an embodiment of the present application is shown;

[0028] Fig. 9 Another schematic diagram of a syntax tree proposed in an embodiment of the present application is shown;

[0029] Fig.10 Another schematic diagram of a syntax tree proposed in an embodiment of the present application is shown;

[0030] Fig.11 Another schematic diagram of a syntax tree proposed in an embodiment of the present application is shown;

[0031] Fig.12 Another flowchart of a blockchain-based data synchronization method proposed in an embodiment of the present application is shown;

[0032] Fig.13 A connection block diagram of a blockchain-based data synchronization device provided in an embodiment of the present application is shown;

[0033] Fig.14 A structural block diagram of an electronic device for executing the method of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0035] The following explains the terms used in this application.

[0036] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of blocks generated by cryptographic methods. Each block contains a batch of network transaction information, which is used to verify the validity of the information (anti-counterfeiting) and generate the next block.

[0037] like Figure 1 As shown, the blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores input information feature values, version numbers, timestamps, and difficulty values, and the block body stores input information. The next block of the genesis block uses the genesis block as the parent block. The next block also includes a block header and a block body. The block header stores the input information feature values ​​of the current block, the block header feature values ​​of the parent block, version numbers, timestamps, and difficulty values, and so on, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, ensuring the security of the input information in the block. The input information feature value of the above current block is specifically the hash value of the data stored in the current block (the hash value of this block), and the block header feature value of the parent block is specifically the hash value of the parent block.

[0038] The blockchain system is a distributed system that can be formed by connecting multiple nodes (any form of computing devices connected to the network, such as servers and user terminals) through network communication. The blockchain system is formed by multiple blockchain nodes, and a peer-to-peer network is formed between blockchain nodes.

[0039] Blockchain nodes can be any form of computing device in the network, a server, or a terminal device. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal device can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. Each node can be directly or indirectly connected by wired or wireless communication, and this application is not limited here. Each node can receive input information when performing normal work, and maintain the shared data in the blockchain system based on the received input information. In order to ensure the information intercommunication within the blockchain system, there can be an information connection between each node in the blockchain system, and the nodes can transmit information through the above information connection.

[0040] Among them, blockchain nodes can be divided into two categories, one is light node and the other is full node. Light node can also be called SPV (Simplified Payment Verification) node, which refers to the node in the blockchain system that does not participate in consensus and supports the storage of all block headers in the blockchain; usually, light node does not support the storage of transaction data, but can synchronize the block headers of each block from the full node, that is, the light node stores the block headers of each block in the blockchain. Full node refers to the node in the blockchain system that has a complete blockchain ledger (i.e. blockchain). Full node needs to occupy memory to synchronize all blockchain data, can independently verify all transactions on the blockchain and update data in real time, and is mainly responsible for the broadcast and verification of blockchain transactions, that is, the full node stores the complete blockchain.

[0041] The functions of each blockchain node in the blockchain network include:

[0042] 1) Routing, a basic function of blockchain nodes, used to support communication between nodes.

[0043] In addition to the routing function, blockchain nodes can also have the following functions:

[0044] 2) Blockchain, including a series of blocks that are connected to each other in the order of their generation. Once a new block is added to the blockchain, it will not be removed. The block records the record data submitted by the nodes in the blockchain network, such as transaction data.

[0045] 3) Applications are deployed in the blockchain to implement specific businesses based on actual business needs, record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain network for other nodes to add the record data to the temporary block when they successfully verify the source and integrity of the record data.

[0046] Each blockchain node in the blockchain system has a node identifier corresponding to it, and each blockchain node in the blockchain system can store the node identifiers of other blockchain nodes, so that the generated blocks can be broadcast to other blockchain nodes in the blockchain system according to the node identifiers of other blockchain nodes. A node identifier list can be maintained in each node, and the node name and node identifier are stored in the node identifier list accordingly. Among them, the node identifier can be an IP (Internet Protocol, a protocol for interconnecting networks) address or any other information that can be used to identify the node.

[0047] Synchronization is an important process in the blockchain system, which can be functionally divided into transaction synchronization and state synchronization. Transaction synchronization can be performed when the transaction is submitted, and it is prioritized to ensure that the transaction can be sent to all blockchain nodes in the blockchain system so that the blockchain nodes can package and process the received transactions. State synchronization can be used to quickly catch up to the highest block height in the entire network when a blockchain node in the blockchain system finds that its own block height lags behind the entire network (for example, the block height of a blockchain node is 5, and the block height of the entire network is 7). The synchronization in this application is mainly state synchronization.

[0048] In the related technology, the configuration and use process of data permissions of the blockchain node (target blockchain node) that needs to synchronize data mainly includes the following process: the blockchain nodes that need to synchronize data are divided into different types, each type of blockchain node corresponds to a fixed permission, and the logic for obtaining data corresponding to each permission is encoded to implement specific rules. When synchronizing data to the target blockchain node, the blockchain node (synchronization node) that provides data first obtains the node type of the target blockchain node, and then executes the corresponding block data screening logic according to the node type to screen the block data. And send the screened data to the target blockchain node.

[0049] The inventors have discovered that in the related art, since each type of blockchain node is pre-defined and the logic implementation is embedded in the system code, as demand increases, the system code needs to be expanded, which makes maintenance and updating difficult; secondly, user needs are forcibly bound to the implemented permission logic, which cannot support the needs of different users for different data permissions.

[0050] Based on this, the present application provides a blockchain-based data synchronization method, the method comprising: if data synchronization to a target blockchain node is required, obtaining a rule string corresponding to the node identifier of the target blockchain node; the rule string is used to limit the transaction data conditions for which the target blockchain node has access rights; generating a logical matching function based on the rule string; executing the logical matching function to obtain target transaction data that meets the transaction data conditions from the block to be synchronized; and synchronizing the target transaction data to the target blockchain node.

[0051] By adopting the above method, when data synchronization is required to the target blockchain node, it is only necessary to generate a logical matching function according to the rule string of the target blockchain node, so as to use the logical matching function to filter and screen the transaction data in the block to be synchronized in the synchronization node, and the rule string is pre-configured, and the pre-configured rule string is different for target blockchain nodes of different roles or purposes, so that the synchronization node can provide different transaction data to the target blockchain node based on the rule string during the synchronization data process. In addition, when the transaction data condition of the target blockchain node changes, it is only necessary to adjust the rule string corresponding to the target blockchain node, so that when the logical matching function generated based on the adjusted rule string obtains the target transaction data from the block to be synchronized, the acquired transaction data meets the changed transaction data condition, and the adjustment of the rule string is less than that of adjusting the system code, the adjustment efficiency is high, and the possibility of errors is low. Therefore, by adopting the above method of the present application, the efficiency and security of data sharing in the blockchain system can be effectively improved.

[0052] Combine the following Figure 2 A schematic diagram illustrating a blockchain system according to an embodiment of the present invention. Figure 1 The blockchain system 100 shown may correspond to a blockchain network, which may include but is not limited to a blockchain network corresponding to a consortium chain. The blockchain system 100 refers to a system for sharing data between blockchain nodes, and the blockchain system may include multiple blockchain nodes, which may specifically include blockchain nodes 10a, blockchain nodes 10b, blockchain nodes 10c, ..., blockchain nodes 10n, where blockchain nodes 10a, blockchain nodes 10b, blockchain nodes 10c, ..., blockchain nodes 10n may be collectively referred to as blockchain nodes.

[0053] Each blockchain node can receive input information when performing normal work, and maintain the shared data in the blockchain system based on the received input information. In order to ensure the information exchange within the blockchain system, there can be an information connection between each blockchain node in the blockchain system, and information can be transmitted between blockchain nodes through the above information connection. It is understandable that the above information connection does not limit the connection method, and can be directly or indirectly connected through wired communication, directly or indirectly connected through wireless communication, or through other connection methods, and the present invention is not limited here.

[0054] It is understandable that the blockchain network can realize the information connection between blockchain nodes based on the node identification. For each blockchain node in the blockchain system, there is a node identification corresponding to it, and each blockchain node in the blockchain system can store the node identification of other blockchain nodes in the blockchain system, so that the generated blocks or data can be broadcast to other blockchain nodes in the blockchain system according to the node identification of other blockchain nodes. A node identification list can be maintained in each blockchain node, including the node name and node identification of each blockchain node in the blockchain system. Among them, the node identification can be an IP (Internet Protocol, a protocol for interconnecting networks) address and any other information that can be used to identify a blockchain node in a blockchain network.

[0055] It is understandable that the data synchronization method based on blockchain provided in the embodiment of the present invention can be applied to any computer device with data processing and computing capabilities, and this computer device can be various terminals or servers. When the computer device in the embodiment of the present invention is a server, the server is an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network, content distribution network), and big data and artificial intelligence platforms. Optionally, the terminal is a smart phone, a tablet computer, a laptop computer, a desktop computer, etc., but is not limited to this.

[0056] It should be further explained that the terminals involved in the embodiments of the present invention include but are not limited to smart phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. The embodiments of the present invention can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc.

[0057] When the synchronization node in the above-mentioned blockchain system is used to execute the blockchain-based data synchronization method, the specific execution process is as follows: when the target blockchain node needs to synchronize data, it sends a synchronization request to other blockchain nodes in the blockchain system (other blockchain nodes include the synchronization node). When the synchronization node receives the synchronization request, it determines that data synchronization needs to be performed on the target blockchain node, and obtains a rule string corresponding to the node identifier of the target blockchain node; the rule string is used to limit the transaction data conditions that the target blockchain node has access rights to; a logical matching function is generated based on the rule string; the logical matching function is executed to obtain target transaction data that meets the transaction data conditions from the block to be synchronized; and the target transaction data is synchronized to the target blockchain node.

[0058] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0059] See also Figure 3 , Figure 3 The data synchronization method based on blockchain provided by the embodiment of the present application is shown as follows. Figure 2 The synchronization node in the blockchain system shown, the data synchronization method based on blockchain includes steps S110 to S150:

[0060] Step S110: If data synchronization with the target blockchain node is required, obtain a regular string corresponding to the node identifier of the target blockchain node.

[0061] The rule string is used to limit the transaction data conditions under which the target blockchain node has access rights.

[0062] Among them, the synchronization node can confirm the need to synchronize data with the target blockchain node when receiving a data synchronization request sent by the target blockchain node; the synchronization node can also confirm the need to synchronize data with the target blockchain node when detecting that a node (target blockchain node) has joined the blockchain system where the synchronization node is located; the synchronization node can also determine the need to synchronize data with the target blockchain node when receiving a synchronization instruction sent by the master node in the blockchain system that carries the identification information of the target blockchain node. It should be understood that the above-mentioned method of determining the need to synchronize data with the target blockchain node is only illustrative, and there can be more confirmation methods, which are not specifically limited here.

[0063] A synchronization node refers to a blockchain node in a blockchain system that can synchronize data with other nodes. A synchronization node can be a full node, which has access rights to all transaction data. A synchronization node can also be a lightweight node, and the data access rights of the synchronization node include the data access rights of the target blockchain node, that is, all transaction data accessible to the target blockchain node can be accessed by the synchronization node.

[0064] The target blockchain node is any blockchain node in the blockchain system that needs to be synchronized with data, that is, any blockchain node that needs to be synchronized with data by other blockchain nodes in the blockchain system; the node identifier can be a string that can uniquely identify the blockchain node in the blockchain system, which can be composed of one or more of letters, numbers, symbols, etc., and the node identifier of the blockchain node can be pre-set or generated when joining the blockchain system. Each blockchain node in the blockchain system can store the identification information and regular strings of other blockchain nodes.

[0065] The rule string corresponding to the target blockchain node is pre-configured for the target blockchain node and stored in the synchronization node. The synchronization node obtains the node identification of the target blockchain node and the corresponding string and stores them in the following ways: receiving the data broadcasted when the target blockchain node joins the block where the synchronization node is located, the data includes the node identification and rule string of the target blockchain node, and the node identification of the target blockchain node is associated with the rule string and stored; or receiving the data synchronized by the master node in the blockchain system, the data includes the node identification of the target blockchain node and the rule string corresponding to the node identification of the target blockchain node, and the node identification of the target blockchain node is associated with the rule string and stored. It should be understood that the above-mentioned way in which the synchronization node obtains the node identification of the target blockchain node and the corresponding string and stores them is only illustrative, and there may be more ways to obtain them, which are not specifically limited here.

[0066] It should be understood that when pre-configuring the rule string of the target blockchain node, the administrator can configure different rule strings for the target blockchain node according to the corresponding needs or uses, so as to filter and screen the transaction data in the synchronization node according to its needs or applications, thereby achieving the purpose of using the synchronization node to provide different transaction data for target blockchain nodes with different needs or uses.

[0067] When the node identifier of the target blockchain node is associated with the rule string and stored, it can be stored in the form of a key-value pair or in the form of a list. There is no specific limitation here and it can be set according to actual needs.

[0068] The rule string can be any string that can limit the transaction data conditions that the target blockchain node has access rights to. Specifically, the rule string can be a regular expression; or it can be a string composed of one or more of an operator, an identifier representing the attributes of the transaction in the transaction information, an attribute value, and a priority limiter. It should be understood that the type or composition of the above rule string is only illustrative, and there can be more formats or types, as long as it can limit the transaction data conditions that the target blockchain node has access rights to, and no specific limitation is made here.

[0069] Among them, the attributes of the transaction include one or more of the transaction initiator organization, the transaction initiator identity, the contract name, the transaction ID and the transaction type, among which the transaction initiator organization can be represented by the letter O, the transaction initiator identity can be represented by the letter T, the contract name can be represented by the letter C, the transaction ID can be represented by the letters TD, and the transaction type can be represented by the letters TT.

[0070] The operator can be composed of one or more of the operators supporting the grammar definition grammar and the logical operators supporting the logical operation definition grammar, etc. The operators supporting the grammar definition grammar include "equal to" (i.e., "=") or "not equal to" (i.e., "!="); the logical operators supporting the logical operation definition grammar can include "and" (i.e., "&&"), "or" (i.e., " / / ") and "not" (i.e., "!"); the priority symbols supported by the grammar can be one or more of "()", "[]" and "{}", etc.

[0071] The rule string may also include a built-in function that represents an identifier and its corresponding value. Exemplarily, the built-in function may include one or more of "ContainOf(identifier, "value of identifier")" (used to represent that the value matched by the identifier is included) or "InArray(identifier, "value of identifier")" (used to represent that the value matched by the identifier is in an array). Exemplarily, if the built-in function included in the rule string is "ContainOf(O, "org-x")", the built-in function limits the transaction data conditions that the target blockchain node has access rights to include transaction data whose transaction initiator organization begins with "org" (such as: "org1", "org2"... "orgn"); if the built-in function included in the rule string is InArray(I, "admin1, admin2, admin3"), the built-in function limits the transaction data conditions that the target blockchain node has access rights to include transaction data whose transaction initiator identity is "admin1", "admin2" or "admin3".

[0072] For example, if the target blockchain node has access rights to all transaction data in the synchronization node, the string can be any string that can represent access rights to all data in the synchronization node, such as a string representing a restriction condition of 0. It can also be directly represented by an empty string, where an empty string represents a string consisting of zero characters, also called an "empty string", and has a length of 0, which can be represented as "".

[0073] If the target blockchain node only has access to part of the transaction data in the blockchain system, for example, if the target blockchain node only has access to transaction data initiated by the transaction initiating organization "org1", the rule string can be "O=org1"; if the target blockchain node has access to transaction data initiated by the transaction initiating organization "org1" or to transaction data initiated by the transaction initiating organization "org2" and the transaction initiator "admin1", the rule string is: O=="org1"||(O=="org2"&&T=="admin1"); if the target blockchain node has access to transaction data initiated by the transaction initiating organization "org1" or to transaction data initiated by the transaction initiating organization "org1" and the transaction initiator includes "adminx", the rule string is: O=="org1"||(O=="org2"&&containOf(T,"adminx")).

[0074] The rule strings of the above target blockchain nodes are only for illustration. It should be understood that different access rights correspond to different rule strings, and the same access rights can also be expressed by different rule strings.

[0075] Step S120: Generate a logic matching function based on the rule character string.

[0076] The method of generating a logical matching function based on a rule string can be to generate a logical function based on a rule string using a code generator; or to convert the rule characters according to predefined conversion rules to obtain a logical matching function; or to define and parse the rule string to obtain multiple substrings, generate a logical function corresponding to each substring, and generate a logical function corresponding to the rule string based on the logical function corresponding to each substring. It is also possible to convert the rule string into a syntax tree to generate a logical matching function based on the syntax tree. The above-mentioned method of generating a logical matching function based on a rule string is only illustrative, and there can be more generation methods, which are not specifically limited here and can be set according to actual needs.

[0077] In one possible implementation, if a code generator is used to generate a logic function based on a rule string, the rule string only needs to be input into the code generator to obtain the logic function corresponding to the rule string.

[0078] In one possible implementation, when a rule string is defined and parsed to obtain multiple substrings, a logic function corresponding to each substring is generated, and based on the logic function corresponding to each substring, a logic function corresponding to the rule string is generated, each substring can be composed of an operator and two parameters, and the parameter can refer to an identifier, or the value of an identifier, or a substring represented by a definition character consisting of an identifier, an identifier value, and an operator, or a new substring consisting of an operator represented by a definition character and two substring definition characters. For each string, the logic function corresponding to each string is generated, and the logic function corresponding to the rule string can be obtained. Exemplarily, taking the rule string O=="org1"||(O=="org2"&&T=="admin1") as an example, the generated substrings include O=="org1", O=="org2, T=="admin1, J&&K, L||M, where J refers to O=="org2 in the aforementioned rule string, K refers to T=="admin1 in the aforementioned rule string, L refers to O=="org2", and M refers to J&&K. At this time, for each substring, a logical matching function corresponding to the substring is generated, and the logical functions corresponding to each substring are connected according to the operators in each substring to obtain the logical function of the rule string.

[0079] In one possible implementation, if the rule string is converted into a syntax tree to generate a logical matching function based on the syntax tree, the generated syntax tree includes at least an identifier node representing an identifier, a value node for representing the value of the identifier, and an operation node for representing an operator. The identifier is used to represent the attributes of the transaction. The syntax tree is traversed and a logical matching function is generated based on the node information of the identifier node, the node information of the value node, and the node information of the operation node obtained by the traversal.

[0080] Step S130: Execute a logic matching function to obtain target transaction data that meets the transaction data condition from the block to be synchronized.

[0081] Exemplarily, the logical matching function can be matched with the transaction data in the block to be synchronized to obtain the target transaction data that meets the transaction data conditions in the block to be synchronized. The logical matching function can also be executed for each transaction data in the block to be synchronized to obtain the matching result between each transaction data in the block to be synchronized and the transaction data conditions. When the matching result indicates that the transaction data meets the transaction data conditions, the transaction data is determined as the target transaction data.

[0082] The block to be synchronized can be any block in the synchronization node, or it can be determined based on the block height of the blockchain on the target node and the block height of the blockchain on the synchronization node. Exemplarily, if the block height of the blockchain on the synchronization node is the target block height, then at least one block to be synchronized is determined based on the target block height and the block height of the blockchain on the target blockchain node, and the block height of the block to be synchronized is between the block height of the blockchain on the target blockchain node and the target block height.

[0083] In one possible implementation of the present application, the above-mentioned step S130 includes: for each transaction data in the block to be synchronized, executing a logical matching function to determine the matching result between the transaction data and the transaction data condition; if the matching result indicates that the transaction data meets the transaction data condition, determining the transaction data as the target transaction data.

[0084] The matching result is a successful match or a failed match. If the match is successful, it means that the transaction data meets the transaction data conditions. If the match fails, it means that the transaction data does not meet the transaction data conditions.

[0085] Step S140: Synchronize the target transaction data to the target blockchain node.

[0086] Among them, data synchronization between the synchronization node and the target blockchain node can rely on the blockchain system protocol. The blockchain system protocol is a set of protocols that stipulate the communication format and behavior specifications between nodes. Common blockchain system protocols include the Ethereum Protocol. By following the network protocol, data can be effectively synchronized between nodes to ensure the normal operation of the entire blockchain system.

[0087] When there are multiple blocks to be synchronized, the target transaction data includes the block number corresponding to each block to be synchronized and the transaction data corresponding to each block number. The synchronization node can synchronize the transaction data corresponding to each block number to the target blockchain node through the blockchain system protocol, or synchronize the transaction data corresponding to each block to be synchronized to the target blockchain node in the form of blocks. It can be set according to actual needs.

[0088] By adopting the above method of the present application, when it is necessary to synchronize data to the target blockchain node, it is only necessary to generate a logical matching function according to the rule string of the target blockchain node, so as to use the logical matching function to filter and screen the transaction data in the block to be synchronized in the synchronization node, and the rule string is pre-configured, and the pre-configured rule string is different for the target blockchain nodes of different roles or purposes, so that the synchronization node can provide different transaction data to the target blockchain node based on the rule string during the synchronization data process. In addition, when the transaction data conditions of the target blockchain node change, it is only necessary to adjust the rule string corresponding to the target blockchain node, so that when the logical matching function generated based on the adjusted rule string obtains the target transaction data from the block to be synchronized, the acquired transaction data meets the changed transaction data conditions, and the content of adjusting the rule string is less than that of adjusting the system code, so the adjustment efficiency is high and the possibility of errors is low. Therefore, by adopting the above method of the present application, the efficiency and security of data sharing in the blockchain system can be effectively improved.

[0089] Please combine Figure 4 As shown, Figure 4 The following is a data synchronization method based on blockchain provided by an embodiment of the present application. The method can be applied to synchronization nodes in a blockchain system. The method includes:

[0090] Step S210: If data synchronization with the target blockchain node is required, obtain a regular string corresponding to the node identifier of the target blockchain node.

[0091] The rule string is used to limit the transaction data conditions under which the target blockchain node has access rights.

[0092] For the specific description of step S210, please refer to the specific description of step S110 above, and no specific limitation is made here.

[0093] Step S220: Parse the regular string and generate a syntax tree corresponding to the regular string.

[0094] The syntax tree includes at least one of an identifier node representing an identifier, a value node representing a value of an identifier, an operation node representing an operator, and a function type node representing a built-in function. The identifier is used to represent a property of a transaction, and the built-in function includes an identifier and its corresponding value.

[0095] Among them, the identifier node and the value node are leaf nodes in the syntax tree, and the operation node is the upper node of the leaf node in the syntax tree.

[0096] The type of the syntax tree can be a binary tree or a multi-branch tree, as long as the regular string can be expressed in a tree structure, and no specific limitation is made here.

[0097] For example, if the rule string is (O=="org1"||O=="org2"||O=="org3")&&T=="admin1", if the syntax tree type is a binary tree, then the syntax tree corresponding to the rule string is as follows: Figure 5 As shown; if the type of syntax tree is a multi-branch tree, such as a ternary tree, the syntax tree corresponding to the rule string is as follows Figure 6 shown.

[0098] It should be noted that the aforementioned rule string includes a priority symbol. Since the connection relationship between the nodes of the syntax tree already implies the priority order, the nodes of the syntax tree do not include nodes of the priority symbol. In addition, if the rule string includes other types of symbols in addition to identifiers, nodes of identifiers, operators, and priority symbols, the generated syntax tree may also include nodes representing the corresponding symbols. Exemplarily, if the rule string also includes built-in functions, the syntax tree may also include nodes corresponding to the built-in functions.

[0099] Step S230: Traverse the syntax tree, and obtain node information of each node according to the traversal, and generate a logic matching function.

[0100] The syntax tree may be traversed by starting from the root node, performing a pre-order traversal, performing semantic analysis on the traversed syntax tree nodes in turn, and generating a logical matching function.

[0101] To improve the convenience of traversing the syntax tree and reduce the complexity of the generated logical matching function. In one possible implementation of the present application, the syntax tree is a binary tree, each parent node of the binary tree has two corresponding child nodes, the parent node of the syntax tree is an operation node, and the leaf node of the syntax tree is an identifier node or a value node. Figure 7 , step S230 specifically includes:

[0102] Step S231: start traversing from the root node and determine the currently traversed node as the target node.

[0103] Step S232: Determine, according to the target node, whether there is a target grammar subtree including the target node.

[0104] The target grammar subtree is formed by the target node and two child nodes connected to the target node as leaf nodes, or the target grammar subtree is formed by the target node as a function type node. The two leaf nodes connected to the target node do not include a function type node.

[0105] If it is determined according to the target node that there is a target grammar subtree including the target node, step S233 is executed: a logical matching function corresponding to the target grammar subtree is generated according to the node information of each node in the target grammar subtree.

[0106] If it is determined based on the target node that there is no target grammar subtree including the target node, at this time, it can be confirmed that the target node is connected to two nodes, and if the two child nodes connected to the target node are not leaf nodes, execute step S234: use the left child node and the right child node connected to the target node as new target nodes respectively, and return to step S232 until the logical matching functions corresponding to all target grammar subtrees under the left child node and the logical matching functions corresponding to all target grammar subtrees under the right child node are obtained; execute step S235: based on the operators represented by the upper nodes of each target grammar subtree, connect the logical matching functions corresponding to the multiple target grammar subtrees to obtain the logical matching functions corresponding to the grammar tree.

[0107] It should be noted that when a syntax tree is generated based on a rule string, different types of rule strings will generate different types of syntax trees, and different types of syntax trees will also have different node identifiers to distinguish them.

[0108] Take the definition of the logic matching function as: function MatchTx(tx*BlockTransaction)bool as an example, where the name of the logic matching function is function MatchTx, and the return value of the logic matching function is a Boolean value, which is 0 or 1. When the value is 1, it indicates that the return result is true (matching successful), and when the value is 0, it indicates that the return result is false (matching failed); BlockTransaction encapsulates the attributes of transaction information.

[0109] See also Figure 8 For example, if the rule string is: O==”org1”, it is a binary tree expression, and according to the grammar analysis, it will generate Figure 8 In the binary tree shown, node 1 is the root node, of type OP (operator), node 2 is the left leaf node, of type Ident (identifier), and node 3 is the right leaf node, of type BasicLit (identifier value). The logical matching function generated based on each node in the traversed syntax tree is func_node1:

[0110] function MatchTx(tx*BlockTransaction)bool{

[0111] return tx.Org=="org1";

[0112] The Boolean return value of the above logic matching function is true or false: BlockTransaction encapsulates the properties of the transaction information, including Org, where Org refers to O in the string, indicating the organization that initiated the transaction.

[0113] Please refer to Figure 9. For example, if the rule string is: containOf(O, "org_a"), it is a function expression, such as Fig. 9 As shown, it will be parsed as an independent node. The node information of this node includes function name, function parameters, parameter type and other information. Obviously, Fig. 9 The syntax tree in contains only one function node.

[0114] like Fig.10 As shown, if the rule string is O=="org1"||(O=="org2"&&T=="admin1"), the generated syntax tree is shown in 10, Fig.10 The numbers below each node in the syntax tree represent the node sequence number. Fig.10 When traversing the syntax tree in to generate a logical matching function, start from the root node 1 and traverse to the left child node 2 of the root node as the target node. Determine that the two child nodes connected to the target node 2 are both leaf nodes. Then first determine whether the identifier represented by the leaf node 4 conforms to the predefined identifier. After determining that the identifier of the leaf node 4 is O, then determine that the symbol represented by the symbol node 2 is the predefined supported symbol "==". Then generate the logical matching function func_node2 of the target syntax subtree corresponding to the node 2 as follows:

[0115] function MatchTx(tx*BlockTransaction)bool{

[0116] return tx.Org=="org1";

[0117] }

[0118] The "Org" in the function refers to the "O" in the string, which indicates the organization that initiated the transaction.

[0119] After that, the right child node 3 of the root node 1 is used as the new target node, where the two child nodes connected to node 3 are not leaf nodes, then the left child node 6 of node 3 is traversed as the new target node, and the two child nodes of the target node are leaf nodes. Therefore, first determine whether the identifier represented by the leaf node 8 conforms to the predefined identifier. After determining that the identifier of the leaf node 8 is O, then determine that the symbol represented by the symbol node 6 is the predefined supported symbol "==", then generate the logical matching function func_node6 of the target grammar subtree corresponding to node 6 as:

[0120] function MatchTx(tx*BlockTransaction)bool{

[0121] return tx.Org=="org2";

[0122] }

[0123] Then, when traversing to the right child node 7 of node 3, node 7 is used as the new target node, where both child nodes of the target node are leaf nodes. Therefore, it is first determined whether the identifier represented by leaf node 10 conforms to the predefined identifier. After determining that the identifier of leaf node 10 is T, it is determined that the symbol represented by symbol node 11 is the predefined supported symbol "==", and the logical matching function of the target grammar subtree corresponding to node 7 is generated as func_node7:

[0124] function MatchTx(tx*BlockTransaction)bool{

[0125] return tx.Sender=="admin1";

[0126] }

[0127] Among them, tx.Sender refers to T, which is used to represent the sender of transaction data.

[0128] At this point, the two child nodes connected to node 3 have been traversed. By connecting the functions generated by the corresponding target grammar subtrees through the symbol "&&" represented by node 3, the logical matching function func_node3 corresponding to node 3 is generated:

[0129] function MatchTx(tx*BlockTransaction)bool{

[0130] return func_node6(tx)&&func_node7(tx)

[0131] }

[0132] At this point, the right subtree traversal of the root node 1 is completed, and we return to node 1. We use the symbol represented by node 1 to connect the logical matching functions corresponding to its left and right child nodes to generate the function func_node1:

[0133] function MatchTx(tx*BlockTransaction)bool{

[0134] return func_node2(tx)||func_node3(tx)

[0135] }

[0136] At this point, the entire syntax tree is traversed, and the generated function func_node1 is the final logical function.

[0137] For example, Fig.11 As shown, if the rule string is O=="org1"||(O=="org2"&&containOf(I,"adminx")), the generated syntax tree is shown in 11. Fig.11 The numbers below each node in the syntax tree represent the node sequence number. Fig.11 When traversing the syntax tree in to generate a logical matching function, start from the root node 1 and traverse to the left child node 2 of the root node as the target node. Determine that the two child nodes connected to the target node 2 are both leaf nodes. Then first determine whether the identifier represented by the leaf node 4 conforms to the predefined identifier. After determining that the identifier of the leaf node 4 is O, then determine that the symbol represented by the symbol node 2 is the predefined supported symbol "==". Then generate the logical matching function func_node2 of the target syntax subtree corresponding to the node 2 as follows:

[0138] function MatchTx(tx*BlockTransaction)bool{

[0139] return tx.Org=="org1";

[0140] }

[0141] The Boolean return value of the above logic matching function is true or false: BlockTransaction encapsulates the properties of the transaction information, including Org, where Org refers to O in the string, indicating the organization that initiated the transaction.

[0142] Afterwards, the right child node 3 of the root node 1 is used as the new target node. Among the two child nodes connected by node 3, there is a function type node, and the left child node of node 3 is not a leaf node. Then, the left child node 6 of node 3 is traversed as the new target node. Both child nodes of the target node are leaf nodes. Therefore, firstly, it is determined whether the identifier represented by the leaf node 8 conforms to the predefined identifier. After determining that the identifier of the leaf node 8 is O, it is determined that the symbol represented by the symbol node 6 is the predefined supported symbol "==". Then, the logical matching function func_node6 of the target grammar subtree corresponding to the generated node 6 is:

[0143] function MatchTx(tx*BlockTransaction)bool{

[0144] return tx.Org=="org2";

[0145] }

[0146] After that, when the current traversal reaches the right child node 7 of node 3, node 7 is used as the new target node. There is no leaf node in the target node, and node 7 is a function type node. At this time, it is determined whether the function name represented by the function node is predetermined to be supported. Since contianOf is predetermined to be compatible, then check whether the function parameters meet the definition. The logical matching function corresponding to this node 7 is: function containOf(lable string,matchStr string)bool

[0147] This contains two string parameters. The first parameter lable represents the matching identifier, and the second parameter matchStr is the value that matches the identifier. When both the identifier and the value that matches the identifier are verified, a logical matching function, func_node7, is generated to generate the target grammar subtree corresponding to node 7:

[0148] function MatchTx(tx*BlockTransaction)bool{

[0149] return strings.Contians(tx.Sender,"adminx") / / Judge whether the first string contains the second string.

[0150] At this point, the two child nodes connected to node 3 have been traversed. By connecting the functions generated by the corresponding target grammar subtrees through the symbol "&&" represented by node 3, the logical matching function func_node3 corresponding to node 3 is generated:

[0151] function MatchTx(tx*BlockTransaction)bool{

[0152] return func_node6(tx)&&func_node7(tx)

[0153] }

[0154] At this point, the right subtree traversal of the root node 1 is completed, and we return to node 1. We use the symbol represented by node 1 to connect the logical matching functions corresponding to its left and right child nodes to generate the function func_node1:

[0155] function MatchTx(tx*BlockTransaction)bool{

[0156] return func_node2(tx)||func_node3(tx)

[0157] }

[0158] At this point, the entire syntax tree is traversed, and the generated function func_node1 is the final logical function.

[0159] Step S240: Execute a logic matching function to obtain target transaction data that meets the transaction data condition from the block to be synchronized.

[0160] Step S250: Synchronize the target transaction data to the target blockchain node.

[0161] For the detailed description of the above steps S240-S250, please refer to the detailed description of steps S130-S140 above, which will not be further limited here.

[0162] The present application provides a synchronization method based on blockchain. When data synchronization is required to the target blockchain node, it is only necessary to generate a syntax tree according to the rule string of the target blockchain node, and generate a logic matching function based on the syntax tree, which ensures the convenience and accuracy of the obtained logic matching function. So that the logic matching function can be used to filter and screen the transaction data in the block to be synchronized in the synchronization node in the future, and the rule string is pre-configured, and the pre-configured rule string is different for the target blockchain node with different roles or purposes, so that the synchronization node can provide different transaction data to the target blockchain node based on the rule string during the synchronization data process. In addition, when the transaction data condition of the target blockchain node changes, it is only necessary to adjust the rule string corresponding to the target blockchain node, so that when the logic matching function generated based on the adjusted rule string obtains the target transaction data from the block to be synchronized, the acquired transaction data meets the changed transaction data condition, and the adjustment of the rule string is less adjusted than adjusting the system code, the adjustment efficiency is high, and the possibility of errors is low. Thus, while meeting the requirements of the variable access rights of the target blockchain node, the stability of the target blockchain node access data is guaranteed.

[0163] See also Fig.12 As shown, the embodiment of the present application provides a data synchronization method based on blockchain, which can be applied to synchronization nodes in a blockchain system. The method includes:

[0164] Get the rule string corresponding to the node ID of the target blockchain node. The rule string is used to limit the transaction data conditions that the target blockchain node has access rights to. After that, parse the rule string to determine whether the parsing is successful. If the parsing fails, it means that the rule string definition is wrong, and the process ends and returns an exception prompt.

[0165] If the parsing is successful, a syntax tree corresponding to the rule string is generated, wherein the syntax tree is a binary tree. Afterwards, the syntax tree is traversed, and the node information of each node is obtained according to the traversal, and a logical matching function is generated.

[0166] Specifically, the root node of the syntax tree can be obtained first. If the root node is empty, it indicates that the target blockchain node has access rights to all data in the synchronization node (full node).

[0167] If the root node is not empty, the root node is used as the target node to determine whether the target node constitutes the target grammar subtree.

[0168] Among them, the method for determining whether the target node constitutes a grammar subtree can be to determine whether the target node is an operation node. If so, determine whether the two child nodes connected to the target node include a value node or an identifier node. If it is determined whether the target node is an operation node and whether the two child nodes connected to the target node include a direct point or an identifier node, it can be determined whether the operator in the operation node is a predefined operator and whether the identifier in the identifier node is a predefined identifier. If so, generate a logical matching function corresponding to the grammar subtree according to the operator in the operation node, the identifier in the identifier node, and the value in the value node. The method for determining whether the target node constitutes a grammar subtree can also be to determine whether the target node is a function type node. If so, determine whether the built-in function in the function type node is a predefined built-in function. If so, determine whether the identifier in the built-in function is a predefined identifier. If so, determine whether the value corresponding to the identifier is valid. If valid, generate the target grammar subtree according to the built-in function in the target node.

[0169] If the target node does not constitute the target grammar subtree, traverse the left child node of the target node to determine whether the left child node is empty. If it is not empty, use the left child node as the new target node, and return to execute to confirm whether the target node constitutes the target grammar subtree until the logical matching functions corresponding to all target grammar subtrees under the left child node are obtained.

[0170] After completing the traversal of the left child node of the root node, traverse the right child node of the root node to determine whether the right child node is empty. If it is not empty, the right child node is used as the new target node, and return to the step of confirming whether the target node constitutes the target grammar subtree until the logical matching functions corresponding to all target grammar subtrees under the right child node are obtained.

[0171] After obtaining the logical matching functions corresponding to all target grammar subtrees under the left child node and the logical matching functions corresponding to all target grammar subtrees under the right child node, the logical matching functions corresponding to multiple target grammar subtrees are connected based on the operators represented by the upper nodes of each target grammar subtree to obtain the logical matching functions corresponding to the grammar tree.

[0172] Afterwards, the logic matching function is executed to obtain the target transaction data that meets the transaction data conditions from the block to be synchronized, and synchronize the target transaction data to the target blockchain node.

[0173] See also Fig.13 The present application provides a blockchain-based data synchronization device 300, which can be applied to the synchronization node in the blockchain system. The device 300 includes: a string acquisition module 310, which is used to obtain a rule string corresponding to the node identifier of the target blockchain node when data synchronization is required to the target blockchain node; the rule string is used to limit the transaction data conditions that the target blockchain node has access rights; a function generation module 320, which is used to generate a logic matching function based on the rule string; a function execution module 330, which is used to execute the logic matching function to obtain target transaction data that meets the transaction data conditions from the block to be synchronized; a data synchronization module 340, which is used to synchronize the target transaction data to the target blockchain node.

[0174] In one possible implementation, the function generation module 330 includes a parsing module and a function generation submodule. The parsing module is used to parse the rule string and generate a syntax tree corresponding to the rule string, wherein the syntax tree includes at least one of an identifier node representing an identifier, a value node representing the value of the identifier, an operation node representing an operator, and a function type node representing a built-in function, wherein the identifier is used to represent the attribute of the transaction, and the built-in function includes the identifier and its corresponding value; the function generation submodule is used to traverse the syntax tree and generate a logic matching function based on the node information of each node obtained through the traversal.

[0175] In one possible implementation, the syntax tree is a binary tree, each parent node of the binary tree has two corresponding child nodes connected to it, the parent node of the syntax tree is an operation node, and the leaf nodes of the syntax tree are identifier nodes, value nodes or function type nodes; the function generation submodule is also used to traverse from the root node to determine the currently traversed node as the target node; if it is determined according to the target node that there is a target syntax subtree including the target node, a logical matching function corresponding to the target syntax subtree is generated according to the node information of each node in the target syntax subtree; wherein the target syntax subtree is formed by the target node and two child nodes connected to the target node as leaf nodes, or the target syntax subtree is formed by the target node as a function type node.

[0176] In one possible implementation, the function generation submodule is also used to, when both child nodes connected to the target node are not leaf nodes, use the left child node and the right child node connected to the target node as new target nodes respectively, until the logical matching functions corresponding to all target grammar subtrees under the left child node and the logical matching functions corresponding to all target grammar subtrees under the right child node are obtained; based on the operators represented by the upper nodes of each target grammar subtree, the logical matching functions corresponding to multiple target grammar subtrees are connected to obtain the logical matching functions corresponding to the grammar trees.

[0177] In one possible implementation, the device 300 also includes a data receiving module and a storage module. The data receiving module is used to receive data broadcast by the target blockchain node when joining the blockchain system where the synchronization node is located, and the data includes the node identifier and rule string of the target blockchain node; the storage module is used to associate and store the node identifier of the target blockchain node with the rule string.

[0178] In one possible implementation, the function execution module 340 is also used to execute a logic matching function for each transaction data in the block to be synchronized to determine the matching result between the transaction data and the transaction data condition; if the matching result indicates that the transaction data meets the transaction data condition, the transaction data is determined as the target transaction data.

[0179] In one possible implementation, the device 300 also includes a block determination module, which is used to determine at least one block to be synchronized based on the target block height and the block height of the blockchain on the target blockchain node, and the block height of the block to be synchronized is between the block height of the blockchain on the target blockchain node and the target block height.

[0180] In one possible implementation, the synchronization node is a full node, and the full node has access rights to all transaction data.

[0181] It should be noted that the device embodiment in the present application corresponds to the aforementioned method embodiment. The specific principles in the device embodiment can be found in the contents of the aforementioned method embodiment and will not be repeated here.

[0182] The following will be combined Fig.14 An electronic device provided by the present application is described.

[0183] See also Fig.14 Based on the blockchain data synchronization method provided in the above embodiment, the embodiment of the present application also provides another electronic device 100 including a processor 102 that can execute the above method. The electronic device 100 can be a server or a terminal device, and the terminal device can be a smart phone, a tablet computer, a computer or a portable computer. The electronic device 100 can serve as the above synchronization node.

[0184] The electronic device 100 further includes a memory 104 . The memory 104 stores a program that can execute the contents of the aforementioned embodiments, and the processor 102 can execute the program stored in the memory 104 .

[0185] Among them, the processor 102 may include one or more cores for processing data and a message matrix unit. The processor 102 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 104, and calling data stored in the memory 104. Optionally, the processor 102 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 102 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 102, but may be implemented separately through a communication chip.

[0186] The memory 104 may include a random access memory (RAM) or a read-only memory (ROM). The memory 104 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 104 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function, instructions for implementing the following various method embodiments, etc. The data storage area may also store data obtained by the electronic device 100 during use (e.g., the node identification and rule string of the target blockchain node), etc.

[0187] The electronic device 100 may also include a network module and a screen, wherein the network module is used to receive and send electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, and thus communicate with a communication network or other devices, such as communicating with an audio playback device. The network module may include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, user identity modules (SIM) cards, memories, and the like. The network module may communicate with various networks such as the Internet, corporate intranets, wireless networks, or communicate with other devices via wireless networks. The above-mentioned wireless networks may include cellular telephone networks, wireless local area networks, or metropolitan area networks. The screen may display interface content and perform data interaction, such as displaying the molecular property prediction results of the audio to be identified, and recording audio through the screen.

[0188] In some embodiments, the electronic device 100 may further include: a peripheral interface 106 and at least one peripheral device. The processor 102, the memory 104 and the peripheral interface 106 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral interface via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: a radio frequency component 108, etc.

[0189] The peripheral interface 106 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 102 and the memory 104. In some embodiments, the processor 102, the memory 104, and the peripheral interface 106 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 102, the memory 104, and the peripheral interface 106 may be implemented on a separate chip or circuit board, which is not limited in the embodiments of the present application.

[0190] The radio frequency component 108 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency component 108 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency component 108 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency component 108 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The radio frequency component 108 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes, but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency component 108 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.

[0191] The embodiment of the present application also provides a structural block diagram of a computer-readable storage medium. The computer-readable medium stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0192] The computer-readable storage medium may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium has storage space for program codes that execute any of the method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code can be compressed, for example, in an appropriate form.

[0193] The embodiment of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device performs the method described in the above various optional implementations.

[0194] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A data synchronization method based on blockchain, characterized in that: Applied to a synchronization node in a blockchain system, the method comprises: If data synchronization is required to the target blockchain node, a rule string corresponding to the node identifier of the target blockchain node is obtained; the rule string is used to limit the transaction data conditions for which the target blockchain node has access rights; Generate a logic matching function based on the rule string; Executing the logic matching function to obtain target transaction data that meets the transaction data condition from the block to be synchronized; Synchronize the target transaction data to the target blockchain node.

2. The method according to claim 1, characterized in that The generating a logic matching function based on the rule string comprises: Parsing the rule string to generate a syntax tree corresponding to the rule string, the syntax tree including at least one of an identifier node representing an identifier, a value node representing a value of the identifier, an operation node representing an operator, and a function type node representing a built-in function, the identifier being used to represent an attribute of a transaction, and the built-in function including an identifier and its corresponding value; The syntax tree is traversed, and node information of each node is obtained according to the traversal, and a logic matching function is generated.

3. The method according to claim 2, characterized in that The syntax tree is a binary tree, each parent node of the binary tree has two correspondingly connected child nodes, the parent node of the syntax tree is a calculation node, and the leaf nodes of the syntax tree are identifier nodes, value nodes or function type nodes; The traversing of the syntax tree and obtaining node information of each node according to the traversal to generate a logic matching function includes: Start traversing from the root node and determine the currently traversed node as the target node; If it is determined based on the target node that there is a target grammar subtree including the target node, a logical matching function corresponding to the target grammar subtree is generated based on the node information of each node in the target grammar subtree; wherein the target grammar subtree is formed by the target node and two child nodes connected to the target node as leaf nodes, or the target grammar subtree is formed by the target node as a function type node.

4. The method according to claim 3, characterized in that The traversing of the syntax tree and generating a logic matching function corresponding to the syntax tree according to the semantic identifier representing the transaction data obtained through the traversal also include: If both child nodes connected to the target node are not leaf nodes, the left child node and the right child node connected to the target node are respectively used as new target nodes, and the execution is returned. If it is determined according to the target node that there is a target grammar subtree including the target node, the logical matching function corresponding to the target grammar subtree is generated according to the node information of each node in the target grammar subtree, until the logical matching functions corresponding to all target grammar subtrees under the left child node and the logical matching functions corresponding to all target grammar subtrees under the right child node are obtained; Based on the operators represented by the upper nodes of the target grammar subtrees, the logical matching functions corresponding to the multiple target grammar subtrees are connected to obtain the logical matching functions corresponding to the grammar trees.

5. The method according to claim 1, characterized in that If data synchronization is required to the target blockchain node, before obtaining the rule string corresponding to the node identifier of the target blockchain node, the method further includes: Receive data broadcasted by the target blockchain node when joining the blockchain system where the synchronization node is located, the data including the node identifier of the target blockchain node and the rule string; The node identifier of the target blockchain node is associated with the rule string and stored.

6. The method according to claim 1, characterized in that The executing the logic matching function to obtain target transaction data satisfying the transaction data condition from the block to be synchronized includes: For each transaction data in the block to be synchronized, executing the logic matching function to determine a matching result between the transaction data and the transaction data condition; If the matching result indicates that the transaction data meets the transaction data condition, the transaction data is determined as the target transaction data.

7. The method according to claim 6, characterized in that Before executing the logic matching function to obtain target transaction data satisfying the transaction data condition from the block to be synchronized, the method further includes: According to the target block height and the block height of the blockchain on the target blockchain node, at least one block to be synchronized is determined, and the block height of the block to be synchronized is between the block height of the blockchain on the target blockchain node and the target block height.

8. The method according to claim 1, characterized in that The synchronization node is a full node, and the full node has access rights to all transaction data.

9. A data synchronization device based on blockchain, characterized in that: Applied to a synchronization node in a blockchain system, the device comprises: A string acquisition module, used to acquire a rule string corresponding to the node identifier of the target blockchain node when data synchronization with the target blockchain node is required; the rule string is used to limit the transaction data conditions for which the target blockchain node has access rights; A function generation module, used for generating a logic matching function based on the rule string; A function execution module, used for executing the logic matching function to obtain target transaction data satisfying the transaction data condition from the block to be synchronized; A data synchronization module is used to synchronize the target transaction data to the target blockchain node.

10. An electronic device, characterized in that: include: one or more processors; Memory; One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, and the program codes can be called by a processor to execute the method according to any one of claims 1 to 8.

12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method described in any one of claims 1 to 8 are implemented.