A data query method, device, equipment and readable medium

By caching the query results of the blockchain system in the cache server and using the signature of the blockchain node to verify the data validity, the problem of slow data query speed in the blockchain system is solved, the query efficiency is improved and the data validity is ensured. Improved user experience.

CN114625767BActive Publication Date: 2024-09-03ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210247877.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-10
Publication Date
2024-09-03
Estimated Expiration
2040-11-10

AI Technical Summary

Technical Problem

Query requests for massive data in the blockchain system lead to slow query speeds and affect user experience.

Method used

By caching the query results of the blockchain system in the cache server, and using the signature information of the blockchain node to verify the data validity, the query results are obtained and fed back from the cache server.

Benefits of technology

It improves the efficiency of data query, ensures the validity of data, reduces direct access to the blockchain system, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114625767B
    Figure CN114625767B
Patent Text Reader

Abstract

The embodiments of this specification disclose a data query method, apparatus, device and readable medium, and the scheme includes: a business server obtains a first query request containing a data identifier of data to be queried; sends a second query request containing the data identifier of the data to be queried to a cache server; obtains a first query result for the data identifier fed back by the cache server; the first query result includes at least query result data and node signature information of a blockchain node storing the query result data; verifies whether the query result data is valid data based on the node signature information; if the query result data is valid data, feeds back the query result data to the initiator of the first query request.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the development of computer technology, more and more users use the Internet to store data, which can effectively save users' storage space and facilitate management. For example, the blockchain system, as a decentralized database, is favored by more and more users due to its characteristics of immutability and traceability. Users can upload data to the blockchain system for storage, and correspondingly, users can also query the data stored in the blockchain system. Generally, the blockchain system can be used by multiple users to store and query data, and the massive amount of stored data in the blockchain may face a large number of query requests every day.

[0003] Therefore, how to increase query speed and improve user experience is an urgent problem to be solved. Summary of the invention

[0004] The embodiments of this specification provide a data query method, apparatus, device and readable medium for increasing the speed of data query and improving user experience.

[0005] To achieve the above purpose, the embodiments of this specification are implemented as follows:

[0006] A data query method provided in an embodiment of this specification includes:

[0007] The business server obtains a first query request including a data identifier of the data to be queried;

[0008] Sending a second query request including the data identifier of the data to be queried to the cache server;

[0009] Obtaining a first query result for the data identifier fed back by the cache server; the first query result at least includes query result data and node signature information of a blockchain node storing the query result data;

[0010] Verify whether the query result data is valid data according to the node signature information;

[0011] If the query result data is valid data, the query result data is fed back to the initiator of the first query request.

[0012] The embodiment of this specification provides a data query device, including:

[0013] A request acquisition module, used to acquire a first query request containing a data identifier of data to be queried;

[0014] A request sending module, used for sending a second query request including a data identifier of the data to be queried to the cache server;

[0015] A result acquisition module, used to obtain a first query result for the data identifier fed back by the cache server; the first query result at least includes query result data and node signature information of a blockchain node storing the query result data;

[0016] A result verification module, used to verify whether the query result data is valid data according to the node signature information;

[0017] The result feedback module is used to feed back the query result data to the initiator of the first query request if the query result data is valid data.

[0018] A data query device provided in an embodiment of the present specification includes:

[0019] at least one processor; and,

[0020] a memory communicatively connected to the at least one processor; wherein,

[0021] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:

[0022] Obtaining a first query request including a data identifier of data to be queried;

[0023] Sending a second query request including the data identifier of the data to be queried to the cache server;

[0024] Obtaining a first query result for the data identifier fed back by the cache server; the first query result at least includes query result data and node signature information of a blockchain node storing the query result data;

[0025] Verify whether the query result data is valid data according to the node signature information;

[0026] If the query result data is valid data, the query result data is fed back to the initiator of the first query request.

[0027] An embodiment of the present specification provides a computer-readable medium on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement the above-mentioned data query method.

[0028] An embodiment of this specification can achieve the following beneficial effects:

[0029] In the embodiments of the present specification, the business server can obtain data from the cache server based on the user's data query request, wherein the data in the cache server can be data obtained from the blockchain system, and then when the user needs to query data from the blockchain system, it can be obtained from the cache server, thereby improving the efficiency of data query. In order to ensure that the data obtained from the cache server is valid, the data can also be verified based on the signature of the blockchain node, thereby improving the efficiency of data query while also ensuring the validity of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0031] Figure 1 This is a schematic diagram of an application scenario of a data query method in an embodiment of this specification;

[0032] Figure 2 A flowchart of a data query method provided in an embodiment of this specification;

[0033] Figure 3 A schematic diagram of a process for verifying valid data provided in an embodiment of this specification;

[0034] Figure 4 A schematic diagram of a process for verifying valid data provided in an embodiment of this specification;

[0035] Figure 5 The embodiments of this specification provide corresponding to Figure 2 A structural schematic diagram of a data query device;

[0036] Figure 6 The embodiments of this specification provide corresponding to Figure 2 A structural diagram of a data query device. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical solutions and advantages of one or more embodiments of this specification clearer, the technical solutions of one or more embodiments of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this description, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of one or more embodiments of this specification.

[0038] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.

[0039] In the prior art, when a blockchain node of a blockchain system stores data, the data is usually stored in a hard disk storage space. When a user obtains data from a blockchain node, it is necessary to read the node's hard disk data, which takes a long time. Especially when a large amount of data is stored in the blockchain system and the query volume is large, the time it takes for the node to read the data will be significantly extended, affecting the efficiency of the user's query data.

[0040] In order to solve the defects in the prior art, this solution provides the following embodiments:

[0041] Figure 1 Schematic diagram of an application scenario of a data query method in an embodiment of this specification. Figure 1 As shown, the scenario mainly includes a business server 1, a cache server 2 and a blockchain system 3. The business server 1 can send a data query request to the cache server 2 according to the user's data query needs, and the cache server 2 can feed back the cached data corresponding to the request to the business server 1. When the data in the cache server 2 cannot meet the user's needs, the business server 1 can send a data query request to the blockchain node of the blockchain system 3 to obtain the data required by the user from at least one blockchain node of the blockchain system 3. In the embodiments of this specification, the cache server 2 can be used to provide query data for the user, which can reduce the access to the blockchain system and improve the data query efficiency.

[0042] Considering that the cache service of cache server 2 is usually a centralized service, there may be a risk of fraud. To ensure that the data obtained from cache server 2 is valid, the business server can verify the data based on the signature information of the blockchain node contained in the data, and provide the verified data to the user, thereby ensuring that the user can obtain valid data.

[0043] In actual applications, query data may be pre-stored in the blockchain system 3. For example, an individual or enterprise or institution may upload the data to be stored in the blockchain system 3 for storage. When the data is needed, the business server 1 may obtain it from the blockchain system 3. The cache server 2 may cache and store at least part of the historical query results queried by the business server 1, and may also store at least part of the data uploaded to the blockchain system 3 by the cache server 2. When the cache server 2 contains the data required by the user, the data stored in its own cache may be fed back to the business server 1.

[0044] Next, a data query method provided in the embodiment of the specification will be specifically described with reference to the accompanying drawings:

[0045] Figure 2 The flowchart of a data query method provided by the embodiment of this specification is as follows. From the program perspective, the execution subject of the process can be a program installed on an application server or an application client.

[0046] like Figure 2 As shown, the process may include the following steps:

[0047] Step 202: The business server obtains a first query request including a data identifier of data to be queried.

[0048] In practical applications, people can upload the data they need to save to the blockchain system, and use the reliability and immutability of the blockchain system to ensure the validity of the data. For example, public security, procuratorial and judicial departments can use the blockchain system to store evidence.

[0049] The business server can be a server that provides data query services to users, for example, a server that provides a client of data query services, through which users can query the on-chain data. Users can enter the data identifier of the data to be queried in the client and initiate a query request to the business server. The business server can query the corresponding data based on the data identifier and feedback it to the user. In practical applications, the data identifier can be an identifier corresponding to the data generated in the process of uploading the data to the chain, and the corresponding data can be found based on the data identifier. For example, the data identifier can be an identifier that can distinguish different data, such as name, certificate number, file number, etc.

[0050] In the embodiments of this specification, data can also exist in the form of key-value pairs. Key-value pairs are a form of data existence, which can be specifically expressed as "key-value", where key can be the hash value corresponding to the data; value can be the data itself; for example, key can also be a user ID, and value is some configuration data of the user. In practical applications, key can be used as a data identifier to find the corresponding value data based on the corresponding relationship between key and value.

[0051] Step 204: Send a second query request including the data identifier of the data to be queried to the cache server.

[0052] The cache server can be a server that is mainly based on memory cache and provides data query. In the embodiments of this specification, the cache server can cache data that the business server has recently queried from the blockchain system. For example, when a user initiates a data query request to the business server through the client, the business server can obtain data from the blockchain system. The data can be sent to the business server through the cache server, or when the blockchain system sends the data to the business server, it also sends the data to the business server, so that the cache server can cache the data that the business server has recently queried from the blockchain system.

[0053] In actual applications, when uploading data to the chain, the business server providing the uploading service can send the data to be uploaded to the cache server, and then the cache server sends the data to the blockchain system. Furthermore, the cache server can also cache the data to be uploaded to the chain.

[0054] Step 206: Obtain a first query result for the data identifier fed back by the cache server; the first query result includes at least query result data and node signature information of a blockchain node storing the query result data.

[0055] In the example of this manual, the business server can initiate a data query request to the cache server, requesting to obtain the query data from the cache server's cache. If the cache server's cache contains the data to be queried, the query result can be fed back to the business server in response to the business server's request.

[0056] After the data is uploaded to the chain, the blockchain node can sign the data and store it. The data obtained by the business server and / or cache server from the blockchain node can be data containing the signature of the blockchain node.

[0057] Step 208: Verify whether the query result data is valid data based on the node signature information.

[0058] The business server can verify the query result data obtained from the cache server based on the node signature information contained in the query result, and determine whether the query result data cached in the cache server has been tampered with. If it has not been tampered with, the data is consistent with the data in the blockchain system, and the data is valid data.

[0059] Step 210: If the query result data is valid data, the query result data is fed back to the initiator of the first query request.

[0060] It should be understood that the order of some steps in the methods described in one or more embodiments of this specification can be interchanged according to actual needs, or some steps can be omitted or deleted.

[0061] Figure 2 According to the method in the embodiment, the business server can obtain data from the cache server based on the user's data query request, thereby improving the efficiency of data query. In addition, to ensure that the data obtained from the cache server is valid, the data can also be verified based on the signature of the blockchain node, thereby improving the efficiency of data query while ensuring the validity of the data.

[0062] based on Figure 2 The method, the examples of this specification also provide some specific implementation plans of the method, which are described below.

[0063] Optionally, the node signature information is the signature information of a blockchain node that sends the query result data to the cache server. Verifying whether the query result data is valid data in step 208 may specifically include:

[0064] Determine whether the blockchain node is a secure node, and obtain a first determination result;

[0065] If the first judgment result indicates that the one blockchain node is a secure node, then using the node signature information to verify whether the query result data has not been tampered with;

[0066] If the query result data passes the verification, it is determined that the query result data is valid data.

[0067] Among them, a secure node can be understood as a node that has not been attacked, and the data stored in it is not tampered with and is trustworthy.

[0068] In actual applications, when uploading data to the blockchain system, if the data passes the consensus mechanism of the blockchain node, the blockchain node can add its own node signature information to the data, save the signed data, and broadcast the signature and / or signed data to other blockchain nodes.

[0069] The data stored in the cache server in the embodiments of this specification may include the data itself, node security information, and node signature information, wherein it may be determined whether the target node sending the data is a secure node based on the node security information, and whether the data is sent by the target node and whether the data has been tampered with based on the node signature information.

[0070] The signature information can be a digital string that can only be generated by the sender of the data information and cannot be forged by others. This digital string is also a valid proof of the authenticity of the data sent by the sender of the data information. The signature information can determine which blockchain node in the blockchain system sent the data, and can also verify whether the data has been tampered with.

[0071] In actual applications, each blockchain node can have its own pair of public keys and private keys. Assuming that the node receives data A, it can obtain the summary B of data A through hash operation, sign the summary B with the private key, and obtain the node signature information C. Finally, the node signature information C can be saved together with the data A in the node.

[0072] When the business server receives a first query request for query data A, based on the request, the business server sends a second query request for query data A to the cache server. Assuming that the business server or other business servers have previously obtained data A from blockchain node M, blockchain node M also sends data A and node signature information C to the cache server.

[0073] Figure 3 A schematic diagram of a process for verifying valid data provided in an embodiment of this specification, such as Figure 3 As shown, the cache server 310 can send the data A cached by itself and the node signature information C of the blockchain node M to the business server 320 based on the second query request; wherein, the data A and the node signature information C are sent by the blockchain node M in the blockchain system 330 to the cache server 310; the business server 320 obtains the data summary B' through hash operation on the data A, and verifies the node signature information C using the public key of the blockchain node M, wherein if the summary B can be obtained using the public key, it means that the data A is sent by the blockchain node M. Assuming that the blockchain node M is a secure node, it can be further determined whether the data A has been tampered with; wherein, if B' is consistent with B, it means that the data A sent by the cache server 310 received by the business server 320 has not been tampered with, is authentic and valid, and the business server can feedback the data A to the initiator of the query request.

[0074] As another implementation mode, the data in the cache server in the embodiment of this specification may also include the data itself and the node signature information of each blockchain node in the blockchain system, and verify whether the data is valid according to the node signature information of each blockchain node. Specifically, the node signature information in the embodiment of this specification may also be the signature information of each blockchain node in the blockchain system storing the query result data. The verification of whether the query result data is valid data may specifically include:

[0075] Using the signature information of each blockchain node to verify whether the query result data has not been tampered with;

[0076] If the query result data passes the verification, it is determined that the query result data is valid data.

[0077] Figure 4 A schematic diagram of a process for verifying valid data provided in an embodiment of this specification, such as Figure 4 As shown, assuming that the blockchain system 430 includes 5 blockchain nodes M1, M2, M3, M4 and M5, when data A is uploaded to the chain, the blockchain nodes respectively perform hash operations on the data A to obtain data summaries B1, B2, B3, B4 and B5, and then use their respective private keys to sign the summaries to obtain node signature information C1, C2, C3, C4 and C5 of their respective nodes. Each node can broadcast its respective signature information to other nodes, that is, each node can contain the signature information of each node. Assume that the business server 420 or other business servers have previously obtained data A from the blockchain node M1, and the blockchain node M1 has also sent the data A and its own node signature information C1 and the node signature information C2, C3, C4 and C5 of other nodes to the cache server 410; the cache server 410 may contain data A and the node signature information C1~C5 of each node, and the cache server may send its own cached data A and each node signature information to the business server based on the second query request; the business server 420 obtains the data summary B1' by performing a first hash operation on the data A, and verifies the node signature information C1 using the public key of the node M1. If the summary B1 can be obtained using the public key, and B1 and B1' are consistent, it means that the data A obtained by the business server 420 is the data A stored in the node M1; similarly, the business server 420 may also obtain the data summary B1' by performing a second hash operation on the data A. Abstract B2', the node signature information C2 is verified by the public key of node M2. If the summary B2 can be obtained by using the public key, and B2 and B2' are consistent, it means that the data A obtained by the business server is consistent with the data A stored in node M2. Similarly, the business server 420 can obtain the data summary B5' by performing the fifth hash operation on the data A, and verify the node signature information C5 by the public key of node M5. If the summary B5 can be obtained by using the public key, and B5 and B5' are consistent, it means that the data A obtained by the business server is consistent with the data A stored in node M5. Then, whether the data A is consistent with the data A stored in each node can be verified according to the signature information of each node. If the verification result indicates that the data A obtained by the business server is consistent with the data A stored in each data node in the blockchain, it means that the data A obtained by the business server is credible, has not been tampered with, and is valid data.

[0078] It can be understood that the above-mentioned first hash operation, second hash operation and fifth hash operation are only for illustrating that corresponding hash operations can be used for related data of different nodes. In actual applications, the hash operations can be the same hash operation or different hash operations. There is no specific limitation here, as long as the data verification can be achieved.

[0079] In actual applications, the business server may also cache the historical query results of recent queries in its own local cache. To improve data query efficiency, before sending the second query request containing the data identifier of the data to be queried to the cache server in step 204 in the embodiment of this specification, the following may also be included:

[0080] querying the data corresponding to the data identifier in the local cache of the business server to obtain a second query result;

[0081] The sending of the second query request including the data identifier of the to-be-queried data to the cache server may specifically include:

[0082] If the second query result indicates that the query fails, a second query request including the data identifier of the data to be queried is sent to the cache server.

[0083] Among them, when the query data required by the user exists in the local cache of the business server, the data stored in the local cache can be fed back to the user, and there is no need to query the cache server and / or blockchain system for data; when the local cache of the business server does not have the data required by the user, querying the cache server and / or blockchain system for data can improve the efficiency of data query, reduce the access to the cache server and / or blockchain system, and save resources.

[0084] In the embodiments of this specification, the security of the node can be determined based on statistical methods. For example, when data is obtained from a node of the blockchain system and it is found that the data has been tampered with, the node can be considered to be unsafe and the node can be marked as an unsafe node. For another example, an illegal user may replay an attack on one or some blockchain nodes. When the node is accessed abnormally many times, the node can be considered to be an attacked node and can be marked as an unsafe node. When a node is found to be abnormal, the node can be marked accordingly, or the security information of the node can be manually entered. In the above steps, determining whether a blockchain node is a safe node can specifically include:

[0085] Obtain manually entered node security information;

[0086] According to the node security information, determine whether the blockchain node is a secure node.

[0087] When the blockchain node is determined to be a secure node, it can be further determined whether the data cached in the cache server is valid.

[0088] As another implementation method, the business server in the embodiment of this specification can also obtain data from the blockchain node of the blockchain system regularly or irregularly, and use the obtained data to verify whether the blockchain node is safe. In the above steps, determining whether a blockchain node is a safe node may specifically include:

[0089] Obtaining a security verification result of the blockchain node in advance;

[0090] Before verifying whether the query result data is valid data, the method further includes:

[0091] Obtaining block data stored in the blockchain node;

[0092] Obtaining a hash value corresponding to the original evidence data in the block data; the hash value is generated by a business server that uploads the original evidence data to the blockchain system;

[0093] Whether the original stored evidence data has not been tampered with is verified according to the hash value to obtain the security verification result.

[0094] In actual applications, the blockchain system can store data uploaded by multiple business servers, and can also provide data query services for multiple business servers. When uploading data, the business server can upload multiple data to the chain in the form of a data queue. The business server can obtain multiple data to be uploaded to the chain, determine the queue identifier of each data in the data queue composed of the multiple data, and then generate a queue hash value corresponding to each data based on the queue identifier and the value of each data. The queue identifier of each data and the corresponding queue hash value can also be sent to other business servers, so that the business server and other business servers can search for data from the blockchain system based on the queue identifier and queue hash value of the data.

[0095] When the business server verifies the security of the blockchain node in the embodiment of the present specification, it can obtain the block data stored in the blockchain node to be verified, calculate the hash value corresponding to the evidence data in the block data, and the business server can also obtain the hash value of the evidence data generated by the business server that uploaded the evidence data to the blockchain system. Then, it is determined whether the hash value of the data obtained from the blockchain node is consistent with the hash value obtained from the business server that uploaded the data. If they are consistent, it means that the data in the blockchain node has not been tampered with, and the blockchain node is a secure node.

[0096] The obtaining of the hash value corresponding to the original evidence data in the block data specifically includes obtaining the hash value corresponding to the original evidence data broadcasted by another business server;

[0097] Uploading the original evidence data to the business server of the blockchain system to generate the hash value may specifically include:

[0098] The other business server determines the order of the original evidence data in the data queue to be uploaded to the blockchain system;

[0099] Based on the order, if the original evidence data is the first data in the data queue, performing a hash operation on the original evidence data to obtain a hash value of the original evidence data in the data queue;

[0100] If the original evidence data is any data in the data queue except the first data, the hash value of the original evidence data in the data queue is summed based on the value of the original evidence data and the hash value of the previous data of the original evidence data in the data queue, and a hash operation is performed on the sum result to obtain the hash value of the original evidence data in the data queue.

[0101] In the embodiment of this specification, if the data for verification obtained by the business server from the blockchain node is the first data of the queue data, the hash value of the data can be calculated and compared with the hash value of the data obtained from the business server that uploaded the data to determine whether the data in the blockchain node has been tampered with;

[0102] If the data for verification obtained by the business server from the blockchain node is not the first data in the queue, the business server also needs to obtain all the data before the data in the data queue from the blockchain node, and then calculate the hash value of the first data, and sum the hash value of the first data with the second data to obtain the hash value of the second data, and so on, according to the value of the current data and the queue hash value of the previous data in the data queue, perform a hash operation on the sum result to obtain the queue hash value of the current data, until the hash value of the data used for verification is calculated; then compare it with the hash value of the data obtained from the business server that uploaded the data to determine whether the data in the blockchain node has been tampered with.

[0103] Assume that the data queue contains 10 data, arranged in order from 1 to 10. The first data is A1, and the hash operation is performed to obtain the corresponding queue hash value B1. The second data is A2, and the hash operation is performed to obtain the queue hash value B2, where B2=hash(B1+A2). Similarly, the tenth data is A10, and the corresponding queue hash value B10=hash(B9+A10).

[0104] Among them, when the data obtained by the business server from the blockchain node for verification is normal data, but any data obtained before the data in the data queue is tampered with, the calculated hash value of the data will be inconsistent with the hash value of the data obtained from the business server that uploaded the data. It can be determined that certain data in the data queue in the blockchain node has been tampered with, and it can also be explained that the blockchain node is unsafe, so that the security of the blockchain node can be more comprehensively verified.

[0105] In actual applications, in order to reduce the amount of data transmission and the amount of data storage, the business server that uploads data may only send the first queue hash value corresponding to the first data in the data queue and the second queue hash value corresponding to the last data in the data queue to other business servers. At this time, the business server can obtain the data of the entire data queue from the blockchain node, and based on the order of the data in the data queue, perform a queue hash operation on the first data in the data queue to obtain the queue hash value corresponding to the first data; for any data in the data queue except the first data, sum the value of the arbitrary data and the queue hash value of the previous data in the data queue, perform a hash operation on the sum result, obtain the queue hash value of the arbitrary data, and then obtain the hash value of the last data in the data queue. In this way, it is possible to determine whether the calculated hash value corresponding to the first data and / or the last data is consistent with the first queue hash value and / or the second queue hash value obtained from the business server that uploaded the data, so as to determine the security of the blockchain node.

[0106] In actual applications, users may repeatedly query the same data. To improve the efficiency of the service server in feeding back query data, the method in the embodiment of this specification may further include:

[0107] If the query result data is valid data, the query result data is cached in the local cache of the business server.

[0108] When a user queries for data, the business server can first check whether the data required by the user exists in its local cache. If so, the local cache data can be fed back to the user. In addition, the local cache of the business server can only store valid data, thereby improving the utilization rate of the local cache.

[0109] Considering that cache is a temporary and volatile storage method, in the embodiments of this specification, the query result data cached in the local cache of the business server can also be synchronously stored in the non-volatile memory of the business server at a preset time point.

[0110] Among them, the preset time point can be a time point set according to actual needs. For example, it can be a time point when the workload of the business server is relatively small, such as 2 am to 4 am. The specific time is not limited in the embodiments of this specification as long as it can meet the needs.

[0111] In practical applications, since the cache service of the cache server is usually a centralized storage server, the data therein may be tampered with. When the blockchain node is attacked, the data stored therein may also be tampered with. The tampered data may be called invalid data. In order to reduce the occupation of the cache space of the cache server by invalid data, the business server may send an instruction to delete the invalid data to the cache server, and the cache server may delete the corresponding invalid data based on the instruction. Specifically, the data query method provided in the embodiment of this specification may also include:

[0112] If the query result data is not valid data, an instruction is sent to the cache server, where the instruction is used to instruct the cache server to delete the query result data stored in the cache server.

[0113] In actual applications, when the cache server finds the data required by the user, it can also feed back information indicating that the data has been found to the business server, so that the business server can feed back a result indicating that the data has not been found to the user. Specifically, the data query method provided in the embodiment of this specification can also include:

[0114] A second query result for the data identifier fed back by the cache server is obtained; the second query result indicates that the to-be-queried data is not found.

[0115] In order to avoid some meaningless queries and reduce the workload of business servers, cache servers and blockchain systems, for example, queries on invalid data, queries on unstored data, etc., in the embodiments of this specification, the data identifiers that have been queried but have not produced any results can also be marked. When the data queried again corresponds to the mark, the query step can be no longer executed, and the information indicating that no results were found can be directly fed back to the user. Specifically, the data query method provided in the embodiments of this specification can also include:

[0116] The cache server searches for a mark corresponding to the data identifier from the data stored in the cache server, wherein the mark indicates that the data corresponding to the data identifier has been queried in the blockchain system but has not been found;

[0117] The cache server generates the second query result based on the tag.

[0118] For example, when the data cached in the cache server is not valid data or the data obtained from the blockchain node is not valid data, the business server can mark the data identifier of the data accordingly. When the user queries the data again, the unqueried results can be fed back based on the mark. When the data queried by the user is not stored in the blockchain system, the cache server can record the data identifier of the queried data and mark the data identifier accordingly. When the user queries the data again, the unqueried results can also be fed back based on the mark.

[0119] In actual applications, when it is determined that the data obtained from a blockchain node is not valid data, the node can be considered as a non-secure node, and the node can also be marked as a non-secure node, and data will no longer be obtained from the node.

[0120] In actual applications, when too much data is stored in the cache space, it may affect the performance of the server. In order to reduce the impact of cache data on the server, the cache data in the server can be deleted under preset conditions in the embodiments of this specification to reasonably release the cache space of the server.

[0121] Specifically, the method in the embodiments of this specification may also include:

[0122] The business server records the query frequency of the historical query result data locally cached by the business server;

[0123] When the amount of historical query result data cached locally by the business server exceeds a set threshold, the historical query result data with a query frequency lower than the set frequency is determined as the historical query result data to be deleted, or, after arranging the historical query result data in descending order according to the numerical values ​​of the query frequency, the historical query result data corresponding to the last n query frequencies in the sequence are determined as the historical query result data to be deleted;

[0124] Delete the historical query result data to be deleted.

[0125] In the embodiments of the present specification, historical query results whose query frequency is lower than the set frequency can be deleted. When the query frequency is not lower than the set frequency, but the amount of historical query result data cached locally by the business server still exceeds the set threshold, the historical query result data corresponding to the last n queried frequencies in the sequence can be arranged in descending order according to the numerical values ​​of the queried frequencies, and deleted, so as to prevent too much historical query result data from being cached and stored in the local cache of the business server.

[0126] As another implementation method, the cache data may be deleted according to a time condition in the embodiment of this specification, wherein the method in the embodiment of this specification may further include:

[0127] The business server records the query time of the historical query result data locally cached by the business server;

[0128] When the amount of historical query result data cached locally by the business server exceeds a set threshold, the historical query result data whose queried time is greater than a set time from the current moment is determined as the historical query result data to be deleted, or, after arranging the queried time in descending order of the time from the current moment, the historical query result data corresponding to the first n queried times in the sequence are determined as the historical query result data to be deleted;

[0129] Delete the historical query result data to be deleted.

[0130] It is understandable that in actual applications, other preset conditions may be set as needed to reasonably release the cache space of the server. This specification does not make any specific limitations here, as long as the requirements can be met.

[0131] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method. Figure 5 The embodiments of this specification provide corresponding to Figure 2 A structural diagram of a data query device. Figure 5 As shown, the device may include:

[0132] A request acquisition module 502, used to acquire a first query request including a data identifier of data to be queried;

[0133] A request sending module 504 is used to send a second query request including a data identifier of the data to be queried to the cache server;

[0134] A result acquisition module 506 is used to obtain a first query result for the data identifier fed back by the cache server; the first query result at least includes query result data and node signature information of a blockchain node storing the query result data;

[0135] A result verification module 508 is used to verify whether the query result data is valid data according to the node signature information;

[0136] The result feedback module 510 is configured to feed back the query result data to the initiator of the first query request if the query result data is valid data.

[0137] based on Figure 5 The present specification also provides some specific implementation schemes of the device, which are described below.

[0138] Optionally, the node signature information is the signature information of a blockchain node that sends the query result data to the cache server, and the result verification module can be specifically used to:

[0139] Determine whether the blockchain node is a secure node, and obtain a first determination result;

[0140] If the first judgment result indicates that the one blockchain node is a secure node, then using the node signature information to verify whether the query result data has not been tampered with;

[0141] If the query result data passes the verification, it is determined that the query result data is valid data.

[0142] Optionally, the node signature information is the signature information of each blockchain node in the blockchain system storing the query result data, and the result verification module can be specifically used to:

[0143] Using the signature information of each blockchain node to verify whether the query result data has not been tampered with;

[0144] If the query result data passes the verification, it is determined that the query result data is valid data.

[0145] Optionally, the data query device provided in the embodiments of this specification may further include:

[0146] A local query module, used to query the data corresponding to the data identifier in the local cache of the business server to obtain a second query result;

[0147] The request sending module can be specifically used for:

[0148] If the second query result indicates that the query fails, a second query request including the data identifier of the data to be queried is sent to the cache server.

[0149] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.

[0150] Figure 6 The embodiments of this specification provide corresponding to Figure 2 A structural diagram of a data query device. Figure 6 As shown, the device 600 may include:

[0151] at least one processor 610; and,

[0152] A memory 630 is communicatively connected to the at least one processor; wherein,

[0153] The memory 630 stores instructions 620 executable by the at least one processor 610. The instructions are executed by the at least one processor 610 to enable the at least one processor 610 to:

[0154] Obtaining a first query request including a data identifier of data to be queried;

[0155] Sending a second query request including the data identifier of the data to be queried to the cache server;

[0156] Obtaining a first query result for the data identifier fed back by the cache server; the first query result at least includes query result data and node signature information of a blockchain node storing the query result data;

[0157] Verify whether the query result data is valid data according to the node signature information;

[0158] If the query result data is valid data, the query result data is fed back to the initiator of the first query request.

[0159] Based on the same idea, the embodiment of this specification also provides a computer-readable medium corresponding to the above method. The computer-readable medium stores computer-readable instructions, and the computer-readable instructions can be executed by a processor to implement the above data query method.

[0160] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. Figure 4 As for the device shown, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0161] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0162] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.

[0163] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0164] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0165] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0166] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0167] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0168] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0169] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0170] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0171] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0172] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0173] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0174] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0175] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A data query method, comprising: Obtaining a first query request including a data identifier of data to be queried; Sending a second query request including the data identifier of the data to be queried to the cache server; Obtaining a first query result for the data identifier fed back by the cache server; The first query result includes at least query result data and node signature information of the blockchain node storing the query result data; Determine whether a blockchain node is a security node to obtain a first determination result; the blockchain node is a blockchain node that sends the query result data to the cache server; The secure node is a node that has not been attacked; If the first judgment result indicates that the one blockchain node is a secure node, verifying whether the query result data is valid data according to the node signature information; If the query result data is valid data, the query result data is fed back to the initiator of the first query request.

2. According to the method of claim 1, the node signature information is the signature information of a blockchain node that sends the query result data to the cache server, and the verification of whether the query result data is valid data specifically includes: Determine whether the blockchain node is a secure node, and obtain a first determination result; If the first judgment result indicates that the one blockchain node is a secure node, then using the node signature information to verify whether the query result data has not been tampered with; If the query result data passes the verification, it is determined that the query result data is valid data.

3. According to the method of claim 1, the node signature information is the signature information of each blockchain node in the blockchain system storing the query result data, and the verification of whether the query result data is valid data specifically includes: Using the signature information of each blockchain node to verify whether the query result data has not been tampered with; If the query result data passes the verification, it is determined that the query result data is valid data.

4. The method according to claim 1, before sending the second query request containing the data identifier of the to-be-queried data to the cache server, further comprising: Querying the data corresponding to the data identifier in the local cache of the business server to obtain a second query result; The sending a second query request including the data identifier of the to-be-queried data to the cache server specifically includes: If the second query result indicates that the query fails, a second query request including the data identifier of the data to be queried is sent to the cache server.

5. According to the method of claim 2, the determining whether the blockchain node is a secure node specifically comprises: Obtain manually entered node security information; According to the node security information, determine whether the blockchain node is a secure node.

6. According to the method of claim 2, the determining whether the blockchain node is a secure node specifically comprises: Obtaining a security verification result of the blockchain node in advance; Before verifying whether the query result data is valid data, the method further includes: Obtaining block data stored in the blockchain node; Obtaining a hash value corresponding to the original evidence data in the block data; the hash value is generated by a business server that uploads the original evidence data to the blockchain system; Whether the original stored evidence data has not been tampered with is verified according to the hash value to obtain the security verification result.

7. According to the method of claim 6, the step of obtaining the hash value corresponding to the original evidence data in the block data specifically comprises: Obtaining a hash value corresponding to the original evidence data broadcasted by another business server; Uploading the original evidence data to the business server of the blockchain system to generate the hash value specifically includes: The other business server determines the order of the original evidence data in the data queue to be uploaded to the blockchain system; Based on the order, if the original evidence data is the first data in the data queue, performing a hash operation on the original evidence data to obtain a hash value of the original evidence data in the data queue; If the original evidence data is any data in the data queue except the first data, the hash value of the original evidence data in the data queue is summed based on the value of the original evidence data and the hash value of the previous data of the original evidence data in the data queue, and a hash operation is performed on the sum result to obtain the hash value of the original evidence data in the data queue.

8. The method according to claim 1, further comprising: If the query result data is valid data, the query result data is cached in the local cache of the business server.

9. The method according to claim 8, further comprising: At a preset time point, the query result data cached in the local cache of the business server is synchronously stored in the non-volatile memory of the business server.

10. The method according to claim 1, further comprising: If the query result data is not valid data, an instruction is sent to the cache server, where the instruction is used to instruct the cache server to delete the query result data stored in the cache server.

11. The method according to claim 1, further comprising: Obtaining a second query result for the data identifier fed back by the cache server; The second query result indicates that the to-be-queried data is not found.

12. The method according to claim 11, further comprising: The cache server searches for a mark corresponding to the data identifier from the data stored in the cache server, wherein the mark indicates that the data corresponding to the data identifier has been queried in the blockchain system but has not been found; The cache server generates the second query result based on the tag.

13. The method according to claim 1, further comprising: Record the query frequency of historical query result data cached locally on the business server; When the amount of historical query result data cached locally by the business server exceeds a set threshold, the historical query result data with a query frequency lower than the set frequency is determined as the historical query result data to be deleted, or, after arranging the historical query result data in descending order according to the numerical values ​​of the query frequency, the historical query result data corresponding to the last n query frequencies in the sequence are determined as the historical query result data to be deleted; Delete the historical query result data to be deleted.

14. The method according to claim 1, further comprising: Record the query time of the historical query result data cached locally on the business server; When the amount of historical query result data cached locally by the business server exceeds a set threshold, the historical query result data whose queried time is greater than a set time from the current moment is determined as the historical query result data to be deleted, or, after arranging the queried time from the current moment in descending order, the historical query result data corresponding to the first n queried times in the sequence are determined as the historical query result data to be deleted; Delete the historical query result data to be deleted.

15. According to the method of claim 1, the cache server caches at least part of the historical query results that the business server has queried from the blockchain system; And / or, the cache server caches at least a portion of the data uploaded to the blockchain system by the cache server.

16. A data query device, comprising: A request acquisition module, used to acquire a first query request containing a data identifier of data to be queried; A request sending module, used for sending a second query request including a data identifier of the data to be queried to the cache server; A result acquisition module, used to acquire a first query result for the data identifier fed back by the cache server; The first query result includes at least query result data and node signature information of the blockchain node storing the query result data; A result verification module, used to determine whether a blockchain node is a safe node, and obtain a first judgment result; the blockchain node is a blockchain node that sends the query result data to the cache server; The secure node is a node that has not been attacked; If the first judgment result indicates that the one blockchain node is a secure node, verifying whether the query result data is valid data according to the node signature information; The result feedback module is used to feed back the query result data to the initiator of the first query request if the query result data is valid data.

17. The device according to claim 16, wherein the node signature information is the signature information of each blockchain node in the blockchain system storing the query result data, and the result verification module is specifically used to: Using the signature information of each blockchain node to verify whether the query result data has not been tampered with; If the query result data passes the verification, it is determined that the query result data is valid data.

18. The apparatus according to claim 16, further comprising: A local query module, used to query the data corresponding to the data identifier in the local cache of the business server to obtain a second query result; The request sending module is specifically used for: If the second query result indicates that the query fails, a second query request including the data identifier of the data to be queried is sent to the cache server.

19. A data query device, comprising: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Obtaining a first query request including a data identifier of data to be queried; Sending a second query request including the data identifier of the data to be queried to the cache server; Obtaining a first query result for the data identifier fed back by the cache server; the first query result at least includes query result data and node signature information of a blockchain node storing the query result data; Determine whether a blockchain node is a secure node to obtain a first determination result; the blockchain node is a blockchain node that sends the query result data to the cache server; the secure node is a node that has not been attacked; If the first judgment result indicates that the one blockchain node is a secure node, verifying whether the query result data is valid data according to the node signature information; If the query result data is valid data, the query result data is fed back to the initiator of the first query request.

20. A computer-readable medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to implement the data query method according to any one of claims 1 to 15.