Data query method, master node and slave node
By introducing master nodes and slave nodes into the alliance chain system, and using the load balancing principle to allocate query tasks to multiple slave nodes, the problem of low efficiency in transaction data query on the blockchain is solved and more efficient query processing is achieved.
Patent Information
- Application Number
- CN202110284951.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-17
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2041-03-17
AI Technical Summary
In the prior art, the query efficiency of transaction data on blockchain is relatively low.
By introducing master nodes and slave nodes in the consortium chain system, the query task is assigned to multiple slave nodes using the load balancing principle, so that multiple slave nodes can process query tasks in parallel. The master node receives a query request, obtains the slave node that can perform block queries, and allocates the block to be queried according to the load balancing principle, sends a query processing message to the slave node, and after receiving the message, the slave node obtains the target block based on the data to be queried and the block identification information.
It improves the query efficiency of transaction data on the blockchain, and reduces query time by processing query tasks in parallel.
Smart Images

Figure CN115114009B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data query, and in particular relates to a data query method, a master node and a slave node. Background Art
[0002] Blockchain technology is a shared distributed database technology, and its advantages are mainly reflected in distributed decentralization, no need for trust system, non-tamperability and encryption security. As a technology that maintains a complete, distributed, and non-tamperable ledger database, it uses a decentralized consensus mechanism to allow participants in the blockchain to achieve a unified ledger system without establishing a trust relationship. However, as the amount of data on the chain increases, it becomes increasingly difficult to query transaction data on the chain.
[0003] In the process of implementing this application, the inventors found that there are at least the following problems in the prior art:
[0004] Although the prior art also provides a method for querying transaction data on the blockchain, the data query method provided in the prior art has the problem of low query efficiency. Summary of the invention
[0005] The embodiments of the present application provide a data query method, a master node, and a slave node, which can solve the problem of low query efficiency in the data query method on the blockchain provided in the prior art.
[0006] In order to solve the above technical problems, an embodiment of the present invention provides a data query method, which is applied to a consortium chain system including a master node and a slave node, comprising:
[0007] When receiving the query request, the master node obtains at least one slave node capable of performing block query;
[0008] According to the load balancing principle, allocating a block to be queried to each of the at least one slave node;
[0009] According to the block to be queried, a query processing message is sent to the at least one slave node, wherein the query processing message includes: identification information of the block to be queried and identification information of the slave node;
[0010] At least one slave node receives the query processing message sent by the master node respectively;
[0011] According to the data to be queried and the identification information of the block to be queried, a target block containing the data to be queried is acquired.
[0012] The embodiment of the present invention further provides a data query method, which is applied to a master node and includes:
[0013] Upon receiving the query request, obtaining at least one slave node capable of performing block query;
[0014] According to the load balancing principle, allocating a block to be queried to each of the at least one slave node;
[0015] According to the block to be queried, a query processing message is sent to the at least one slave node, so that each slave node searches for a target block containing the data to be queried in the query request in the corresponding block to be queried;
[0016] The query processing message includes: identification information of the block to be queried and identification information of the slave node.
[0017] Optionally, obtaining at least one slave node capable of performing block query includes:
[0018] Receive resource usage status sent by each slave node;
[0019] Acquire at least one slave node whose resource usage status meets a preset condition;
[0020] Each of the at least one slave node is capable of performing block query.
[0021] The resource usage status includes at least one of the following: CPU utilization, bandwidth resource utilization, memory resource utilization, and input / output resource utilization.
[0022] Among them, the preset conditions include at least one of the following: CPU utilization is less than or equal to a first preset value, memory resource utilization is less than or equal to a second preset value, bandwidth resource utilization is less than or equal to a third preset value, and input / output resource utilization is less than or equal to a fourth preset value.
[0023] Optionally, the sending the query processing message to the at least one slave node includes:
[0024] A query processing message is broadcast to the at least one slave node.
[0025] The identification information of the block to be queried includes: the block number of the block to be queried and / or the block hash value of the block to be queried.
[0026] The embodiment of the present invention further provides a data query method, which is applied to a slave node and includes:
[0027] Receive a query processing message sent by the master node, wherein the query processing message includes: identification information of the block to be queried and identification information of the slave node;
[0028] According to the data to be queried and the identification information of the block to be queried, obtaining a target block containing the data to be queried;
[0029] The query processing message is generated by the master node according to the load balancing principle for the block to be queried allocated to each slave node of at least one slave node capable of performing block query.
[0030] Optionally, obtaining the target block containing the data to be queried includes:
[0031] Acquire a candidate block according to the data to be queried and the identification information of the block to be queried;
[0032] The candidate blocks are traversed to obtain the target block containing the data to be queried.
[0033] Optionally, acquiring the candidate block according to the to-be-queried data and the identification information of the to-be-queried block includes:
[0034] By using the Bloom filter, candidate blocks containing the data to be queried are obtained from the blocks to be queried.
[0035] Optionally, the using a Bloom filter to obtain a candidate block containing the data to be queried in the block to be queried includes:
[0036] Using K hash functions, obtain K hash values of the data index of the data to be queried;
[0037] Compare the K hash values with the bits of the Bloom filter corresponding to each block in the block to be queried;
[0038] If the comparison result indicates that the values of the K hash values at the corresponding positions of the Bloom filter of a block are all 1, then the block is determined to be a candidate block;
[0039] Wherein, K is an integer greater than or equal to 1.
[0040] Optionally, before using the Bloom filter to obtain a candidate block containing the data to be queried in the block to be queried, the method further includes:
[0041] For each block on the blockchain, hash calculation is performed on the data index of each data item in the block according to K hash functions to obtain the hash value;
[0042] Mapping the hash value to obtain a Bloom filter with a data length of M;
[0043] The initial value of the bit in the Bloom filter is 0, and when a mapping value exists on a bit, the value of the bit is set from 0 to 1;
[0044] K and M are both integers greater than or equal to 1.
[0045] Optionally, after acquiring the target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried, the method further includes:
[0046] Verifying the target block;
[0047] After the target block is verified, the target block is broadcasted.
[0048] Optionally, the verifying the target block includes:
[0049] Obtaining the Merkle root hash value corresponding to the target block;
[0050] Obtaining the Merkle root verification path corresponding to the data to be queried in the target block;
[0051] Obtaining the Merkle root hash value corresponding to the data to be queried according to the hash value corresponding to the data to be queried and the Merkle root verification path;
[0052] Determine whether the Merkle root hash value corresponding to the data to be queried is equal to the Merkle root hash value corresponding to the target block;
[0053] If the hash value of the Merkle root of the data to be queried is equal to the hash value of the Merkle root of the target block, the target block is verified.
[0054] Optionally, before receiving the query processing message sent by the master node, the method further includes:
[0055] Send resource usage status to the master node.
[0056] The resource usage status includes at least one of the following: CPU utilization, bandwidth resource utilization, memory resource utilization, and input / output resource utilization.
[0057] The embodiment of the present invention further provides a master node, including:
[0058] A first acquisition module, configured to acquire at least one slave node capable of performing block query when a query request is received;
[0059] An allocation module, configured to allocate a block to be queried to each of the at least one slave node according to a load balancing principle;
[0060] A first sending module, configured to send a query processing message to the at least one slave node according to the block to be queried, so that each slave node searches for a target block containing the data to be queried in the query request in the corresponding block to be queried;
[0061] The query processing message includes: identification information of the block to be queried and identification information of the slave node.
[0062] Optionally, the first acquisition module includes:
[0063] A receiving unit, used for receiving the resource usage status sent by each slave node;
[0064] A first acquisition unit, used to acquire at least one slave node whose resource usage status meets a preset condition;
[0065] Each of the at least one slave node is capable of performing block query.
[0066] An embodiment of the present invention further provides a master node, comprising a transceiver and a processor;
[0067] The processor is configured to: upon receiving a query request, obtain at least one slave node capable of performing block query, and allocate a block to be queried to each of the at least one slave node according to a load balancing principle;
[0068] The transceiver is used to: send a query processing message to the at least one slave node according to the block to be queried, so that each slave node searches for a target block containing the data to be queried in the query request in the corresponding block to be queried;
[0069] The query processing message includes: identification information of the block to be queried and identification information of the slave node.
[0070] An embodiment of the present invention further provides a master node, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned data query method when executing the program.
[0071] An embodiment of the present invention further provides a slave node, including:
[0072] A receiving module, configured to receive a query processing message sent by a master node, wherein the query processing message includes: identification information of a block to be queried and identification information of a slave node;
[0073] A second acquisition module, configured to acquire a target block containing the data to be queried according to the data to be queried and identification information of the block to be queried;
[0074] The query processing message is generated by the master node according to the load balancing principle for the block to be queried allocated to each slave node of at least one slave node capable of performing block query.
[0075] Optionally, after the second acquisition module acquires the target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried, the method further includes:
[0076] A verification module, used for verifying the target block;
[0077] The broadcast module is used to broadcast the target block after the target block is verified.
[0078] Optionally, before the receiving module receives the query processing message sent by the master node, it also includes:
[0079] Send resource usage status to the master node.
[0080] An embodiment of the present invention further provides a slave node, comprising a transceiver and a processor;
[0081] The transceiver is used to: receive a query processing message sent by a master node, wherein the query processing message includes: identification information of a block to be queried and identification information of a slave node;
[0082] The processor is used to: acquire a target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried;
[0083] The query processing message is generated by the master node according to the load balancing principle for the block to be queried allocated to each slave node of at least one slave node capable of performing block query.
[0084] An embodiment of the present invention further provides a slave node, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned data query method when executing the program.
[0085] An embodiment of the present invention further provides a readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in the above-mentioned data query method are implemented.
[0086] The beneficial effects of the present invention are:
[0087] The above scheme distributes the query tasks to multiple slave nodes by utilizing the load balancing principle, so that the multiple slave nodes process the query tasks in parallel, thereby improving the query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0088] Figure 1It is a flowchart of a data query method applied to a master node side according to an embodiment of the present application;
[0089] Figure 2 is a flow chart of a data query method applied to a slave node side according to an embodiment of the present application;
[0090] Figure 3 This is a flowchart for filtering the candidate block list based on the Bloom filter;
[0091] Figure 4 It is a flowchart for querying the block where the exchange is located;
[0092] Figure 5 This is a diagram of the Merkle tree;
[0093] Figure 6 This is a schematic diagram of the alliance chain ledger;
[0094] Figure 7 It is an architectural diagram for implementing an embodiment of the present application;
[0095] Figure 8 It is a module schematic diagram of the master node of an embodiment of the present application;
[0096] Fig. 9 is a module schematic diagram of a slave node in an embodiment of the present application;
[0097] Fig.10 It is a flow chart of a data query method applied to a consortium chain system according to an embodiment of the present application. DETAILED DESCRIPTION
[0098] 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 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.
[0099] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0100] The data query method, master node and slave node provided in the embodiment of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0101] like Figure 1 As shown, an embodiment of the present application provides a data query method, which is applied to a master node, including:
[0102] Step 11, upon receiving a query request, obtaining at least one slave node capable of performing a block query;
[0103] Step 12, allocating a block to be queried to each of the at least one slave node according to the load balancing principle;
[0104] Step 13, according to the block to be queried, sending a query processing message to the at least one slave node, so that each slave node searches for a target block containing the data to be queried in the query request in the corresponding block to be queried;
[0105] Different slave nodes are allocated different blocks to be queried, and the query processing message includes: identification information of the block to be queried and identification information of the slave node.
[0106] It should be noted that the data to be queried and the transactions to be queried mentioned in the embodiment of the present invention and subsequent embodiments have the same meaning, and the data or transactions refer to information items stored in the blockchain.
[0107] It should be noted that the data query method mentioned in the embodiment of the present application is applied to the master node and slave nodes in the alliance chain. Before implementing the data query method in the embodiment of the present application, it is necessary to first use the consensus algorithm to elect a master node and multiple slave nodes in the alliance chain. The master node is responsible for allocating query processing tasks, and multiple slave nodes execute query processing tasks in parallel, thereby improving query efficiency.
[0108] Furthermore, the specific implementation of step 11 of the embodiment of the present application is as follows:
[0109] Receive resource usage status sent by each slave node;
[0110] Acquire at least one slave node whose resource usage status meets a preset condition;
[0111] Each of the at least one slave node is capable of performing block query.
[0112] That is to say, in order to ensure that the master node can accurately issue query processing tasks, the slave node should regularly feedback its own resource usage status to the slave node. Specifically, the resource usage status includes but is not limited to at least one of the following: CPU utilization, bandwidth resource utilization, memory resource utilization, and input and output resource utilization.
[0113] After receiving the resource usage status sent by the slave node, the master node determines whether the resource usage status meets a preset condition (i.e., determines whether the resource utilization rate meets a threshold). Specifically, the preset condition includes but is not limited to at least one of the following:
[0114] A11, CPU utilization is less than or equal to a first preset value;
[0115] For example, the CPU utilization is less than or equal to 50%.
[0116] It should also be noted here that CPU utilization mainly refers to the utilization in user state (user), system state (sys), wait state (wait), and idle state (idle). In specific settings, the CPU utilization in user state should be lower than the industry warning value range, that is, less than or equal to 75%; the CPU utilization in system state should be less than or equal to 30%; the CPU utilization in wait state should be less than or equal to 5%.
[0117] A12, memory resource utilization is less than or equal to a second preset value;
[0118] It should be noted here that the main measure of whether the system memory has a bottleneck is the SWAP (exchange with virtual memory) swap space utilization. In other words, the memory resource utilization refers to the SWAP swap space utilization. Too much swapping will cause poor system performance. Usually, the SWAP swap space utilization should be less than or equal to 70%.
[0119] A13, bandwidth resource utilization is less than or equal to a third preset value;
[0120] It should be noted that bandwidth resources refer to network throughput, which refers to how many megabytes of traffic flow in and out per second. Generally, it cannot exceed 70% of the maximum transmission capacity of the device or link. In other words, the bandwidth resource utilization should be less than or equal to 70% of the maximum transmission capacity of the device or link (i.e., maximum throughput).
[0121] A14, the input and output resource utilization rate is less than or equal to the fourth preset value;
[0122] It should be noted that input and output resources refer to how many megabytes the disk reads and writes per second, mainly including disk busy rate, number of disk queues, average service time, average waiting time, space utilization, etc. The disk busy rate is an important basis for directly reflecting whether the disk has a bottleneck. Under normal circumstances, the disk busy rate should be lower than 70%, that is, the input and output resource utilization should be less than or equal to 70%.
[0123] It should be noted that after the master node selects at least one slave node that can perform block query, query processing tasks are allocated to each slave node that meets the needs, that is, blocks to be queried are allocated to each slave node. When allocating, the slave node load balancing principle is mainly adopted, that is, after the allocation, it is necessary to ensure that the load of each slave node is in a balanced state. For example, there are a total of 100 blocks that need to be queried in the alliance chain. After the slave node query, 6 slave nodes that can execute the query task are found. If the CPU utilization of these 6 slave nodes is equal, the 100 blocks are evenly distributed to these 6 slave nodes. The blocks queried on each slave node are different from the blocks of other slave nodes. If the CPU utilization of these 6 slave nodes is not equal, when allocating 100 blocks, fewer blocks are allocated to the slave nodes with higher CPU utilization, and more blocks are allocated to the slave nodes with lower CPU utilization, so as to achieve load balancing of the slave nodes.
[0124] After the master node assigns the blocks to be queried to each slave node, the master node usually uses a broadcast method to send a query processing message to the at least one slave node. In order to facilitate the slave node to know which blocks need to be processed, the query processing message carries the identification information of the block to be queried and the identification information of the slave node. Usually, the identification information of the slave node corresponds to the identification information of the block to be queried. When a node parses the query processing message to carry its own identification information, it can find the identification information of the block to be queried based on the identification information. Specifically, the identification information of the block to be queried includes: the block number of the block to be queried and / or the block hash value of the block to be queried.
[0125] It should also be noted that the above description is a method for allocating query processing tasks. When the embodiment of the present invention is implemented specifically, the slave node can also allocate query processing tasks to each slave node that can perform block query one by one. Specifically, after the master node obtains at least one slave node that can perform block query, according to the total amount of blocks that need to be queried, starting from the first block, one block is allocated to each slave node that can perform block query for query in turn. Then the master node monitors the resource usage status of the slave node in real time, and re-acquires the slave node that can perform block query according to the monitoring results. Then, the block is allocated in the remaining unallocated blocks in turn, and so on, until all blocks of the master node are allocated to the slave nodes.
[0126] In this case, after the master node allocates the block to be queried to the slave node, the master node usually uses a broadcast method to send the query processing message to the slave node. When the master node broadcasts, it can allocate a block and then broadcast in sequence, or it can broadcast once after a round of allocation is completed; the query processing message carries the identification information of the block to be queried and the identification information of the slave node. Usually, the identification information of the slave node corresponds to the identification information of the block to be queried. When a node parses the query processing message to carry its own identification information, it can find the identification information of the block to be queried based on the identification information. Specifically, the identification information of the block to be queried includes: the block number of the block to be queried and / or the block hash value of the block to be queried.
[0127] In the embodiment of the present application, query tasks are distributed to multiple slave nodes by utilizing the load balancing principle, so that the multiple slave nodes process the query tasks in parallel, thereby improving query efficiency.
[0128] like Figure 2 As shown, an embodiment of the present invention further provides a data query method, which is applied to a slave node, comprising:
[0129] Step 21, receiving a query processing message sent by the master node, wherein the query processing message includes: identification information of the block to be queried and identification information of the slave node;
[0130] Step 22, acquiring a target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried;
[0131] The query processing message is generated by the master node according to the load balancing principle for the block to be queried allocated to each slave node of at least one slave node capable of performing block query.
[0132] Specifically, when the slave node performs a query, that is, implements step 22, the main processing process is:
[0133] Acquire a candidate block according to the data to be queried and the identification information of the block to be queried;
[0134] The candidate blocks are traversed to obtain the target block containing the data to be queried.
[0135] It should be noted that this implementation method is to first perform a coarse screening of blocks, that is, first find the candidate blocks that may contain the data to be queried, and obtain a candidate block list based on the candidate blocks, the candidate block list contains the block numbers of the candidate blocks, and then perform a fine screening of the blocks, that is, find the blocks that must contain the data to be queried in the candidate block list. In this way, it is possible to avoid directly traversing the blocks, which causes a large resource overhead, thereby reducing resource overhead and improving query efficiency.
[0136] It should be further explained that the process of obtaining candidate blocks is as follows:
[0137] By using the Bloom filter, candidate blocks containing the data to be queried are obtained from the blocks to be queried.
[0138] That is, or, here the screening of candidate blocks is mainly performed according to the Bloom filter, that is, each block corresponds to a Bloom filter. Specifically, the Bloom filter is set as follows: for each block on the blockchain, the data index of each data item in the block is hashed according to K hash functions to obtain a hash value; the hash value is mapped to obtain a Bloom filter with a data length of M;
[0139] The initial value of the bit in the Bloom filter is 0, and when a mapping value exists on a bit, the value of the bit is set from 0 to 1;
[0140] Specifically, K and M are both integers greater than or equal to 1.
[0141] Specifically, the specific method of using Bloom filter to obtain candidate blocks is:
[0142] Using K hash functions, obtain K hash values of the data index of the data to be queried;
[0143] Compare the K hash values with the bits of the Bloom filter corresponding to each block in the block to be queried;
[0144] If the comparison result indicates that the values of the K hash values at the corresponding positions of the Bloom filter of a block are all 1, the block is determined to be a candidate block.
[0145] Usually, after obtaining candidate blocks from the node, these candidate blocks will be stored in the form of a candidate block list for subsequent use.
[0146] That is to say, each slave node uses K hash functions to calculate the hash value of the transaction index (i.e., transaction ID) of the transaction to be queried, and compares the calculated K hash values with the bits of the Bloom filter set in each block. If the calculated K hash values are all 1 at the corresponding positions of the Bloom filter, it means that the transaction may exist in the block. At this time, the block number can be returned and stored in the candidate block list; if the calculated K hash values are 0 at the corresponding positions of the Bloom filter, it means that the transaction to be queried does not exist in the block.
[0147] Specifically, Figure 3 As shown in the figure, the main process of screening candidate block lists based on Bloom filters is:
[0148] Step 301, obtain the ID of the transaction T1 to be queried, that is, T1_ID;
[0149] Step 302, using multiple hash functions to obtain multiple hash values of transaction T1;
[0150] For example, taking 3 hash functions as an example, this step will obtain the 3 hash values corresponding to transaction T1.
[0151] Step 303, comparing the multiple hash values with the positions corresponding to the Bloom filter;
[0152] Step 304, determine whether the values of the positions corresponding to the multiple hash values in the Bloom filter are all 1, if the values are all 1, execute step 305, otherwise terminate the operation;
[0153] Step 305, returning the block number corresponding to the block;
[0154] Step 306: Add the block number to the candidate block list.
[0155] Furthermore, the slave node traverses the screened candidate blocks. After the traversal is completed, the result of whether the target block exists can be obtained. If the target block exists, it is necessary to verify the target block first. After the target block is verified, the target block is broadcast. If the verification fails or the target block does not exist in the candidate blocks, the slave node broadcasts to each node that the target block does not exist.
[0156] Furthermore, if Figure 4 As shown in the figure, the process of obtaining the target block from the node based on the candidate block is:
[0157] Step 401, determine whether the candidate block list is empty;
[0158] If it is not empty, execute step 402, otherwise terminate the operation;
[0159] Step 402, traverse the candidate block list according to the transaction ID of the transaction to be queried;
[0160] Step 403, determine whether the transaction exists in the candidate block, if so, execute step 404, otherwise terminate the operation;
[0161] Step 404, returning the block number of the block containing the transaction to be queried.
[0162] Specifically, the specific implementation process of verifying the target block from the node is:
[0163] Obtaining the Merkle root hash value corresponding to the target block;
[0164] Obtaining the Merkle root verification path corresponding to the data to be queried in the target block;
[0165] Obtaining the Merkle root hash value corresponding to the data to be queried according to the hash value corresponding to the data to be queried and the Merkle root verification path;
[0166] Determine whether the Merkle root hash value corresponding to the data to be queried is equal to the Merkle root hash value corresponding to the target block;
[0167] If the hash value of the Merkle root of the data to be queried is equal to the hash value of the Merkle root of the target block, the target block is verified.
[0168] It should be noted that the validity of the queried target block is verified based on the Merkle root hash. A Merkle tree structure is constructed for all transactions in each block and the Merkle root hash path is found. The Merkle root hash value of the transaction to be queried is calculated. If the two Merkle root hash values are the same, the two sets of data must be the same, which indicates that the queried target block must be valid; otherwise, the two sets of data must be different, which indicates that the queried target block is invalid. Based on the Merkle root hash value of the Merkle tree, a large amount of data can be quickly compared.
[0169] For example, Figure 5As shown, assuming that it is necessary to verify whether the transaction T1 exists in the target block, first, it is necessary to obtain the Merkle root hash value Hroot corresponding to the target block, and then obtain the Merkle root verification path, that is, you only need to know the hash values H2, H34, and H58. In other words, H2, H34, and H58 are the Merkle root verification path of the target block. Finally, the Merkle root hash value Hroot' corresponding to transaction T1 is calculated according to the Merkle root verification path, that is, the hash value of Hash(T1) is first calculated to be H1', and then H12'=Hash(H1'+H2), H14'=Hash(H12'+H34), and Hroot'=Hash(H14'+H58); finally, determine whether Hroot and Hroot' are equal. If they are equal, it means that transaction T1 exists in the target block.
[0170] It should also be noted that, before step 21, the method of the embodiment of the present application further includes:
[0171] Send resource usage status to the master node.
[0172] Specifically, the resource usage status includes at least one of the following: CPU utilization, bandwidth resource utilization, memory resource utilization, and input / output resource utilization.
[0173] It should be noted that the present invention is based on the idea of distributed computing and proposes a resource-aware parallel query method for block data. The overall idea is to utilize the computing resources of each node in the alliance chain, dynamically allocate query tasks, and query block data in parallel from a large amount of block data.
[0174] The actual application process of the embodiment of the present application is described in detail below.
[0175] The first thing that needs to be explained here is that when the alliance chain generates a block, the block number and all transaction IDs of the block are stored in the block index table, so that a Bloom filter can be designed for all transaction IDs in each block in each node. The transaction ID can be directly obtained from the block index table, and then each transaction ID in each block is hashed. The calculated hash value is mapped to the corresponding position in the Bloom filter, and the bit position of the corresponding position is set to 1.
[0176] like Figure 6 The figure shows a schematic diagram of the alliance chain ledger. Each node contains an identical ledger and a block index table. The ledger is a chain storage structure composed of blocks connected one by one. The block records the transaction information that has been agreed upon by the entire network. The block index table stores the index information of the block in the form of key / value, where the key value is the block number and the value is the transaction ID.
[0177] like Figure 7 As shown is an architecture diagram for implementing an embodiment of the present invention, there is a master node (leader node) in the figure, and the leader node can implement a resource monitoring function for real-time monitoring of the resource usage status sent by the slave node; a task scheduling function for dynamically allocating blocks to be screened to the slave node based on the resource usage status sent by the slave node; the slave node can implement a filtering function for filtering candidate blocks; and a query function for traversing candidate blocks to obtain target blocks.
[0178] The main implementation process of the master node and the slave node is as follows: the master node is responsible for real-time monitoring of the CPU, memory resources, bandwidth resources, and input and output resource utilization of the slave node, and the slave node is responsible for periodically sending the CPU, memory resources, bandwidth resources, and input and output resource utilization to the master node; secondly, the master node assigns tasks to each slave node based on the resource utilization of each slave node; further, when the slave node receives the query task dynamically assigned by the master node according to the resource utilization and the specified block information, multiple slave nodes use Bloom filters in parallel to filter blocks to obtain a candidate block list; finally, each slave node traverses the candidate block list to determine whether the transaction exists, and returns the block number when the transaction exists.
[0179] In summary, compared with existing technologies, this proposal is based on the idea of distributed computing. It optimizes the design of querying blocks in parallel by multiple nodes instead of querying transaction information from a large amount of block data by a single node to improve query efficiency.
[0180] like Figure 8 As shown, the embodiment of the present invention further provides a master node 80, including:
[0181] A first acquisition module 81 is used to acquire at least one slave node capable of performing block query when a query request is received;
[0182] An allocation module 82, configured to allocate a block to be queried to each of the at least one slave node according to a load balancing principle;
[0183] A first sending module 83 is used to send a query processing message to the at least one slave node according to the block to be queried, so that each slave node searches for a target block containing the data to be queried in the query request in the corresponding block to be queried;
[0184] The query processing message includes: identification information of the block to be queried and identification information of the slave node.
[0185] Optionally, the first acquisition module 81 includes:
[0186] A receiving unit, used for receiving the resource usage status sent by each slave node;
[0187] A first acquisition unit, used to acquire at least one slave node whose resource usage status meets a preset condition;
[0188] Each of the at least one slave node is capable of performing block query.
[0189] The resource usage status includes at least one of the following: CPU utilization, bandwidth resource utilization, memory resource utilization, and input / output resource utilization.
[0190] Among them, the preset conditions include at least one of the following: CPU utilization is less than or equal to a first preset value, memory resource utilization is less than or equal to a second preset value, bandwidth resource utilization is less than or equal to a third preset value, and input / output resource utilization is less than or equal to a fourth preset value.
[0191] Optionally, the first sending module 83 is used to:
[0192] A query processing message is broadcast to the at least one slave node.
[0193] The identification information of the block to be queried includes: the block number of the block to be queried and / or the block hash value of the block to be queried.
[0194] It should be noted that the master node provided in the embodiment of the present invention is a master node capable of executing the above-mentioned data query method. Therefore, all implementation methods in the above-mentioned data query method embodiment applied to the master node side are applicable to the master node and can achieve the same or similar beneficial effects.
[0195] An embodiment of the present invention further provides a master node, comprising a transceiver and a processor;
[0196] The processor is configured to: upon receiving a query request, obtain at least one slave node capable of performing block query, and allocate a block to be queried to each of the at least one slave node according to a load balancing principle;
[0197] The transceiver is used to: send a query processing message to the at least one slave node according to the block to be queried, so that each slave node searches for a target block containing the data to be queried in the query request in the corresponding block to be queried;
[0198] The query processing message includes: identification information of the block to be queried and identification information of the slave node.
[0199] Optionally, when the processor executes acquiring at least one slave node capable of performing block query, it is specifically used to implement:
[0200] Receive resource usage status sent by each slave node;
[0201] Acquire at least one slave node whose resource usage status meets a preset condition;
[0202] Each of the at least one slave node is capable of performing block query.
[0203] The resource usage status includes at least one of the following: CPU utilization, bandwidth resource utilization, memory resource utilization, and input / output resource utilization.
[0204] Among them, the preset conditions include at least one of the following: CPU utilization is less than or equal to a first preset value, memory resource utilization is less than or equal to a second preset value, bandwidth resource utilization is less than or equal to a third preset value, and input / output resource utilization is less than or equal to a fourth preset value.
[0205] Optionally, when the transceiver executes sending the query processing message to the at least one slave node, it is specifically used to implement:
[0206] A query processing message is broadcast to the at least one slave node.
[0207] The identification information of the block to be queried includes: the block number of the block to be queried and / or the block hash value of the block to be queried.
[0208] An embodiment of the present invention also provides a master node, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, each process in the above-mentioned data query method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0209] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, each process in the above-mentioned data query method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0210] like Fig. 9 As shown, the embodiment of the present invention further provides a slave node 90, including:
[0211] The receiving module 91 is used to receive the query processing message sent by the master node, wherein the query processing message includes: identification information of the block to be queried and identification information of the slave node;
[0212] A second acquisition module 92, configured to acquire a target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried;
[0213] The query processing message is generated by the master node according to the load balancing principle for the block to be queried allocated to each slave node of at least one slave node capable of performing block query.
[0214] Optionally, the second acquisition module 92 includes:
[0215] A second acquisition unit, configured to acquire a candidate block according to the data to be queried and the identification information of the block to be queried;
[0216] The third acquisition unit is used to traverse the candidate blocks to acquire the target block containing the data to be queried.
[0217] Optionally, the second acquiring unit is used to:
[0218] By using the Bloom filter, candidate blocks containing the data to be queried are obtained from the blocks to be queried.
[0219] Optionally, the second acquiring unit is specifically configured to:
[0220] Using K hash functions, obtain K hash values of the data index of the data to be queried;
[0221] Compare the K hash values with the bits of the Bloom filter corresponding to each block in the block to be queried;
[0222] If the comparison result indicates that the values of the K hash values at the corresponding positions of the Bloom filter of a block are all 1, then the block is determined to be a candidate block;
[0223] Wherein, K is an integer greater than or equal to 1.
[0224] Optionally, before the second acquisition unit uses the Bloom filter to acquire the candidate block containing the data to be queried from the block to be queried, the method further includes:
[0225] The third acquisition module is used to perform hash calculation on the data index of each data item in each block on the blockchain according to K hash functions to obtain a hash value;
[0226] A fourth acquisition module, used for mapping the hash value to obtain a Bloom filter with a data length of M;
[0227] The initial value of the bit in the Bloom filter is 0, and when a mapping value exists on a bit, the value of the bit is set from 0 to 1;
[0228] K and M are both integers greater than or equal to 1.
[0229] Optionally, after the second acquisition module 92 acquires the target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried, the method further includes:
[0230] A verification module, used to verify the target block;
[0231] The broadcast module is used to broadcast the target block after the target block is verified.
[0232] Optionally, the verification module includes:
[0233] A fourth acquisition unit, configured to acquire a Merkle root hash value corresponding to the target block;
[0234] A fifth acquisition unit, configured to acquire a Merkle root verification path corresponding to the data to be queried in the target block;
[0235] a sixth obtaining unit, configured to obtain the Merkle root hash value corresponding to the data to be queried according to the hash value corresponding to the data to be queried and the Merkle root verification path;
[0236] A verification unit, used to determine whether the Merkle root hash value corresponding to the data to be queried is equal to the Merkle root hash value corresponding to the target block;
[0237] A determination unit is used to determine that if the hash value of the Merkle root of the data to be queried is equal to the hash value of the Merkle root of the target block, then the target block is verified.
[0238] Optionally, before the receiving module 91 receives the query processing message sent by the master node, the receiving module further includes:
[0239] The second sending module is used to send the resource usage status to the master node.
[0240] The resource usage status includes at least one of the following: CPU utilization, bandwidth resource utilization, memory resource utilization, and input / output resource utilization.
[0241] It should be noted that the slave node provided in the embodiment of the present invention is a slave node capable of executing the above-mentioned data query method. Therefore, all implementation methods in the above-mentioned data query method embodiment applied to the slave node side are applicable to the slave node and can achieve the same or similar beneficial effects.
[0242] An embodiment of the present invention further provides a slave node, comprising a transceiver and a processor;
[0243] The transceiver is used to: receive a query processing message sent by a master node, wherein the query processing message includes: identification information of a block to be queried and identification information of a slave node;
[0244] The processor is used to: acquire a target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried;
[0245] The query processing message is generated by the master node according to the load balancing principle for the block to be queried allocated to each slave node of at least one slave node capable of performing block query.
[0246] Optionally, when the processor executes obtaining the target block containing the data to be queried, it is specifically used to implement:
[0247] Acquire a candidate block according to the data to be queried and the identification information of the block to be queried;
[0248] The candidate blocks are traversed to obtain the target block containing the data to be queried.
[0249] Optionally, the processor is used to implement:
[0250] By using the Bloom filter, candidate blocks containing the data to be queried are obtained from the blocks to be queried.
[0251] Optionally, the processor is specifically configured to implement:
[0252] Using K hash functions, obtain K hash values of the data index of the data to be queried;
[0253] Compare the K hash values with the bits of the Bloom filter corresponding to each block in the block to be queried;
[0254] If the comparison result indicates that the values of the K hash values at the corresponding positions of the Bloom filter of a block are all 1, then the block is determined to be a candidate block;
[0255] Wherein, K is an integer greater than or equal to 1.
[0256] Optionally, before the processor uses the Bloom filter to obtain a candidate block containing the data to be queried in the block to be queried, the processor is further configured to implement:
[0257] For each block on the blockchain, hash calculation is performed on the data index of each data item in the block according to K hash functions to obtain the hash value;
[0258] Mapping the hash value to obtain a Bloom filter with a data length of M;
[0259] The initial value of the bit in the Bloom filter is 0, and when a mapping value exists on a bit, the value of the bit is set from 0 to 1;
[0260] K and M are both integers greater than or equal to 1.
[0261] Optionally, after the processor acquires the target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried, the processor is further configured to implement:
[0262] Verifying the target block;
[0263] After the target block is verified, the target block is broadcasted.
[0264] Optionally, when the processor verifies the target block, it is specifically used to implement:
[0265] Obtaining the Merkle root hash value corresponding to the target block;
[0266] Obtaining the Merkle root verification path corresponding to the data to be queried in the target block;
[0267] Obtaining the Merkle root hash value corresponding to the data to be queried according to the hash value corresponding to the data to be queried and the Merkle root verification path;
[0268] Determine whether the Merkle root hash value corresponding to the data to be queried is equal to the Merkle root hash value corresponding to the target block;
[0269] If the hash value of the Merkle root of the data to be queried is equal to the hash value of the Merkle root of the target block, the target block is verified.
[0270] Optionally, before the transceiver receives the query processing message sent by the master node, it is further used to implement:
[0271] Send resource usage status to the master node.
[0272] The resource usage status includes at least one of the following: CPU utilization, bandwidth resource utilization, memory resource utilization, and input / output resource utilization.
[0273] An embodiment of the present invention also provides a slave node, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, each process in the above-mentioned data query method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0274] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, each process in the above-mentioned data query method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0275] like Fig.10 As shown, an embodiment of the present invention further provides a data query method, which is applied to a consortium chain system including a master node and a slave node, comprising:
[0276] Step 101, upon receiving a query request, the master node obtains at least one slave node capable of performing a block query;
[0277] Step 102, allocating a block to be queried to each of the at least one slave node according to a load balancing principle;
[0278] Step 103: Send a query processing message to the at least one slave node according to the block to be queried, wherein the query processing message includes: identification information of the block to be queried and identification information of the slave node;
[0279] Step 104, at least one slave node receives the query processing message sent by the master node respectively;
[0280] Step 105 : acquiring a target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried.
[0281] It should be noted that before implementing the embodiment of the present invention, a consensus algorithm is first used to elect a master node and multiple slave nodes in the alliance chain system. When a query request is obtained, the master node distributes the query task to multiple slave nodes by utilizing the load balancing principle, so that multiple slave nodes process the query task in parallel, thereby improving the query efficiency.
[0282] Specifically, the specific implementation process of step 101 to step 105 refers to the above embodiment and will not be repeated here.
[0283] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0284] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0285] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A data query method, applied to a consortium chain system including a master node and a slave node, characterized in that: include: When receiving the query request, the master node obtains at least one slave node capable of performing block query; According to the load balancing principle, allocating a block to be queried to each of the at least one slave node; According to the block to be queried, a query processing message is sent to the at least one slave node, wherein the query processing message includes: identification information of the block to be queried and identification information of the slave node; At least one slave node receives the query processing message sent by the master node respectively; According to the data to be queried and the identification information of the block to be queried, obtaining a target block containing the data to be queried; Wherein, obtaining the target block containing the data to be queried includes: Acquire a candidate block according to the data to be queried and the identification information of the block to be queried; Traversing the candidate blocks to obtain a target block containing the data to be queried; The process of obtaining the candidate blocks is as follows: Using the Bloom filter, a candidate block containing the data to be queried is obtained from the block to be queried; The Bloom filter is set as follows: for each block on the blockchain, a hash calculation is performed on the data index of each data item in the block according to K hash functions to obtain a hash value; the hash value is mapped to obtain a Bloom filter with a data length of M; the initial value of the bit in the Bloom filter is 0, and when a mapping value exists on a bit, the value of the bit is set from 0 to 1; K and M are both integers greater than or equal to 1.
2. A data query method, applied to a master node, characterized in that: include: Upon receiving the query request, obtaining at least one slave node capable of performing block query; According to the load balancing principle, allocating a block to be queried to each of the at least one slave node; According to the block to be queried, a query processing message is sent to the at least one slave node, so that each slave node searches for a target block containing the data to be queried in the query request in the corresponding block to be queried; The query processing message includes: identification information of the block to be queried and identification information of the slave node; Wherein, searching for a target block containing the data to be queried in the query request includes: Acquire a candidate block according to the data to be queried and the identification information of the block to be queried; Traversing the candidate blocks to obtain a target block containing the data to be queried; The process of obtaining the candidate blocks is as follows: Using the Bloom filter, a candidate block containing the data to be queried is obtained from the block to be queried; The Bloom filter is set as follows: for each block on the blockchain, a hash calculation is performed on the data index of each data item in the block according to K hash functions to obtain a hash value; the hash value is mapped to obtain a Bloom filter with a data length of M; the initial value of the bit in the Bloom filter is 0, and when a mapping value exists on a bit, the value of the bit is set from 0 to 1; K and M are both integers greater than or equal to 1.
3. The data query method according to claim 2, characterized in that: The obtaining of at least one slave node capable of performing block query includes: Receive resource usage status sent by each slave node; Acquire at least one slave node whose resource usage status meets a preset condition; Each of the at least one slave node is capable of performing block query.
4. The data query method according to claim 3, characterized in that: The resource usage status includes at least one of the following: CPU utilization, bandwidth resource utilization, memory resource utilization, and input / output resource utilization.
5. The data query method according to claim 3, characterized in that: The preset conditions include at least one of the following: CPU utilization is less than or equal to a first preset value, memory resource utilization is less than or equal to a second preset value, bandwidth resource utilization is less than or equal to a third preset value, and input / output resource utilization is less than or equal to a fourth preset value.
6. The data query method according to claim 2, characterized in that: The sending of the query processing message to the at least one slave node comprises: A query processing message is broadcast to the at least one slave node.
7. The data query method according to claim 2, characterized in that: The identification information of the block to be queried includes: the block number of the block to be queried and / or the block hash value of the block to be queried.
8. A data query method, applied to a slave node, characterized in that: include: Receive a query processing message sent by the master node, wherein the query processing message includes: identification information of the block to be queried and identification information of the slave node; According to the data to be queried and the identification information of the block to be queried, obtaining a target block containing the data to be queried; The query processing message is generated by the master node according to the load balancing principle for the block to be queried allocated to each slave node of at least one slave node capable of performing block query; Wherein, obtaining the target block containing the data to be queried includes: Acquire a candidate block according to the data to be queried and the identification information of the block to be queried; Traversing the candidate blocks to obtain a target block containing the data to be queried; The step of obtaining a candidate block according to the data to be queried and the identification information of the block to be queried includes: Using the Bloom filter, a candidate block containing the data to be queried is obtained from the block to be queried; The Bloom filter is set as follows: for each block on the blockchain, a hash calculation is performed on the data index of each data item in the block according to K hash functions to obtain a hash value; the hash value is mapped to obtain a Bloom filter with a data length of M; the initial value of the bit in the Bloom filter is 0, and when a mapping value exists on a bit, the value of the bit is set from 0 to 1; K and M are both integers greater than or equal to 1.
9. The data query method according to claim 8, characterized in that: The method of using the Bloom filter to obtain a candidate block containing the data to be queried in the block to be queried includes: Using K hash functions, obtain K hash values of the data index of the data to be queried; Compare the K hash values with the bits of the Bloom filter corresponding to each block in the block to be queried; If the comparison result indicates that the values of the K hash values at the corresponding positions of the Bloom filter of a block are all 1, then the block is determined to be a candidate block; Wherein, K is an integer greater than or equal to 1.
10. The data query method according to claim 8, characterized in that: After acquiring the target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried, the method further includes: Verifying the target block; After the target block is verified, the target block is broadcasted.
11. The data query method according to claim 10, characterized in that: The verifying the target block includes: Obtaining the Merkle root hash value corresponding to the target block; Obtaining the Merkle root verification path corresponding to the data to be queried in the target block; Obtaining the Merkle root hash value corresponding to the data to be queried according to the hash value corresponding to the data to be queried and the Merkle root verification path; Determine whether the Merkle root hash value corresponding to the data to be queried is equal to the Merkle root hash value corresponding to the target block; If the hash value of the Merkle root of the data to be queried is equal to the hash value of the Merkle root of the target block, the target block is verified.
12. The data query method according to claim 8, characterized in that: Before receiving the query processing message sent by the master node, the method further includes: Send resource usage status to the master node.
13. The data query method according to claim 12, characterized in that: The resource usage status includes at least one of the following: CPU utilization, bandwidth resource utilization, memory resource utilization, and input / output resource utilization.
14. A master node, characterized in that: include: A first acquisition module, configured to acquire at least one slave node capable of performing block query when a query request is received; An allocation module, configured to allocate a block to be queried to each of the at least one slave node according to a load balancing principle; A first sending module, configured to send a query processing message to the at least one slave node according to the block to be queried, so that each slave node searches for a target block containing the data to be queried in the query request in the corresponding block to be queried; The query processing message includes: identification information of the block to be queried and identification information of the slave node; Wherein, searching for a target block containing the data to be queried in the query request includes: Acquire a candidate block according to the data to be queried and the identification information of the block to be queried; Traversing the candidate blocks to obtain a target block containing the data to be queried; The process of obtaining the candidate blocks is as follows: Using the Bloom filter, a candidate block containing the data to be queried is obtained from the block to be queried; The Bloom filter is set as follows: for each block on the blockchain, a hash calculation is performed on the data index of each data item in the block according to K hash functions to obtain a hash value; the hash value is mapped to obtain a Bloom filter with a data length of M; the initial value of the bit in the Bloom filter is 0, and when a mapping value exists on a bit, the value of the bit is set from 0 to 1; K and M are both integers greater than or equal to 1.
15. The master node according to claim 14, characterized in that: The first acquisition module includes: A receiving unit, used for receiving the resource usage status sent by each slave node; A first acquisition unit, used to acquire at least one slave node whose resource usage status meets a preset condition; Each of the at least one slave node is capable of performing block query.
16. A master node, characterized in that: including a transceiver and a processor; The processor is configured to: upon receiving a query request, obtain at least one slave node capable of performing block query, and allocate a block to be queried to each of the at least one slave node according to a load balancing principle; The transceiver is used to: send a query processing message to the at least one slave node according to the block to be queried, so that each slave node searches for a target block containing the data to be queried in the query request in the corresponding block to be queried; The query processing message includes: identification information of the block to be queried and identification information of the slave node; Wherein, searching for a target block containing the data to be queried in the query request includes: Acquire a candidate block according to the data to be queried and the identification information of the block to be queried; Traversing the candidate blocks to obtain a target block containing the data to be queried; The process of obtaining the candidate blocks is as follows: Using the Bloom filter, a candidate block containing the data to be queried is obtained from the block to be queried; The Bloom filter is set as follows: for each block on the blockchain, a hash calculation is performed on the data index of each data item in the block according to K hash functions to obtain a hash value; the hash value is mapped to obtain a Bloom filter with a data length of M; the initial value of the bit in the Bloom filter is 0, and when a mapping value exists on a bit, the value of the bit is set from 0 to 1; K and M are both integers greater than or equal to 1.
17. A master node, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the data query method according to any one of claims 2 to 7 when executing the program.
18. A slave node, characterized in that: include: A receiving module, configured to receive a query processing message sent by a master node, wherein the query processing message includes: identification information of a block to be queried and identification information of a slave node; A second acquisition module, configured to acquire a target block containing the data to be queried according to the data to be queried and identification information of the block to be queried; The query processing message is generated by the master node according to the load balancing principle for the block to be queried allocated to each slave node of at least one slave node capable of performing block query; Wherein, the second acquisition module includes: A second acquisition unit, configured to acquire a candidate block according to the data to be queried and the identification information of the block to be queried; A third acquisition unit, configured to traverse the candidate blocks to acquire a target block containing the data to be queried; The second acquiring unit is used for: Using the Bloom filter, a candidate block containing the data to be queried is obtained from the block to be queried; The Bloom filter is set as follows: for each block on the blockchain, a hash calculation is performed on the data index of each data item in the block according to K hash functions to obtain a hash value; the hash value is mapped to obtain a Bloom filter with a data length of M; the initial value of the bit in the Bloom filter is 0, and when a mapping value exists on a bit, the value of the bit is set from 0 to 1; K and M are both integers greater than or equal to 1.
19. The slave node according to claim 18, characterized in that: After the second acquisition module acquires the target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried, the method further includes: A verification module, used to verify the target block; The broadcast module is used to broadcast the target block after the target block is verified.
20. The slave node according to claim 18, characterized in that: Before the receiving module receives the query processing message sent by the master node, it also includes: Send resource usage status to the master node.
21. A slave node, characterized in that: including a transceiver and a processor; The transceiver is used to: receive a query processing message sent by a master node, wherein the query processing message includes: identification information of a block to be queried and identification information of a slave node; The processor is used to: acquire a target block containing the data to be queried according to the data to be queried and the identification information of the block to be queried; The query processing message is generated by the master node according to the load balancing principle for the block to be queried allocated to each slave node of at least one slave node capable of performing block query; Wherein, when the processor executes the step of obtaining the target block containing the data to be queried, it is used to implement: Acquire a candidate block according to the data to be queried and the identification information of the block to be queried; Traversing the candidate blocks to obtain a target block containing the data to be queried; Wherein, the processor is used to implement: Using the Bloom filter, a candidate block containing the data to be queried is obtained from the block to be queried; The Bloom filter is set as follows: for each block on the blockchain, a hash calculation is performed on the data index of each data item in the block according to K hash functions to obtain a hash value; the hash value is mapped to obtain a Bloom filter with a data length of M; the initial value of the bit in the Bloom filter is 0, and when a mapping value exists on a bit, the value of the bit is set from 0 to 1; K and M are both integers greater than or equal to 1.
22. A slave node, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the data query method according to any one of claims 8 to 13 are implemented.
23. A readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps in the data query method as described in any one of claims 2 to 13 are implemented.
Citation Information
Patent Citations
Asset information processing method and device based on block chain, equipment and storage medium
CN109992993A
Blockchain data service system based on alliance chain, access method and storage medium
CN111506589A