Blockchain data query method, device, equipment and storage medium

By obtaining network identifiers in the blockchain network, starting the status database and extracting data, encapsulating it into a general data structure for querying, the problem of data query uniformity in blockchain network is solved, query efficiency and complex query capabilities are improved, and the query efficiency is reduced. Difficulty in development.

CN114860807BActive Publication Date: 2024-11-05KINGDEE SOFTWARE(CHINA) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210508408.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-11
Publication Date
2024-11-05
Estimated Expiration
2042-05-11

AI Technical Summary

Technical Problem

Due to the different data structures and interfaces of blockchain networks, it is difficult to conduct unified query of data stored in each blockchain network, and it is difficult for the existing technology to realize unified query of heterogeneous blockchain networks.

Method used

By obtaining the network identifier of the blockchain network to be synchronized, the target state database is started, the block data is extracted and encapsulated into a general data structure, and stored in the target state database, a unified query interface is provided to achieve the unification of the data of each blockchain network Query.

Benefits of technology

It realizes unified query of various types of blockchain network data, improves data query efficiency, blocks the differences in blockchain network data structure, and supports complex queries required by business systems, reducing blockchain The difficulty and technical complexity of application development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114860807B_ABST
    Figure CN114860807B_ABST
Patent Text Reader

Abstract

The present application relates to a data query method, device, computer equipment, storage medium and computer program product of a blockchain. The method comprises: obtaining a network identifier of a blockchain network to be synchronized through a startup instruction, and starting a target state database according to the network identifier; in the blockchain network to be synchronized, extracting block data stored in a data structure corresponding to the blockchain network to be synchronized; encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in the target state database; querying the block data of the general data structure through a query interface provided by the target state database to obtain a query result. This method can support unified querying of data in each blockchain network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a blockchain data query method, device, computer equipment, storage medium and computer program product. Background Art

[0002] With the development of computer technology, blockchain is widely used to store data in various business fields due to its characteristics of immutable history, traceable process, transparent and controllable permissions, etc. Since the data structures and interfaces of various blockchain networks are different, and the data query statements or syntax supported by each blockchain network are not unified, how to uniformly query the data stored in each blockchain network has become an urgent problem to be solved. Summary of the invention

[0003] Based on this, it is necessary to provide a blockchain data query method, device, computer equipment, computer-readable storage medium and computer program product that can support unified query of data in each blockchain network in response to the above technical problems.

[0004] In a first aspect, the present application provides a method for querying blockchain data. The method comprises:

[0005] Obtain the network identifier of the blockchain network to be synchronized through the startup instruction, and start the target state database according to the network identifier;

[0006] In the blockchain network to be synchronized, extracting block data stored according to the data structure corresponding to the blockchain network to be synchronized;

[0007] Encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in the target state database;

[0008] Through the query interface provided by the target state database, a query is performed in the block data of the general data structure to obtain a query result.

[0009] In a second aspect, the present application also provides a blockchain data query device. The device comprises:

[0010] A startup module, used to obtain the network identifier of the blockchain network to be synchronized through a startup instruction, and start the target state database according to the network identifier;

[0011] An extraction module, used to extract, in the blockchain network to be synchronized, block data stored in a data structure corresponding to the blockchain network to be synchronized;

[0012] A storage module, used for encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in the target state database;

[0013] The query module is used to query the block data of the general data structure through the query interface provided by the target state database to obtain the query result.

[0014] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0015] Obtain the network identifier of the blockchain network to be synchronized through the startup instruction, and start the target state database according to the network identifier;

[0016] In the blockchain network to be synchronized, extracting block data stored according to the data structure corresponding to the blockchain network to be synchronized;

[0017] Encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in the target state database;

[0018] Through the query interface provided by the target state database, a query is performed in the block data of the general data structure to obtain a query result.

[0019] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0020] Obtain the network identifier of the blockchain network to be synchronized through the startup instruction, and start the target state database according to the network identifier;

[0021] In the blockchain network to be synchronized, extracting block data stored according to the data structure corresponding to the blockchain network to be synchronized;

[0022] Encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in the target state database;

[0023] Through the query interface provided by the target state database, a query is performed in the block data of the general data structure to obtain a query result.

[0024] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0025] Obtain the network identifier of the blockchain network to be synchronized through the startup instruction, and start the target state database according to the network identifier;

[0026] In the blockchain network to be synchronized, extracting block data stored according to the data structure corresponding to the blockchain network to be synchronized;

[0027] Encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in the target state database;

[0028] Through the query interface provided by the target state database, a query is performed in the block data of the general data structure to obtain a query result.

[0029] The data query method, device, computer equipment, storage medium and computer program product of the above blockchain obtain the network identification of the blockchain network to be synchronized through the startup instruction, and start the target state database according to the network identification. Therefore, for various types of blockchain networks to be synchronized, the corresponding target state database can be started through the startup instruction, and a unified query interface is provided to the business system through the target state database. In the blockchain network to be synchronized, the block data stored according to the data structure corresponding to the blockchain network to be synchronized is extracted, and the block data is encapsulated as block data of a general data structure, so that the block data of various data structures stored in various heterogeneous blockchain networks can be converted into block data of a general data structure, shielding the differences in data structures of various blockchain networks, so that the business system can query the block data of the general data structure through a unified query method. The block data of the general data structure is stored in the target state database, and the query interface provided by the target state database is used to query the block data of the general data structure to obtain the query result. Therefore, the unified query interface provided by the target state database can be used to query the block data from various blockchain networks stored in the target state database in a unified manner, without the need to build query interfaces for various types of blockchain networks to query them separately, thus achieving unified query of data stored in various types of blockchain networks and improving the efficiency of data query. In addition, since the database technology used in the underlying framework of the blockchain network is generally simple and cannot support the complex queries required by the business system, the query interface provided by the state database can support the complex queries required by the business system, further improving the efficiency of data query. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 This is an application environment diagram of a data query method of a blockchain in one embodiment;

[0031] Figure 2A flowchart of a data query method of a blockchain in one embodiment;

[0032] Figure 3 is a schematic diagram of a query interface in one embodiment;

[0033] Figure 4 A schematic diagram of a blockchain browser in one embodiment;

[0034] Figure 5 A schematic diagram of a blockchain browser in another embodiment;

[0035] Figure 6 A schematic diagram of a query result display interface in one embodiment;

[0036] Figure 7 A schematic diagram of the principle of a data query method in an embodiment;

[0037] Figure 8 is a flow chart of a data query method in another embodiment;

[0038] Fig. 9 It is a structural block diagram of a data query device of a blockchain in one embodiment;

[0039] Fig.10 It is a structural block diagram of a data query device of a blockchain in another embodiment;

[0040] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0041] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0042] The blockchain data query method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the server 102 obtains the network identification of the blockchain network to be synchronized through the startup instruction, and starts the target state database 106 according to the network identification; in the blockchain network to be synchronized, the block data stored according to the data structure corresponding to the blockchain network to be synchronized is extracted; the block data is encapsulated as block data of a general data structure, and the block data of the general data structure is stored in the target state database 106; the business system 104 queries the block data of the general data structure through the query interface provided by the target state database 106 to obtain the query result. Among them, the state database 106 can store the data that the server 102 needs to process, including the block data of the general data structure. The state database can be integrated on the server 102, or it can be placed on the cloud or other network servers. The server 102 can be implemented with an independent server or a server cluster composed of multiple servers. The business system 104 includes but is not limited to financial systems, personnel systems, tax systems, enterprise management systems, ERP (Enterprise Resource Planning) systems, manufacturing management systems, supply chain systems, etc.

[0043] In one embodiment, Figure 2 As shown, a data query method of blockchain is provided, and the method is applied to Figure 1 The server in the example is used to illustrate the following steps:

[0044] S202, obtaining the network identifier of the blockchain network to be synchronized through a startup instruction, and starting the target state database according to the network identifier.

[0045] Among them, the startup instruction is a general instruction for opening the state database. Through the startup instruction, the corresponding state database can be opened for various types of blockchain networks, and the data in the blockchain network can be synchronized to the state database. When the state database is successfully opened through the startup instruction, the server can obtain the network address of the state database through the startup instruction and access the state database through the network address. The obtained network address can be a URL (Uniform Resource Locator) address.

[0046] The blockchain network to be synchronized may be a blockchain network of various network types, and may have various SDK (Software Development Kit) or API (Application Programming Interface) interfaces. The network identifier is an identifier used to identify the blockchain network, and may be an identification code (ID) of the blockchain network. The state database is a database used to store data snapshots of the blockchain network, and may be implemented using a relational database or a non-relational database. For example, a relational database may be a MySQL (My Structured Query Language) database or a ProgreSQL database, and for example, a non-relational database may be a MongoDB database or a CouchDB database.

[0047] S204: In the blockchain network to be synchronized, extract the block data stored in the data structure corresponding to the blockchain network to be synchronized.

[0048] The blockchain network includes multiple blockchains, each blockchain includes multiple blocks, and the blocks store block data, which includes business data generated in the business system. Business data can be, for example, various documents, contracts, tickets, etc. For various types of blockchain networks, each blockchain network stores block data according to its corresponding data structure. The server extracts the block data stored in the data structure corresponding to the blockchain network to be synchronized in the blockchain network to be synchronized.

[0049] In one embodiment, the block data includes historical block data and newly added block data; S204 specifically includes: in the historical blocks of the blockchain network to be synchronized, extracting the historical block data stored in the data structure corresponding to the blockchain network to be synchronized; the historical block is the block generated before the target state database is started; when the block addition message is monitored, in the newly added blocks of the blockchain network to be synchronized, extracting the newly added block data stored in the data structure corresponding to the blockchain network to be synchronized; the newly added block is the block generated after the target state database is started.

[0050] Among them, the historical block data is the data stored in the block generated before the target state database is started. The newly added block data is the data stored in the block generated after the target state database is started. The block new message is a message used to indicate that a new block has been added to the blockchain network. After the server opens the state database, it extracts the historical block data stored in the data structure corresponding to the blockchain network to be synchronized from the historical blocks of the blockchain network to be synchronized, so as to synchronize the historical block data to the state database. In addition, since new blocks are constantly generated in the running blockchain network, the server monitors the blockchain network. When a block new message is monitored, the newly added block is obtained, and the newly added block data is extracted from the newly added block. In this way, the latest block data can be kept updated synchronously, so that a quasi-real-time data backup (or data snapshot) of the blockchain network is stored in the state database.

[0051] S206, encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in a target state database.

[0052] Among them, the general data structure is a unified data structure for various types of blockchain networks. After the server extracts the block data from the blockchain network to be synchronized, since the data structures of the block data stored in various blockchain networks are different, in order to realize unified query of the data in various blockchain networks, the server encapsulates the block data into block data of the general data structure and stores the block data of the general data structure in the target state database.

[0053] In one embodiment, S206 specifically includes: encapsulating the block data into block data of a general data structure; when the amount of the block data is greater than a preset amount, storing the block data of the general data structure in the target state database in a manner of sub-table storage or sub-library storage.

[0054] S208, querying the block data of the general data structure through the query interface provided by the target state database to obtain the query result.

[0055] The query interface is an interface that is uniformly encapsulated for the business system, and is used to enable the business system to query data from the blockchain network through the query interface. Figure 3As shown, the state database provides a query interface to the blockchain browser, and the blockchain browser can query the data stored in the state database through the query interface. The query interface includes a block query interface, a transaction query interface, a business query interface, a fuzzy query interface, a conditional query interface, a keyword search interface, and a data analysis interface. The block query interface is used to query data according to blocks, for example, querying in block 1 or blocks 1-5. The transaction query interface is an interface for querying data according to transactions, for example, querying in transaction data generated by transactions in the last hour. The business query interface is an interface for querying business data, for example, querying the amount, business requester identifier, etc. in business data such as orders and contracts. The fuzzy query interface is an interface for performing fuzzy queries. The conditional query interface is an interface for performing conditional queries, for example, querying orders with an amount greater than 100,000. The keyword search interface is an interface for querying based on keywords, for example, using the transaction party identifier as a keyword to query transaction data with the transaction party identifier AX-1. The data analysis interface is an interface used for data analysis, for example, statistical analysis of the callers of the transaction contract, or statistical analysis of key indicators of the transaction.

[0056] In the above embodiment, the network identifier of the blockchain network to be synchronized is obtained through the startup instruction, and the target state database is started according to the network identifier. Therefore, for various types of blockchain networks to be synchronized, the corresponding target state database can be started through the startup instruction, and a unified query interface is provided to the business system through the target state database. In the blockchain network to be synchronized, the block data stored according to the data structure corresponding to the blockchain network to be synchronized is extracted, and the block data is encapsulated as block data of a general data structure, so that the block data of various data structures stored in various heterogeneous blockchain networks can be converted into block data of a general data structure, shielding the differences in data structures of various blockchain networks, so that the business system can query the block data of the general data structure through a unified query method. The block data of the general data structure is stored in the target state database, and the query interface provided by the target state database is used to query the block data of the general data structure to obtain the query result. Therefore, the unified query interface provided by the target state database can be used to query the block data from various blockchain networks stored in the target state database in a unified manner, without the need to build query interfaces for various types of blockchain networks to query them separately, thus achieving unified query of data stored in various types of blockchain networks and improving the efficiency of data query. In addition, since the database technology used in the underlying framework of the blockchain network is generally simple and cannot support the complex queries required by the business system, the query interface provided by the state database can support the complex queries required by the business system, further improving the efficiency of data query.

[0057] In one embodiment, before S208, it also includes: parsing the block data of the general data structure to obtain business data in a business data format; S208 specifically includes: responding to a business data query request, querying the business data through a query interface provided by the target state database to obtain a query result.

[0058] Among them, the business data format is a data format defined for business data. For example, the data format defined for contracts, orders, etc. The business data query request is a request to query business data, for example, it can be a request to query order amount, completed orders, order completion volume, etc. Since the underlying data architecture of the blockchain network is relatively simple, it usually does not support complex queries on business data on the blockchain. The server parses the block data of the general data structure to obtain business data in the business data format, and then stores the business data in the state database, and queries the business data through the query interface provided by the state database. For example, the server parses the block data, extracts the order from the block data, and then extracts the order amount, ordering party identifier, etc. from the order, and can query or sort the order amount, ordering party identifier, etc.

[0059] In the above embodiment, the server parses the block data of the general data structure to obtain the business data in the business data format. Through the query interface provided by the target state database, the business data is queried to obtain the query result. Thus, complex queries on the business data can be implemented through the query interface provided by the state database, thereby improving the data query efficiency.

[0060] In one embodiment, query parameters are obtained, and query statements are generated according to the query parameters; S208 specifically includes: in response to a query request including a query statement, calling a query interface provided by the target state database; querying the block data of the general data structure according to the query statement through the query interface.

[0061] Among them, query parameters are parameters used to search for query results, including blockchain identifier, transaction contract caller identifier, query object, paging parameters, etc. Query statements are program statements used to execute query tasks, which can be SQL statements or statements written in other database languages. Evidence data is business data for blockchain evidence. According to the query parameters and business data format, the query statement can be customized, and then the query interface provided by the target state database can be used to query the block data in the general data structure according to the query statement.

[0062] In the above embodiment, query parameters are obtained, and query statements are generated according to the query parameters. In response to a query request containing a query statement, the query interface provided by the target state database is called, and then the query is performed in the block data of the general data structure according to the query statement through the query interface. Thus, complex queries on business data can be performed through the query interface provided by the state database, which improves the efficiency of data query. In addition, the differences between heterogeneous blockchain networks are shielded, so that data query does not need to rely on the interface and data structure of the blockchain network, and unified queries on heterogeneous blockchain networks are realized, which reduces the difficulty and technical complexity of blockchain application development.

[0063] In one embodiment, S208 specifically includes: in response to a query request triggered in a blockchain browser, querying the block data of a general data structure through a query interface provided by a target state database to obtain a query result; after S208, it also includes: calculating based on the query result to obtain transaction statistics information and block statistics information; in the interface of the blockchain browser, displaying the transaction statistics information and block statistics information.

[0064] Among them, the blockchain browser is a browser used to view data in the blockchain. Figure 4 As shown in the figure, the blockchain browser can display the current transaction peak, total transaction number, block height in the blockchain, number of transaction contracts, and number of nodes in the blockchain. Figure 5 As shown, the current peak value, block rate, number of transaction contracts, etc. can be displayed in the blockchain browser. A query request is a request for querying block data or transaction data stored in the blockchain network, which can be a request triggered by a query control in the blockchain browser. Transaction statistics are statistical information obtained by counting the data of recorded transactions, such as the total transaction volume, the order of transaction volume per unit time, and the identification of the transaction party. Block statistics are statistical information obtained by counting the data recorded from the perspective of blocks, such as the average block height, block size, and peak block height.

[0065] The server uses the query interface provided by the target state database to query the block data of the general data structure, for example, to query the total number of transactions on 2021-02-11, or to query the block height of blockchain 1, etc., to obtain the query results. The server then calculates the query results, including statistical averages, variances, maximum or minimum values, etc. When the server calculates the transaction statistics and block statistics, it displays the transaction statistics and block statistics in the interface of the blockchain browser.

[0066] In the above embodiment, the server responds to the query request triggered in the blockchain browser, and queries the block data of the general data structure through the query interface provided by the target state database to obtain the query result. Calculation is performed based on the query result to obtain transaction statistics and block statistics, and the transaction statistics and block statistics are displayed in the interface of the blockchain browser. Therefore, the query results, transaction statistics and block statistics can be displayed dynamically and in real time in the blockchain browser, so that the query results can be visualized and convenient for users to view.

[0067] In one embodiment, S202 specifically includes: in response to a state database start operation triggered in a blockchain browser, obtaining a network identifier of the blockchain network to be synchronized through a start instruction; configuring a state database type according to the network identifier; and starting a target state database corresponding to the state database type.

[0068] The state database opening operation is an operation used to trigger the opening of the state database, which can be an operation triggered by clicking, dragging, or sliding a control. Figure 6 As shown, the state database opening operation is triggered by clicking the "Open state database" control in the blockchain browser. State database types include various database types such as MySQL, ProgreSQL, MongoDB, or CouchDB. The server starts the target state database according to the state database type configured by the network identifier. For example, when the configured state database type is a MySQL database, the target state database of the MySQL type is started.

[0069] In the above embodiment, the server responds to the state database start operation triggered in the blockchain browser, and obtains the network identifier of the blockchain network to be synchronized through the start instruction. The state database type is configured according to the network identifier, and the target state database corresponding to the state database type is started. Therefore, the target state database can be started through a unified start instruction for various heterogeneous blockchain networks, shielding the differences between various blockchain networks.

[0070] In one embodiment, after S208, it also includes: in response to a state database closing operation triggered in the blockchain browser, closing the target state database through a closing instruction.

[0071] The state database closing operation is used to trigger the closing of the state database, and may be an operation triggered by clicking, dragging, or sliding a control. Figure 6As shown in the figure, the state database closing operation is triggered by clicking the "Close state database" control in the blockchain browser. The close command is a general command for closing the state database. Through the close command, the corresponding state database can be closed for various types of blockchain networks.

[0072] In the above embodiment, the server responds to the state database closing operation triggered in the blockchain browser and closes the target state database through a closing instruction. Thus, the target state database can be closed through a unified closing instruction for various heterogeneous blockchain networks, shielding the differences between various blockchain networks.

[0073] In one embodiment, Figure 7 As shown in the figure, during the operation of the blockchain, the server opens the state database through a startup instruction that is common to multiple heterogeneous blockchain frameworks, and configures the state database. As shown in Table 1, the parameters obtained by the startup instruction are the network metadata (Network) of the blockchain network, and the network metadata includes a network identification field, a network type field, etc. The server can configure the state database as a relational database or a non-relational database. After the configuration is completed, the server starts the block data synchronization service, and synchronizes the historical block data in the historical blocks generated before the state database is opened to the state database through the block data synchronization service. The server monitors the blockchain network, and when a block new message is heard, it obtains the new block and synchronizes the new block data in the new block to the state database. The server parses the block data synchronized to the state database based on the general data structure, obtains the block data of the general data structure, and stores the block data of the general data structure in the state database. The state database provides a unified encapsulated query interface to the business system, and the business system can query the data synchronized from the blockchain network to the state database through the query interface. The server can also directly use the query language of SQL or NoSQL database to query the data synchronized from the blockchain network to the state database. The server synchronizes the data stored in the blockchain network to the state database, and then uses the state database to query the data in the blockchain network. The query does not require the use of blockchain operating resources, which reduces the use of blockchain resources, improves the efficiency of blockchain resource utilization, and avoids the query process from interfering with the operation of the blockchain network. In addition, the state database supports complex and rich query and analysis of blockchain data, and can use the blockchain browser to visualize the query results and statistical information, so that the dynamics of blockchain operation can be understood intuitively and in real time.

[0074] Table 1

[0075]

[0076] In one embodiment, Figure 8 As shown, the data query method of the blockchain includes the following steps:

[0077] S802, in response to a state database start operation triggered in a blockchain browser, obtain a network identifier of the blockchain network to be synchronized through a start instruction.

[0078] S804, configuring a state database type according to the network identifier; and starting a target state database corresponding to the state database type.

[0079] S806, extracting historical block data stored in a data structure corresponding to the blockchain network to be synchronized from the historical blocks of the blockchain network to be synchronized; the historical blocks are blocks generated before starting the target state database.

[0080] S808, when a block addition message is monitored, in the newly added block of the blockchain network to be synchronized, the newly added block data stored in the data structure corresponding to the blockchain network to be synchronized is extracted; the newly added block is the block generated after the target state database is started.

[0081] S810, encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in a target state database.

[0082] S812: Obtain query parameters, and generate query statements according to the query parameters.

[0083] S814: In response to the query request including the query statement, a query interface provided by the target state database is called.

[0084] S816, querying the block data of the general data structure according to the query statement through the query interface to obtain the query result.

[0085] S818, performing calculations based on the query results to obtain transaction statistics information and block statistics information, and displaying the transaction statistics information and block statistics information in the interface of the blockchain browser.

[0086] S820, in response to a state database closing operation triggered in the blockchain browser, closing the target state database through a closing instruction.

[0087] For the specific contents of S802 to S820 above, reference may be made to the specific implementation process described above.

[0088] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0089] Based on the same inventive concept, the embodiment of the present application also provides a data query device for implementing the data query method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the data query device embodiments of one or more blockchains provided below can refer to the limitations of the data query method of the blockchain above, and will not be repeated here.

[0090] In one embodiment, Fig. 9 As shown, a data query device of a blockchain is provided, including: a startup module 902, an extraction module 904, a storage module 906 and a query module 908, wherein:

[0091] A startup module 902 is used to obtain a network identifier of the blockchain network to be synchronized through a startup instruction, and to start a target state database according to the network identifier;

[0092] An extraction module 904 is used to extract block data stored in a data structure corresponding to the blockchain network to be synchronized in the blockchain network to be synchronized;

[0093] Storage module 906, used to encapsulate the block data into block data of a general data structure, and store the block data of the general data structure in a target state database;

[0094] The query module 908 is used to query the block data of the general data structure through the query interface provided by the target state database to obtain the query result.

[0095] In the above embodiment, the network identifier of the blockchain network to be synchronized is obtained through the startup instruction, and the target state database is started according to the network identifier. Therefore, for various types of blockchain networks to be synchronized, the corresponding target state database can be started through the startup instruction, and a unified query interface is provided to the business system through the target state database. In the blockchain network to be synchronized, the block data stored according to the data structure corresponding to the blockchain network to be synchronized is extracted, and the block data is encapsulated as block data of a general data structure, so that the block data of various data structures stored in various heterogeneous blockchain networks can be converted into block data of a general data structure, shielding the differences in data structures of various blockchain networks, so that the business system can query the block data of the general data structure through a unified query method. The block data of the general data structure is stored in the target state database, and the query interface provided by the target state database is used to query the block data of the general data structure to obtain the query result. Therefore, the unified query interface provided by the target state database can be used to query the block data from various blockchain networks stored in the target state database in a unified manner, without the need to build query interfaces for various types of blockchain networks to query them separately, thus achieving unified query of data stored in various types of blockchain networks and improving the efficiency of data query. In addition, since the database technology used in the underlying framework of the blockchain network is generally simple and cannot support the complex queries required by the business system, the query interface provided by the state database can support the complex queries required by the business system, further improving the efficiency of data query.

[0096] In one embodiment, the block data includes historical block data and newly added block data; the extraction module 904 is further used to:

[0097] In the historical blocks of the blockchain network to be synchronized, extract the historical block data stored in the data structure corresponding to the blockchain network to be synchronized; the historical block is the block generated before the target state database is started;

[0098] When a block addition message is monitored, the newly added block data stored in the data structure corresponding to the blockchain network to be synchronized is extracted from the newly added block of the blockchain network to be synchronized; the newly added block is the block generated after the target state database is started.

[0099] In one embodiment, Fig.10 As shown, the device also includes:

[0100] A parsing module 910 is used to parse the block data of the general data structure to obtain business data in a business data format;

[0101] The query module 908 is further used to respond to a business data query request, query the business data through a query interface provided by the target state database, and obtain a query result.

[0102] In one embodiment, the apparatus further comprises:

[0103] The acquisition module 912 is used to acquire query parameters and generate query statements according to the query parameters;

[0104] The query module 908 is further used for:

[0105] In response to a query request including a query statement, calling a query interface provided by the target state database;

[0106] Through the query interface, queries are performed in the block data of the general data structure according to the query statement.

[0107] In one embodiment, the query module 908 is further configured to:

[0108] In response to a query request triggered in a blockchain browser, a query is performed in the block data of a general data structure through a query interface provided by the target state database to obtain a query result;

[0109] The device also includes:

[0110] A calculation module 914 is used to perform calculations based on the query results to obtain transaction statistics and block statistics;

[0111] The display module 916 is used to display transaction statistics and block statistics in the interface of the blockchain browser.

[0112] In one embodiment, the startup module 902 is further configured to:

[0113] In response to a state database start operation triggered in a blockchain browser, a network identifier of the blockchain network to be synchronized is obtained through a start instruction;

[0114] Configure the state database type according to the network identifier;

[0115] Start the target state database corresponding to the state database type.

[0116] In one embodiment, the apparatus further comprises:

[0117] The closing module 918 is used to close the target state database through a closing instruction in response to the state database closing operation triggered in the blockchain browser.

[0118] Each module in the data query device of the above blockchain can be implemented in whole or in part by software, hardware and their combination. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.

[0119] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.11 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data query data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data query method is implemented.

[0120] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0121] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: obtaining a network identifier of a blockchain network to be synchronized through a startup instruction, and starting a target state database according to the network identifier; in the blockchain network to be synchronized, extracting block data stored in a data structure corresponding to the blockchain network to be synchronized; encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in the target state database; querying the block data of the general data structure through a query interface provided by the target state database to obtain a query result.

[0122] In one embodiment, the block data includes historical block data and newly added block data; when the processor executes the computer program, the following steps are also implemented: in the historical blocks of the blockchain network to be synchronized, the historical block data stored in the data structure corresponding to the blockchain network to be synchronized is extracted; the historical block is the block generated before the target state database is started; when the block addition message is monitored, in the newly added block of the blockchain network to be synchronized, the newly added block data stored in the data structure corresponding to the blockchain network to be synchronized is extracted; the newly added block is the block generated after the target state database is started.

[0123] In one embodiment, when the processor executes the computer program, the following steps are also implemented: parsing the block data of the general data structure to obtain business data in a business data format; responding to a business data query request, querying the business data through a query interface provided by the target state database to obtain a query result.

[0124] In one embodiment, when the processor executes the computer program, the following steps are also implemented: obtaining query parameters and generating query statements based on the query parameters; querying the block data of the general data structure through the query interface provided by the target state database includes: responding to a query request containing a query statement, calling the query interface provided by the target state database; querying the block data of the general data structure according to the query statement through the query interface.

[0125] In one embodiment, the processor further implements the following steps when executing the computer program: in response to a query request triggered in a blockchain browser, query the block data of the general data structure through a query interface provided by the target state database to obtain query results; calculate based on the query results to obtain transaction statistics and block statistics; and display the transaction statistics and block statistics in the interface of the blockchain browser.

[0126] In one embodiment, the processor further implements the following steps when executing the computer program: in response to a state database start operation triggered in a blockchain browser, obtaining a network identifier of the blockchain network to be synchronized through a start instruction; configuring a state database type according to the network identifier; and starting a target state database corresponding to the state database type.

[0127] In one embodiment, when the processor executes the computer program, the following steps are also implemented: in response to a state database closing operation triggered in the blockchain browser, closing the target state database through a closing instruction.

[0128] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: obtaining a network identifier of a blockchain network to be synchronized through a startup instruction, and starting a target state database according to the network identifier; in the blockchain network to be synchronized, extracting block data stored in a data structure corresponding to the blockchain network to be synchronized; encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in the target state database; querying the block data of the general data structure through a query interface provided by the target state database to obtain a query result.

[0129] In one embodiment, the block data includes historical block data and newly added block data; when the computer program is executed by the processor, the following steps are also implemented: in the historical blocks of the blockchain network to be synchronized, the historical block data stored in the data structure corresponding to the blockchain network to be synchronized is extracted; the historical block is the block generated before the target state database is started; when the block addition message is monitored, in the newly added block of the blockchain network to be synchronized, the newly added block data stored in the data structure corresponding to the blockchain network to be synchronized is extracted; the newly added block is the block generated after the target state database is started.

[0130] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: parsing the block data of the general data structure to obtain business data in a business data format; responding to a business data query request, querying the business data through a query interface provided by the target state database to obtain a query result.

[0131] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining query parameters and generating query statements based on the query parameters; querying the block data of the general data structure through the query interface provided by the target state database includes: responding to a query request containing a query statement, calling the query interface provided by the target state database; querying the block data of the general data structure according to the query statement through the query interface.

[0132] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: in response to a query request triggered in a blockchain browser, querying the block data of the general data structure through the query interface provided by the target state database to obtain query results; performing calculations based on the query results to obtain transaction statistics and block statistics; and displaying the transaction statistics and block statistics in the interface of the blockchain browser.

[0133] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: in response to a state database start operation triggered in a blockchain browser, a network identifier of the blockchain network to be synchronized is obtained through a start instruction; a state database type is configured according to the network identifier; and a target state database corresponding to the state database type is started.

[0134] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: in response to a state database closing operation triggered in the blockchain browser, closing the target state database through a closing instruction.

[0135] In one embodiment, a computer program product is provided, including a computer program, which implements the following steps when executed by a processor: obtaining a network identifier of a blockchain network to be synchronized through a startup instruction, and starting a target state database according to the network identifier; in the blockchain network to be synchronized, extracting block data stored in a data structure corresponding to the blockchain network to be synchronized; encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in the target state database; and querying the block data of the general data structure through a query interface provided by the target state database to obtain a query result.

[0136] In one embodiment, the block data includes historical block data and newly added block data; when the computer program is executed by the processor, the following steps are also implemented: in the historical blocks of the blockchain network to be synchronized, the historical block data stored in the data structure corresponding to the blockchain network to be synchronized is extracted; the historical block is the block generated before the target state database is started; when the block addition message is monitored, in the newly added block of the blockchain network to be synchronized, the newly added block data stored in the data structure corresponding to the blockchain network to be synchronized is extracted; the newly added block is the block generated after the target state database is started.

[0137] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: parsing the block data of the general data structure to obtain business data in a business data format; responding to a business data query request, querying the business data through a query interface provided by the target state database to obtain a query result.

[0138] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining query parameters and generating query statements based on the query parameters; querying the block data of the general data structure through the query interface provided by the target state database includes: responding to a query request containing a query statement, calling the query interface provided by the target state database; querying the block data of the general data structure according to the query statement through the query interface.

[0139] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: in response to a query request triggered in a blockchain browser, querying the block data of the general data structure through the query interface provided by the target state database to obtain query results; performing calculations based on the query results to obtain transaction statistics and block statistics; and displaying the transaction statistics and block statistics in the interface of the blockchain browser.

[0140] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: in response to a state database start operation triggered in a blockchain browser, a network identifier of the blockchain network to be synchronized is obtained through a start instruction; a state database type is configured according to the network identifier; and a target state database corresponding to the state database type is started.

[0141] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: in response to a state database closing operation triggered in the blockchain browser, closing the target state database through a closing instruction.

[0142] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0143] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0144] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0145] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A data query method for a blockchain, characterized in that: The method comprises: Obtain the network identifier of the blockchain network to be synchronized through the startup instruction, and start the target state database according to the network identifier; In the blockchain network to be synchronized, extracting block data stored according to the data structure corresponding to the blockchain network to be synchronized; Encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in the target state database; Through the query interface provided by the target state database, a query is performed in the block data of the general data structure to obtain a query result.

2. The method according to claim 1, characterized in that The block data includes historical block data and newly added block data; in the blockchain network to be synchronized, extracting the block data stored in the data structure corresponding to the blockchain network to be synchronized includes: Extracting historical block data stored in a data structure corresponding to the blockchain network to be synchronized from the historical blocks of the blockchain network to be synchronized; the historical blocks are blocks generated before the target state database is started; When a block addition message is monitored, the newly added block data stored in the data structure corresponding to the blockchain network to be synchronized is extracted from the newly added block of the blockchain network to be synchronized; the newly added block is a block generated after the target state database is started.

3. The method according to claim 1, characterized in that: The method further comprises: Parsing the block data of the general data structure to obtain business data in a business data format; The query interface provided by the target state database is used to query the block data of the general data structure, and the query results obtained include: In response to a business data query request, a query is performed in the business data through a query interface provided by the target state database to obtain a query result.

4. The method according to claim 1, characterized in that: The method further comprises: Obtaining query parameters, and generating a query statement according to the query parameters; The querying in the block data of the general data structure through the query interface provided by the target state database includes: In response to a query request including the query statement, calling a query interface provided by the target state database; Through the query interface, a query is performed in the block data of the general data structure according to the query statement.

5. The method according to claim 1, characterized in that The query result obtained by querying the block data of the general data structure through the query interface provided by the target state database includes: In response to a query request triggered in a blockchain browser, querying the block data of the general data structure through a query interface provided by the target state database to obtain a query result; The method further comprises: Calculate based on the query results to obtain transaction statistics and block statistics; In the interface of the blockchain browser, the transaction statistics information and the block statistics information are displayed.

6. The method according to claim 1, characterized in that The obtaining of the network identifier of the blockchain network to be synchronized through the startup instruction and starting the target state database according to the network identifier includes: In response to a state database start operation triggered in a blockchain browser, a network identifier of the blockchain network to be synchronized is obtained through a start instruction; Configuring a state database type according to the network identifier; Start a target state database corresponding to the state database type.

7. The method according to claim 1, characterized in that The method further comprises: In response to a state database closing operation triggered in a blockchain browser, the target state database is closed by a closing instruction.

8. A data query device for blockchain, characterized in that: The device comprises: A startup module, used to obtain the network identifier of the blockchain network to be synchronized through a startup instruction, and start the target state database according to the network identifier; An extraction module, used to extract, in the blockchain network to be synchronized, block data stored in a data structure corresponding to the blockchain network to be synchronized; A storage module, used for encapsulating the block data into block data of a general data structure, and storing the block data of the general data structure in the target state database; The query module is used to query the block data of the general data structure through the query interface provided by the target state database to obtain the query result.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.