A classification retrieval method and its connection query method based on the tamper-proof property of blockchain data
By adopting a classified retrieval structure and a connection query method on the blockchain, the problem of retrieval and maintenance overhead increasing with the data scale in blockchain big data retrieval is solved, constant maintenance overhead and precise I/O are achieved, and the data is up to date and retrieval efficiency is ensured.
Patent Information
- Application Number
- CN202410918721.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2044-07-10
AI Technical Summary
When existing technologies are used to search for big data on blockchain, the search and maintenance overhead increases with the size of the data, and traditional search structures cannot efficiently perform repeated searches given the immutable nature of blockchain data.
It adopts an efficient classification retrieval structure and connection query method based on the tamper-proof nature of blockchain data, achieves constant maintenance overhead through data attribute classification, bit operations and mathematical operations, and performs precise I/O by calculating offsets. After the data is updated, the client only performs repeated searches in the newly added data.
It achieves constant maintenance overhead and precise I/O, reduces repeated retrieval costs, and ensures the latest and efficient retrieval of client data.
Smart Images

Figure CN118626517B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of blockchain technology, and specifically relates to a classification retrieval method and a connection query method based on the tamper-proof property of blockchain data. Background Art
[0002] Blockchain, as a distributed data ledger, achieves data consistency across multiple participants through a specific consensus mechanism. The blockchain data structure consists of chronologically ordered blocks, each containing transaction records and linked to the previous block via hash pointers, forming an immutable and continuously growing chain. The immutability of blockchain data is ensured by cryptographic links between blocks; any modification invalidates all subsequent blocks. Data retrieval is a major requirement on blockchains.
[0003] To address the need for data retrieval on blockchains, industry and academia have proposed some preliminary solutions, most of which are based on upgrades or improvements to B+trees. The retrieval and maintenance costs of these structures are related to the size of the data. Because retrieval requires searching across all indexes, and maintenance may also require adjustments across all indexes, these costs can become unacceptable when the data size is large.
[0004] Traditional search structures are not well suited for big data retrieval in blockchain scenarios. Furthermore, as the scale of blockchain data continues to grow over time, the search and maintenance costs of these search structures will become increasingly high. Furthermore, because blockchain data is immutable, if the data on the blockchain is updated after a client has performed a search, the client only needs to search for the newly updated data that meets the requirements when searching for the same query again. Traditional search structures cannot achieve this cost-effectively. Summary of the Invention
[0005] In view of the above, the present application provides a retrieval structure and a connection query method based on the tamper-proof nature of data in the blockchain, which can achieve constant maintenance overhead and does not increase with the increase of data scale.
[0006] In the first aspect, this application provides an efficient classification retrieval structure based on the tamper-proof nature of blockchain data, in which:
[0007] Data attributes are classified by features. Whether each data has a certain feature is marked by a binary bit, 0 represents no feature, and 1 represents yes feature. The final indexed data maintains the time sequence of the data on the blockchain.
[0008] The retrieval process mainly uses bit operations and mathematical operations. The final retrieval result is the relative offset of the data that meets the conditions relative to the first data. Finally, the offset is calculated in the data file to move the head for precise I / O.
[0009] Secondly, based on the described classification retrieval structure, this application also provides a connection query method based on the tamper-proof characteristics of blockchain data: the client carries an identifier each time it searches, and the server calculates the identifier to obtain the position where the client stopped when searching for the same question last time, and searches for data that meets the conditions between this stopped position and the latest data, and finally obtains the data that meets the search conditions from the data updated since the last search, and the server returns these data and the new identifier to the client.
[0010] The efficient classification retrieval structure of this application achieves constant maintenance overhead, that is, the maintenance cost does not increase with the increase of the total amount of data. It can also perform accurate I / O during retrieval, avoiding a large amount of redundant I / O. In addition, this application also proposes a connection query. Based on the tamper-proof nature of data on the blockchain, the data obtained by the client after a search will be the latest and will not be modified. The next time the client searches for the same question, it only needs to search for data that meets the conditions in the updated data, which will greatly reduce the cost of retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 This is a schematic diagram of the optimal maintenance overhead when a new piece of data is added to the classification retrieval structure of the present invention.
[0012] Figure 2 This is a schematic diagram of the worst case maintenance overhead when a new piece of data is added to the classification retrieval structure of the present invention. DETAILED DESCRIPTION
[0013] In order to describe the present invention more specifically, the technical solution of the present invention is described in detail below in conjunction with specific implementation methods.
[0014] The data is classified according to the data scenario and the demand scenario. The same data can have multiple features. It can be classified according to keywords or the range of a certain attribute value of the data. Finally, the number of feature types F is obtained. n ; Then determine the maximum number of child nodes B for each node based on the data scale and user needs n , B n is a constant greater than 2.
[0015] When establishing a classification retrieval structure, the data on the blockchain is sorted in chronological order, and each data is encoded one by one. Each data has F nbits, and each bit 1 and 0 respectively indicate whether the data has this or not. n Features, F n Determined by the specific application scenario. n The data are grouped into a group. n The feature bits of each feature are divided together in the same way to get F n feature encoding. n The data constitutes a leaf node, and in the same way, B n The leaf nodes are divided together to form a child node of the intermediate node. At this time, the intermediate node has F n feature codes, each feature code has B from left to right n bits indicate whether the leaf nodes from left to right have data containing the feature. n The intermediate nodes are divided together to form a child node of the root node. At this time, the root node has F n feature codes, each feature code has B from left to right n Each bit indicates whether the subtrees from left to right have data containing the feature. In this way, a classification retrieval tree is constructed. When all the data are constructed, a classification retrieval forest is obtained.
[0016] In a preferred example, the trees corresponding to several combined root nodes form a search forest. During the construction process, only the last constructed tree may be incomplete. When new data is added, only the latest constructed tree needs to be maintained without adjusting the entire index structure.
[0017] In a preferred example, after retrieving the leaf node, the relative positions of all 1s in the feature code in the binary code are obtained, and the corresponding relative positions are the relative positions of the data. The position of the result data in the file can be obtained by calculating the head offset based on this relative position.
[0018] In a preferred example, the traversal process is to find all the 1s in the binary, and calculate its relative offset relative to the first node of the same layer by finding the position of the 1. The recursive process finally obtains the relative offset of all data that meet the conditions relative to the first data.
[0019] Based on the above efficient classification search structure, the specific steps for searching this application are as follows:
[0020] Step A. Determine the feature to be retrieved. This feature can be a single feature or a combination of multiple feature logical operations. The subsequent retrieval process will perform the same feature logical operations.
[0021] Step B. Search all the root nodes in the search forest and find all the 1s in the binary code of the feature combination of the specified feature or logical operation through bit operations;
[0022] Step C. Calculate the relative offset of these 1s relative to the first bit in the binary encoding of all root node features to find the intermediate node to be retrieved;
[0023] Step D. Search among all the intermediate nodes found in step C, and find all the 1s in the binary code of the feature combination of the specified feature or logical operation through bit operations;
[0024] Step E. Calculate the relative offset of these 1s relative to the first bit in the binary encoding of all intermediate node features to find the leaf node to be retrieved;
[0025] Step F. Search all leaf nodes found in step E and find all 1s in the binary code of the feature combination of the specified feature or logical operation through bit operations;
[0026] Step G. Calculate the relative offset of these 1s relative to the first bit in the binary encoding of all leaf nodes to find the data to be retrieved;
[0027] Step H: Calculate the relative offset that the magnetic head needs to move using the offset obtained in step G, and read it from the data file.
[0028] When new data is added, only F n In addition, the worst case is that the node needs to be expanded, such as Figure 2 , despite this, the maintenance cost is still of constant order.
[0029] In addition, since the data on the blockchain is tamper-proof, once the client performs a search, the data retrieved will not be modified, which means that they will always be up to date. If the data on the blockchain is updated, when the client searches for the same question again, it only needs to search for data that meets the conditions in the newly added data without having to search again. Therefore, the embodiment of the present application also proposes the following connection query method:
[0030] The client can choose to carry an identifier with each search. The server can calculate the identifier to obtain the position where the client stopped when searching for the same question last time, and the data that meets the conditions between this stopping position and the latest data. Finally, the data that meets the search conditions in the data updated since the last search is obtained. The server returns this data and the new identifier to the client.
[0031] In some embodiments, by calculating this identifier, it is possible to determine which retrieval tree the client stopped at when searching for the same question last time, and then determine which leaf node in the retrieval tree the client stopped at, and finally determine which bit of the feature encoding in the leaf node was obtained.
[0032] In some embodiments, when the client searches for the same question again, it skips all previously searched data and only searches for data that meets the conditions in the newly updated data that the client has not searched before.
[0033] In some embodiments, after each search is completed, the server will return a new identifier to the client to record the location where the client stopped the search. The identifier is saved by the client itself. The next time the search is performed, the client can choose to carry the identifier with the corresponding search conditions for a connection query.
[0034] The above description of the embodiments is intended to facilitate understanding and application of the present invention by those skilled in the art. It is apparent that those skilled in the art can readily make various modifications to the above embodiments and apply the general principles described herein to other embodiments without requiring creative effort. Therefore, the present invention is not limited to the above embodiments. Any improvements or modifications made by those skilled in the art based on the disclosure of the present invention should fall within the scope of protection of the present invention.
Claims
1. A classification retrieval method based on the tamper-proof property of blockchain data, characterized by: Data attributes are classified by features. Whether each data has a certain feature is marked by a binary bit, 0 represents no feature, and 1 represents yes feature. The final indexed data maintains the time sequence of the data on the blockchain. The retrieval process mainly uses bit operations and mathematical operations. The final retrieval result is the relative offset of the data that meets the conditions relative to the first data. Finally, the head is moved by calculating the offset in the data file to perform precise I / O. The search steps are as follows: Step A. Determine the features to be retrieved; Step B. Search all the root nodes in the search forest and find all the 1s in the binary code of the feature combination of the specified feature or logical operation through bit operations; Step C. Calculate the relative offset of these 1s relative to the first bit in the binary encoding of all root node features to find the intermediate node to be retrieved; Step D. Search among all the intermediate nodes found in step C, and find all the 1s in the binary code of the feature combination of the specified feature or logical operation through bit operations; Step E. Calculate the relative offset of these 1s relative to the first bit in the binary encoding of all intermediate node features to find the leaf node to be retrieved; Step F. Search all leaf nodes found in step E and find all 1s in the binary code of the feature combination of the specified feature or logical operation through bit operations; Step G. Calculate the relative offset of these 1s relative to the first bit in the binary encoding of all leaf nodes to find the data to be retrieved; Step H: Calculate the relative offset that the magnetic head needs to move using the offset obtained in step G, and read it from the data file.
2. The classification search method according to claim 1, characterized in that: For all data in the leaf nodes, the order of their indexes is consistent with the temporal sequence of the data in the blockchain. The order in which all data in all leaf nodes are arranged from left to right is the order in which the data in the blockchain are arranged in chronological order.
3. The classification search method according to claim 1, characterized in that: Classify the different characteristics of all attributes of each data. The retrieval process is to search for the characteristics of different classifications. After classification, F n Features, F n Determined by the specific application scenario.
4. The classification search method according to claim 3, characterized in that: Each piece of data has F n Features, corresponding to F in the encoding n bits, the order of binary bits in each feature code is the same as the time sequence of data in the blockchain, and each node has a maximum of B n child nodes, among which B n is a constant greater than 2; B n Data groups are grouped into a leaf node, B n leaf nodes are grouped into child nodes of an intermediate node, B n The intermediate nodes are grouped into a child node of the root node, and the final result is that each node has F n Each feature code has B n bits, corresponding to B n data or child nodes.
5. The classification search method according to claim 1, characterized in that: The trees corresponding to several combined root nodes form a search forest. During the construction process, only the last constructed tree may be incomplete.
6. The classification search method according to claim 1, characterized in that: After retrieving the leaf node, what is obtained is the relative position of all 1s in the feature code in the binary code, which corresponds to the relative position of the data. By calculating the head offset based on this relative position, the position of the result data in the file can be obtained.
7. The classification search method according to claim 1, characterized in that: The traversal process is to find all the 1s in the binary system, and calculate the relative offset of the 1 relative to the first node in the same layer by finding the position of the 1. The recursive process finally obtains the relative offset of all the data that meets the conditions relative to the first data.
8. A connection query method based on the tamper-proof property of blockchain data, based on the classification search method according to any one of claims 1 to 7, characterized in that: Each time the client searches, it carries an identifier. The server calculates the identifier to obtain the position where the client stopped when searching for the same question last time. It then searches for data that meets the conditions between this position and the latest data. Finally, it obtains the data that meets the search conditions from the data updated since the last search. The server returns this data and the new identifier to the client.
9. The connection query method according to claim 8, characterized in that: By calculating this identifier, we can get the search tree where the client stopped when searching for the same question last time, and then get the leaf node where the client stopped in this search tree, and finally get a bit of the feature code in this leaf node; After each search is completed, the server will return a new identifier to the client to record the location where the client stopped searching. The identifier is saved by the client. The next time the search is performed, the client selects the identifier that carries the corresponding search conditions for a subsequent query.
Citation Information
Patent Citations
Block chain light client verification and query method based on bitmap index
CN109766389A