CN114780642B - Block chain data processing method and device and electronic equipment - Google Patents
Block chain data processing method and device and electronic equipment Download PDFInfo
- Publication number
- CN114780642B CN114780642B CN202210547111.9A CN202210547111A CN114780642B CN 114780642 B CN114780642 B CN 114780642B CN 202210547111 A CN202210547111 A CN 202210547111A CN 114780642 B CN114780642 B CN 114780642B
- Authority
- CN
- China
- Prior art keywords
- block
- data
- storage unit
- interval
- blocks
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2291—User-Defined Types; Storage management thereof
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2457—Query processing with adaptation to user needs
- G06F16/24578—Query processing with adaptation to user needs using ranking
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- Data Mining & Analysis (AREA)
- General Engineering & Computer Science (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- Computing Systems (AREA)
- Software Systems (AREA)
- Computational Linguistics (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- Strategic Management (AREA)
- Technology Law (AREA)
- General Business, Economics & Management (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a block chain data processing method, a block chain data processing device and electronic equipment, which relate to the technical field of block chains and comprise the following steps: when block data reading operation is performed on a block chain, determining a rollback block interval corresponding to the block chain, wherein the rollback block interval represents an interval in which a target number of new blocks are required to be generated under the condition that the block cannot be subjected to rollback operation after any block is linked; and starting the first block analysis thread to analyze the blocks corresponding to the rolling block intervals in the read block chain and then storing the blocks in a second data storage unit in a queue form, starting the second block analysis thread to analyze the blocks of the block chain, and storing the block data, except the blocks corresponding to the rolling block intervals, in the analyzed block chain in the first data storage unit. And providing data of different data storage units according to different user requirements to ensure the accuracy of the block data analysis result.
Description
Technical Field
The invention relates to the technical field of block chains, in particular to a block chain data processing method and device and electronic equipment.
Background
The blockchain can be regarded as a distributed computing network, which has no central node and is completely dispersed, and can act uniformly by means of information exchange among all nodes to achieve consensus. All distributed systems face the problem of consistency, when a plurality of different nodes dig out blocks in the same short period of time and add the blocks to a chain, and different subsequent chains are respectively and automatically developed on the basis of the nodes, the fault-tolerant function of the block chain plays a role, and by utilizing the principle that a small number obeys a majority, all the nodes select one with more subsequent chain nodes and abandon the other one, so that the unification of the whole block chain network is finally achieved.
When data analysis is performed on a block chain, a common method is to read data by using a block as a unit and perform data analysis according to the block height through a data reading interface of a block chain node program, reorganize and calculate the analyzed data from multiple dimensions according to the data analysis requirement, and store the data into a local database, wherein the reorganized data amount is several times to dozens of times or more larger than the original data amount according to the dimension of the data analysis. When the data reading procedure encounters data inconsistency, a rollback phenomenon may be caused, a latest block in the read data may have been discarded in the chain, and new block data needs to be used to replace the read data, which requires careful handling, otherwise, irrecoverable data errors may easily occur, a large amount of analyzed data needs to be deleted, some data after accumulated calculation needs to be restored to a state before the blocks are generated, which is extremely complex, and the process is very prone to errors, thereby affecting analysis results of the block data obtained by analysis.
Disclosure of Invention
Therefore, the technical problem to be solved by the present invention is to overcome the defect that the conventional rollback processing process for the read block data is easy to cause data analysis errors and affect the accuracy of a data analysis result, thereby providing a block chain data processing method, an apparatus and an electronic device.
According to a first aspect, an embodiment of the present invention discloses a method for processing block chain data, including: when block data reading operation is performed on a block chain, determining a rolling block interval corresponding to the block chain, wherein the rolling block interval represents an interval where a target number of new blocks are located, wherein the new blocks need to be generated under the condition that the block is not subjected to rolling operation after any block is chained; and starting the first block analysis thread to analyze the blocks corresponding to the rollback block interval in the read block chain and then store the blocks in a second data storage unit in a queue form, starting the second block analysis thread to analyze the blocks of the block chain, and storing the block data, except the blocks corresponding to the rollback block interval, in the analyzed block chain in the first data storage unit.
Optionally, after storing, in the first data storage unit, the block data in the block chain obtained through analysis except for the block corresponding to the rolling-back block interval, the method further includes: when an offline data analysis request of a user node is received, feeding back block data stored in the first data storage unit to the user node; and when a data online display request of a user node is received, merging and displaying the block data stored in the first data storage unit and the block data stored in the second data storage unit.
Optionally, the method further comprises: when a newly added block in the block chain is monitored, the newly added block is analyzed by the first block analysis thread and then stored at the tail of the queue of the second data storage unit; and shifting out the block data corresponding to the corresponding number of blocks from the top of the queue of the second data storage unit.
Optionally, the method further comprises: and storing the block data corresponding to the shifted-out block analyzed by the first block analysis thread into the first data storage unit.
Optionally, when a data online display request of a user node is received, merging and displaying the block data stored in the first data storage unit and the block data stored in the second data storage unit, where the merging and displaying includes: when the block corresponding to the rolling block interval comprises the rolled back block, the block data quality information displayed by the user node is prompted before the block data corresponding to the rolled back block is updated.
Optionally, the method further comprises: when the block corresponding to the rolling block interval comprises a rolled back block, re-analyzing the block data corresponding to the rolled back block; or when the block corresponding to the rolling-back block section comprises a rolled-back block, analyzing the block data corresponding to the section from the rolled-back block to the latest block corresponding to the rolling-back block section.
According to a second aspect, an embodiment of the present invention further discloses a block chain data processing apparatus, including:
the determining module is used for determining a rolling-back block interval corresponding to a block chain when block data reading operation is performed on the block chain, wherein the rolling-back block interval represents an interval where a target number of new blocks which are required to be generated under the condition that the block cannot be rolled back by any block after the block chain is linked; and the storage module is used for starting the first block analysis thread to analyze the blocks corresponding to the rollback block interval in the read block chain and then storing the blocks in the second data storage unit in a queue form, starting the second block analysis thread to analyze the blocks of the block chain, and storing the block data, except the blocks corresponding to the rollback block interval, in the analyzed block chain in the first data storage unit.
Optionally, the apparatus further comprises: the first processing module is used for feeding back the block data stored in the first data storage unit to the user node when receiving an offline data analysis request of the user node; and the second processing module is used for merging and displaying the block data stored in the first data storage unit and the block data stored in the second data storage unit when a data online display request of a user node is received.
According to a third aspect, an embodiment of the present invention further discloses an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to cause the at least one processor to perform the steps of the block chain data processing method according to the first aspect or any one of the optional embodiments of the first aspect.
According to a fourth aspect, the embodiments of the present invention also disclose a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of the block chain data processing method according to the first aspect or any one of the optional embodiments of the first aspect.
The technical scheme of the invention has the following advantages:
when block data reading operation is performed on a block chain, a rollback block interval corresponding to the block chain is determined, the rollback block interval represents an interval in which new blocks of a target quantity are required to be generated under the condition that the blocks cannot be subjected to rollback operation after any block is uplink-linked, a first block analysis thread is started to analyze the blocks corresponding to the rollback block interval in the read block chain and then store the blocks in a second data storage unit in a queue form, a second block analysis thread is started to analyze the blocks of the block chain, and block data except the blocks corresponding to the rollback block interval in the analyzed block chain is stored in a first data storage unit. The block data corresponding to the rollback block interval which is likely to be rolled back is stored in the second data storage unit, and the block data except the block corresponding to the rollback block interval is stored in the first storage unit by determining the rollback block interval and analyzing the block through different block analysis threads, so that in the subsequent use process of the data obtained through analysis, the data of different data storage units can be provided according to different user requirements to ensure the accuracy of the block data analysis result.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of an exemplary block chain data processing method according to an embodiment of the present invention;
fig. 2 is a schematic block diagram of a specific example of a block chain data processing apparatus according to an embodiment of the present invention;
fig. 3 is a diagram illustrating an embodiment of an electronic device.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In addition, the technical features involved in the different embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
The embodiment of the invention discloses a block chain data processing method, as shown in figure 1, the method comprises the following steps:
For example, the main body for performing the block data reading operation may be any data acquisition node on the block chain, which synchronizes all block data in the block chain network and performs the reading operation on the synchronized block data or which responds to the reading operation of the block data when receiving the data analysis requirement of an external user. When block data reading operation is executed, the target number of blocks included in the rolling-back block section of the block chain can be determined according to the attribute information of the block chain, for example, the target number of blocks included in the rolling-back block section is calculated according to the average block outlet time, the common identification mode, the global node density and the like of the block chain, the number of new blocks is calculated after a certain block P is linked in the rolling-back block section, the block will not be rolled back again, and the target number is recorded as N. If the average block-out time of a block chain is 10 minutes/block, and the current global node density is about 8 blocks, the number of blocks included in the rolling block interval is about 8 blocks, that is, if 8 blocks are left after a certain block P, the block P will not be rolled back any more, all rolling back will occur in 8 blocks, and therefore the number N of the blocks in the rolling block interval can be 8.
The rolling block intervals corresponding to different block chains can also be obtained by counting the rolling block intervals of the corresponding block chains according to the branching conditions of historical block chains, selecting the chains which are discarded after branching, taking the blocks corresponding to the maximum block number as the rolling block intervals when the chains are discarded, or selecting the blocks corresponding to any numerical value larger than the maximum block number from the rolling block intervals to form the rolling block intervals.
And step 102, starting a first block analysis thread to analyze the blocks corresponding to the rollback block interval in the read block chain and then store the blocks in a second data storage unit in a queue form, starting a second block analysis thread to analyze the blocks of the block chain, and storing the block data, except the blocks corresponding to the rollback block interval, in the analyzed block chain in the first data storage unit.
Exemplarily, two block analysis threads are preset, a first block analysis thread is enabled to analyze the read blocks corresponding to the rolling block interval in the block chain and store the blocks in a second data storage unit in a queue form, a second block analysis thread is enabled to analyze all the blocks in the analyzed block chain, and the block data except the blocks corresponding to the rolling block interval is stored in the first data storage unit. That is, the data analyzed by different threads is stored in the first data storage unit as the credible block data, and the block data corresponding to the rolling block interval which may be rolled back due to forking is stored in the second data storage unit.
According to the block chain data processing method provided by the invention, the block data corresponding to the rollback block interval which is likely to be rolled back is stored in the second data storage unit by determining the rollback block interval and analyzing the block through different block analysis threads, and the block data except the block corresponding to the rollback block interval is stored in the first storage unit, so that in the subsequent use process of the analyzed data, the data of different data storage units can be provided according to different user requirements to ensure the accuracy of the block data analysis result, the rollback block data does not need to be processed, and the error of the analyzed data caused by the rollback can not be caused.
As an optional embodiment of the present invention, after step 102, the method further comprises: when an offline data analysis request of a user node is received, feeding back block data stored in the first data storage unit to the user node; and when a data online display request of a user node is received, merging and displaying the block data stored in the first data storage unit and the block data stored in the second data storage unit.
Exemplarily, when an offline data analysis request of the user node is received, the data stored in the first data storage unit with relatively accuracy is fed back to the user node, so that the accuracy of a data analysis result is ensured, and the situations of data analysis rework and the like caused by data analysis by using data which may be rolled back are avoided. When a data online display request of a user node is received, since the second tile analysis thread analyzes all the tiles in the read tile chain, the first block analysis thread only analyzes the corresponding block in the rolling block interval, the block data needed to be analyzed by the first block analysis thread is smaller than the block data needed to be analyzed by the second block analysis thread, the first block resolution thread resolves data faster than the second block resolution thread, since the requirement of the user node is an online display request for the parsed data, data analysis is not needed, so that the parsed block data stored in the first data storage unit and the parsed block data stored in the second data storage unit can be merged and displayed, to ensure that the data in the current blockchain can be displayed as much as possible for the user node sending the data online display request.
As an optional embodiment of the present invention, the method further comprises: when a newly added block in the block chain is monitored, the newly added block is analyzed by the first block analysis thread and then stored at the tail of the queue of the second data storage unit; and shifting out the block data corresponding to the corresponding number of blocks from the top of the queue of the second data storage unit.
Illustratively, when a newly added block exists in the block chain, the newly added block is directly analyzed by using the first block analysis thread and the block data obtained by analysis is stored in the second data storage unit. Since only the block corresponding to the rolling block interval may be rolled back, when a block is newly added to the block chain, the corresponding number of blocks is shifted out from the top of the queue of the second data storage unit, so that the data stored in the second data storage unit is the data of the fixed number of blocks.
As an optional embodiment of the invention, the method further comprises: and storing the block data corresponding to the shifted-out block analyzed by the first block analysis thread into the first data storage unit.
For example, since the second tile parsing thread parses all the read tiles, the number of the read tiles is large, and in order to improve the parsing efficiency of the second tile parsing thread, tile data corresponding to the shifted-out tile parsed by the first tile parsing thread may be stored in the first data storage unit. The block moved out from the top of the queue of the second storage unit is block data which cannot be rolled back, so that the block is stored in the first data storage unit, the accuracy of the data stored in the first data storage unit is not influenced, the second block analysis thread does not need to analyze the block, and the efficiency of the second block analysis thread in analyzing the block data is further improved.
As an optional embodiment of the present invention, the merging and displaying the block data stored in the first data storage unit and the block data stored in the second data storage unit when receiving a data online display request of a user node includes: when the block corresponding to the rolling block interval comprises the rolled back block, the block data quality information displayed by the user node is prompted before the block data corresponding to the rolled back block is updated.
For example, when the block corresponding to the rolling-back block interval includes a rolled-back block, before the first block analysis thread does not re-analyze the rolled-back block, the data stored in the first data storage unit may have inaccurate data (e.g., the number of tokens remaining after the user node transaction) within a certain time, so that when the block that needs to be rolled back exists, the user node is prompted to display block data quality information, such as a data range of correct data, to the user node.
As an optional embodiment of the present invention, the method further comprises: when the block corresponding to the rolling-back block interval comprises a rolled-back block, re-analyzing the block data corresponding to the rolled-back block; or when the block corresponding to the rolling-back block section comprises a rolled-back block, analyzing the block data corresponding to the section from the rolled-back block to the latest block corresponding to the rolling-back block section.
For example, when the block corresponding to the rolling block section includes the rolled block, the data of the rolled block may be directly re-analyzed, or in order to ensure the accuracy of the analyzed data, the block data of the rolled section may also be re-analyzed until the section where the latest block corresponding to the rolling block section is located. And replacing and updating the data stored in the second data storage unit by using the analyzed data.
Specifically, two databases D1 and D2 are provided for storing the confirmed tile data and the tile data where a rollback may exist, respectively. Assuming that the current latest block height is H, the block data stored in D1 are 0-H-N blocks, the data stored in D2 are H-N + 1-H blocks, and the block data in database D1 are stable data, and can only be written into and cannot be deleted. The database D2 holds the data of N blocks in a queue mode, and when a new block of data is inserted at the tail of the queue and a block at the head of the queue is deleted, the database does not need to be considered to be rolled back; if the front-end application program performs data analysis offline, only the block data is acquired from D1, the block data to be analyzed is only N blocks less than the full amount of block data, and the block data is determined not to be rolled back and can be used for accurately performing data analysis; if the front-end application program is an application for displaying the block data on the chain in real time, the block data obtained by analysis is simultaneously acquired from the D1 and the D2 and is combined for display, only the rolled-back data generated in a short time cannot be displayed before the D2 queue is completely updated, and the data smaller than or equal to the H-N block can be correctly displayed.
Taking a certain block chain as an example, the data acquisition device (node) comprises a stable block database (MongoDB) and a latest block database (Redis), at least two block chain data analysis programs, an offline analysis program, and a real-time block browser. The analysis program is responsible for analyzing the block data and storing the block data into different databases, and the front-end application reads the data from the different databases according to respective requirements. If the average block output time of the block chain is 10 minutes/block, under the current global node density, about 8 blocks are rolling block intervals, that is, if 8 blocks are output after a certain block P, the P block will not be rolled back any more, and all rolling back will occur in 8 blocks, so N = 8; the method comprises the steps that a stable block database (MongoDB) and a latest block database (Redis) are deployed to store different data, the embodiment of the application is not limited to the two databases, the stable block database and the latest block database can be freely selected according to business requirements, and different tables in the same database instance can be used for storing the different data respectively; two sets of block chain data analysis programs are deployed, along with the continuous creation of blocks, analyzed data of all blocks from 0 to H-8 are stored in the MongoDB, only data of the latest block is analyzed, the data are continuously written into the Redis, only the data of the blocks from H-7 to H are reserved in the Redis, and redundant data are deleted after the data of the latest block are written; deploying an offline analysis program for block chain data analysis, wherein the program only reads data from MongoDB; and deploying a real-time block browser, wherein the program reads data from the MongoDB and the Redis simultaneously, and the data have the same structure and do not conflict with each other, so that the data can be merged and uniformly displayed.
The embodiment of the present invention further discloses a block chain data processing apparatus, as shown in fig. 2, the apparatus includes:
a determining module 201, configured to determine a rolling-back block interval corresponding to a block chain when a block data reading operation is performed on the block chain, where the rolling-back block interval represents an interval where new blocks of a target number that need to be generated when a block is not subjected to a rolling-back operation are located after any block is linked;
the storage module 202 is configured to enable the first block analysis thread to analyze the blocks corresponding to the rollback block interval in the read block chain and store the blocks in the second data storage unit in a queue form, enable the second block analysis thread to analyze the blocks of the block chain, and store the block data of the block chain obtained through analysis, except the blocks corresponding to the rollback block interval, in the first data storage unit.
According to the block chain data processing device, the block data corresponding to the rollback block interval which is likely to be rolled back is stored in the second data storage unit by determining the rollback block interval and analyzing the block through different block analysis threads, and the block data except the block corresponding to the rollback block interval is stored in the first storage unit, so that in the subsequent use process of the analyzed data, the data of different data storage units can be provided according to different user requirements to ensure the accuracy of the block data analysis result.
As an optional embodiment of the present invention, the apparatus further comprises: the first processing module is used for feeding back the block data stored in the first data storage unit to the user node when receiving an offline data analysis request of the user node; and the second processing module is used for merging and displaying the block data stored in the first data storage unit and the block data stored in the second data storage unit when a data online display request of a user node is received.
As an optional embodiment of the present invention, the apparatus further comprises: the analysis module is used for analyzing the newly added block by using the first block analysis thread and then storing the newly added block in the tail part of the queue of the second data storage unit when the newly added block in the block chain is monitored; and the shifting-out module is used for shifting out the block data corresponding to the blocks with the corresponding quantity from the top of the queue of the second data storage unit.
As an optional implementation manner of the present invention, the move-out module is further configured to store, in the first data storage unit, block data corresponding to the moved-out block parsed by the first block parsing thread.
As an optional implementation manner of the present invention, the second processing module is further configured to, when the block corresponding to the rolling block section includes a rolled block, prompt the user node to display block data quality information before the block data corresponding to the rolled block is updated.
As an optional embodiment of the present invention, the apparatus further comprises: the rollback analysis module is used for reanalyzing the block data corresponding to the rolled back block when the block corresponding to the rollback block interval comprises the rolled back block; or when the block corresponding to the rolling block interval comprises a rolled block, analyzing the block data corresponding to the interval from the rolled block to the latest block corresponding to the rolling block interval.
An embodiment of the present invention further provides an electronic device, as shown in fig. 3, the electronic device may include a processor 401 and a memory 402, where the processor 401 and the memory 402 may be connected through a bus or in another manner, and fig. 3 takes the connection through the bus as an example.
The memory 402, which is a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as program instructions/modules corresponding to the blockchain data processing method in the embodiments of the present invention. The processor 401 executes various functional applications and data processing of the processor by running non-transitory software programs, instructions and modules stored in the memory 402, that is, the block chain data processing method in the above method embodiment is implemented.
The memory 402 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created by the processor 401, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 402 may optionally include memory located remotely from processor 401, which may be connected to processor 401 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more modules are stored in the memory 402 and when executed by the processor 401, perform the block chain data processing method in the embodiment shown in fig. 1.
The details of the electronic device may be understood with reference to the corresponding related description and effects in the embodiment shown in fig. 1, and are not described herein again.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard Disk (Hard Disk Drive, abbreviated as HDD) or a Solid State Drive (SSD), etc.; the storage medium may also comprise a combination of memories of the kind described above.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.
Claims (10)
1. A method for processing block chain data, comprising:
when block data reading operation is performed on a block chain, determining a rolling block interval corresponding to the block chain, wherein the rolling block interval represents an interval where a target number of new blocks are located, wherein the new blocks need to be generated under the condition that the block is not subjected to rolling operation after any block is chained;
and starting the first block analysis thread to analyze the blocks corresponding to the rollback block interval in the read block chain and then store the blocks in a second data storage unit in a queue form, starting the second block analysis thread to analyze the blocks of the block chain, and storing the block data, except the blocks corresponding to the rollback block interval, in the analyzed block chain in the first data storage unit.
2. The method according to claim 1, wherein after storing the block data of the parsed block chain except for the block corresponding to the rolling block interval in the first data storage unit, the method further comprises:
when an offline data analysis request of a user node is received, feeding back block data stored in the first data storage unit to the user node;
and when a data online display request of a user node is received, merging and displaying the block data stored in the first data storage unit and the block data stored in the second data storage unit.
3. The method of claim 1, further comprising:
when a newly added block in the block chain is monitored, the newly added block is analyzed by the first block analysis thread and then stored at the tail of the queue of the second data storage unit;
and shifting out the block data corresponding to the corresponding number of blocks from the top of the queue of the second data storage unit.
4. The method of claim 3, further comprising:
and storing the block data corresponding to the shifted-out block analyzed by the first block analysis thread into the first data storage unit.
5. The method according to claim 2, wherein when receiving a data online display request from a user node, merging and displaying the block data stored in the first data storage unit and the block data stored in the second data storage unit, comprises:
when the block corresponding to the rolling block interval comprises the rolled back block, the block data quality information displayed by the user node is prompted before the block data corresponding to the rolled back block is updated.
6. The method according to any one of claims 1-5, further comprising:
when the block corresponding to the rolling-back block interval comprises a rolled-back block, re-analyzing the block data corresponding to the rolled-back block; alternatively, the first and second electrodes may be,
and when the block corresponding to the rolling block interval comprises a rolled back block, analyzing the block data corresponding to the interval from the rolled back block to the latest block corresponding to the rolling block interval.
7. A block chain data processing apparatus, comprising:
the determining module is used for determining a rolling block interval corresponding to a block chain when the block data reading operation is performed on the block chain, wherein the rolling block interval represents an interval where a target number of new blocks are required to be generated under the condition that the block cannot be rolled back under the condition that any block is chained;
and the storage module is used for starting the first block analysis thread to analyze the blocks corresponding to the rollback block interval in the read block chain and then storing the blocks in the second data storage unit in a queue form, starting the second block analysis thread to analyze the blocks of the block chain, and storing the block data, except the blocks corresponding to the rollback block interval, in the analyzed block chain in the first data storage unit.
8. The apparatus of claim 7, further comprising:
the first processing module is used for feeding back the block data stored in the first data storage unit to the user node when receiving an offline data analysis request of the user node;
and the second processing module is used for merging and displaying the block data stored in the first data storage unit and the block data stored in the second data storage unit when a data online display request of a user node is received.
9. An electronic device, comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to cause the at least one processor to perform the steps of the blockchain data processing method of any one of claims 1 to 6.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the block chain data processing method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210547111.9A CN114780642B (en) | 2022-05-20 | 2022-05-20 | Block chain data processing method and device and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210547111.9A CN114780642B (en) | 2022-05-20 | 2022-05-20 | Block chain data processing method and device and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114780642A CN114780642A (en) | 2022-07-22 |
CN114780642B true CN114780642B (en) | 2022-08-26 |
Family
ID=82407926
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210547111.9A Active CN114780642B (en) | 2022-05-20 | 2022-05-20 | Block chain data processing method and device and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114780642B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110442577A (en) * | 2019-07-15 | 2019-11-12 | 杭州复杂美科技有限公司 | A kind of storage of status data, inquiry and management method, equipment and storage medium |
CN111274318A (en) * | 2020-01-16 | 2020-06-12 | 杭州趣链科技有限公司 | Block chain state data storage and rollback method, equipment and storage medium |
CN111861471A (en) * | 2020-07-30 | 2020-10-30 | 杭州复杂美科技有限公司 | Parallel chain consensus method, parallel chain block rollback method, device and storage medium |
CN112650629A (en) * | 2020-12-30 | 2021-04-13 | 杭州趣链科技有限公司 | Block chain index data recovery method, device, equipment and computer storage medium |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20220019575A1 (en) * | 2018-12-04 | 2022-01-20 | Zeu Technologies, Inc. | System And Method For Augmenting Database Applications With Blockchain Technology |
CN109903026A (en) * | 2018-12-14 | 2019-06-18 | 阿里巴巴集团控股有限公司 | Event-handling method and device, electronic equipment based on block chain |
-
2022
- 2022-05-20 CN CN202210547111.9A patent/CN114780642B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110442577A (en) * | 2019-07-15 | 2019-11-12 | 杭州复杂美科技有限公司 | A kind of storage of status data, inquiry and management method, equipment and storage medium |
CN111274318A (en) * | 2020-01-16 | 2020-06-12 | 杭州趣链科技有限公司 | Block chain state data storage and rollback method, equipment and storage medium |
CN111861471A (en) * | 2020-07-30 | 2020-10-30 | 杭州复杂美科技有限公司 | Parallel chain consensus method, parallel chain block rollback method, device and storage medium |
CN112650629A (en) * | 2020-12-30 | 2021-04-13 | 杭州趣链科技有限公司 | Block chain index data recovery method, device, equipment and computer storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN114780642A (en) | 2022-07-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108108127B (en) | File reading method and system | |
CN104252481A (en) | Dynamic check method and device for consistency of main and salve databases | |
CN106339274A (en) | Method and system for obtaining data snapshot | |
CN108153587B (en) | Slow task reason detection method for big data platform | |
US10514993B2 (en) | Analyzing large-scale data processing jobs | |
CN111159157A (en) | Method and device for indexing processing of enterprise report data | |
EP3264291A1 (en) | Data block processing method and device | |
CN105630653A (en) | CPU vacancy rate determination method and device for Docker container | |
CN114780642B (en) | Block chain data processing method and device and electronic equipment | |
US8548980B2 (en) | Accelerating queries based on exact knowledge of specific rows satisfying local conditions | |
CN115329011A (en) | Data model construction method, data query method, data model construction device and data query device, and storage medium | |
CN113360581A (en) | Data processing method, device and storage medium | |
CN109710698B (en) | Data aggregation method and device, electronic equipment and medium | |
CN104317820B (en) | Statistical method and device for report forms | |
CN116089518A (en) | Data model extraction method and system, terminal and medium | |
CN112612773A (en) | Database synchronization test method and device, computer equipment and storage medium | |
CN109829016B (en) | Data synchronization method and device | |
CN114048231A (en) | Data processing method, device and computer program product | |
CN107590286B (en) | Method and device for managing transaction information in cluster file system | |
CN116467162A (en) | Simulation environment construction method and system for index recommendation of distributed database | |
CN112035484B (en) | Local fault feature extraction method and system for fault record data | |
US20240104137A1 (en) | Main path analysis method and device | |
CN113762665B (en) | Real-time index related real-time data backtracking method and system | |
CN117421322A (en) | Data reading method, device, equipment and medium | |
CN115809820A (en) | Index calculation method, electronic device and computer-readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |