Blockchain data aggregation storage method and device, equipment and storage medium
Patent Information
- Application Number
- CN202311663181.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-06
- Publication Date
- 2026-11-03
- Estimated Expiration
- 2043-12-06
AI Technical Summary
现有区块链数据存储技术缺乏数据目录或索引功能,导致数据查询效率低且资源占用量高,无法有效压缩数据。
The method for storing directory-based blockchain data involves inserting directory blocks into the blockchain using a data aggregation storage device, equipment, and storage medium. It determines the block range based on the positions of the current and previous directory blocks, obtains transaction entity and location information, and compresses and stores non-directory block data within the block range.
By generating a data summary directory block, the retrieval of all blocks is reduced, improving query efficiency, and resource utilization efficiency is improved through compressed storage.
Smart Images

Figure CN117668045B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, and in particular to a blockchain data aggregation and storage method, apparatus, device and storage medium. Background Technology
[0002] A blockchain is essentially a chain of blocks. Each block stores specific information, and these blocks are linked together in chronological order. This chain is stored on all servers, and as long as at least one server in the system is operational, the entire blockchain is secure. Blockchain can be applied to asset-related fields such as smart contracts, securities trading, e-commerce, the Internet of Things, social communication, file storage, proof of existence, identity verification, and equity crowdfunding. Regardless of its application, blockchain blocks store all the data, and because it currently lacks data cleanup capabilities, the amount of data stored keeps increasing. Furthermore, when complex queries are needed on transaction data stored on the blockchain, all transaction history must be re-executed in chronological order to complete the query, resulting in very low query efficiency.
[0003] To facilitate retrieval, existing blockchain data storage technologies can store each block's data using additional disks and memory outside the blockchain. However, when this additional external data is frequently loaded, each block needs to be fully traversed and queried to construct various query data, resulting in additional resource consumption. Furthermore, as the amount of data stored in the blockchain continues to increase, data compression becomes difficult, leading to high resource consumption. Summary of the Invention
[0004] This application provides a blockchain data aggregation and storage method, apparatus, device, and storage medium to solve the problems of existing blockchain data storage technologies lacking data catalog or index functions, resulting in low data query efficiency, inability to compress data, and high resource consumption.
[0005] Firstly, this application provides a blockchain data aggregation and storage method, including:
[0006] When blockchain data meets preset conditions, a directory block is inserted into the blockchain;
[0007] Determine the block range of the current directory block based on the location of the current directory block and the location of the previous directory block;
[0008] Based on the transaction information of each block within the block range, at least one transaction entity and the location information of each transaction entity are obtained;
[0009] Store the block range of the current directory block, the position of the previous directory block, the transaction entity and its location information into the current directory block;
[0010] The block data of non-directory blocks within the block range is compressed and stored.
[0011] Optionally, in the method described above, inserting a directory block into the blockchain when the blockchain data meets preset conditions includes:
[0012] Based on a preset period, starting from the generation time of the first block in the blockchain, a directory block is inserted into the blockchain every specified period.
[0013] Optionally, in the method described above, inserting a directory block into the blockchain when the blockchain data meets preset conditions includes:
[0014] Based on a preset block count value, starting from the first block in the blockchain, a directory block is inserted into the blockchain every block count value.
[0015] Optionally, in the method described above, determining the block range of the current directory block based on the location of the current directory block and the location of the previous directory block includes:
[0016] If the current directory block is the first directory block in the blockchain, then the block range of the current directory block is the blocks from the first block in the blockchain to the block preceding the current directory block;
[0017] If the current directory block is not the first directory block in the blockchain, then the block range of the current directory block is the blocks between the previous directory block and the block preceding the current directory block.
[0018] Optionally, in the method described above, the transaction information includes the transaction entity, and the step of obtaining at least one transaction entity and the location information of each transaction entity based on the transaction information of each block in the block range includes:
[0019] Obtain the transaction entities from the transaction information in each block.
[0020] The blocks related to the transaction entity are used as the location of the transaction entity to generate a set of location information corresponding to each transaction entity.
[0021] Optionally, the method described above, after obtaining the transaction subject from the transaction information in each block, further includes:
[0022] The transaction entities are sorted according to the preset transaction entity sorting rules, and the pointer relationship between the transaction entity and the block where the transaction entity is located is stored in a binary tree structure.
[0023] Optionally, in the method described above, the transaction information includes changes in the transaction entity, and after generating the location information set corresponding to each transaction entity, the method further includes:
[0024] Select a target transaction entity, and record the block where the transaction entity change value of the target transaction entity is not 0 as 1, and the block where the transaction entity change value of the target transaction entity is 0 as 0;
[0025] The location information of the target transaction entity is recorded using a 0-1 bitmap in the location information set.
[0026] Secondly, this application provides a blockchain data aggregation and storage device, comprising:
[0027] The directory block insertion module is used to insert directory blocks into the blockchain when the blockchain data meets preset conditions.
[0028] The block range confirmation module is used to confirm the block range of the current directory block based on the location of the current directory block and the location of the previous directory block.
[0029] The transaction entity acquisition module is used to acquire at least one transaction entity and the location information of each transaction entity based on the transaction information of each block in the block range.
[0030] The summary storage module is used to store the block range of the current directory block, the position of the previous directory block, the transaction subject and the transaction subject's position information into the current directory block;
[0031] The compression module is used to compress and store block data that is not part of the directory block within the block range.
[0032] Thirdly, this application provides an electronic device, including a memory, a processor, and computer-executable instructions stored in the memory and executable on the processor, wherein the processor executes the computer-executable instructions to implement the blockchain data aggregation and storage method described in any one of the first aspects above.
[0033] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the blockchain data aggregation and storage method described in any one of the first aspects above.
[0034] The blockchain data aggregation and storage method, apparatus, device, and storage medium provided in this application insert directory blocks into the blockchain when blockchain data meets preset conditions; determine the block range of the current directory block based on the current directory block's location and the previous directory block's location; obtain at least one transaction entity and the location information of each transaction entity based on the transaction information of each block within the block range; store the block range of the current directory block, the location of the previous directory block, the transaction entity, and the transaction entity's location information into the current directory block; and compress and store the block data that is not a directory block within the block range. By generating a data aggregation directory block for a fixed period of time based on the original blocks, and statistically recording all "transaction information" for this period of time in the data aggregation directory block, queries can only view the data in the data aggregation directory block, reducing the need to search all blocks and improving retrieval efficiency; at the same time, ordinary blocks can be compressed, further reducing resource consumption and improving resource utilization efficiency. Attached Figure Description
[0035] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0036] Figure 1 This is a schematic diagram illustrating an application scenario of the blockchain data aggregation and storage method provided in the embodiments of this application.
[0037] Figure 2 A flowchart illustrating the blockchain data aggregation and storage method provided in this application embodiment.
[0038] Figure 3 A schematic diagram of a blockchain data aggregation and storage device provided in an embodiment of this application.
[0039] Figure 4 A schematic diagram of the structure of an electronic device for a blockchain data aggregation and storage device provided in an embodiment of this application.
[0040] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0041] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0042] In related technologies, blockchain blocks store all the data. Because they currently lack data cleanup capabilities, the amount of data stored keeps increasing. Furthermore, to facilitate querying, additional disk space and memory are needed outside the blockchain to store the data for each block. This is especially problematic when external data is frequently loaded, requiring a full query and traversal of each block to construct various query data, resulting in additional resource consumption.
[0043] To address the aforementioned technical issues, this application aims to propose a blockchain data aggregation and storage method, apparatus, device, and storage medium. The core concept of this method is to generate a data aggregation directory block for a fixed period of time, and to statistically record all "transaction information" for that period of time in the data aggregation directory block. When querying, only the data in the data aggregation directory block can be viewed, reducing the need to search all blocks and improving retrieval efficiency. At the same time, ordinary blocks can be compressed to further reduce resource consumption and improve resource utilization efficiency.
[0044] To better understand the solutions of the embodiments of this application, an application scenario involved in the embodiments of this application will be introduced below.
[0045] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating an application scenario of the blockchain data aggregation and storage method provided in the embodiments of this application, such as... Figure 1 As shown, the system includes a data source 100 and a server 200. The data source 100 can generate blockchain data, such as transaction data, and send the blockchain data to the server 200 for on-chain storage. The server 200 can insert directory blocks into the blockchain according to preset blockchain data processing conditions, and confirm the block range of the current directory block, the position of the previous directory block, the transaction subject and the transaction subject's position information. Then, it can compress and store the block data of non-directory blocks within the current directory block range.
[0046] The technical solution of this application and how it solves the above-mentioned technical problems will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.
[0047] Figure 2 A flowchart illustrating the blockchain data aggregation and storage method provided in this application embodiment. Figure 2 As shown, the method in this embodiment includes:
[0048] S201: When the blockchain data meets the preset conditions, insert a directory block into the blockchain.
[0049] The execution entity of this application embodiment can be a server or a blockchain data aggregation and storage system in the server, wherein the blockchain data aggregation and storage system can be implemented by software.
[0050] Understandably, directory blocks can be inserted into the blockchain by time or number of blocks. The directory block records the summary information of a block in the blockchain and records the block position corresponding to each transaction entity based on the transaction information in the block.
[0051] S202: Determine the block range of the current directory block based on the location of the current directory block and the location of the previous directory block.
[0052] In this step, the range of blocks included in each directory block can be calculated based on the location of each directory block. For example, when the block range corresponding to a directory block is the information of blocks 1 to 129, it can also be understood as a summary of the information of blocks 1 to 129.
[0053] S203: Based on the transaction information of each block in the block range, obtain at least one transaction entity and the location information of each transaction entity.
[0054] In this embodiment, the directory block generates summary information based on the transaction entity. The same transaction entity may have multiple transaction records, so they are recorded in the transaction information of different blocks. The directory block mainly uses the transaction entity as the main content and records the position of the transaction entity within the block, thereby enabling effective indexing of the transaction entity.
[0055] S204: Store the block range of the current directory block, the position of the previous directory block, the transaction entity and its location information into the current directory block.
[0056] Understandably, the information contained in the directory block, namely the summary information of the block, allows for quick retrieval of the directory block's position within the block based on the current directory block's block range and the position of the previous directory block. Based on the stored transaction entity and transaction entity location information, the corresponding transaction information of the transaction entity can be quickly screened.
[0057] S205: Compress and store the block data of non-directory blocks within the block range.
[0058] In this step, ordinary blocks are compressed to further reduce resource consumption and improve resource utilization efficiency.
[0059] The blockchain data aggregation and storage method provided in this embodiment inserts a directory block into the blockchain when the blockchain data meets preset conditions; determines the block range of the current directory block based on the location of the current directory block and the location of the previous directory block; obtains at least one transaction entity and the location information of each transaction entity based on the transaction information of each block within the block range; stores the block range of the current directory block, the location of the previous directory block, the transaction entity, and the transaction entity's location information into the current directory block; generates a data aggregation directory block for a fixed period of time based on the original blocks, and statistically records all "transaction information" for this period of time in the data aggregation directory block; when querying, only the data in the data aggregation directory block can be viewed, reducing the retrieval of all blocks and improving retrieval efficiency; compresses and stores the block data of non-directory blocks within the block range, which can compress ordinary blocks, further increasing resource utilization and improving resource efficiency.
[0060] The technical solution of the above-mentioned blockchain data aggregation and storage method will be described in detail below.
[0061] In one possible implementation, the blockchain data aggregation and storage method provided in this embodiment inserts directory blocks into the blockchain by time or number of blocks.
[0062] Specifically, when blockchain data meets preset conditions, a directory block is inserted into the blockchain, including: according to a preset period, starting from the generation time of the first block in the blockchain, inserting a directory block into the blockchain every said period.
[0063] Alternatively, based on a preset number of blocks, a directory block can be inserted into the blockchain every certain number of blocks, starting from the first block.
[0064] It is understandable that the generation of blocks in a blockchain is chronological and immutable. Therefore, based on a preset period, all blocks that record this period can be grouped into a block range corresponding to a directory block.
[0065] From another perspective, for some businesses, the frequency of transactions is not high, so the number of blocks can be used as the division of the block range.
[0066] In this embodiment, by inserting directory blocks into the blockchain according to time or number of blocks, a simple summary and statistics mode is provided for the blockchain, supporting most of the query and statistics work.
[0067] In one possible implementation, the blockchain data aggregation and storage method provided in this embodiment first determines whether the current directory block is the first directory block in the blockchain, and then divides the block range of the current directory block according to the determination result.
[0068] Specifically, the block range of the current directory block is determined based on the location of the current directory block and the location of the previous directory block, including: if the current directory block is the first directory block in the blockchain, then the block range of the current directory block is the blocks from the first block in the blockchain to the block preceding the current directory block; if the current directory block is not the first directory block in the blockchain, then the block range of the current directory block is the blocks from the previous directory block to the block preceding the current directory block.
[0069] It should be noted that the current directory block includes the previous directory block. To avoid duplication, the content of the previous directory block is not included in the subsequent transaction information extraction process. This detail can be achieved by different data formats in directory blocks and ordinary blocks and by setting the extraction fields.
[0070] In this embodiment, by first determining whether the current directory block is the first directory block in the blockchain, and then dividing the block range of the current directory block according to the determination result, the location of the directory block in the block can be quickly found, thus achieving the purpose of fast query.
[0071] In one possible implementation, the blockchain data aggregation and storage method provided in this embodiment generates a set of location information corresponding to each transaction entity by using the blocks related to the transaction entity as the location of the transaction entity.
[0072] Specifically, the transaction information includes the transaction entity. The step of obtaining at least one transaction entity and the location information of each transaction entity based on the transaction information of each block in the block range includes: obtaining the transaction entity from the transaction information in each block, taking the block related to the transaction entity as the location of the transaction entity, and generating a set of location information corresponding to each transaction entity.
[0073] In this embodiment, the directory block uses the transaction entity as the summary information, including the transaction entity's name, balance (or other summary content), location information, etc. Within the block range (e.g., block 1, block 2, block 3), the transaction entity corresponding to block 1 is entity 1, the transaction entity corresponding to block 2 is entity 2, and the transaction entity corresponding to block 3 is entity 1. Therefore, within the block range corresponding to this directory block, there are two transaction entities: transaction entity 1 and transaction entity 2. Furthermore, the location information corresponding to transaction entity 1 is blocks 1 and 3, and the location information corresponding to transaction entity 2 is block 2.
[0074] Following a certain format, the contents of this directory block can be organized as: "Transaction Entity 1: Balance, Location Information 1 (Block 1), Location Information 2 (Block 3)" and "Transaction Entity 2: Balance, Location Information 1 (Block 2)".
[0075] Furthermore, after obtaining the transaction subject from the transaction information in each block, the method further includes: sorting each transaction subject according to a preset transaction subject sorting rule, and storing the pointer relationship between the transaction subject and the block where the transaction subject is located in a binary tree structure.
[0076] It is understandable that using a binary tree structure to store the pointer relationship between the transaction subject and the block containing that transaction subject can effectively improve the search speed. That is, by using a binary tree to store the block subjects sequentially, the transaction subjects are stored in a sequential structure, and a binary search can be used to quickly locate whether a certain transaction subject is included in the directory block. For example, taking numbers as an example, when there are 6 transaction subjects, namely 8, 6, 2, 4, 1, and 9, they need to be stored in order, with the storage structure being: 1, 2, 4, 6, 8, 9. When querying whether 6 is included, the structure head (1) and structure tail (9) are used to determine whether 6 might be included, and then it is determined whether it is between the middle position (6) and the structure tail (9). Thus, by comparing the structure in half, the query can be quickly located.
[0077] Furthermore, the transaction information includes changes in the transaction entities, and after generating the location information set corresponding to each transaction entity, it also includes:
[0078] Select a target transaction entity, and record the blocks where the transaction entity change value of the target transaction entity is not 0 as 1, and the blocks where the transaction entity change value of the target transaction entity is 0 as 0; record the location information of the target transaction entity in the location information set using a 0-1 bitmap.
[0079] It is understandable that the change value of the transaction entity can be the balance, that is, the amount change of the transaction entity can be judged based on the balance. If the block stores billing information, then the occurrence of the cumulative amount and the remaining amount are recorded.
[0080] Furthermore, the directory block records a summary of information from a segment of blocks in the blockchain. If the current directory block records information between blocks 110 and 120, where blocks 110, 115, 116, 118, and 120 contain transaction information of the transaction entities, the data storage size can be further compressed using a bitmap, as shown below:
[0081] (High bit - Block 120) 1 0 1 0 1 1 0 0 0 0 1 (Low bit - Block 110).
[0082] In this embodiment, by using the blocks related to the transaction entity as the location of the transaction entity, a set of location information corresponding to each transaction entity is generated. The directory block itself has a block pointer, and the traversal of the entire blockchain data can be completed by traversing the directory block.
[0083] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0084] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0085] Figure 3 This is a schematic diagram of a blockchain data aggregation and storage device provided in an embodiment of this application. Figure 3 As shown, the blockchain data aggregation and storage device includes:
[0086] The directory block insertion module 31 is used to insert a directory block into the blockchain when the blockchain data meets the preset conditions.
[0087] The block range confirmation module 32 is used to confirm the block range of the current directory block based on the location of the current directory block and the location of the previous directory block.
[0088] The transaction entity acquisition module 33 is used to acquire at least one transaction entity and the location information of each transaction entity based on the transaction information of each block in the block range.
[0089] The summary storage module 34 is used to store the block range of the current directory block, the position of the previous directory block, the transaction subject and the transaction subject location information into the current directory block;
[0090] Compression module 35 is used to compress and store block data that is not part of the directory block within the block range.
[0091] In one possible design, the directory block insertion module 31 is specifically used for:
[0092] Based on a preset period, starting from the generation time of the first block in the blockchain, a directory block is inserted into the blockchain every specified period.
[0093] In one possible design, the directory block insertion module 31 is specifically used for:
[0094] Based on a preset block count value, starting from the first block in the blockchain, a directory block is inserted into the blockchain every block count value.
[0095] In one possible design, the block range confirmation module 32 is specifically used for:
[0096] If the current directory block is the first directory block in the blockchain, then the block range of the current directory block is the blocks from the first block in the blockchain to the block preceding the current directory block;
[0097] If the current directory block is not the first directory block in the blockchain, then the block range of the current directory block is the blocks between the previous directory block and the block preceding the current directory block.
[0098] In one possible design, the transaction information includes the transaction entity, and the transaction entity acquisition module 33 is specifically used for:
[0099] Obtain the transaction entities from the transaction information in each block.
[0100] The blocks related to the transaction entity are used as the location of the transaction entity to generate a set of location information corresponding to each transaction entity.
[0101] In one possible design, the transaction subject acquisition module 33 is also specifically used for:
[0102] The transaction entities are sorted according to the preset transaction entity sorting rules, and the pointer relationship between the transaction entity and the block where the transaction entity is located is stored in a binary tree structure.
[0103] In one possible design, the transaction information includes changes in the transaction entity, and the transaction entity acquisition module 33 is further specifically used for:
[0104] Select a target transaction entity, and record the block where the transaction entity change value of the target transaction entity is not 0 as 1, and the block where the transaction entity change value of the target transaction entity is 0 as 0;
[0105] The location information of the target transaction entity is recorded using a 0-1 bitmap in the location information set.
[0106] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.
[0107] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.
[0108] Figure 4 A schematic diagram of the structure of an electronic device for a blockchain data aggregation and storage device provided in an embodiment of this application. (See attached diagram.) Figure 4 As shown, the electronic device of this embodiment includes: at least one processor 40 ( Figure 4 (Only one is shown) a processor, a memory 41, and a computer program stored in the memory 41 that can run on at least one processor 40, which executes the computer program to implement the steps in any of the above method embodiments.
[0109] The electronic device may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will understand that... Figure 4 This is merely an example of an electronic device and does not constitute a limitation on electronic devices. It may include more or fewer components than shown in the illustration, or combinations of certain components, or different components. For example, it may also include input / output devices, network access devices, etc.
[0110] The processor 40 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0111] The specific implementation process of processor 401 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0112] In some embodiments, memory 41 may be an internal storage unit of an electronic device, such as the memory of the electronic device. In other embodiments, memory 41 may be an external storage device of the electronic device, such as a plug-in hard drive, smart media card (SMC), secure digital (SD) card, flash card, etc. Furthermore, memory 41 may include both internal and external storage units of the electronic device. Memory 41 is used to store operating systems, applications, bootloaders, data, and other programs, such as program code for computer programs. Memory 41 can also be used to temporarily store data that has been output or will be output.
[0113] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps described in the various method embodiments above.
[0114] The aforementioned computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0115] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an application-specific integrated circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the aforementioned electronic device.
[0116] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0117] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.
[0118] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0119] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A blockchain data aggregation and storage method, characterized in that, include: When blockchain data meets preset conditions, a directory block is inserted into the blockchain; Determine the block range of the current directory block based on the location of the current directory block and the location of the previous directory block; The transaction entity is obtained from the transaction information in each block within the aforementioned block range. The blocks related to the transaction entity are used as the location of the transaction entity to generate a set of location information corresponding to each transaction entity. Select a target transaction entity, mark the block where the transaction entity change value of the target transaction entity is not 0 as 1, and mark the block where the transaction entity change value of the target transaction entity is 0 as 0, the transaction information includes the transaction entity change value; The location information set uses a 0-1 bitmap to record the location information of the target transaction entity; Store the block range of the current directory block, the position of the previous directory block, the transaction entity and its location information into the current directory block; Compress and store the block data that is not in the directory block within the specified block range; The step of determining the block range of the current directory block based on the location of the current directory block and the location of the previous directory block includes: If the current directory block is the first directory block in the blockchain, then the block range of the current directory block is the blocks from the first block in the blockchain to the block preceding the current directory block; If the current directory block is not the first directory block in the blockchain, then the block range of the current directory block is the blocks between the previous directory block and the block preceding the current directory block.
2. The method according to claim 1, characterized in that, The step of inserting a directory block into the blockchain when the blockchain data meets preset conditions includes: Based on a preset period, starting from the generation time of the first block in the blockchain, a directory block is inserted into the blockchain every specified period.
3. The method according to claim 1, characterized in that, The step of inserting a directory block into the blockchain when the blockchain data meets preset conditions includes: Based on a preset block count value, starting from the first block in the blockchain, a directory block is inserted into the blockchain every block count value.
4. The method according to claim 1, characterized in that, After obtaining the transaction subject from the transaction information in each block, the process further includes: The transaction entities are sorted according to the preset transaction entity sorting rules, and the pointer relationship between the transaction entity and the block where the transaction entity is located is stored in a binary tree structure.
5. A blockchain data aggregation and storage device, characterized in that, include: The directory block insertion module is used to insert directory blocks into the blockchain when the blockchain data meets preset conditions. The block range confirmation module is used to confirm the block range of the current directory block based on the location of the current directory block and the location of the previous directory block. The transaction entity acquisition module is used to acquire at least one transaction entity and the location information of each transaction entity based on the transaction information of each block in the block range. The summary storage module is used to store the block range of the current directory block, the position of the previous directory block, the transaction subject and the transaction subject's position information into the current directory block; A compression module is used to compress and store block data that is not part of the directory block within the block scope; Specifically, the block range confirmation module is used to: if the current directory block is the first directory block in the blockchain, then the block range of the current directory block is the blocks from the first block in the blockchain to the block preceding the current directory block. If the current directory block is not the first directory block in the blockchain, then the block range of the current directory block is the blocks between the previous directory block and the block preceding the current directory block. The transaction entity acquisition module is specifically used for: The transaction entity is obtained from the transaction information in each block within the aforementioned block range. The blocks related to the transaction entity are used as the location of the transaction entity to generate a set of location information corresponding to each transaction entity. Select a target transaction entity, mark the block where the transaction entity change value of the target transaction entity is not 0 as 1, and mark the block where the transaction entity change value of the target transaction entity is 0 as 0, the transaction information includes the transaction entity change value; The location information of the target transaction entity is recorded using a 0-1 bitmap in the location information set.
6. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Block chain index structure based on grouped account transaction chain
CN112988841A
