Data processing method and apparatus, and computer device and storage medium

By using block prefixes and array structures in the blockchain, the problem of low efficiency of blockchain data query is solved, fast and stable blockchain data query is achieved, query complexity is reduced, and system performance is improved.

WO2025214115A1PCT designated stage Publication Date: 2025-10-16TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/083788
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-04-10
Filing Date
2025-03-20
Publication Date
2025-10-16

AI Technical Summary

Technical Problem

In the existing technology, blockchain data query efficiency is low, especially when the query involves a large number of blocks, the query time will be significantly extended, resulting in performance degradation.

Method used

The block prefix and array structure is adopted to store the prefix sum of block data to achieve fast query of the target block interval in the blockchain, and the characteristics of the prefix and array are used to calculate the sum of data in any interval in constant time.

Benefits of technology

It improves the efficiency of blockchain data query, reduces query complexity, ensures the stability and reliability of the system, and can obtain query results in a constant time regardless of the size of the query interval.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025083788_16102025_PF_FP_ABST
    Figure CN2025083788_16102025_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed in the embodiments of the present invention are a data processing method and apparatus, and a computer device and a storage medium. The method comprises: acquiring a data query request for requesting the query of block data in a blockchain which is located in a target block interval [i, j]; acquiring a block prefix sum array corresponding to the blockchain, wherein the block prefix sum array includes at least one block prefix sum, any block prefix sum is associated with a block height in the blockchain, and any block prefix sum is used for storing block data in a block corresponding to the associated block height and block data in a block corresponding to a block height preceding the associated block height; determining, from the block prefix sum array, a first block prefix sum associated with a block height i-1 and a second block prefix sum associated with a block height j; and on the basis of block data stored in the first block prefix sum and block data stored in the second block prefix sum, generating block data requested by the data query request. Therefore, the efficiency of performing data query on a blockchain can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Data processing method and device, computer device, and storage medium

[0001] The present application claims priority to the Chinese patent application No. 2024104444772, filed on April 10, 2024, and entitled "Data processing method and device, computer device, and storage medium", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD

[0002] The present application relates to the technical field of computers, and in particular to a data processing method and device, a computer device, and a storage medium. BACKGROUND

[0003] Based on the data security and tamper resistance of the blockchain network, more and more data are stored in the form of on-chain storage. However, after the data are stored on-chain, the current query method is to traverse the entire blockchain or rely on external databases for data synchronization to achieve the query. Such a query method is particularly inefficient, and when the query data involve a large number of blocks, the query time will be further lengthened, thereby causing a substantial reduction in the query performance. Therefore, after the data are stored on-chain, how to improve the data query efficiency of the blockchain has become a research hotspot. SUMMARY

[0004] The embodiments of the present application provide a data processing method and device, a computer device, and a storage medium, which can improve the efficiency of data query on the blockchain.

[0005] In one aspect, the embodiments of the present application provide a data processing method, comprising:

[0006] obtaining a data query request, the data query request being used to request to query block data of blocks located in a target block interval [i, j] in a blockchain, i and j being used to indicate block heights, i and j being positive integers and j > i;

[0007] obtaining a block prefix sum array corresponding to the blockchain, the block prefix sum array containing at least one block prefix sum, any block prefix sum being associated with a block height in the blockchain, any block prefix sum being used to store block data of a block corresponding to the associated block height and block data of a block corresponding to a block height before the associated block height;

[0008] determining, from the block prefix sum array, a first block prefix sum associated with the block height i-1 and a second block prefix sum associated with the block height j;

[0009] generating, according to the block data stored in the first block prefix sum and the block data stored in the second block prefix sum, block data requested to be queried by the data query request.

[0010] In still another aspect, an embodiment of the present application provides a data processing apparatus, comprising:

[0011] The obtaining unit is configured to obtain a data query request, the data query request being used to request to query block data in a target block interval [i, j] in a blockchain, i and j being used to indicate block heights, i and j being positive integers and j > i;

[0012] The obtaining unit is further configured to obtain a block prefix sum array corresponding to the blockchain, the block prefix sum array containing at least one block prefix sum, each block prefix sum being associated with a block height in the blockchain, and each block prefix sum being used to store block data of a block corresponding to the associated block height and block data of a block corresponding to a block height before the associated block height;

[0013] The processing unit is configured to determine, from the block prefix sum array, a first block prefix sum associated with the block height i-1 and a second block prefix sum associated with the block height j;

[0014] The processing unit is further configured to generate, according to the block data stored in the first block prefix sum and the block data stored in the second block prefix sum, the block data requested by the data query request.

[0015] In still another aspect, an embodiment of the present application provides a computer device, comprising a processor, an input device, an output device and a memory, the processor, the input device, the output device and the memory being connected to each other, wherein the memory is configured to store a computer program supporting a terminal to execute the above method, the computer program comprising program instructions, and the processor is configured to invoke the program instructions to perform the following steps:

[0016] The obtaining unit is configured to obtain a data query request, the data query request being used to request to query block data in a target block interval [i, j] in a blockchain, i and j being used to indicate block heights, i and j being positive integers and j > i;

[0017] The obtaining unit is further configured to obtain a block prefix sum array corresponding to the blockchain, the block prefix sum array containing at least one block prefix sum, each block prefix sum being associated with a block height in the blockchain, and each block prefix sum being used to store block data of a block corresponding to the associated block height and block data of a block corresponding to a block height before the associated block height;

[0018] The processing unit is configured to determine, from the block prefix sum array, a first block prefix sum associated with the block height i-1 and a second block prefix sum associated with the block height j;

[0019] According to the first block prefix and the stored block data and the second block prefix and the stored block data, the block data requested by the data query request is generated.

[0020] In another aspect, the embodiment of the present application provides a computer readable storage medium, and the computer readable storage medium stores program instructions. When the program instructions are executed by a processor, the program instructions are used to execute the data processing method of the first aspect.

[0021] In another aspect, the embodiment of the present application provides a computer program product, and the computer program product includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, the computer program or computer instructions are used to execute the data processing method of the first aspect.

[0022] In the embodiment of the present application, when the computer device performs data query on the blockchain, the computer device can first acquire a data query request, so as to determine a target block interval in which to-be-queried data is located. In addition, the computer device can also acquire a block prefix and array corresponding to the blockchain, so as to determine a first block prefix sum and a second block prefix sum associated with the target block interval from the block prefix and array based on the target block interval. Based on the determination of the first block prefix sum and the second block prefix sum by the computer device, the computer device can determine data requested by the data query request according to data stored by the first block prefix sum and data stored by the second block prefix sum. Thus, the computer device realizes fast query of block data in different block intervals in the blockchain based on the block prefix and array, and improves the query efficiency of the blockchain data. In addition, the query of the blockchain data based on the block prefix and array enables the computer device to obtain the queried block data in a constant time regardless of the size of the query interval when performing data query, thereby effectively reducing the complexity of the computer device when performing block data query. The effective improvement of the efficiency and the effective reduction of the complexity of the computer device when performing blockchain data query can effectively ensure the stability and reliability of the system for the computer device to perform blockchain data query. BRIEF DESCRIPTION OF DRAWINGS

[0023] FIG. 1a is a schematic diagram of a data sharing system provided by an embodiment of the present application;

[0024] FIG. 1b is a schematic diagram of block data provided by an embodiment of the present application;

[0025] FIG. 1c is a schematic diagram of a data processing system provided by an embodiment of the present application;

[0026] FIG. 2 is a schematic flowchart of a data processing method provided by an embodiment of the present application;

[0027] FIG. 3a is a schematic diagram of a block prefix and an array according to an embodiment of the present application;

[0028] FIG. 3b is a schematic diagram of a block prefix and a block size determination according to an embodiment of the present application;

[0029] FIG. 3c is a schematic diagram of data query based on a target block interval according to an embodiment of the present application;

[0030] FIG. 3d is a schematic diagram of a computer device according to an embodiment of the present application;

[0031] FIG. 4 is a schematic flowchart of a data processing method according to an embodiment of the present application;

[0032] FIG. 5a is a schematic diagram of determining requested query data according to an embodiment of the present application;

[0033] FIG. 5b is another schematic diagram of determining requested query data according to an embodiment of the present application;

[0034] FIG. 5c is a schematic diagram of merging block prefixes according to an embodiment of the present application;

[0035] FIG. 5d is another schematic diagram of merging block prefixes according to an embodiment of the present application;

[0036] FIG. 6a is a schematic diagram of generating a new block as a prefix array according to an embodiment of the present application;

[0037] FIG. 6b is a schematic diagram of merging prefix arrays according to an embodiment of the present application;

[0038] FIG. 7 is a schematic diagram of data query based on a prefix array according to an embodiment of the present application;

[0039] FIG. 8 is a schematic block diagram of a data processing apparatus according to an embodiment of the present application;

[0040] FIG. 9 is a schematic block diagram of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION

[0041] The embodiment of the present application provides a data processing method based on a block chain. A computer device can query block data in a target block interval on a block chain based on a stored block prefix and array, so that the computer device realizes efficient query of block data in the block chain based on the block prefix and array. The computer device is any node device in a block chain network, and the block chain network can be a data sharing system as shown in FIG. 1a. The data sharing system 100 is a system for sharing data between nodes. The system can include multiple nodes, such as the node identified by 101 in FIG. 1a. Any node can be a client in the data sharing system. Each node 101 can receive input information when working normally, and maintain shared data in the data sharing system based on the received input information. The nodes 101 in the data sharing system 100 can share data in different nodes 101 by maintaining a block chain. The block chain is essentially a decentralized database, a series of data blocks associated using a cryptographic method, each data block (or block) containing relevant transaction data. It is a distributed ledger technology in the information technology field, generally including consensus, transaction block, state data storage, and identity security. Since the ledger is distributed and the block is consensus, it has the characteristics of non-tamperability, traceability, and common maintenance. In addition, each block contains quantity information involved in the transaction execution process, such as the total number of transactions and the total amount of Gas (a digital resource). The quantity information involved in each block can include various quantity information as shown in FIG. 1b.

[0042] The block prefix and array involved in the embodiment of the present application applies the prefix and array idea to the block chain technology. The prefix and array is a data structure used to store the cumulative sum of any target sequence, so that the cumulative sum stored in the prefix and array can be used to quickly calculate the total sum of any interval in the target sequence. If the target sequence is arr[], which includes elements from arr[0] to arr[n], n is a positive integer, the cumulative sum of the first i elements of the target sequence is represented by the array prefixSum[], i is a certificate greater than or equal to 0 and less than n, then the cumulative sum of the first i elements of the target sequence is represented as: prefixSum[i] = arr[0] to arr[i], that is, the array prefixSum[] is the prefix and array of the target sequence arr[]. The block prefix and array refers to an array composed of the prefix and of block data.

[0043] The target block interval on the blockchain refers to the interval of blocks corresponding to the block height between two heights. For example, if the target block interval is [2, 5], the target block interval refers to the interval of blocks corresponding to the block height of 2 to the block height of 5. Then, when querying the data on the blockchain in the target block interval based on the block prefix sum array, the block interval sum is queried based on the block prefix sum array. In an embodiment, the block interval sum refers to the sum of a certain data (such as the transaction volume, Gas consumption, transaction number, etc.) of continuous blocks in a certain range in the blockchain. For example, the total transaction volume of the 100th to 200th block is calculated, and so on. Then, when the computer device queries the data in the target block interval on the blockchain based on the block prefix sum array, if the target block interval to be queried is [i, j] and the prefix sum array is represented by the above array prefixSum[], the total amount of data in the target block interval [i, j] can be represented as prefixSum[j]-prefixSum[i-1].

[0044] In an embodiment, since one of the key features of the prefix sum array is that the sum of any interval [i, j] can be calculated in constant time (i.e., the complexity is O(1)), the data processing method in the embodiment can effectively improve the efficiency of the computer device in querying the total amount of data (or the sum of data) in the blockchain, thereby realizing efficient querying of the blockchain data. That is, querying the block interval sum based on the block prefix sum array can improve the effectiveness of the query, and since the query complexity of the prefix sum array is constant, the efficiency of the computer device in performing a large amount of data interval sum and query based on the prefix sum array is significantly improved. Algorithm complexity is a standard for measuring the execution efficiency of an algorithm, which is usually divided into time complexity and space complexity. Time complexity refers to the amount of calculation required to execute an algorithm, and space complexity refers to the storage space required to execute an algorithm. Algorithm complexity is usually represented by the capital letter O (O-notation), for example, algorithm complexity can be represented as O(1), O(n), O(n2), etc. Where n represents the size of the input data, O(1) indicates that the execution time of the algorithm does not increase with the growth of the input data, i.e., constant time complexity, O(n) indicates that the execution time of the algorithm increases linearly with the growth of the input data, and O(n2) indicates that the execution time of the algorithm increases exponentially with the growth of the input data. The algorithm complexity of the block interval sum based on the block prefix sum array in the embodiment is O(1), which means that the time consumption of data query based on such an algorithm is constant time complexity, which is a relatively ideal state.

[0045] When the computer device performs data query in the blockchain based on the block prefix sum and the array, the computer device can determine the corresponding block prefix sum from the block prefix sum and the array based on the target block interval indicated by the data query request after obtaining the data query request, and determine the requested query data based on the determined block prefix sum. In an embodiment, the blockchain-based data processing method can be applied in the data processing system shown in FIG. 1c, which includes a query device 10, i.e., a device where a query user is located, and a computer device 11, which is any node device in the blockchain network. Then, the query device 10 can send a data query request to the blockchain network, so that the computer device 11 can obtain the data query request from the blockchain network and determine the requested query data based on the data query request and the block prefix sum array. The determined requested query data can also be returned to the query device 10. In an embodiment, the query device 10 can be a terminal device, and the computer device can be a terminal device or a server. The terminal device includes but is not limited to a smartphone, a tablet computer, a smart wearable device, a smart voice interaction device, a smart home appliance, a personal computer, a vehicle-mounted terminal, and the like. The number of terminal devices is not limited. The server can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms, and the like. The number of servers is not limited.

[0046] Referring to FIG. 2, FIG. 2 is a schematic flowchart of a blockchain-based data processing method according to an embodiment of the present application. As shown in FIG. 2, the method can include the following steps.

[0047] S201, obtaining a data query request, the data query request being used to request to query block data in the blockchain located in a target block interval [i, j], i and j being used to indicate block heights, i and j being positive integers and j > i.

[0048] S202, obtaining a block prefix sum array corresponding to the blockchain, the block prefix sum array including at least one block prefix sum, any block prefix sum being associated with a block height in the blockchain, any block prefix sum being used to store block data of a block corresponding to the associated block height and block data of a block corresponding to a block height before the associated block height.

[0049] In step S201 and step S202, the computer device queries the block interval and data in the block chain based on the stored block prefix and array. Next, the way of obtaining the block prefix and array corresponding to the block chain is described. In an embodiment, the block prefix and array contains at least one block prefix and, a block prefix and is associated with a block height in the block chain and is used to store the block data of the block corresponding to the associated height and the block data of the block before the associated height. That is, a block prefix and is used to store the block data of the block corresponding to the associated height and the block data of the block before the associated height. The block corresponding to the height refers to the block with the height, and the block height before the associated height can be the block height with an exponential value less than the block height. That is, if a block prefix and in the block prefix and array is associated with a block height of 5, the block prefix and is used to store the block data of the block with a block height of 5 and the block data of the block with a block height before the block height of 5 (i.e., the block with a block height of 1-4). That is, the block prefix and associated with the block height of 5 is used to store the data sum of the block data with a block height of 1-5.

[0050] Based on the generation method of the block prefix and, the computer device can obtain the block prefix and associated with any block height based on the block height in the block chain. In an embodiment, if the block chain contains 5 blocks, the block heights of the 5 blocks are 1-5 respectively, the computer device can generate the block prefix and associated with each block height respectively when generating the block prefix and array corresponding to the block chain, thereby obtaining the block prefix and array corresponding to the block chain. The block chain containing the blocks with block heights of 1-5 and the corresponding prefix and array can be shown in FIG. 3a. In FIG. 3a, the basic block information includes the blocks with block heights of 1-5. It can be understood that block 1 in FIG. 3a is the block with a block height of 1 in the block chain, block 2 is the block with a block height of 2 in the block chain, and so on. The block prefix and information in FIG. 3a represents the block prefix and array corresponding to the block chain. As shown in FIG. 3a, block 1 in the block prefix and array is the block data of the block with a block height of 1 in the block chain (i.e., block 1), and block 1-2 is the block data sum of the blocks with block heights of 1 and 2 in the block chain. The data representation of the block prefix and in the block prefix and array can be described in the same way.

[0051] In one embodiment, the block prefix and and the data of the corresponding block in the blockchain can be stored in the block structure as shown in FIG. 3a, that is, each block prefix and in the block prefix and array can also be stored as a block. In other embodiments, each block prefix and in the block prefix and array can also be stored in other forms, such as a number table, and in the form of a number table, one block prefix and can correspond to one number table, and different block prefix ands can be stored in different number tables to distinguish different block prefix ands. As shown in FIG. 3a, the length of the block interval represented by the block prefix and associated with each block height in the block prefix and array in the blockchain can be as shown in Table 1.

[0052] Table 1

[0053] As shown in FIG. 3a, the data types of the data contained in each block prefix and in the block prefix and array are the same as the data types of the data contained in each block in the blockchain, but the values of the corresponding data are different. Since one block prefix and in the block prefix and array corresponding to the blockchain is used to store the data sum of the block corresponding to the associated block height and the previous block, and the data sum of the previous block of the block height associated with the block prefix and is stored in the previous block prefix and of the block prefix and, when the computer device calculates each block prefix and in the block prefix and array except the first block prefix and, such as the third block prefix and, the computer device can first obtain the block data of the block corresponding to the block height (block height 3) associated with the block prefix and to be calculated (such as the third block prefix and) (assuming the block data is a), and obtain the data stored in the previous block prefix and (i.e., the second block prefix and) of the block prefix and to be calculated (assuming the stored data is b), and then the computer device can determine that the block prefix and to be calculated is the sum of the block data of the associated block height and the data of the previous block prefix and, that is, a+b.

[0054] That is, the data of the block prefix and to be calculated in the block prefix and array is equal to the sum of the data of the current block and the data of the previous block prefix and, where the current block refers to the block corresponding to the block height associated with the block prefix and to be calculated, and the data in the block prefix and includes the data of each data type in FIG. 1b, such as block size, total amount of block transactions, and the like. Taking the block size as an example of the data of the block prefix and, as shown in FIG. 3b, if the blockchain is the blockchain in FIG. 3a, the values of the block size recorded by each block prefix and in the block prefix and array can be as shown in FIG. 3b.

[0055] In the embodiments of the present application, the block data recorded in each block includes data related to the generation of the corresponding block and data related to the transaction data in the block. Different generation processes of different blocks and different execution conditions of transaction data will result in differences in the relevant data recorded in the blocks. In an embodiment, the block data recorded in the block also includes different data types, as shown in FIG. 1b, the block data recorded in the block includes data of the total gas type, data of the total transaction type, data of the block size type, and the like. The computer device includes the same data types in the block prefix and the array when generating the block prefix and the array. Therefore, the computer device obtains the data sum of the data of the same type in the corresponding block when obtaining the data of each type in the block prefix and the array. As shown in FIG. 3a, the total number of block transactions recorded in block 1-3 in the block prefix and array information is the sum of the total number of block transactions in block 1, the total number of block transactions in block 2, and the total number of block transactions in block 3. It is also the sum of the total number of block transactions in block 1-2 and the total number of block transactions in block 3.

[0056] Based on the above generation method of each block prefix and in the block prefix and array, the computer device can query the block interval data in the block chain based on the block prefix and array. In a specific implementation, the computer device can first obtain a data query request, wherein the data query request is used to query the data of the target block interval [i, j] in the block chain, and i and j are used to represent the block height in the block chain and are both positive integers. For example, the target block interval can be [1, 2], which is used to query the sum of the data of the block with the block height of 1 and the block with the block height of 2. If the target block interval is [2, 8], it is used to query the sum of all block data between the block with the block height of 2 and the block with the block height of 8. In addition, the target block interval [i, j] also satisfies j>i. For the case of j=i, [i, j] is used to indicate a block in the block chain, such as [1, 1], which is used to represent the first block in the block chain, and [3, 3] is used to represent the third block in the block chain. The case of i=j also applies to the embodiments of the present application.

[0057] The computer device obtains the data query request from the query device, i.e., the device of the query user. Specifically, the query user can determine the block interval to be queried, and then package and encapsulate the block interval to be queried and the content to be queried, etc. The content to be queried refers to the data type of the data to be queried, such as the total amount of block gas and the total number of block transactions. After the query user completes the packaging and encapsulation, the query user can sign the packaged content, and then send the packaged content and the signature to the blockchain node (i.e., the computer device). The computer device can receive the packaged content and the signature information of the query user, and then perform the verification of the certificate and the signature. After the verification is passed, the computer device obtains the block interval to be queried from the packaged content, and performs the subsequent query process. When the computer device obtains the packaged content and the signature information, the computer device obtains the data query request.

[0058] After the computer device determines the target block interval [i, j] to be queried based on the data query request, the computer device can further obtain the block prefix sum array corresponding to the block chain, so as to obtain the requested block data based on each block prefix sum in the block prefix sum array. In a specific implementation, after the computer device determines the target block interval [i, j] to be queried, the computer device can obtain the block prefix sum array corresponding to the block chain in the sparse table, and then determine the first block prefix sum associated with the block height i-1 and the second block prefix sum associated with the block height j from the obtained block prefix sum array based on the target block interval [i, j]. Then, the computer device generates the requested data based on the determined first block prefix sum and the second block prefix sum, and then performs step S203.

[0059] S203, determining the first block prefix sum associated with the block height i-1 and the second block prefix sum associated with the block height j from the block prefix sum array.

[0060] S204, generating the block data requested by the data query request based on the block data stored in the first block prefix sum and the block data stored in the second block prefix sum.

[0061] In step S203 and step S204, when the computer device determines the block data of the target block interval [i, j] based on the block prefix sum array, the computer device can determine the first block prefix sum associated with the block height i-1 and the second block prefix sum associated with the block height j from the block prefix sum array, and then calculate the difference between the data sums recorded by the two block prefix sums, which can be referred to as the first difference data. The first difference data can be the block data that is more than the block data in the first block prefix sum associated with the block height i-1 in the second block prefix sum associated with the block height j. The first difference data calculated can be the block data requested by the data query request. For the case where i is equal to 1, since i-1 is 0, there is no block prefix sum associated with the block height 0 in the block prefix sum array, that is, the first block prefix sum cannot be obtained. Therefore, when i = 1, the computer device can only obtain the second block prefix sum associated with the block height j, and the block data stored in the obtained second block prefix sum can be the block data requested by the data query request. For the case where i is not equal to 1, i-1 is necessarily greater than 0, so the computer device can obtain the first block prefix sum and the second block prefix sum to obtain the block data requested by the data query request.

[0062] In one embodiment, the computer device determines the requested block data based on the block prefix sum array and the target block interval [i, j] indicated by the data query request, as shown in FIG. 3c. When the data type of the data to be queried is the total amount of block Gas, the computer device specifically performs the following steps ①-⑤.

[0063] ①Obtain the target block interval [5, 14] and the content to be queried as the total amount of block Gas;

[0064] ②Determine two subintervals based on the target block interval, namely [1, 4] and [1, 14], wherein [1, 4] is the left subinterval and [1, 14] is the right subinterval;

[0065] ③Obtain the first block prefix sum corresponding to the left subinterval [1, 4] and obtain the corresponding block Gas total amount 1, i.e., SUM_Gas[1, 4], from the first block prefix sum; and obtain the second block prefix sum corresponding to the right subinterval [1, 14] and obtain the corresponding Gas total amount 2, i.e., SUM_Gas[1, 14], from the second block prefix sum;

[0066] IV. According to the first block prefix and the total block gas amount 1 stored in the prefix sum array, and the second block prefix and the total block gas amount 2 stored in the prefix sum array, difference calculation is performed to obtain the total block gas amount in the interval [5, 14] between the target interval;

[0067] V. The obtained total block gas amount is returned to the querying user as the queried data.

[0068] The block data querying process based on the computer device using the block prefix sum array can be applied to the following application scenarios.

[0069] 1. Financial transaction analysis scenario: In the field of financial services, such as cryptocurrency exchanges or decentralized finance (DeFi) platforms, it is necessary to analyze indicators such as transaction volume, transaction fees (Gas consumption), and user activity in real time. Based on the method provided in the embodiments of the present application, the computer device can quickly determine the cumulative data of a certain historical time period based on the prefix sum array, thereby helping analysts make faster and more accurate transaction decisions.

[0070] 2. Supply chain management scenario: In the supply chain management scenario, enterprises need to obtain transaction records and related data of products from production to transaction. Therefore, the computer device of the enterprise can quickly query the transaction records and related data in a specific time period through the prefix sum array to ensure the transparency and efficiency of the supply chain.

[0071] 3. Data service provider scenario: The computer device corresponding to the data service provider can provide efficient blockchain data querying services using the embodiments of the present application. For example, based on the data stored in the prefix sum array, historical data analysis and reports can be provided for market research and business intelligence.

[0072] 4. Smart contract auditing scenario: A smart contract is a computer protocol designed to disseminate, verify, or execute contracts in an information-based manner, allowing trusted transactions without third parties, and these transactions are traceable and irreversible. Therefore, the security of the smart contract is crucial. When auditors need to analyze the contract behavior of a smart contract in a specific time period, they can use the corresponding computer device and the block prefix sum array in the embodiments of the present application to quickly obtain the historical data of the smart contract execution, thereby helping auditors detect potential security problems of the smart contract.

[0073] 5. Voting and governance system scenario: In a blockchain-based voting and governance system, if it is necessary to count the voting behavior and participation in a specific time period, the computer device can provide these statistical data based on the prefix sum array in the embodiments of the present application, thereby ensuring the transparency and fairness of the governance process.

[0074] 6. Real-time viewing and alarm system scenario: For applications that need to obtain the state of the blockchain network in real time, such as security inspection and abnormal behavior detection systems, the computer device can provide fast data access based on the embodiments of the application, so as to trigger an alarm immediately when an abnormal behavior is detected.

[0075] 7. Blockchain analysis tool scenario: Developers and researchers can develop blockchain analysis tools through the computer device using the embodiments of the application to quickly obtain and analyze various data on the blockchain, thereby improving research efficiency and depth.

[0076] Based on the application of the above different application scenarios of the embodiments of the application, the embodiments of the application have wide applicability in different industries and fields, especially in applications that require efficient and real-time data access and analysis. The characteristics of data acquisition through the embodiments of the application are particularly evident, and therefore, based on the block prefix and array, the performance of processing blockchain data can be significantly improved to provide higher value services to users and enterprises.

[0077] In the embodiments of the application, when the computer device queries data on the blockchain, it can first obtain a data query request, thereby determining the target block interval where the data to be queried is located. In addition, the computer device can also obtain the block prefix and array corresponding to the blockchain, thereby determining the first block prefix sum and the second block prefix sum associated with the target block interval from the block prefix and array based on the target block interval. Based on the determination of the first block prefix sum and the second block prefix sum by the computer device, the computer device can determine the data requested by the data query request according to the data stored in the first block prefix sum and the data stored in the second block prefix sum. Thus, the computer device realizes fast querying of block data in different block intervals in the blockchain based on the block prefix and array, thereby improving the querying efficiency of the blockchain data. Moreover, the querying of the blockchain data based on the block prefix and array enables the computer device to obtain the requested block data within a constant time regardless of the size of the query interval when querying data, thereby effectively reducing the complexity of the computer device when querying block data. The effective improvement of the efficiency and the effective reduction of the complexity of the computer device when querying blockchain data can effectively ensure the stability and reliability of the system for querying blockchain data by the computer device.

[0078] Please refer to FIG. 4, which is a data processing method based on a blockchain provided by an embodiment of the present application. The embodiment of the present application mainly describes the whole cycle process of a high-performance blockchain interval summation query scheme based on multi-level prefix and array storage, which specifically includes the generation process of the block prefix and array corresponding to the blockchain (i.e. the whole process of generating interval prefix and array when a new block is generated by the blockchain), the merging process of the block multi-level prefix and array corresponding to the blockchain (i.e. the merging and refreshing process of the new block prefix and array storage to the historical block prefix and array storage), and the query process of the block interval multi-level prefix and array (i.e. the query interaction process of the user querying the sum of the block interval to the blockchain), as shown in FIG. 4. The method can include:

[0079] S401, the query device obtains query information, and the query information includes a target block interval where the data to be queried is located and a data identifier of the data to be queried.

[0080] S402, the query device performs signature processing on the query information, and sends the signed query information as a data query request to the blockchain.

[0081] S403, a data query request is obtained, and the data query request is used to request to query the block data located in the target block interval [i, j] in the blockchain, i and j are both used to indicate the block height, i and j are both positive integers and j>i.

[0082] In steps S401-S403, the data query request obtained by the computer device is obtained from the blockchain network after being sent to the blockchain network by the query device. When the query device sends the data query request to the blockchain network, it can first obtain the query information, that is, the target block interval to be queried and the data identifier of the data to be queried (i.e. the content to be queried), and then the query device can perform signature processing on the query information and send the signed query information as a data query request to the blockchain network. After the network module in the blockchain node receives the data query request, it can perform verification processing on the data query request, and perform data query processing based on the block interval contained in the data query request after determining that the verification is passed. In an embodiment, the blockchain node mentioned above for verifying the data query request is the computer device, and the network module in the blockchain node is the network module in the computer device. When the blockchain node verifies the data query request, it includes two verification processes, which are: verifying the signature information contained in the data query request and verifying the certificate of the signature information. Through the two verification processes, the computer device can effectively ensure the safety and reliability of the source of the obtained data query request, thereby effectively avoiding the leakage of data in the blockchain, and achieving the guarantee of the security of the data in the blockchain.

[0083] In one embodiment, after the computer device obtains the data query request from the blockchain network, the computer device can perform signature verification processing on the data query request, and obtain the query suspension information of the block prefix and array when the signature verification passes; wherein the query suspension information is used to indicate whether the obtained block prefix and array supports obtaining the stored data, therefore, after obtaining the query suspension information, the computer device can trigger the steps of determining the first block prefix and array associated with the block height i-1 and the second block prefix and array associated with the block height j from the block prefix and array when the query suspension information indicates that the block prefix and array has not suspended the query, that is, to execute step S404. If the query suspension information obtained by the computer device indicates that the block prefix and array has suspended the query, the computer device can store the obtained data query request in the query waiting queue, and reobtain the data query request from the query waiting queue when the block prefix and array starts to support the query, and perform data query processing in combination with the block prefix and array.

[0084] Wherein, the process of the computer device (i.e. the blockchain node) performing data query on the blockchain is the process of the computer device performing high-performance blockchain inter-block summation query in the blockchain network, that is, the computer device is a system for performing high-performance blockchain inter-block summation query in the blockchain network, therefore, in addition to the network module mentioned above, the computer device also includes several other processing modules, which can be specifically shown in FIG. 3d. Next, the internal implementation of the computer device, the processing modules contained therein, and the interaction between the modules will be described in combination with FIG. 3d:

[0085] 1) Network module.

[0086] The network module is responsible for processing communication between different nodes in the blockchain, including data transmission, reception and broadcast. Through the network module, each node can send and receive transactions, blocks and other important information in the blockchain network. In addition, the network module is also responsible for processing network connection, node discovery and data synchronization in the blockchain.

[0087] 2) Verification module.

[0088] The verification module is the security line of the blockchain node, and includes two sub-modules:

[0089] ① Certificate verification module: responsible for verifying the digital signature of transactions and blocks to ensure the integrity of data and the credibility of the source.

[0090] ② Permission verification module: responsible for checking whether the user or node initiating the request has the corresponding permission to perform specific operations, such as submission of transactions or data query, etc.

[0091] 3) Transaction Pool module.

[0092] Transaction Pool (also known as mem pool) is a data structure in a blockchain network, which is used to store pending transactions that have not yet been packaged into a block. When a user submits a new transaction to the blockchain network, the transaction will first enter the transaction pool. When a blockchain node is preparing to generate a new block, it will select a certain number of transactions from the transaction pool for packaging. The transaction pool helps to improve the processing capacity of the blockchain network, and also serves as a strategy to prioritize transactions with higher fees for packaging, thereby increasing the number of virtual resources obtained from packaging blocks. The transaction pool module is then used to manage all transactions that have not yet been packaged into a block, and can be responsible for receiving, verifying and storing these transactions until they are included in a new block. In addition, the module can also be responsible for the sorting and selection process of transactions to optimize the construction of blocks.

[0093] 4) Query module.

[0094] The query module is a core module involved in the embodiments of the present application, which includes multiple sub-modules and is specifically responsible for the range maximum / minimum value query. The sub-modules included in the query module include:

[0095] ① Block prefix sum array storage module: responsible for storing the calculated prefix sum array to quickly respond to range sum queries. The block prefix sum array storage module further includes a historical prefix sum array storage module, a new block prefix sum array storage module (or current prefix sum array storage module), and a pre-stored new block prefix sum module.

[0096] The historical prefix sum array storage module is used to store the prefix sum array of historical block data for long-term queries; the new block prefix sum array storage module is used to store the prefix sum array of recent block data for quick queries; and the pre-stored new block prefix sum module is used to temporarily store the prefix sum data of a new block, waiting to be merged into the new block prefix sum array storage. The temporarily stored prefix sum data of the new block does not support query processing, and only provides query services after being merged into the new block prefix sum array or the historical prefix sum array.

[0097] ② Block prefix sum array generation module: responsible for generating the prefix sum array of a new block.

[0098] ③ Block prefix sum array merging module: responsible for merging the new block prefix sum array into the historical prefix sum array.

[0099] ④ Block prefix sum array query module: responsible for handling prefix sum array query requests, calculating and returning range sum results.

[0100] 5) Scheduling Module.

[0101] The scheduling module is responsible for coordinating the activities of the blockchain nodes, which includes:

[0102] ① Block Generator: responsible for creating new blocks, including selecting transactions, executing transactions, and building block structures.

[0103] ② Transaction Scheduling Module: used to manage the execution order and priority of transactions.

[0104] ③ Contract Repository: used to store the code and related data of smart contracts.

[0105] ④ Contract Process Pool: used to manage the execution environment and resource allocation of smart contracts.

[0106] 6) Consensus Module.

[0107] The consensus module is used to implement the consensus algorithm of the blockchain, mainly responsible for reaching agreement among the nodes of the blockchain network, verifying and confirming the validity of transaction blocks, and this module is the key part of the security and decentralization of the blockchain.

[0108] 7) Storage Module.

[0109] The storage module is used to persistently save all data of the blockchain, including the following two sub-modules:

[0110] ① State Database: used to store the current state of the blockchain, such as the remaining electronic resources of accounts, the state of smart contracts, etc. Among them, state data is a data structure used to represent the current state of the system in the blockchain system, including the remaining electronic resources of all accounts, the state of smart contracts and other related information, state data is constantly updated with the execution of transactions, reflecting the global state of the blockchain system at a certain point in time, in the blockchain system, state data is usually stored in the form of Merkle tree or other cryptographic data structure to ensure its integrity and security.

[0111] ② Block Ledger: used to store the confirmed history of the blockchain, including all blocks and transaction records. Among them, the block ledger is the core data structure in the blockchain system, used to store and manage all confirmed blocks, the block ledger is organized in a chain structure, each block contains a set of transactions, block header (including the hash value of the previous block, timestamp and other metadata) and other information, the block ledger provides a public, tamper-proof transaction history record for the blockchain system, ensuring the transparency and consistency of the system.

[0112] It can be understood that the above modules work together to ensure that the blockchain node (i.e., the computer device) can efficiently and securely process and store transaction data and provide fast query services. Moreover, based on this modular design, the computer device can be flexibly adapted to different blockchain network requirements, thereby achieving the scalability and maintainability of the embodiments of the present application.

[0113] S404, obtaining a block prefix sum array corresponding to the blockchain, the block prefix sum array including at least one block prefix sum, each block prefix sum being associated with a block height in the blockchain, each block prefix sum being used to store block data of a block corresponding to the associated block height and block data of a block corresponding to a block height before the associated block height.

[0114] S405, determining a first block prefix sum associated with the block height i-1 and a second block prefix sum associated with the block height j from the block prefix sum array.

[0115] S406, generating block data requested by the data query request according to the block data stored in the first block prefix sum and the block data stored in the second block prefix sum.

[0116] In steps S404-S406, after the computer device obtains the data query request, it can further obtain the block prefix sum array corresponding to the blockchain, and when it is determined that the block prefix sum array supports the query service, it can determine the first block prefix sum and the second block prefix sum from the block prefix sum array based on the target block interval indicated by the data query request, to determine the block data requested by the data query request based on the determined first block prefix sum and second block prefix sum. In an embodiment, the block prefix sum array corresponding to the blockchain can be a multi-level prefix sum array, which is an extension of the prefix sum array and stores prefix sums at different levels to adapt to different granularity query requirements. For example, the first level can store data of each block, the second level can store a total of data of every 10 blocks, the third level can store a total of data of every 100 blocks, and so on. Using this structure, the most suitable level can be selected for querying according to the size of the query interval, thereby optimizing the query efficiency. In the embodiments of the present application, the multi-level prefix sum array mainly includes a historical prefix sum array and a current prefix sum array (or a new prefix sum array, a newer prefix sum array), wherein the historical prefix sum array includes at least one historical block prefix sum and is stored in a persistent cache, and the current prefix sum array includes at least one current block prefix sum and is stored in a temporary cache.

[0117] In one embodiment, when the computer device determines the first block prefix sum associated with block height i-1 and the second block prefix sum associated with block height j from the block prefix sum array, if the maximum block height determined from the block heights associated with the current block prefix sums of the current prefix sum array is greater than or equal to i and the maximum block height determined from the block heights associated with the historical block prefix sums of the historical prefix sum array is greater than or equal to j, it means that the block data of the target block interval [i, j] are stored in both the current prefix sum array and the historical prefix sum array. In this case, the computer device can determine the current block prefix sum associated with block height i-1 from the current prefix sum array in the temporary cache as the first block prefix sum, and determine the historical block prefix sum associated with block height i-1 from the historical prefix sum array in the persistent cache as the second block prefix sum, and further determine the block data requested by the data query request based on the first block prefix sum and the second block prefix sum.

[0118] In another implementation, when the computer device determines the first block prefix sum associated with block height i-1 and the second block prefix sum associated with block height j from the block prefix sum array, it can first determine the minimum block height and the maximum block height from the block heights associated with the current block prefix sums of the current prefix sum array, and the maximum block height can be referred to as the second maximum block height. If the computer device determines that the minimum block height is greater than or equal to i and the second maximum block height is greater than or equal to j, it means that the block data of the target block interval [i, j] are stored in the current prefix sum array. In this case, the computer device can determine the current block prefix sum associated with block height i-1 from the current prefix sum array in the temporary cache as the first block prefix sum, and determine the current block prefix sum associated with block height j from the current prefix sum array in the temporary cache as the second block prefix sum, and further determine the block data requested by the data query request based on the first block prefix sum and the second block prefix sum.

[0119] When the first block prefix sum and the second block prefix sum are both determined from the historical prefix sum array or both determined from the current prefix sum array, the computer device can first obtain the total sum of the block data stored in the first block prefix sum and the total sum of the block data stored in the second block prefix sum, and then calculate the difference data between the block data stored in the first block prefix sum and the block data stored in the second block prefix sum, when generating the block data requested by the data query request according to the data stored in the first block prefix sum and the block data stored in the second block prefix sum.

[0120] In one embodiment, the multi-level prefix sum array can be as shown in FIG. 5a, the historical prefix sum array contained in the multi-level prefix sum array is used to record each prefix sum corresponding to the block height of 1 to 100 in the block chain, and the current prefix sum array is used to record each prefix sum corresponding to the block height of 101 to 120 in the block chain. Then based on the above process of performing data query on the first block prefix sum and the second block prefix sum, combined with FIG. 5a, if the target block interval obtained by the computer device is [10, 20], then the computer device can determine that the block data of the target block interval is all recorded in the historical prefix sum array based on the target block interval [10, 20], therefore, the computer device can obtain the historical block 1-10 in the historical prefix sum array as the first block prefix sum and obtain the historical block 1-20 as the second block prefix sum based on the target block interval [10, 20], so as to obtain the difference between the total sum of the data recorded in the historical block 1-10 and the total sum of the data recorded in the historical block 1-20 as the data obtained by the query. In another implementation manner, if the target block interval obtained by the computer device is [102, 110], then the computer device can determine that the block data of the target block interval is all recorded in the current prefix sum array based on the target block interval [102, 110], therefore, the computer device can obtain the current block 101-102 in the current prefix sum array as the first block prefix sum and obtain the current block 101-110 as the second block prefix sum based on the target block interval [102, 110], so as to obtain the difference data between the total sum of the data recorded in the current block 101-102 and the total sum of the data recorded in the current block 101-110 as the block data obtained by the query.

[0121] In one embodiment, if the computer device determines, after determining the maximum block height (e.g., the first maximum block height) from the historical block prefix sums and the associated block heights of the historical block prefix sums of the historical prefix sum array, that the determined first maximum block height is greater than or equal to i and less than j, it means that the block data of the target block interval [i, j] is stored in the historical block prefix sums of the historical prefix sum array and the current block prefix sums of the current prefix sum array, respectively. In this case, the computer device needs to determine the first block prefix sum and the second block prefix sum from the historical prefix sum array and the current prefix sum array, respectively. In a specific implementation, since the first maximum block height determined from the historical prefix sum array is greater than or equal to i, it means that the prefix sum associated with the block height i-1 is a historical block prefix sum, and since the first maximum block height determined from the historical prefix sum array is less than j, it means that the block prefix sum associated with the block height j is a current block prefix sum. Therefore, the computer device can determine the historical block prefix sum associated with the block height i-1 from the historical prefix sum array in the persistent cache as the first block prefix sum, and determine the current block prefix sum associated with the block height j from the current prefix sum array in the temporary cache as the second block prefix sum.

[0122] When the first block prefix sum and the second block prefix sum obtained by the computer device are obtained from the historical prefix sum array and the current prefix sum array, respectively, when generating the block data requested by the data query request according to the block data stored in the first block prefix sum and the block data stored in the second block prefix sum, the computer device can first obtain the total sum of the block data stored in the historical block prefix sum associated with the first maximum block height, the total sum of the block data stored in the first block prefix sum, and the total sum of the block data stored in the second block prefix sum. Then, the computer device can calculate the difference value between the total sum of the block data stored in the historical block prefix sum associated with the first maximum block height and the total sum of the block data stored in the first block prefix sum, which can be referred to as the second difference value. The second difference value can be the block data in the historical block prefix sum associated with the first maximum block height that is more than the block data stored in the first block prefix sum. The computer device can also obtain the total sum of the block data stored in the second block prefix sum. Then, the computer device can take the second difference value and the total sum of the block data stored in the second block prefix sum as the block data requested by the data query request. The requested block data includes the second difference value and the block data stored in the second block prefix sum.

[0123] In an embodiment, if the multi-level prefix sum arrays are as shown in FIG. 5b, the prefix sums corresponding to the block heights 1-100 in the blockchain are recorded in the historical prefix sum array, and the prefix sums corresponding to the block heights 101-120 in the blockchain are recorded in the current prefix sum array. Then, if the target block interval obtained by the computer device is [90, 110], the computer device can determine that the block data of the target block interval is recorded in the historical prefix sum array and the current prefix sum array respectively based on the target block interval [90, 110]. Therefore, the computer device can obtain the historical block prefix sum 1-89 in the historical prefix sum array as the first block prefix sum and obtain the current block 101-110 as the second block prefix sum based on the target block interval [90, 110]. Then, when determining the block data requested by the data query request, the computer device can obtain the total sum of the block data stored in the historical block prefix sum with the largest block height associated, that is, the total sum of the data recorded in the historical block 1-100, and obtain the first difference value Δ1 based on the total sum of the data recorded in the historical block 1-100 and the total sum of the data recorded in the historical block 1-89, that is, the total sum of the data in the block interval [90, 100]. In addition, the computer device can also obtain the total sum of the block data stored in the second block prefix sum, that is, the total sum of the data recorded in the current block 101-120, and then the computer device can take Δ1 and Δ2 as the block data requested by the data query request.

[0124] In an embodiment, since the historical prefix sum array is stored in the persistent cache and the current prefix sum array is stored in the temporary cache, the response efficiency of the temporary cache to the query request is relatively high. Therefore, based on the divided cache manner of the historical prefix sum array and the current prefix sum array in the embodiment of the present application, the efficiency of the computer device in querying data based on the prefix sum array can be effectively improved. At the same time, the embodiment of the present application also provides a merging manner of the historical block prefix sum in the historical prefix sum array and the current block prefix sum in the current prefix sum array, so that the historical prefix sum array and the current prefix sum array can be constantly refreshed to ensure the timely storage of the current block prefix sum in the current prefix sum array, effectively ensuring the continuity of the stored prefix sum data, and improving the reliability and integrity of the block data queried by the computer device based on the prefix sum array.

[0125] In the multi-level block prefix and array structure, the updating of the historical prefix sum array and the current prefix sum array is generated when the merging opportunity arrives. Specifically, the current block prefix sum in the current prefix sum array is merged into the historical prefix sum array as a historical prefix sum when the merging opportunity arrives, and the current prefix sum array also receives the prefix sum of the newly arrived block as a current block prefix sum. The merging opportunity includes the arrival of a preset time threshold, or the arrival of a quantity threshold of blocks contained in the current prefix sum array, and the like. When the merging opportunity arrives, the merging process of the historical prefix sum array and the current prefix sum array can be as shown in FIGS. 5c and 5d.

[0126] In an embodiment, the block prefix sum of the new block received by the current prefix sum array is the pre-stored block prefix sum. When the computer device determines that there is a new block in the block chain, the computer device can first obtain a target block that has completed consensus processing and a pre-stored prefix sum array. Then, the computer device can further determine whether there is a pre-stored block prefix sum in the pre-stored prefix sum array. If it is determined that there is no pre-stored block prefix sum in the pre-stored prefix sum array, the block data of the target block can be stored as the first pre-stored block prefix sum in the pre-stored prefix sum array. If the computer device determines that there is a pre-stored block prefix sum in the pre-stored prefix sum array, the computer device can obtain the pre-stored block prefix sum with the largest associated block height from the pre-stored prefix sum array, obtain the block data stored by the pre-stored block prefix sum with the largest associated block height, and further perform merging processing on the obtained block data (i.e., the block data stored by the pre-stored block prefix sum with the largest associated block height) and the block data of the target block, and store the merging-processed block data as a new pre-stored block prefix sum in the pre-stored prefix sum array.

[0127] In an embodiment, neither the pre-stored block prefix sum nor the pre-stored prefix sum array provides a query service to the outside, so that the pre-stored block prefix sum can only realize the query function after being merged into the current prefix sum array, and each pre-stored block prefix sum in the pre-stored prefix sum array can also be merged into the current prefix sum array when the merging opportunity arrives. In a specific implementation, the computer device can obtain the total sum of the pre-stored block prefix sums contained in the pre-stored prefix sum array, so that the pre-stored prefix sum array can be merged into the current prefix sum array when the total sum meets a preset threshold. After the computer device merges the pre-stored prefix sum array into the current prefix sum array, each pre-stored prefix sum in the pre-stored prefix sum array is the current prefix sum in the current prefix sum array.

[0128] Next, in combination with FIG. 6a, the process of storing the target block into the pre-stored prefix sum array and subsequently merging it into the current prefix sum array and the historical prefix sum array after determining the existence of a new target block in the blockchain by the computer device as a blockchain node in the blockchain is described. When the computer device executes the flow, the following steps are mainly involved:

[0129] s10, consensus storage is performed on the new target block, and the block data in the new block is obtained, including the total amount of Gas, block size, block transaction quantity, etc.

[0130] s11, it is determined whether there is a pre-stored block prefix sum in the current pre-stored prefix sum array. If it is determined that there is, step s13 is executed, otherwise step s12 is executed.

[0131] s12, the block data in the target block is stored in the pre-stored block prefix sum, and is taken as the first pre-stored block prefix sum in the pre-stored prefix sum array.

[0132] s13, the latest pre-stored block data is obtained from the pre-stored prefix sum array.

[0133] s14, the latest pre-stored block data is summed with the block data of the current target block.

[0134] s15, the summed data is taken as a new pre-stored block prefix sum and stored in the pre-stored prefix sum array.

[0135] s16, it is determined whether the number of pre-stored block prefix sums contained in the current pre-stored prefix sum array reaches a threshold value, and step s17 is executed when it is determined that the threshold value is reached.

[0136] s17, when it is determined that the threshold value is reached, it is determined that the query service can be provided externally, and the pre-stored block prefix sum is merged into the current prefix sum array for storage, in order to prepare to provide efficient and fast query service.

[0137] s18, each current block prefix sum in the current prefix sum array (or new prefix sum array) is merged into the historical block prefix sum array, in order to prepare to provide query service.

[0138] For each current block prefix sum in the current prefix sum array and each historical block prefix sum in the historical prefix sum array, when the computer device merges each current block prefix sum in the current prefix sum array into the historical prefix sum array, the computer device can detect a triggering operation of the merging process of the historical prefix sum array and the current prefix sum array, obtain a historical block prefix sum with the largest block height associated from the historical prefix sum array; then, the computer device can obtain the total block data stored in the historical block prefix sum with the largest block height associated, and merge the obtained total block data into the current prefix sum array to obtain an adjusted prefix sum array; and then, the computer device can store the adjusted prefix sum array into the persistent cache where the historical prefix sum array is located. The triggering operation includes an operation of detecting that the number of current block prefix sums contained in the current prefix sum array reaches a number threshold. When the computer device detects the triggering operation of the merging process of the historical prefix sum array and the current prefix sum array, the computer device can also pause the data query process based on each current block prefix sum in the current prefix sum array.

[0139] In one embodiment, the specific process of the computer device for merging the pre-stored prefix sum into the current prefix sum array and merging the current block prefix sum in the current prefix sum array into the historical interval prefix sum can be as shown in FIG. 6b, and specifically includes the following processes:

[0140] 1. When the blockchain node determines that each new block prefix sum (i.e., the current block prefix sum) in the new prefix sum array (i.e., the current prefix sum array) is ready to be merged, the blockchain node determines that the data stored in the current block prefix sum needs to be adjusted.

[0141] 2. The storage content of the new prefix sum array needs to be changed, and the query service provided to the outside is paused, while the data stored in the historical prefix sum array does not change, and thus the query service of the historical prefix sum array does not need to be paused.

[0142] 3. The historical prefix sum array storage directly merges the old new block prefix sum array storage;

[0143] 4. Since the merged prefix sum does not contain the block data stored in the historical prefix sum, the blockchain node first determines the block data S of each dimension stored in the historical prefix sum corresponding to the maximum block height in the historical prefix sum array, i.e., the historical total sum.

[0144] 5. The data of the historical total sum is appended to the new block prefix sum stored after the historical prefix sum array storage, and the block height is incremented.

[0145] 6. The values stored in all new block prefix sum arrays are updated, and the starting block height is uniformly set to 1, and the values of each dimension are added by the S values of each dimension to obtain an adjusted prefix sum array.

[0146] 7. The historical block prefix and array storage is merged and supplemented to complete, and the pre-stored new block prefix and is converted into a new block prefix and array storage;

[0147] 8. The new block prefix and array storage is re-provided to query services.

[0148] Based on the above merging process, the current prefix and array and the historical prefix and array can be continuously updated. Since the current prefix and array is stored in the temporary cache, and the historical prefix and array is stored in the persistent cache, it can be understood that the update of the current prefix and array can update the block prefix and data stored in the temporary cache, and the update of the historical prefix and array can update the block prefix and data in the persistent cache, that is, the computer device realizes the periodic update processing of the temporary cache and the persistent cache. Based on the periodic update processing of the temporary cache and the persistent cache, the timeliness of the data stored in the temporary cache and the persistent cache can be guaranteed, and the reliability and accuracy of the computer device in obtaining data from the temporary cache and the persistent cache can be guaranteed.

[0149] Based on the storage of the current prefix and array and the historical prefix and array by the computer device, the computer device realizes a storage mode of hierarchical cache and persistent storage cooperation. Based on the storage mode, the computer device can realize a fast access strategy of blockchain data, so that the computer device can optimize the interval summation query process of the blockchain by combining the memory cache and the persistent storage. In the access strategy, the prefix and array of the new block is first stored in the cache to quickly respond to the query request of the recent block, and over time, the data is intelligently merged into the historical prefix and array of the persistent storage, thereby providing support for longer time range queries. The computer device adopts this hierarchical data management method, which not only improves the query efficiency of the computer device, but also ensures the persistence and integrity of the data, and optimizes the use efficiency of the storage space of the computer device. By intelligently merging and updating the prefix and array, the mechanism ensures the real-time performance of the data and the efficiency of the query, reduces the dependence on external databases, and improves the self-sufficiency and stability of the blockchain system.

[0150] The update processing of the computer device on the temporary cache and the persistent cache makes the computer device reliable and fast when obtaining the block interval data from the temporary cache and the persistent cache, so that the computer device realizes high-performance block chain interval summation based on multi-level prefix and array storage. When the computer device realizes interval summation based on multi-level prefix and array storage, the system architecture shown in FIG. 3d can also be used, wherein the system architecture of the computer device includes a network module, a verification module, a transaction pool module, a query module, a scheduling module, a consensus module, and a storage module. The following describes the process of obtaining block interval data based on temporary cache and persistent cache of the computer device as a block chain node according to each processing module included in the computer device, which specifically performs the following steps:

[0151] s10, the query user packs and encapsulates the block interval to be queried (i.e., the target block interval), the query content, etc., and performs signature processing on the packed content;

[0152] s11, the signature and the packed content are sent to the block chain node (i.e., the computer device);

[0153] s12, the network module of the block chain node receives the above information and determines that the data query request is obtained;

[0154] S13, the block chain node performs certificate and signature verification, and when the verification is passed, step s15 is performed, and when the verification is not passed, step s14 is started;

[0155] s14, the result of the signature verification not passing is returned to the query user;

[0156] s15, the authentication module in the computer device is used to perform authority verification on the above data query request to determine whether the query user has the authority to obtain block interval data from the block chain, and when it is determined that there is no authority, step s16 is performed, and when it is determined that the query user has the authority to obtain data, step s17 is performed;

[0157] s16, the result of the authority verification not passing is returned to the query user;

[0158] s17, the computer device calls the block prefix sum array through the query module for querying;

[0159] s18, it is determined whether the block prefix sum array providing the query service has stopped the query access service; if it is determined that the block prefix sum array has stopped the query access service, step s19 is performed; if it is determined that the block prefix sum array has not stopped the query access service, step s20 is performed;

[0160] s19, the data query request is stored in a waiting queue, and the data query request is stored in the waiting queue until the block prefix sum array to be queried provides the query access service again.

[0161] s20, the computer device determines whether the target query interval falls in the historical block prefix sum array or the new block prefix sum array through the data query request by the block prefix sum and array query module;

[0162] s21, if it is determined that the target query interval falls in the historical block prefix sum array or the new block prefix sum array, the block prefix sum and array query module obtains the start block height i and the end block height j corresponding to the interval;

[0163] s22, the block prefix sum and array query module obtains the block prefix sum corresponding to the start block height i and the end block height i-1 of the prefix sum array falling in the interval;

[0164] s23, the block prefix sum and array query module obtains the block prefix sum corresponding to the start block height i and the end block height j of the prefix sum array falling in the interval; and returns the obtained block prefix sum to the query user to obtain the queried block data;

[0165] s24, if it is determined that the target query interval does not fall in the historical block prefix sum array or the new block prefix sum array, the block prefix sum and array query module determines the interval sum stored in the new block prefix sum array based on the target block interval;

[0166] s25, the block prefix sum and array query module determines the interval sum stored in the historical block prefix sum array based on the target block interval.

[0167] s26, the sum of the two interval sums is calculated;

[0168] s27, the obtained interval sum is returned to the query user to obtain the queried block data.

[0169] Through the multi-level prefix sum array built in the block chain, the computer device can realize instant and efficient interval sum query of the block chain data, significantly improve the query performance of the computer device on the block chain, reduce the system dependence, enhance the data real-time performance and system stability, and provide strong data support for financial analysis, supply chain tracking and other fields, thereby promoting the wide application and value maximization of the block chain technology. Among them, the system architecture of the computer device is the running basis of the whole environment, and the block chain block prefix sum array structure, the block chain block prefix sum array storage method and calculation process, the block chain block prefix sum array query process, the multi-level block prefix sum array query process, and the multi-level block prefix sum array merging and updating process are all based on the system architecture. It can be understood that the above-mentioned implementation and system architecture ensure the efficient and stable operation of the system.

[0170] In the embodiment of the present application, after obtaining the query information, the query device can perform signature processing on the query information, and send the signed query information as a data query request to the blockchain network, and the computer device can obtain the data query request from the blockchain network, and determine the target block interval to be queried based on the data query request. In addition, the blockchain also corresponds to a block prefix and array, and the block prefix and array is stored in a hierarchical cache and persistent storage cooperative storage mode. Therefore, after determining the target block interval, the computer device can determine the corresponding block prefix and from the current prefix and array and the historical prefix and array based on the target block interval, and then determine the block data requested to be queried based on the determined block prefix and. Due to the hierarchical storage form of the block prefix and array in the blockchain, the computer device can quickly obtain the corresponding block prefix and from the stored prefix and array, thereby enabling the computer device to quickly respond to the queried block data and improving the efficiency of data query.

[0171] Based on the description of the above data processing method embodiment, the embodiment of the present application further proposes a data processing device, which can be a computer program (including program code) running in the above computer device. The data processing device can be used to execute the data processing methods of FIGS. 2 and 4. Please refer to FIG. 8, the data processing device includes an acquisition unit 801 and a processing unit 802.

[0172] The acquisition unit 801 is configured to acquire a data query request, and the data query request is used to request to query the block data of the target block interval [i, j] in the blockchain, wherein i and j are used to indicate the block height, and i, j are positive integers and j>i;

[0173] The acquisition unit 801 is further configured to acquire the block prefix and array corresponding to the blockchain, wherein the block prefix and array includes at least one block prefix and, any block prefix and is associated with a block height in the blockchain, and any block prefix and is used to store the block data of the block corresponding to the associated block height and the block data of the block corresponding to the block height before the associated block height;

[0174] The processing unit 802 is configured to determine a first block prefix and associated with the block height i-1 and a second block prefix and associated with the block height j from the block prefix and array;

[0175] The processing unit 802 is further configured to generate the block data requested to be queried by the data query request according to the block data stored in the first block prefix and and the block data stored in the second block prefix and.

[0176] In one embodiment, the array of block prefix sums includes a historical array of block prefix sums, the historical array of block prefix sums including at least one historical block prefix sum and being stored in the persistent cache; and the processing unit 802 is specifically configured to:

[0177] determine a first maximum block height from the block heights associated with the historical block prefix sums in the historical array of block prefix sums;

[0178] if the first maximum block height is greater than or equal to j, determine, as the first block prefix sum, a historical block prefix sum associated with block height i-1 from the historical array of block prefix sums in the persistent cache, and determine, as the second block prefix sum, a historical block prefix sum associated with block height j from the historical array of block prefix sums in the persistent cache.

[0179] In one embodiment, the array of block prefix sums includes a current array of block prefix sums, the current array of block prefix sums including at least one current block prefix sum and being stored in the temporary cache; and the processing unit 802 is specifically configured to:

[0180] determine a minimum block height and a second maximum block height from the block heights associated with the current block prefix sums in the current array of block prefix sums;

[0181] if the minimum block height is greater than or equal to i and the second maximum block height is greater than or equal to j, determine, as the first block prefix sum, a current block prefix sum associated with block height i-1 from the current array of block prefix sums in the temporary cache, and determine, as the second block prefix sum, a current block prefix sum associated with block height j from the current array of block prefix sums in the temporary cache.

[0182] In one embodiment, the processing unit 802 is specifically configured to:

[0183] calculate a first difference data between the block data stored in the first block prefix sum and the block data stored in the second block prefix sum;

[0184] use the first difference data as the block data requested to be queried by the data query request.

[0185] In one embodiment, the array of block prefix sums further includes a current array of block prefix sums, the current array of block prefix sums including at least one current block prefix sum and being stored in the temporary cache; and the processing unit 802 is further configured to: if the first maximum block height is greater than or equal to i and less than j, determine, as the first block prefix sum, a historical block prefix sum associated with block height i-1 from the historical array of block prefix sums in the persistent cache, and determine, as the second block prefix sum, a current block prefix sum associated with block height j from the current array of block prefix sums in the temporary cache.

[0186] In one embodiment, the processing unit 802 is specifically configured to:

[0187] calculate second difference data between the block data stored in the historical block prefix and associated with the first maximum block height and the block data stored in the first block prefix;

[0188] query the block data stored in the second block prefix and the second difference data as the block data requested by the data query request.

[0189] In one embodiment, the obtaining unit 801 is configured to obtain a target block which has completed consensus processing and a pre-stored prefix and array;

[0190] The processing unit 802 is further configured to determine whether there is a pre-stored block prefix and in the pre-stored prefix and array, and if there is no pre-stored block prefix and in the pre-stored prefix and array, store the block data of the target block as the first pre-stored block prefix and in the pre-stored prefix and array.

[0191] In one embodiment, the processing unit 802 is further configured to, if there is a pre-stored block prefix and in the pre-stored prefix and array, obtain a pre-stored block prefix and with the largest associated block height from the pre-stored prefix and array.

[0192] The processing unit 802 is further configured to perform merging processing on the block data stored in the pre-stored block prefix and with the largest associated block height and the block data of the target block, and store the merging-processed block data as a new pre-stored block prefix and in the pre-stored prefix and array.

[0193] In one embodiment, the processing unit 802 is further configured to obtain a total sum of the number of pre-stored block prefix and s contained in the pre-stored prefix and array.

[0194] The processing unit 802 is further configured to, if the total sum meets a preset threshold, merge the pre-stored prefix and array into a current block prefix and array.

[0195] In one embodiment, the block prefix and array includes a historical prefix and array and a current prefix and array.

[0196] The processing unit 802 is further configured to, when detecting a trigger operation of performing merging processing on the historical prefix and array and the current prefix and array, obtain a historical block prefix and with the largest associated block height from the historical prefix and array.

[0197] The obtaining unit 801 is further configured to merge the block data stored in the historical block prefix and with the largest associated block height into the current prefix and array to obtain an adjusted prefix and array.

[0198] The processing unit 802 is further configured to store the adjusted prefix sum array into a persistent cache where the historical prefix sum array is stored.

[0199] In an embodiment, the triggering operation comprises: detecting that a number of current block prefix sums contained in the current prefix sum array reaches a number threshold; and the processing unit 802 is specifically configured to:

[0200] suspending data query processing based on each current block prefix sum in the current prefix sum array.

[0201] In an embodiment, the data query request is obtained from a query device; and the query device generates the data query request in the following manner:

[0202] The query device obtains query information, and the query information comprises: a target block interval where the data to be queried is located, and a data identifier of the data to be queried.

[0203] The query device performs signature processing on the query information, and sends the signed query information to the blockchain as the data query request.

[0204] In an embodiment, the processing unit 802 is further configured to: perform signature verification processing on the data query request, and obtain the query suspension information of the block prefix sum array when the signature verification passes;

[0205] The processing unit 802 is further configured to: when the query suspension information indicates that the block prefix sum array is not suspended for query, trigger the step of determining the first block prefix sum associated with the block height i-1 and the second block prefix sum associated with the block height j from the block prefix sum array.

[0206] In the embodiment of the present application, when data query is performed on the blockchain, the obtaining unit 801 can first obtain a data query request, so that the processing unit 802 can determine a target block interval in which the data to be queried is located. In addition, the obtaining unit 801 can also obtain the block prefix and array corresponding to the blockchain, so that the processing unit 802 can determine a first block prefix sum and a second block prefix sum associated with the target block interval from the block prefix and array based on the target block interval. Based on the determination of the first block prefix sum and the second block prefix sum by the processing unit 802, the data requested by the data query request can be determined according to the data stored by the first block prefix sum and the data stored by the second block prefix sum. Thus, the fast query of the block data in different block intervals of the blockchain based on the block prefix and array is realized, and the query efficiency of the blockchain data is improved. Moreover, the query of the blockchain data based on the block prefix and array enables the processing unit 802 to obtain the queried block data within a constant time regardless of the size of the query interval when performing data query, thereby effectively reducing the complexity of the block data query. The effective improvement of the efficiency and the effective reduction of the complexity of the blockchain data query can effectively ensure the stability and reliability of the system for querying the blockchain data.

[0207] Please refer to FIG. 9, which is a structural schematic block diagram of a computer device provided by an embodiment of the present application. The computer device is any node device in a blockchain network. As shown in FIG. 9, the computer device in the embodiment of the present application can include one or more processors 901, one or more input devices 902, one or more output devices 903, and a memory 904. The above-mentioned processor 901, input device 902, output device 903, and memory 904 are connected through a bus 905. The memory 904 is used to store a computer program, and the computer program includes program instructions. The processor 901 is used to execute the program instructions stored in the memory 904.

[0208] The memory 904 can include a volatile memory such as a random-access memory (RAM); the memory 904 can also include a non-volatile memory such as a flash memory, a solid-state drive (SSD), etc.; and the memory 904 can also include a combination of the above-mentioned kinds of memories.

[0209] The processor 901 can be a central processing unit (CPU). The processor 901 can further include a hardware chip. The hardware chip can be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or the like. The PLD can be a field-programmable gate array (FPGA), a generic array logic (GAL), or the like. The processor 901 can also be a combination of the above structures.

[0210] In the embodiment of the application, the memory 904 is configured to store a computer program, and the computer program includes program instructions. The processor 901 is configured to execute the program instructions stored in the memory 904, so as to implement the steps of the above-mentioned corresponding method in FIG. 2 and FIG. 4.

[0211] In one embodiment, the processor 901 is configured to execute the program instructions to perform the following steps.

[0212] Obtaining a data query request, the data query request is used to request to query block data in a target block interval [i, j] in a block chain, i and j are used to indicate block heights, i and j are positive integers and j > i;

[0213] Obtaining a block prefix sum array corresponding to the block chain, the block prefix sum array includes at least one block prefix sum, each block prefix sum is associated with a block height in the block chain, each block prefix sum is used to store block data of a block corresponding to the associated block height and block data of a block corresponding to a block height before the associated block height;

[0214] Determining, from the block prefix sum array, a first block prefix sum associated with the block height i-1 and a second block prefix sum associated with the block height j;

[0215] Generating, according to the block data stored in the first block prefix sum and the block data stored in the second block prefix sum, block data requested by the data query request.

[0216] The embodiment of the present application provides a computer program product or computer program, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer equipment reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer equipment executes the method embodiment shown in FIG. 2 or FIG. 4. Wherein, the computer readable storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM) and the like.

[0217] The above only discloses part of the embodiments of the present application, of course cannot limit the scope of the present application, and those skilled in the art can understand that the above-mentioned embodiments can be implemented by all or part of the processes, and the equivalent changes made according to the claims of the present application still belong to the scope of the present application.

Claims

1. A data processing method, characterized in that: include: Get a data query request, where the data query request is used to query the block data in the target block interval [i, j] in the blockchain, where i and j are used to indicate the block height, and both i and j are positive integers and j>i; Obtaining a block prefix sum array corresponding to the blockchain, wherein the block prefix sum array includes at least one block prefix sum, each of which is associated with a block height in the blockchain, and each of which is used to store block data of a block corresponding to the associated block height, as well as block data of a block corresponding to a block height before the associated block height; Determining a first block prefix sum associated with block height i-1 and a second block prefix sum associated with block height j from the block prefix sum array; The block data requested by the data query request is generated according to the block data stored in the first block prefix sum and the block data stored in the second block prefix sum.

2. The method according to claim 1, wherein The block prefix sum array includes a historical prefix sum array, wherein the historical prefix sum array includes at least one historical block prefix sum and is stored in a persistent cache; determining a first block prefix sum associated with a block height i-1 and a second block prefix sum associated with a block height j from the block prefix sum array includes: Determining a first maximum block height from each historical block prefix and the associated block height in the historical prefix sum array; If the first maximum block height is greater than or equal to j, then the historical block prefix sum associated with block height i-1 is determined from the historical prefix sum array in the persistent cache as the first block prefix sum; and, the historical block prefix sum associated with block height j is determined from the historical prefix sum array in the persistent cache as the second block prefix sum.

3. The method according to any one of claims 1 to 2, characterized in that The block prefix sum array includes a current prefix sum array, wherein the current prefix sum array contains at least one current block prefix sum and is stored in a temporary buffer; Determining a first block prefix sum associated with block height i-1 and a second block prefix sum associated with block height j from the block prefix sum array includes: Determine a minimum block height and a second maximum block height from each current block prefix and the associated block height in the current prefix and array; If the minimum block height is greater than or equal to i, and the second maximum block height is greater than or equal to j, then determine the current block prefix sum associated with block height i-1 from the current prefix sum array in the temporary cache as the first block prefix sum; and, determine the current block prefix sum associated with block height j from the current prefix sum array in the temporary cache as the second block prefix sum.

4. The method according to any one of claims 1 to 3, wherein The step of generating the block data requested by the data query request according to the block data stored in the first block prefix sum and the block data stored in the second block prefix sum includes: Calculating first difference data between the block data stored in the first block prefix sum and the block data stored in the second block prefix sum; The first difference data is used as the block data requested by the data query request.

5. The method according to any one of claims 1 to 4, characterized in that The block prefix sum array further includes a current prefix sum array, wherein the current prefix sum array includes at least one current block prefix sum and is stored in a temporary buffer; The method further comprises: If the first maximum block height is greater than or equal to i and less than j, then the historical block prefix sum associated with block height i-1 is determined from the historical prefix sum array in the persistent cache as the first block prefix sum; and the current block prefix sum associated with block height j is determined from the current prefix sum array in the temporary cache as the second block prefix sum.

6. The method according to any one of claims 1 to 5, wherein: The step of generating the block data requested by the data query request according to the block data stored in the first block prefix sum and the block data stored in the second block prefix sum includes: Calculating second difference data between the block data stored in the historical block prefix sum associated with the first maximum block height and the block data stored in the first block prefix sum; The second difference data and the block data stored in the second block prefix sum are used as the block data requested by the data query request.

7. The method according to any one of claims 1 to 6, wherein: The method further comprises: Get the target block that has completed consensus processing, as well as the pre-stored prefix and array; determining whether a pre-stored block prefix sum exists in the pre-stored prefix sum array; If the pre-stored block prefix sum does not exist in the pre-stored prefix sum array, the block data of the target block is stored as the first pre-stored block prefix sum in the pre-stored prefix sum array.

8. The method according to any one of claims 1 to 7, wherein: The method further comprises: If the pre-stored block prefix sum exists in the pre-stored prefix sum array, obtaining the pre-stored block prefix sum with the largest associated block height from the pre-stored prefix sum array; The block data stored in the pre-stored block prefix sum with the largest associated block height is merged with the block data of the target block, and the merged block data is stored as a new pre-stored block prefix sum in the pre-stored prefix sum array.

9. The method according to any one of claims 1 to 8, wherein The method further comprises: Obtaining the total number of pre-stored block prefix sums contained in the pre-stored prefix sum array; If the total number meets a preset threshold, the pre-stored prefix sum array is merged into the current block prefix sum array.

10. The method according to any one of claims 1 to 9, wherein The block prefix sum array includes a historical prefix sum array and a current prefix sum array; the method further includes: When a triggering operation of merging the historical prefix sum array and the current prefix sum array is detected, obtaining the historical block prefix sum with the largest associated block height from the historical prefix sum array; Merging the block data stored in the prefix sum of the historical block with the largest associated block height into the current prefix sum array to obtain an adjusted prefix sum array; The adjusted prefix sum array is stored in the persistent cache where the historical prefix sum array is located.

11. The method according to any one of claims 1 to 10, wherein: The triggering operation includes: detecting that the number of current block prefix sums included in the current prefix sum array reaches a number threshold; When a triggering operation of merging the historical prefix sum array and the current prefix sum array is detected, the method further includes: pausing data query processing based on each current block prefix sum in the current prefix sum array.

12. The method according to any one of claims 1 to 11, wherein: The data query request is obtained from a query device, and the query device generates the data query request in a manner including: The query device acquires query information, the query information including: the target block interval where the data to be queried is located, and the data identifier of the data to be queried; The query device signs the query information and sends the signed query information as the data query request to the blockchain.

13. The method according to any one of claims 1 to 12, wherein: The method further comprises: Performing signature verification on the data query request, and obtaining query pause information of the block prefix and array when the signature verification passes; When the query pause information indicates that the block prefix sum array has not paused querying, the step of determining the first block prefix sum associated with block height i-1 and the second block prefix sum associated with block height j from the block prefix sum array is triggered.

14. A data processing device, characterized in that: include: an acquiring unit, configured to acquire a data query request, wherein the data query request is used to request to query block data located in a target block interval [i, j] in the blockchain, where i and j are both used to indicate block heights, and both i and j are positive integers and j>i; The acquisition unit is further configured to acquire a block prefix sum array corresponding to the blockchain, wherein the block prefix sum array includes at least one block prefix sum, each of the block prefix sums is associated with a block height in the blockchain, and each of the block prefix sums is used to store block data of a block corresponding to the associated block height, as well as block data of a block corresponding to a block height before the associated block height; a processing unit, configured to determine, from the block prefix sum array, a first block prefix sum associated with block height i-1 and a second block prefix sum associated with block height j; The processing unit is further configured to generate the block data requested by the data query request based on the block data stored in the first block prefix sum and the block data stored in the second block prefix sum.

15. A computer device, characterized in that: The method comprises a processor, an input device, an output device and a memory, wherein the processor, the input device, the output device and the memory are interconnected, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 13.

16. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 13.

17. A computer program product, characterized in that The computer program product comprises a computer program or computer instructions, and the computer program or the computer instructions are executed by a processor to perform the method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Data processing method, device and storage medium

    CN108805570A

  • Data storage method and device and storage medium

    CN109614411A

  • Data synchronization method and device, storage medium and electronic equipment

    CN116821234A

  • Method and system for performing range-sum queries on a data cube

    US5799300A