Blockchain data query method, terminal, and storage medium
Quickly locate blockchain historical data through the preset block aggregation index, which solves the problems of low retrieval efficiency and large storage overhead, achieves efficient retrieval and saves storage, and avoids the risk of system crash.
Patent Information
- Application Number
- PCT/CN2023/091255
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-17
- Filing Date
- 2023-04-27
- Publication Date
- 2024-10-24
AI Technical Summary
The retrieval efficiency of blockchain historical status data is low and the storage overhead is high, resulting in increased system operating pressure and potential risk of collapse.
Through the preset block aggregation index, the index block header and index block body are used to quickly locate the target block record, avoiding a large number of file operations and deserialization, and only providing summary aggregation of historical status data, saving storage resources.
It improves the retrieval efficiency of blockchain historical status data, reduces storage overhead, avoids the risk of system crash, and ensures the normal operation of the blockchain system.
Smart Images

Figure CN2023091255_24102024_PF_FP_ABST
Abstract
Description
Blockchain data query method, terminal and storage medium Technical Field
[0001] The present invention relates to the field of data query technology, and in particular to a blockchain data query method, terminal, and storage medium. Background Art
[0002] Blockchains utilize a fully replicated data storage mechanism, maintaining a complete copy of the entire blockchain for each node. Each copy is a blockchain ledger that records the complete history of the blockchain. The data that needs to be stored and managed in a blockchain primarily includes current state data and historical state data. Current state data is the final result after a node has processed all blocks and transactions from the genesis block to the current height. Historical state data is the path from the genesis block to the current state, including both block data and transaction data. Currently, current state data is typically stored in a state database, while historical state data is stored in historical ledger files.
[0003] With the development of blockchain technology and industry, it has been applied in numerous industries, including finance, government, energy, industrial production, healthcare, and logistics, often involving the retrieval of historical status data. For example, in logistics applications, the location of a package is stored on the blockchain as current status data. While the blockchain can quickly retrieve the current location (current status data), it cannot quickly determine the package's location within a specific historical event (historical status data).
[0004] There are two main methods for retrieving historical state data on the blockchain in the existing technology: the first method is to obtain block files one by one when retrieving a certain historical state data, deserialize the files and search. If the block file does not match the information to be searched, the next block file must be obtained and deserialized again, and the cycle repeats until the search conditions are met or the entire blockchain account book is traversed. The second method is to divide the historical state data into certain time periods and store the state values within each time period in the state database as current state data. When retrieving historical state data, the time period to be searched is first compared with the time periods stored in the state database, and the state values with overlapping time periods are removed before returning the result, thereby retrieving the historical state data.
[0005] The first method is simple and primitive, requiring numerous file operations and deserialization, resulting in significant disk IO and processor overhead and extremely low retrieval efficiency. While the second method can improve retrieval efficiency somewhat compared to the first solution, it requires maintaining the state values of each historical state data item at different time periods. This means that even if a piece of historical state data does not change subsequently, the historical state values for each time period must still be stored in the state database over time, resulting in inefficient storage. Furthermore, in most application scenarios, only a small portion of historical state data will experience frequent changes, leading to significant unnecessary storage overhead. Furthermore, due to the blockchain's immutable nature, the blockchain ledger is a storage structure that only grows and never decreases. As the amount of data continues to grow, this places enormous pressure on the state database and memory, severely hindering normal system operation and even potentially causing system crashes.
[0006] Based on this, how to save storage overhead while improving the retrieval efficiency of blockchain historical status data has become a technical problem that needs to be solved urgently.
[0007] Summary of the Invention
[0008] The main purpose of the present invention is to provide a blockchain data query method, terminal and storage medium, aiming to solve the problems of low retrieval efficiency and high storage overhead of blockchain historical status data in the existing technology.
[0009] In order to achieve the above objectives, the present invention provides a blockchain data query method, which includes:
[0010] Receive a historical data query request from a client and obtain a preset block aggregation index; the historical data query request includes: an identifier of a subject to be queried and a time range to be queried; the preset block aggregation index is composed of a plurality of index blocks including an index block header and an index block body;
[0011] Based on the index action time range and index write set in the index block header, and according to the time range to be queried and the subject identifier to be queried, the target index block of the historical data query request is determined from the preset block aggregate index; the index action time range is used to represent the time range involved in executing transactions in the blockchain block recorded by the index block; the index write set is composed of the block write set of the blockchain block recorded by the index block; and the block write set is composed of the transaction write set in the blockchain block;
[0012] Based on the index block body of the target index block, according to the time range to be queried and the subject identifier to be queried, determining the target block record corresponding to the historical data query request from the target index block; the index block body is composed of a plurality of block records, each of which includes: a block action time and the block write set;
[0013] The block ID corresponding to the target block record is sent to the client, so that the client performs an account book query based on the target block corresponding to the block ID to obtain a query result of the historical data query request.
[0014] Optionally, determining the target index block for the historical data query request from a preset block aggregate index based on the index action time range and index write set in the index block header, according to the time range to be queried and the subject identifier to be queried, specifically includes:
[0015] Determine, based on the time range to be queried and the index action time range in the index block header, an index block in the preset block aggregate index that intersects with the time range to be queried, as a pending index block for the historical data query request;
[0016] The subject identifier to be queried is matched with the index write set of the index block header of the pending index block, and the target index block of the historical data query request is determined according to the corresponding matching result.
[0017] Optionally, the index block header further includes: a first Bloom filter; and matching the subject identifier to be queried with the index write set of the index block header of the pending index block specifically includes:
[0018] The subject identifier to be queried is matched with the index write set of the index block header of the pending index block through the first Bloom filter of the index block header.
[0019] Optionally, the determining, based on the index block body of the target index block and according to the time range to be queried and the subject identifier to be queried, a target block record corresponding to the historical data query request from the target index block specifically includes:
[0020] Based on the block action time of each block record in the index block body of the target index block, determine the block record in the index block body of the target index block that intersects with the time range to be queried as the pending block record;
[0021] The subject identifier to be queried is matched with the block write set in the pending block record, and the target block record of the historical data query request is determined according to the corresponding matching result.
[0022] Optionally, the block record further includes: a second Bloom filter; and matching the subject identifier to be queried with the block write set in the pending block record specifically includes:
[0023] The subject identifier to be queried is matched with the block write set in the pending block record through the second Bloom filter in the pending block record.
[0024] Optionally, the index action time range is used to represent the time range involved in transactions successfully executed in the blockchain block recorded by the index block.
[0025] Optionally, the block write set is a key parameter of a key-value pair in a transaction record in the blockchain block, and the key parameter is used to represent the transaction subject of the transaction record.
[0026] Optionally, before obtaining the preset block aggregation index, the method further includes:
[0027] For each on-chain block, traverse all transaction records in the on-chain block and generate the block write set and the block action time based on the transaction records; wherein the on-chain block is used to represent the on-chain blockchain block in the blockchain;
[0028] Constructing the block record based on the block identifier of the on-chain block, the block write set, and the block action time;
[0029] According to the order in which the on-chain blocks are on-chained, a preset number of block records of the on-chain blocks that are continuously connected form the index block body;
[0030] Generate the corresponding index block header according to each block record in the index block body;
[0031] The index block header and the corresponding index block body are combined into the index block, and the index blocks are connected in a preset order to obtain the preset block aggregation index.
[0032] To achieve the above objectives, an embodiment of the present invention further provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps in the blockchain data query method as described in any one of the above.
[0033] In order to achieve the above-mentioned objectives, an embodiment of the present invention further provides a terminal, which includes: a processor and a memory; the memory stores a computer-readable program that can be executed by the processor; when the processor executes the computer-readable program, the steps in the blockchain data query method described in any one of the above items are implemented.
[0034] The present invention determines the target index block of the historical data query request from the preset block aggregation index based on the index action time range and index write set in the index block header, the time range to be queried, and the subject identifier to be queried; based on the index block body of the target index block, the target block record corresponding to the historical data query request is determined from the target index block according to the time range to be queried and the subject identifier to be queried; and then sends the block ID corresponding to the target block record to the client, so that the client performs a ledger query based on the target block corresponding to the block ID to obtain the query result of the historical data query request. On the one hand, the preset block aggregation index of the blockchain realizes the rapid positioning of the blockchain block where the data to be queried is located, which can avoid a large amount of system overhead and improve the retrieval efficiency of blockchain data; on the other hand, the preset block aggregation index of the blockchain only provides a summary aggregation of historical status data, which will not generate a large amount of additional redundant data over time, effectively saving storage overhead and avoiding the risk of affecting the normal operation of the blockchain system and system crash. Based on this, it is achieved that the query and retrieval efficiency of the historical status data of the blockchain is improved while saving storage space resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] FIG1 is an application scenario diagram of a blockchain data query method provided by an embodiment of the present invention;
[0036] FIG2 is a flowchart of a blockchain data query method provided by an embodiment of the present invention;
[0037] FIG3 is a schematic diagram of the structure of a preset block aggregation index provided by an embodiment of the present invention;
[0038] FIG4 is a schematic diagram of the structure of an index block provided by an embodiment of the present invention;
[0039] FIG5 is another flow chart of a blockchain data query method provided by an embodiment of the present invention;
[0040] FIG6 is a schematic structural diagram of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solutions and advantages of the present invention more clear and distinct, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0042] The present invention provides a blockchain data query method. It can be understood that the execution subject of the method can be a corresponding terminal device or server, which is not specifically limited in the embodiments of the present invention.
[0043] Taking the execution subject as the server as an example, Figure 1 is an application scenario diagram of the blockchain data query method provided by the present invention. The client 100 initiates a historical data query request for the blockchain 300, and the server 200 obtains the preset block aggregation index of the blockchain and quickly locates the block where the data to be queried corresponding to the historical data query request is located according to the preset block aggregation index, and then sends the quickly located block identifier to the client 100. The client 100 initiates a corresponding block query to the blockchain account book and obtains the corresponding query result, thereby realizing a rapid query of the historical status data in the blockchain.
[0044] FIG2 is a flow chart of a blockchain data query method provided by an embodiment of the present invention. As shown in FIG2 , the blockchain data query method includes at least the following steps:
[0045] S201, receiving a historical data query request from a client and obtaining a preset block aggregation index.
[0046] The historical data query request includes the subject identifier and the time range. The subject identifier identifies the subject for the data query and can be represented by an ID. For example, in a logistics application, the subject identifier could be a courier number, a recipient name, or a sender name.
[0047] The above query time range is used to represent the query time range of the subject to be queried for this data query. Taking the logistics application as an example, the subject to be queried is courier number: X00001. This historical data query request requires the location information of the package with courier number X00001 between April 10, 2023 and April 12, 2023. That is, April 10, 2023 to April 12, 2023 is the above query time range.
[0048] As shown in Figure 3, the above-mentioned preset block aggregation index is composed of several index blocks. As shown in Figure 4, each index block consists of an index block header (i.e., the index block header in Figure 4) and an index block body (i.e., the index block body in Figure 4). Each index block body consists of several block records. One block record corresponds to one blockchain block in the blockchain account book, that is, one index block body corresponds to m consecutive blockchain blocks, as shown in Figure 3. The above-mentioned block record includes: block ID, block action time Δt b , block write set and the second control filter corresponding to the block write set, as shown in Figure 4.
[0049] The BlockWrite Set (BWS) is used to represent all the TransactionWrite Sets (TxWS) in the blockchain block corresponding to the block record, that is, Bm WS=Tx1WS∪...∪Tx i WS,{Tx1,...,Tx i}∈B m The block ID is used to identify the blockchain block corresponding to the block record, that is, to provide a mapping of the blockchain block corresponding to the block record. Block action time Δt b It is used to represent the time range of all transactions in the blockchain block corresponding to the block record, that is, Δt b =[t min ,t max ], where t min is the minimum value of the transaction timestamp in the blockchain block, t max The maximum value of the transaction timestamps in the blockchain block. For example, if blockchain block A contains 100 transactions, the block action time of block A can be determined based on the minimum and maximum transaction timestamps in the 100 transactions.
[0050] Furthermore, the block write set is composed of key parameters in the state key-value pairs of the transaction write set in the blockchain block, and the key parameters are used to represent the transaction subjects in the transaction write set.
[0051] In the embodiment of the present invention, the block write set is only the key parameter in the state key-value pair of the transaction write set, and does not include the value parameter in the state key-value pair. Compared with the block write set being the state key-value pair of the transaction write set, it can further save storage space resources.
[0052] Furthermore, the block write set consists of all successfully executed transaction write sets in the blockchain block corresponding to the block record, and the corresponding block action time Δt b It is used to represent the time range of all successfully executed transactions in the blockchain block corresponding to the block record, that is, Δt b =[t min ,t max ], where t min is the minimum value of the successful transaction timestamp in the blockchain block, t max It is the maximum value of successful transaction timestamps in the blockchain block.
[0053] Since the number of transaction write sets is large, the number of block write sets is also large. Therefore, in the embodiment of the present invention, only the transaction write sets that are successfully executed in the blockchain block are composed into the corresponding block write set, which can further save storage space resources.
[0054] As shown in FIG4 , the index block header includes: index block ID, starting block ID, index action time ΔT i And the first Bloom filter corresponding to the index write set.
[0055] The index block ID is the unique identifier of the index block. The starting block ID indicates the ID of the starting blockchain block of the index block. Indexing time ΔT i It is used to characterize the time range of transactions in all blockchain blocks recorded by the index block, that is, ΔT i =[T min ,T max ], where T min is the minimum value of the transaction timestamp in all blockchain blocks recorded in index block i, T max is the maximum value.
[0056] Since an index block aggregates transactions in multiple blockchain blocks, the index write set (IWS) is the block write set of the blockchain blocks recorded in the index block, that is: k WS=B m WS∪...∪B n WS,{B m ,...,B n}∈I k .
[0057] As shown in FIG5 , before obtaining the preset block aggregation index, the blockchain data query method provided by the embodiment of the present invention may further include at least the following steps:
[0058] S501: For each on-chain block, traverse all transaction records in the on-chain block and generate a block write set and block action time based on the transaction records.
[0059] Among them, the on-chain block is used to represent the blockchain blocks that have been on-chain in the blockchain.
[0060] Furthermore, for each on-chain block, all transaction records in the on-chain block are traversed, and the block write set and block action time are generated based on the successfully executed transaction records.
[0061] In the embodiment of the present invention, a block write set is generated only based on successfully executed transaction records, which can further save storage space resources.
[0062] S502: Construct a block record based on the block identifier, block write set, and block action time in the on-chain block.
[0063] S503 , according to the order in which the on-chain blocks are on-chained, grouping the block records of a preset number of consecutively connected on-chain blocks into an index block body.
[0064] S504: Generate a corresponding index block header according to each block record in the index block body.
[0065] S505 , assembling an index block from an index block header and a corresponding index block body, and connecting the index blocks in a preset order to obtain a preset block aggregation index.
[0066] The above-mentioned preset order may refer to the order of each blockchain block in the blockchain.
[0067] Through the above steps S501-S505, the preset block aggregation index of the blockchain can be obtained and stored, so that the preset block aggregation index can be obtained after receiving the historical data query request from the client.
[0068] It is understandable that when there is a new on-chain block on the blockchain, the above S501-S504 can also be used to obtain the index block of the on-chain block and connect it to the preset block aggregation index, and update the preset block aggregation index to adapt to the continuous growth of data.
[0069] S202 , based on the index action time range and index write set in the index block header, according to the time range to be queried and the subject identifier to be queried, determine the target index block corresponding to the historical data query request from the preset block aggregation index.
[0070] Specifically, we can first determine the index block in the preset block aggregation index that intersects with the time range to be queried based on the time range to be queried and the index action time range in the index block header, and use it as the pending index block for the historical data query request; then match the subject identifier to be queried with the index write set in the index block header of the pending index block, and determine the target index block for the historical data query request based on the corresponding matching result.
[0071] Furthermore, the first Bloom filter of the index block header is used to match the subject identifier to be queried with the index write set of the index block header of the pending index block to obtain a corresponding matching result.
[0072] In this embodiment of the present invention, an index block that intersects the time range to be queried is first determined based on the indexing time of each index block. This is then used as the pending index block. Then, using the first Bloom filter in the index block header, the subject identifier to be queried is matched against the index write set in the index block header of the pending index block to obtain a corresponding matching result. The matching result indicates whether the subject identifier to be queried exists in the index write set.
[0073] If there is a subject identifier to be queried in the index write set, it means that the pending index block matches the historical data query request and serves as the target index block of the historical data query request; if there is no subject identifier to be queried in the index write set, it means that the pending index block does not match the historical data query request, then the matching result between the next pending index block and the subject identifier to be queried is determined until the target index block of the historical data query request is found.
[0074] S203 , based on the index block body of the target index block, according to the time range to be queried and the subject identifier to be queried, determining the target block record corresponding to the historical data query request from the target index block.
[0075] The index block is composed of several block records, and the block records include block action time and block write set.
[0076] Specifically, based on the block action time of each block record in the index block body of the target index block, the block records in the index block body of the target index block that intersect with the time range to be queried can be determined as pending block records; then the subject identifier to be queried is matched with the block write set in the pending block record write set, and the target block record of the historical data query request is determined according to the corresponding matching result.
[0077] Furthermore, the subject identifier to be queried is matched with the block write set in the pending block record through the second Bloom filter in the pending block record.
[0078] In an embodiment of the present invention, the block action time of the block record of the index block body in the target index block is first used to determine the block record that intersects with the time range to be queried, and use it as the pending block record; then, the second Bloom filter in the pending block record is used to match the subject identifier to be queried with the block write set in the pending block record to obtain a corresponding matching result, which is used to indicate whether the subject identifier to be queried exists in the block write set.
[0079] If there is a subject identifier to be queried in the block write set, it means that the pending block record matches the historical data query request and serves as the target block record of the historical data query request; if there is no subject identifier to be queried in the block write set, it means that the pending block record does not match the historical data query request, then the matching result between the next pending block record and the subject identifier to be queried is determined until the target block record of the historical data query request is found.
[0080] S204: Send the block ID corresponding to the target block record to the client, so that the client performs a ledger query on the target block corresponding to the block ID to obtain the query result of the historical data query request.
[0081] In an embodiment of the present invention, the block ID corresponding to the target block record is sent to the client. The client uses the blockchain block corresponding to the block ID as the target block, performs a ledger query on the target block, and obtains the query result of the historical data query request.
[0082] In an embodiment of the present invention, after obtaining the query result of the historical data query request, the query result needs to be sent to the client, and the client can display the query result to the user to complete the blockchain data query.
[0083] In some embodiments of the present invention, the blockchain is used to store medical data. The blockchain data query method provided by the present invention enables efficient retrieval and query of historical medical data on the blockchain while conserving storage resources. Such medical data includes at least medical image data, medical device data, surgical data, and the like.
[0084] The blockchain data query method provided by the present invention uses a historical data query request and a preset block aggregation index of the blockchain. The method first searches through the index block header of the index block in the preset block aggregation index. After determining the target index block of the historical data query request, the method then determines the target block corresponding to the historical data query request through the index block body of the target index block, thereby performing a ledger query on the target block to obtain the query result of the historical data query request. This scheme, on the one hand, enables rapid location of the blockchain block containing the data to be queried through the block aggregation index, thus avoiding significant system overhead. On the other hand, the preset block aggregation index provided by the present invention only provides a summary aggregation of historical status data, which does not generate a large amount of additional redundant data over time, effectively saving storage overhead and avoiding the risk of affecting the normal operation of the blockchain system and causing system crashes.
[0085] Based on the above-mentioned blockchain data query method, the present invention also provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps in the blockchain data query method described in the above embodiment.
[0086] Based on the above-mentioned blockchain data query method, the present invention also provides a terminal, as shown in Figure 6, which includes at least one processor 60; a display screen 61; and a memory 62. It may also include a communications interface 63 and a bus 64. The processor 60, display screen 61, memory 62, and communications interface 63 can communicate with each other via bus 64. The display screen 61 is configured to display a preset user guidance interface in the initial settings mode. The communications interface 63 can transmit information. The processor 60 can call the logic instructions in the memory 62 to execute the blockchain data query method in the above-mentioned embodiment.
[0087] In addition, the logic instructions in the memory 62 can be implemented in the form of software functional units and stored in a computer-readable storage medium when sold or used as an independent product.
[0088] The memory 62, as a computer-readable storage medium, can be configured to store software programs or computer-executable programs, such as program instructions or modules corresponding to the methods in the embodiments of the present disclosure. The processor 60 executes the software programs, instructions, or modules stored in the memory 62 to perform functional applications and data processing, thereby implementing the methods in the above embodiments.
[0089] The memory 62 may include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data created based on the use of the terminal. Furthermore, the memory 62 may include high-speed random access memory and non-volatile memory. For example, various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, may also be transient storage media.
[0090] The various embodiments in this application are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the description of the terminal and medium embodiments is relatively simple because they are basically similar to the method embodiments. For relevant parts, refer to the partial description of the method embodiments.
[0091] The terminal and medium provided in the embodiments of the present application correspond one-to-one to the method. Therefore, the terminal and the medium also have similar beneficial technical effects to their corresponding methods. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the terminal and the medium will not be repeated here.
[0092] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0093] Of course, those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware (such as a processor, controller, etc.) through a computer program. The program can be stored in a computer-readable storage medium that can be read by a computer. When the program is executed, it can include the processes in the above-described method embodiments. The computer-readable storage medium can be a memory, a magnetic disk, an optical disk, etc.
[0094] It should be understood that the application of the present invention is not limited to the above examples. For those skilled in the art, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A blockchain data query method, characterized in that: The blockchain data query method includes: Receive a historical data query request from a client and obtain a preset block aggregation index; the historical data query request includes: an identifier of a subject to be queried and a time range to be queried, and the preset block aggregation index is composed of a plurality of index blocks including an index block header and an index block body; Based on the index action time range and index write set in the index block header, according to the time range to be queried and the subject identifier to be queried, the target index block of the historical data query request is determined from the preset block aggregation index; the index action time range is used to characterize the time range involved in executing transactions in the blockchain block recorded by the index block; the index write set is composed of the block write set of the blockchain block recorded by the index block; the block write set is composed of the transaction write set in the blockchain block; Based on the index block body of the target index block, according to the time range to be queried and the subject identifier to be queried, determine the target block record corresponding to the historical data query request from the target index block; the index block body is composed of a plurality of block records, and the block record includes: block action time and the block write set; The block ID corresponding to the target block record is sent to the client, so that the client performs an account book query based on the target block corresponding to the block ID to obtain a query result of the historical data query request.
2. The blockchain data query method according to claim 1, characterized in that: The step of determining the target index block of the historical data query request from a preset block aggregation index based on the index action time range and the index write set in the index block header and according to the time range to be queried and the subject identifier to be queried specifically includes: According to the time range to be queried and the index action time range in the index block header, determine an index block in the preset block aggregation index that has an intersection with the time range to be queried as a pending index block for the historical data query request; The subject identifier to be queried is matched with the index write set of the index block header of the pending index block, and the target index block of the historical data query request is determined according to the corresponding matching result.
3. The blockchain data query method according to claim 2 is characterized in that: The index block header further includes: a first Bloom filter; the matching of the subject identifier to be queried with the index write set of the index block header of the pending index block specifically includes: The subject identifier to be queried is matched with the index write set of the index block header of the pending index block through the first Bloom filter of the index block header.
4. The blockchain data query method according to claim 1, characterized in that: The index block body based on the target index block, according to the time range to be queried and the subject identifier to be queried, determines the target block record corresponding to the historical data query request from the target index block, specifically including: Determine the target index block based on the block action time recorded in each block in the index block body of the target index block. The block records in the index block body that have an intersection with the time range to be queried are used as pending block records; The subject identifier to be queried is matched with the block write set in the pending block record, and the target block record of the historical data query request is determined according to the corresponding matching result.
5. The blockchain data query method according to claim 4 is characterized in that: The block record further includes: a second Bloom filter; the matching of the subject identifier to be queried with the block write set in the pending block record specifically includes: The subject identifier to be queried is matched with the block write set in the pending block record through the second Bloom filter in the pending block record.
6. The blockchain data query method according to claim 1, characterized in that: The index action time range is used to characterize the time range involved in the successful execution of transactions in the blockchain block recorded by the index block.
7. The blockchain data query method according to claim 1, characterized in that: The block write set is a key parameter of a key-value pair in a transaction record in the blockchain block, and the key parameter is used to characterize a transaction subject of the transaction record.
8. The blockchain data query method according to claim 1, characterized in that: Before obtaining the preset block aggregation index, the method further includes: For each on-chain block, traverse all transaction records in the on-chain block, and generate the block write set and the block action time according to the transaction records; wherein the on-chain block is used to represent the on-chain blockchain block in the blockchain; The block record is formed based on the block identifier of the on-chain block, the block write set, and the block action time; According to the chaining order of the chained blocks, a preset number of block records of the chained blocks connected continuously are combined into the index block body; Generate the corresponding index block header according to each block record in the index block body; The index block header and the corresponding index block body are combined into the index block, and the index blocks are connected in a preset order to obtain the preset block aggregation index.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in the blockchain data query method as described in any one of claims 1 to 8.
10. A terminal, characterized in that: include: Processor and memory; The memory stores a computer-readable program that can be executed by the processor; when the processor executes the computer-readable program, the steps in the blockchain data query method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Block chain data storage and acquisition method and device based on data index
CN111078711A
Data query method and system
CN111782707A
Data query method and device based on block chain, equipment and storage medium
CN115098510A
Optimizing queries and other retrieve operations in a blockchain
US20190042620A1
Blockchain-based transaction query method, apparatus and device, and blockchain-based transaction data processing method, apparatus and device
WO2021063045A1
Cited By
Block chain data storage method and device and computer equipment
CN119669365A
