Information query method and device, information synchronization method and device

By synchronously saving blockchain data change records in the target database and implementing multi-thread parallel processing, the problem of low blockchain query efficiency is solved and query efficiency and adaptability are improved.

CN111813788BActive Publication Date: 2025-01-21BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010431296.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-20
Publication Date
2025-01-21
Estimated Expiration
2040-05-20

AI Technical Summary

Technical Problem

The query efficiency of data change history records in blockchain is low, and the inability to process in parallel leads to high time costs, especially in a massive data environment, it is difficult to meet the needs of high-frequency transaction data change history query.

Method used

By synchronously saving the data change record information of objects on the blockchain in the target database, and after receiving the client's query request, it searches for and sends the corresponding data change record information from the target database to achieve multi-thread/multi-processor parallel processing.

Benefits of technology

It improves the query efficiency of blockchain information, solves the problem of low query efficiency due to the inability to process in parallel, and is suitable for historical traceability queries of massive data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111813788B_ABST
    Figure CN111813788B_ABST
Patent Text Reader

Abstract

The present application relates to a method and device for querying information, a storage medium and an electronic device, wherein the method comprises: receiving a query request sent by a client, wherein the query request is used to request to query the data change record information of a target object on a blockchain; responding to the query request, searching the data change record information of the target object from a target database, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, and the one or more objects include the target object; when the target data change record information corresponding to the target object is found, the target data change record information is sent to the client. The present application solves the problem of low query efficiency due to the inability to process in parallel in the blockchain data query method in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to an information query method and device, and an information synchronization method and device. Background Art

[0002] Blockchain is a storage technology. The blockchain system can use cryptography to ensure the security of data transmission and access, and generate a distributed ledger system that cannot be forged or tampered with.

[0003] BaaS (Blockchain as a Service) is a service based on blockchain technology that helps users create, manage and maintain enterprise-level blockchain networks and applications. BaaS can provide asset trading modules based on blockchain networks, including: asset trading on-chain, transaction confirmation and other functions. BaaS can communicate with each blockchain node in the blockchain network to manage and maintain the blockchain network.

[0004] There are many behaviors in the blockchain, such as user registration, user recharge, asset issuance, etc. These behaviors will generate a large amount of data records. With the rapid growth of blockchain business, the query of data change history has brought severe challenges.

[0005] At present, the blockchain generally uses a traversal method to query the data change history. If you want to count the entire change history of a certain type of data on the blockchain, for example, if you want to query the corresponding change history transaction record of a user's account assets in the blockchain network, you need to traverse the blocks starting from the genesis block of the blockchain network, and find and identify all the record values ​​corresponding to the data to be queried in the block, so as to obtain the historical change record of the data.

[0006] The query method for the historical change records of data in the above blockchain is mainly to traverse the entire blockchain multiple times according to the order of block generation to obtain all the data (for example, transaction records). However, the above query method is a sequential serial process, and the entire blockchain needs to be traversed once each time. Based on the characteristics of the blockchain, it cannot be processed in parallel by multiple threads / multiple processors, and the time cost is high. It is not suitable for the historical tracing of massive data. When the data volume is large, it is easily limited by the memory and processor capabilities of a single machine.

[0007] Therefore, the blockchain data query method in the related technology has the problem of low query efficiency due to the inability to process in parallel. Summary of the invention

[0008] The present application provides an information query method and device, and an information synchronization method and device, so as to at least solve the problem of low query efficiency due to the inability to perform parallel processing in the blockchain data query method in the related art.

[0009] According to one aspect of an embodiment of the present application, a method for querying information is provided, including: receiving a query request sent by a client, wherein the query request is used to request a query for data change record information of a target object on a blockchain; responding to the query request, searching for data change record information of the target object from a target database, wherein the target database is used to synchronously save data change record information of one or more objects on the blockchain, the one or more objects including the target object; and when target data change record information corresponding to the target object is found, sending the target data change record information to the client.

[0010] According to another aspect of an embodiment of the present application, a method for synchronizing information is provided, including: detecting that record information corresponding to a target key value on a blockchain is updated, wherein the target key value is identification information of a target object in the blockchain, and the record information corresponding to the target key value is used to record transaction information of the target object; determining that the record information corresponding to the target key value is updated to first transaction record information; synchronizing the first transaction record information as first data change record information of the target object in a target database, wherein the target database is used to synchronously save data change record information of one or more objects on the blockchain, and the one or more objects include the target object.

[0011] According to another aspect of an embodiment of the present application, a device for querying information is provided, including: a first receiving unit, used to receive a query request sent by a client, wherein the query request is used to request to query data change record information of a target object on the blockchain; a search unit, used to respond to the query request and search for data change record information of the target object from a target database, wherein the target database is used to synchronously save data change record information of one or more objects on the blockchain, and the one or more objects include the target object; a first sending unit, used to send the target data change record information to the client when target data change record information corresponding to the target object is found.

[0012] According to another aspect of an embodiment of the present application, there is provided an information synchronization device, comprising: a detection unit, configured to detect that record information corresponding to a target key value on a blockchain is updated, wherein the target key value is identification information of a target object in the blockchain, and the record information corresponding to the target key value is used to record transaction information of the target object; a first determination unit, configured to determine that the record information corresponding to the target key value is updated to first transaction record information; and a first synchronization unit, configured to synchronize the first transaction record information to first data change record information of the target object in a target database, wherein the target database is configured to synchronize and save data change record information of one or more objects on the blockchain, the one or more objects including the target object.

[0013] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.

[0014] According to another aspect of the embodiments of the present application, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0015] In an embodiment of the present application, a database is used to synchronously save data change record information of one or more objects on the blockchain, and a query request sent by a client is received, wherein the query request is used to request to query the data change record information of the target object on the blockchain; in response to the query request, the data change record information of the target object is searched from the target database, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, and the one or more objects include the target object; when the target data change record information corresponding to the target object is found, the target data change record information is sent to the client. Since the data change record information of the target object on the blockchain is queried by searching a database for synchronously saving the data change record information of one or more objects on the blockchain, there is no need to traverse the entire blockchain multiple times according to the order of block generation to obtain all transaction records, and multi-threaded / multi-processor parallel processing can be performed to achieve the purpose of quickly finding the data change record of the object, thereby achieving the technical effect of improving the query efficiency of blockchain information, and then solving the problem of low query efficiency caused by the inability to parallel process in the blockchain data query method in the related art. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0017] In order to more clearly illustrate the embodiments of the present invention 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0018] Figure 1 is a schematic diagram of a hardware environment of a method for querying information according to an embodiment of the present application;

[0019] Figure 2 is a flowchart of an optional information query method according to an embodiment of the present application;

[0020] Figure 3 is an optional flow chart of recording transaction data according to an embodiment of the present application;

[0021] Figure 4 is a flowchart of another optional information query method according to an embodiment of the present application;

[0022] Figure 5 is a flowchart of an optional information synchronization method according to an embodiment of the present application;

[0023] Figure 6 is a flowchart of another optional information query method according to an embodiment of the present application;

[0024] Figure 7 is a schematic diagram of an optional information query device according to an embodiment of the present application;

[0025] Figure 8 is a schematic diagram of an optional information synchronization device according to an embodiment of the present application;

[0026] Fig. 9 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0029] According to one aspect of the embodiments of the present application, an embodiment of a method for querying information is provided. Optionally, in this embodiment, the method for querying information can be applied to Figure 1 In the hardware environment composed of the terminal 101 and the server 103 shown in FIG. Figure 1 As shown, the server 103 is connected to the terminal 101 through a network, and can be used to provide services (such as game services, application services, etc.) for the terminal or the client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 103. The above network includes but is not limited to: a wide area network, a metropolitan area network or a local area network, and the terminal 101 is not limited to a PC, a mobile phone, a tablet computer, etc. The information query method of the embodiment of the present application can be executed by the server 103, or by the terminal 101, or by the server 103 and the terminal 101. Among them, the terminal 101 executes the information query method of the embodiment of the present application, which can also be executed by the client installed thereon.

[0030] Figure 2 is a flowchart of an optional information query method according to an embodiment of the present application, such as Figure 2 As shown, the method may include the following steps:

[0031] Step S202, receiving a query request sent by a client, wherein the query request is used to request to query data change record information of a target object on the blockchain;

[0032] Step S204, in response to the query request, searching for data change record information of the target object from the target database, wherein the target database is used to synchronously store data change record information of one or more objects on the blockchain, and the one or more objects include the target object;

[0033] Step S206: When target data change record information corresponding to the target object is found, the target data change record information is sent to the client.

[0034] Through the above steps S202 to S206, a query request sent by the client is received, wherein the query request is used to request to query the data change record information of the target object on the blockchain; in response to the query request, the data change record information of the target object is searched from the target database, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, and the one or more objects include the target object; when the target data change record information corresponding to the target object is found, the target data change record information is sent to the client, which solves the problem of low query efficiency caused by the inability to process in parallel in the blockchain data query method in the related art, and improves the query efficiency of blockchain information.

[0035] In the technical solution provided in step S202, a query request sent by a client is received, wherein the query request is used to request to query data change record information of a target object on the blockchain.

[0036] The information query method in this embodiment can be applied to an existing hyperledger framework, such as Fabric. When querying the blockchain data change history, the SDK (Software Development Kit) in the hyperledger framework can be used for querying. The data query scheme in the related art requires a lot of traversal and identification, which makes the query process of the data change history in the blockchain slow and complicated, reduces the query efficiency, and is difficult to meet the user's high-frequency transaction data change history query needs in the rapidly growing blockchain business.

[0037] BaaS platform can be a service platform built on the Hyperledger framework (such as Fabric). BaaS is a service that combines blockchain technology to help users create, manage and maintain enterprise-level blockchain networks and applications. The main purpose of BaaS is to quickly establish the required blockchain application environment and provide a series of operational services such as search query, transaction, operation and maintenance, data analysis, etc. based on the blockchain network.

[0038] BaaS converts computing resources, communication resources, storage resources, as well as upper-level blockchain accounting capabilities, blockchain application development capabilities, and blockchain supporting facilities capabilities into programmable interfaces, making the application development and deployment processes simple and efficient. At the same time, through standardized capacity building, it ensures the security and reliability of blockchain applications and provides support for the operation of blockchain businesses.

[0039] As a cloud service, BaaS is a cloud-based rental platform for blockchain facilities. Its multi-tenant feature allows computing resources, platform resources, and software resources to be shared to the greatest extent. BaaS provides node rental, chain rental, and tool rental capabilities, including development tools, deployment tools, monitoring tools, etc., and through a large-capacity resource pool, it ensures that the business scale of tenants can be flexibly scaled, the rental facilities can be shared and exclusive, and operate safely and reliably. In addition, it can also provide necessary technical support services. BaaS's capabilities include: the ability to build blockchain nodes and the entire chain, the ability to develop blockchain applications, the ability to deploy block applications, and the ability to monitor blockchain operations.

[0040] The system chain code in Fabric can be deployed in the network nodes of the Hyperledger framework, which is responsible for the processing logic of the Fabric node itself, including system configuration, endorsement, verification, etc., and will automatically complete registration and deployment when the Peer node is started.

[0041] There are five types of system chaincodes:

[0042] (1) CSCC (Configuration System Chaincode), responsible for the configuration management of the ledger and chain;

[0043] (2) ESCC (Endorsement System Chaincode), which is responsible for the endorsement (signature) process and can support the management of endorsement policies;

[0044] (3) LSCC (Lifecycle System Chaincode), responsible for managing the lifecycle of user chaincodes; the chaincode lifecycle includes installation, deployment, upgrade, permission management, and information acquisition;

[0045] (4) QSCC (Query System Chaincode), responsible for providing information query functions for ledgers and chains;

[0046] (5) VSCC (Verification System Chaincode) is responsible for checking the endorsement policy before the transaction is submitted.

[0047] Optionally, the information query method in this embodiment may be executed by a system chain code, which may be QSCC, or QSCC may be combined with other system chain codes.

[0048] The user can submit a query request through the client running on the terminal device to request to query the data change record information of the target object on the blockchain. The query request can carry the query parameters entered by the user through the terminal device (data device), and the content of the query parameters can include: the key value name of the data to be queried, for example, the target key value. The client can submit the query request to the system chain code on the blockchain. The system chain code on the blockchain can receive the query request sent by the client.

[0049] In the technical solution provided in step S204, in response to the query request, data change record information of the target object is searched from the target database, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, and the one or more objects include the target object.

[0050] In order to improve the efficiency of data query, the data change record information (for example, transaction record information) of one or more objects on the blockchain can be synchronously saved as corresponding data change record information in the target database, and the one or more objects may include the target object.

[0051] In response to the received query request, the system chain code can search the target object's data change record information from the target database to determine whether the target object's data change record information is stored in the target database, and which data change record information of the target object is stored.

[0052] As an optional embodiment, searching for data change record information of the target object from the target database includes: obtaining a target key value carried in the query request, wherein the target key value is identification information of the target object in the blockchain; and searching for data change record information of the target object from the target database using a hash value of the target key value.

[0053] The target database may be a state database (stateDB), which stores the latest values ​​of all keys in the transaction log, also known as the world state, and may be implemented based on levelDB or couchDB.

[0054] The system chain code can first parse the data key value (target key value) to be queried from the query parameters of the query request. The data key value is the identification information of the target object in the blockchain, that is, it is used to uniquely identify the target object in the blockchain; then, according to the hash value of the data key value, the change history of the corresponding data key value is searched from the stateDB to determine whether the data change history record to be queried is found.

[0055] Through this embodiment, by querying the change history records through the hash value of the key value corresponding to the object, the query efficiency can be improved and the security of data query can be improved.

[0056] As an optional embodiment, searching for data change record information of a target object from a target database includes: obtaining time period information carried in a query request, wherein the time period information is used to indicate data change record information of the target object within a target time period; and searching for data change record information of the target object within a target time period from the target database according to the time period information.

[0057] The data change record information stored in the target database may include: timestamp information of the data change, for example, a transaction timestamp, which can be used to trace the original information in the blockchain when necessary for verification reference, thereby effectively ensuring the authenticity of the data change information.

[0058] For example, in a blockchain network system, user A's initial balance is 30 yuan. After a transaction, user A earns 10 yuan from the transaction, and the balance becomes 40 yuan. The data change information that can be read in the relevant technology is "user A's initial balance is 30 yuan, user earns 10 yuan, and user A's balance is 40 yuan", and it is determined that the system chain code has written the data. However, it is not possible to determine when the transaction occurred.

[0059] To ensure that the change records stored in the target database can be traced and verified when necessary, the system chain code can record the transaction ID, block height, timestamp and other information of the transaction, and save the block height and transaction timestamp information to the target database. In this way, the time and transaction parameters of the transaction / block can be quickly confirmed in the blockchain as needed to ensure the authenticity of the blockchain data change history in the database.

[0060] In addition to the key value, the query parameters entered by the user through the data device may also include: time period information, for example, specifying the historical time period of the query, that is, the target time period. The system chain code can parse the time period information from the query parameters of the query request and search the target database for the data change record information of the target object within the target time period.

[0061] For example, the data history change information of user A is shown in Table 1, and the query parameters indicate returning the balance change record of user A on March 6, 2020. The results are shown in Table 2.

[0062] Table 1

[0063] Transaction ID Block height Transaction timestamp lx001 101 2020-03-05 00:04:41 lx002 101 2020-03-05 01:14:41 lx003 102 2020-03-06 02:24:41 lx004 102 2020-03-06 03:34:41 lx005 103 2020-03-07 04:44:41

[0064] Table 2

[0065] Transaction ID Block height Transaction timestamp lx003 102 2020-03-06 02:24:41 lx004 102 2020-03-06 03:34:41

[0066] Through this embodiment, by limiting the time period for querying data change record information, the flexibility of data query can be improved and the authenticity of the blockchain data change history stored in the database can be ensured.

[0067] In order to maintain the target database, the data change record information in the target database can be synchronously updated according to the transaction record of the object on the blockchain.

[0068] As an optional embodiment, when it is detected that the record information corresponding to the target key value on the blockchain is updated, it can be determined that the record information corresponding to the target key value is updated to the first transaction record information, wherein the target key value is the identification information of the target object in the blockchain, and the record information corresponding to the target key value is used to record the transaction information of the target object; the first transaction record information is synchronized as the first data change record information in the target database, wherein the target data change record information includes the first data change record information.

[0069] There are many behaviors in the blockchain, such as user registration, user recharge, asset issuance, etc. These behaviors will generate a large amount of data records. The above data records can be saved on the blockchain in the form of data change record information. The system chain code can monitor the data changes in the change history on the blockchain periodically or by event triggering.

[0070] The system chain code can automatically track the changes of data key values ​​(key values, i.e., target key values) in each transaction record in the blockchain network system: after the record variables (value values, i.e., record information) corresponding to each data key value are written into the block in the blockchain network system, the system chain code obtains the information of this transaction and the information of the block in which the transaction is located.

[0071] For the target object, whenever it is found that the record variable corresponding to the target key value on the blockchain is updated due to the generation of a transaction, the system chaincode can synchronize the transaction information (for example, the first transaction record information) to the stateDB.

[0072] For example, after user A makes a transaction at a certain point in time, the user's balance in the blockchain ledger becomes 30 yuan. In order to record the change in user A's balance on the blockchain at this point in time, the system chain code will synchronize a data change record in stateDB.

[0073] Through this embodiment, by monitoring the changes in the transaction change history data on the blockchain and synchronizing them to the target database, the accuracy and timeliness of the data information in the target database can be improved.

[0074] As an optional embodiment, synchronizing the first transaction record information as the first data change record information in the target database includes: obtaining the target record information in the first transaction record information, wherein the target record information includes: transaction identifier, transaction timestamp, and block height where the first transaction record information is located; synchronizing the target record information as the first data change record information in the target database.

[0075] When synchronizing the transaction record information on the blockchain with the data change record information in the target database, the transaction record information can be directly synchronized to the target database. In this case, the complete transaction record information is saved in the target database.

[0076] In order to rationally utilize the data storage capacity of the target database and avoid excessive resource occupation due to excessive information volume, which leads to reduced query efficiency, part of the transaction record information can be synchronized as data change record information in the target database.

[0077] The system chain code can obtain the transaction identifier, transaction timestamp, block height of the first transaction record information, and other information contained in the first transaction record information, that is, the target record information, and synchronize the target record information as the first data change record information in the target database.

[0078] For example, in stateDB, for the data key value of user A’s balance: key = user A’s hash value, value = {transaction ID-1, transaction time-1, block height-1}.

[0079] Through this embodiment, by acquiring part of the transaction record information and synchronizing it to the target database, the data storage capacity of the target database can be improved and the resource occupation of each data storage can be reduced.

[0080] As an optional embodiment, after synchronizing the first transaction record information as the first data change record information in the target database, when it is detected that the record information corresponding to the target key value on the blockchain is updated, it can be determined that the record information corresponding to the target key value is updated to the second transaction record information; after the location of the first data change record information in the target database, the second data change record information corresponding to the second transaction record information is added, wherein the target data change record information includes the second data change record information.

[0081] User data changes are random, that is, they can be changed according to user needs, etc. Therefore, after the first transaction record information is synchronized as the first data change record information, a new transaction record can be generated on the blockchain. The system chain code can synchronize the new transaction record to the target database.

[0082] In order to improve data query efficiency, new transaction record information may be synchronized to the existing data change record information, that is, the new data change record information may be appended to the existing data change record information.

[0083] If it is detected that the record information corresponding to the target key value on the blockchain is updated to the second transaction record information, the system chain code can append the second data change record information corresponding to the second transaction record information after the location of the first data change record information in the target database.

[0084] For example, after user A makes a transaction at a certain point in time, the user's balance in the blockchain account book becomes 40 yuan. To record the data changes of a block on the blockchain at this point in time, the system chain code will add a new historical record to the stateDB. The historical record content includes: transaction ID, block height where the transaction record is located, and transaction timestamp information. key = user A's hash value, value = {{transaction ID-1, transaction time-1, block height-1}, {transaction ID-2, transaction time-2, block height-2}}.

[0085] If a series of transactions continue to occur in the blockchain network system, the above method can continue to be used to update the record variables corresponding to the data key value.

[0086] Through this embodiment, by synchronizing new transaction record information in a manner of appending new data change record information to existing data change record information, the efficiency of information query can be improved.

[0087] It should be noted that before uploading transaction records to the chain or synchronizing information, the information can be verified in advance: the transaction structure can be parsed and the transaction structure format can be verified; the element version in the transaction read set can be checked to be consistent with the version in the local ledger; the endorsement information with legality (mainly signature information) can be checked; if passed, a correct result is returned, otherwise an error message is returned.

[0088] In addition, stop and start commands are supported to disable and re-enable the chain code. After the chain code is successfully installed and instantiated, the chain code is active (running) and can be called to process transactions through the invoke command.

[0089] The following is an explanation of the storage and recording of transaction history with optional examples. Figure 3 As shown, the process of the transaction data recording method in this example may include the following steps:

[0090] Step S302: monitor and obtain data changes of the change history to be queried on the blockchain.

[0091] The system chaincode can monitor and track the key field of each transaction data on the blockchain, and automatically track the changes in the data key value (key value) in each transaction record. After the record variable (value value) corresponding to each data key value is written into the block in the blockchain network system, that is, when the value value corresponding to the key field in a transaction is updated, the system chaincode obtains the information of this transaction and the information of the block where the transaction is located (specifically the transaction ID, block height, timestamp, etc. of this transaction).

[0092] Step S304: The transaction ID, block height, timestamp and other information corresponding to the updated data on the blockchain are synchronized and appended to the stateDB.

[0093] Synchronize the updated data on the blockchain to stateDB through the system chaincode: the system chaincode will use the hash value of the corresponding key field as the new key in stateDB, append the change record information, and keep the data change information in stateDB synchronized. The content of the change record includes: the transaction ID involved in the change, block height, timestamp and other information.

[0094] Repeat the above steps to ensure the synchronization of transaction ID, block height, timestamp and other information generated by the data key value change.

[0095] In the technical solution provided in step S206, when the target data change record information corresponding to the target object is found, the target data change record information is sent to the client.

[0096] If the data change record information corresponding to the target object is found, that is, the target data change record information, the system chain code can send the target data change record information to the client. For example, the returned query result can be shown in Table 2.

[0097] If the target data change record information is part of the target transaction record information, that is, the part of the user's transaction record information stored in the target database, and the query request requests the complete transaction record information, then the system chain code can obtain the target block height contained in the target data change record information; obtain the target transaction record information corresponding to the target object from the block indicated by the target block height on the blockchain; and send the target transaction record information to the client.

[0098] Optionally, in this embodiment, the target data change record information may correspond to the target transaction record information (if any) of the target object on the blockchain, and the target data change record information includes: the target transaction identifier of the target transaction record information, the target transaction timestamp of the target transaction record information, and the target block height where the target transaction record information is located. In the case where there are multiple target data change record information, each data change record information corresponds to a combination of a transaction identifier, a transaction timestamp, and a block height.

[0099] As an optional implementation, after the target data change record information is sent to the client, a verification request sent by the client can be received, wherein the verification request is used to request verification of the target data change record information, and the verification request carries a target transaction identifier, a target transaction timestamp, and a target block height; according to the target transaction identifier and the target transaction timestamp, the target transaction record information is obtained from the block corresponding to the target block height on the blockchain; when the target transaction record information is obtained, the target data change record information is verified using the target transaction record information to obtain a first verification result; and the first verification result is sent to the client.

[0100] The target data change record information sent to the user is obtained by the system chain code from the target database, not from the blockchain. In order to avoid affecting the user experience due to the user's doubts about the authenticity and accuracy of the obtained data, a data verification service on the blockchain can be provided to the user. For example, through BaaS, data verification is performed on the blockchain based on information such as the transaction identifier, transaction timestamp, and the block height where the transaction record information corresponding to the data change record information is located.

[0101] After receiving the target data change record information, the user can operate the client interface to trigger the verification process of the target data change record information. After detecting the target operation performed on the client interface, the client can generate a verification request, which carries the target transaction identifier, target transaction timestamp and target block height, and sends the verification request to the system chain code (a type of blockchain node, or other blockchain nodes) to request verification of the target data change record information. In the case of multiple target data change record information, the verification request can carry the transaction identifier, transaction timestamp and block height in all or part of the data change record information to verify all or part of the data change record information.

[0102] After receiving the verification request, the system chain code can obtain the target transaction record information from the block corresponding to the target block height on the blockchain according to the target transaction identifier and the target transaction timestamp. If the target transaction record information is obtained, the target transaction record information can be used to verify the target data change record information, for example, verify the transaction amount, transaction party, amount change information, etc., to obtain a first verification result, which can indicate the authenticity and accuracy of the target data change record information.

[0103] After obtaining the first verification result, the system chain code can send the first verification result to the client so that the client can display the verification result to the user.

[0104] As another optional implementation, after obtaining the target transaction record information from the block corresponding to the target block height on the blockchain based on the target transaction identifier and the target transaction timestamp, if the target transaction record information is not obtained, a second verification result can be sent to the client, wherein the second verification result is used to indicate that the target data change record information verification has failed.

[0105] If the transaction record information corresponding to the target transaction identifier and the target transaction timestamp is not obtained from the block corresponding to the target block height on the blockchain, it can be determined that the target data change record information is untrue or inaccurate, and further determined that the target data change record information verification has failed. The system chain code can send the second verification result to the client to indicate that the target data change record information verification has failed.

[0106] Through this embodiment, by receiving a verification request carrying a transaction identifier, a transaction timestamp and a block height, and verifying the data change record information, it is possible to avoid affecting the user's experience due to the user's doubts about the authenticity and accuracy of the acquired data.

[0107] As an optional embodiment, after searching for data change record information of the target object from the target database, if the data change record information corresponding to the target object is not found, a prompt message can be sent to the client, wherein the prompt message is used to prompt that the data change record information corresponding to the target object is not found.

[0108] For example, if the change history of the corresponding data key value is queried in the stateDB table, the query result is returned to the client. If the query result is empty, corresponding prompt information can be returned to prompt that the corresponding change record information is not found.

[0109] The following is an explanation of the query process of change history information with optional examples. Figure 4 As shown, the process of the information query method in this example may include the following steps:

[0110] Step S402: input a query request into BaaS.

[0111] In BaaS, users can submit the key value fields of the data change history to be queried to the system chain code on the blockchain. The query request is the query parameter entered by the user through the data device. The query parameter content includes: the key value name of the data to be queried and the specified query history time period, etc.

[0112] Step S404: the system chain code is queried in stateDB.

[0113] The system chain code can parse the data key value to be queried from the query parameters, and then search the change history of the corresponding data key value from the stateDB according to the hash value of the data key value to determine whether the change history record of the data to be queried has been found.

[0114] Step S406: Return the query result to BaaS.

[0115] If the change history of the corresponding data key value is queried in the stateDB table, the system chaincode can return the query result to BaaS. If the query result is empty, the corresponding prompt information is returned.

[0116] According to another aspect of the embodiment of the present application, an embodiment of a method for synchronizing information is also provided. The method for synchronizing information can be applied to the synchronization process of data on the blockchain and data in the target database in the above-mentioned information query method, and can also be applied to other scenarios where data on the blockchain and data in the target database need to be synchronized. The methods for synchronizing data on the blockchain and data in the target database in the above-mentioned embodiments can all be used for the information synchronization process in this embodiment.

[0117] Optionally, in this embodiment, the above information synchronization method can be applied to Figure 1 In the hardware environment shown, the information synchronization method can be executed by the server 103, or by the terminal 101, or by both the server 103 and the terminal 101. The terminal 101 can also execute the information synchronization method of the embodiment of the present application by the client installed thereon.

[0118] Figure 5 is a flowchart of an optional information synchronization method according to an embodiment of the present application, such as Figure 5 As shown, the method may include the following steps:

[0119] Step S502: It is detected that the record information corresponding to the target key value on the blockchain is updated, wherein the target key value is the identification information of the target object in the blockchain, and the record information corresponding to the target key value is used to record the transaction information of the target object.

[0120] There are many behaviors of multiple users in the blockchain, such as user registration, user recharge, asset issuance, etc. These behaviors will generate a large amount of data records. The above data records can be saved on the blockchain in the form of data change record information, and different users' data records can be uniquely identified by different key values. For the target object, the target object can be uniquely identified by the target key value, and the data change record information of the target object can be the transaction record information of the target object.

[0121] If the target object undergoes a transaction or other operation, a new transaction record can be generated, which can be written to the blockchain. The record variable (value, i.e., record information) corresponding to the target key value on the blockchain is updated because of the transaction.

[0122] System chaincodes can monitor data changes in the change history on the blockchain periodically or triggered by events. After the record variable corresponding to the target key value is written into the block in the blockchain network system, the system chaincode can detect that the record information corresponding to the target key value on the blockchain has been updated.

[0123] Step S504: determine that the record information corresponding to the target key value is updated to the first transaction record information.

[0124] If the system chain code detects that the record information corresponding to the target key value on the blockchain has been updated, it can be determined that the record information corresponding to the target key value has been updated to the first transaction record information.

[0125] Step S506: synchronize the first transaction record information as the first data change record information of the target object in the target database, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, and the one or more objects include the target object.

[0126] On the blockchain, the first data change record information can be synchronized to multiple blocks through the system chain code. At the same time, when the system chain code synchronizes the blocks, the records generated by each change can be appended to the target database, and each transaction record can be synchronized as a data change record information in the target database.

[0127] The target database can be used to synchronize and save data change record information of one or more objects (e.g., target objects) on the blockchain. For the first transaction record information, the system chain code can synchronize it as the first data change record information of the target object in the target database.

[0128] Through the above steps S502 to S506, it is detected that the record information corresponding to the target key value on the blockchain is updated, wherein the target key value is the identification information of the target object in the blockchain, and the record information corresponding to the target key value is used to record the transaction information of the target object; it is determined that the record information corresponding to the target key value is updated to the first transaction record information; the first transaction record information is synchronized as the first data change record information of the target object in the target database, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, and the one or more objects include the target object, which can facilitate the query of the user's transaction record by querying the target database, thereby solving the problem of low query efficiency caused by the inability to process in parallel in the blockchain data query method in the related art, and improving the query efficiency of blockchain information.

[0129] As an optional embodiment, synchronizing the first transaction record information as the first data change record information of the target object in the target database includes:

[0130] Obtain target record information in the first transaction record information, wherein the target record information includes: a transaction identifier, a transaction timestamp, and a block height where the first transaction record information is located;

[0131] The target record information is synchronized as the first data change record information of the target object in the target database.

[0132] As an optional embodiment, after synchronizing the first transaction record information as the first data change record information of the target object in the target database, the method further includes:

[0133] When it is detected that the record information corresponding to the target key value on the blockchain is updated, determining that the record information corresponding to the target key value is updated to the second transaction record information;

[0134] After the location of the first data change record information in the target database, second data change record information corresponding to the second transaction record information is added.

[0135] As an optional embodiment, synchronizing the first transaction record information as the first data change record information of the target object in the target database includes:

[0136] Obtain a target hash value corresponding to the target key value, where the target hash value is identification information of the target object in the target database;

[0137] Determine first data change record information according to the first transaction record information;

[0138] The first data change record information is written into the target database according to the target hash value.

[0139] The present application also provides an optional embodiment, which provides a blockchain data change history query method based on BaaS and system chain code.

[0140] As time goes by, the number of blocks on the blockchain will increase. For traceability queries, such as querying the value change history corresponding to a key, it is necessary to traverse the entire blockchain from the beginning, which will be slower.

[0141] In this optional embodiment, the system chain code is used to monitor and obtain the data key values ​​required for query in the blockchain business. After the value values ​​corresponding to these key values ​​are updated, the system chain code saves the transaction ID, block height, timestamp and other information corresponding to the transaction block generated by this update operation to the stateDB, and the stateDB can be directly queried through BaaS later. When it is necessary to query the blockchain data change history, enter the query request in BaaS, and query the blockchain data change history in stateDB through the system chain code.

[0142] like Figure 6 As shown, the process of the information query method provided in this optional embodiment may include the following steps:

[0143] Step S602: The system chaincode synchronizes the updated data on the blockchain to the stateDB.

[0144] When synchronizing blocks through the system chain code, the transactions generated by each change, the blocks to which they belong, timestamps and other information are recorded or appended to the value of the stateDB corresponding to the new key obtained by calculating the hash with the key.

[0145] Step S604: input a query request through BaaS, and the system chain code receives the query request.

[0146] Step S606: The system chain code queries the data change history in stateDB.

[0147] If you need to query the value change history corresponding to a key, you only need to directly query the corresponding value in stateDB based on the hash value of the key, and you can get all the blocks, transactions, timestamps and other information related to the value change corresponding to the key without traversing the entire blockchain.

[0148] Step S608: The system chain code returns the result to BaaS.

[0149] Compared with the blockchain data change history query method in the related art, the information query method of this embodiment can greatly improve the efficiency of blockchain data change history query because it reduces the time of traversing the blockchain during query, and retains the transaction ID, block height and timestamp in the data change history of stateDB. When it is necessary to check a certain change history record separately according to business needs, the transaction ID, block height and timestamp and other information can be used to directly locate the queried blockchain and check the data, thereby ensuring the authenticity and consistency of the data change history.

[0150] Through this embodiment, the data change history record is stored in the database, which improves the query speed of the data change history.

[0151] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0152] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0153] According to another aspect of an embodiment of the present application, a device for querying information for implementing the above-mentioned information query method is also provided. Figure 7 is a schematic diagram of an optional information query device according to an embodiment of the present application, such as Figure 7 As shown, the device may include:

[0154] (1) a first receiving unit 72, configured to receive a query request sent by a client, wherein the query request is used to request to query data change record information of a target object on the blockchain;

[0155] (2) a search unit 74, connected to the receiving unit 72, configured to respond to the query request and search for data change record information of the target object from a target database, wherein the target database is configured to synchronously store data change record information of one or more objects on the blockchain, wherein the one or more objects include the target object;

[0156] (3) A first sending unit 76 is connected to the searching unit 74 and is used to send the target data change record information to the client when the target data change record information corresponding to the target object is found.

[0157] It should be noted that the first receiving unit 72 in this embodiment can be used to execute the above step S202, the searching unit 74 in this embodiment can be used to execute the above step S704, and the first sending unit 76 in this embodiment can be used to execute the above step S706.

[0158] Through the above module, a query request sent by a client is received, wherein the query request is used to request to query the data change record information of a target object on the blockchain; in response to the query request, the data change record information of the target object is searched from a target database, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, and the one or more objects include the target object; when the target data change record information corresponding to the target object is found, the target data change record information is sent to the client, which solves the problem of low query efficiency due to the inability to process in parallel in the blockchain data query method in the related art, and improves the query efficiency of blockchain information.

[0159] As an optional embodiment, the above device also includes:

[0160] (1) a second determining unit, configured to determine, before receiving a query request sent by a client, that the record information corresponding to the target key value on the blockchain is updated to first transaction record information when it is detected that the record information corresponding to the target key value on the blockchain is updated, wherein the target key value is identification information of a target object in the blockchain, and the record information corresponding to the target key value is used to record transaction information of the target object;

[0161] (2) A second synchronization unit, configured to synchronize the first transaction record information into first data change record information in a target database, wherein the target data change record information includes the second data change record information.

[0162] As an optional embodiment, the second synchronization unit includes:

[0163] (1) a first acquisition module, configured to acquire target record information from the first transaction record information, wherein the target record information includes: a transaction identifier, a transaction timestamp, and a block height where the first transaction record information is located;

[0164] (2) A first synchronization module, used to synchronize the target record information to the first data change record information in the target database.

[0165] As an optional embodiment, the above device also includes:

[0166] (1) a third determining unit, configured to, after synchronizing the first transaction record information as the first data change record information in the target database, determine that the record information corresponding to the target key value is updated to the second transaction record information when it is detected that the record information corresponding to the target key value on the blockchain is updated;

[0167] (2) A first adding unit, configured to add second data change record information corresponding to the second transaction record information after the location of the first data change record information in the target database.

[0168] As an optional embodiment, the searching unit 74 includes:

[0169] (1) a second acquisition module, configured to acquire a target key value carried in the query request, wherein the target key value is identification information of a target object in the blockchain;

[0170] (2) A first search module, used to use the hash value of the target key value to search for data change record information of the target object from the target database.

[0171] As an optional embodiment, the searching unit 74 includes:

[0172] (1) a third acquisition module, used to acquire time period information carried in the query request, wherein the time period information is used to represent data change record information of the query target object within the target time period;

[0173] (2) A second search module is used to search the target database for data change record information of the target object within the target time period according to the time period information.

[0174] As an optional embodiment, the target data change record information corresponds to the target transaction record information of the target object on the blockchain, and the target data change record information includes: the target transaction identifier of the target transaction record information, the target transaction timestamp of the target transaction record information, and the target block height where the target transaction record information is located.

[0175] As an optional embodiment, the above device also includes:

[0176] (1) a second receiving unit, configured to receive a verification request sent by the client after sending the target data change record information to the client, wherein the verification request is used to request verification of the target data change record information, and the verification request carries a target transaction identifier, a target transaction timestamp, and a target block height;

[0177] (2) an acquisition unit, configured to acquire target transaction record information from a block corresponding to the target block height on the blockchain according to the target transaction identifier and the target transaction timestamp;

[0178] (3) a verification unit, configured to verify the target data change record information using the target transaction record information when the target transaction record information is obtained, to obtain a first verification result;

[0179] (4) A second sending unit, used to send the first verification result to the client.

[0180] As an optional embodiment, the above device also includes:

[0181] (1) A third sending unit is used to send a second verification result to the client when the target transaction record information is not obtained, wherein the second verification result is used to indicate that the verification of the target data change record information has failed.

[0182] As an optional embodiment, the above device also includes:

[0183] (1) A fourth sending unit is used to send a prompt message to the client after searching for the data change record information of the target object from the target database and if the data change record information corresponding to the target object is not found, wherein the prompt message is used to prompt that the data change record information corresponding to the target object is not found.

[0184] According to another aspect of an embodiment of the present application, a device for synchronizing information for implementing the above-mentioned method for synchronizing information is also provided. Figure 8 is a schematic diagram of an optional information synchronization device according to an embodiment of the present application, such as Figure 8 As shown, the device may include:

[0185] (1) a detection unit 82, configured to detect that the record information corresponding to the target key value on the blockchain is updated, wherein the target key value is identification information of the target object in the blockchain, and the record information corresponding to the target key value is used to record transaction information of the target object;

[0186] (2) a first determining unit 84, connected to the detecting unit 82, configured to determine whether the record information corresponding to the target key value is updated to the first transaction record information;

[0187] (3) A first synchronization unit 86, connected to the first determination unit 84, configured to synchronize the first transaction record information into first data change record information of a target object in a target database, wherein the target database is configured to synchronize and store data change record information of one or more objects on the blockchain, the one or more objects including the target object.

[0188] Optionally, in this embodiment, the detection unit 82 and the aforementioned third determination unit may be the same unit or different units; the first determination unit 84 and the aforementioned second determination unit may be the same unit or different units.

[0189] It should be noted that the detection unit 82 in this embodiment can be used to execute the aforementioned step S502, the first determination unit 84 in this embodiment can be used to execute the aforementioned step S504, and the first synchronization unit 86 in this embodiment can be used to execute the aforementioned step S506.

[0190] Through the above module, it is detected that the record information corresponding to the target key value on the blockchain is updated, wherein the target key value is the identification information of the target object in the blockchain, and the record information corresponding to the target key value is used to record the transaction information of the target object; it is determined that the record information corresponding to the target key value is updated to the first transaction record information; the first transaction record information is synchronized as the first data change record information of the target object in the target database, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, and the one or more objects include the target object, which solves the problem of low query efficiency caused by the inability to process in parallel in the blockchain data query method in the related technology, and improves the query efficiency of blockchain information.

[0191] As an optional embodiment, the first synchronization unit 86 includes:

[0192] (1) a fourth acquisition module, configured to acquire target record information from the first transaction record information, wherein the target record information includes: a transaction identifier, a transaction timestamp, and a block height where the first transaction record information is located;

[0193] (2) A second synchronization module, used to synchronize the target record information to the first data change record information of the target object in the target database.

[0194] It should be noted that the fourth acquisition module and the aforementioned first acquisition module may be the same module or different modules; the second synchronization module and the aforementioned first synchronization module may be the same module or different modules.

[0195] As an optional embodiment, the above device also includes:

[0196] (1) a fourth determining unit, configured to, after synchronizing the first transaction record information as the first data change record information of the target object in the target database, determine that the record information corresponding to the target key value is updated to the second transaction record information when it is detected that the record information corresponding to the target key value on the blockchain is updated;

[0197] (2) A second adding unit, configured to add second data change record information corresponding to the second transaction record information after the location of the first data change record information in the target database.

[0198] It should be noted that the fourth determining unit and the aforementioned third determining unit may be the same unit or different units; the second adding unit and the aforementioned first adding unit may be the same unit or different units.

[0199] As an optional embodiment, the first synchronization unit 86 includes:

[0200] (1) a fifth acquisition module, configured to acquire a target hash value corresponding to the target key value, the target hash value being identification information of a target object in a target database;

[0201] (2) a determination module, configured to determine first data change record information according to the first transaction record information;

[0202] (3) A writing module, used to write the first data change record information into a target database according to the target hash value.

[0203] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 1 In the hardware environment shown, it can be implemented by software or by hardware, wherein the hardware environment includes a network environment.

[0204] According to another aspect of the embodiment of the present application, an electronic device for implementing the above-mentioned information query method or information synchronization method is also provided, and the electronic device can be a server, a terminal, or a combination thereof. Optionally, the electronic device can be a node on the blockchain, and the system chain code can be deployed on the node.

[0205] Fig. 9 is a structural block diagram of an electronic device according to an embodiment of the present application, such as Fig. 9 As shown, the electronic device includes a memory 902 and a processor 904. The memory 902 stores a computer program, and the processor 904 is configured to execute the steps in any of the above method embodiments through the computer program.

[0206] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.

[0207] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:

[0208] S1, receiving a query request sent by a client, wherein the query request is used to request to query the data change record information of the target object on the blockchain;

[0209] S2, in response to the query request, searching for data change record information of the target object from the target database, wherein the target database is used to synchronously store data change record information of one or more objects on the blockchain, and the one or more objects include the target object;

[0210] S3: When target data change record information corresponding to the target object is found, the target data change record information is sent to the client.

[0211] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:

[0212] S1, detecting that the record information corresponding to the target key value on the blockchain is updated, wherein the target key value is the identification information of the target object in the blockchain, and the record information corresponding to the target key value is used to record the transaction information of the target object;

[0213] S2, determining that the record information corresponding to the target key value is updated to the first transaction record information;

[0214] S3, synchronizing the first transaction record information as the first data change record information of the target object in the target database, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, and the one or more objects include the target object.

[0215] Alternatively, a person skilled in the art may understand that: Fig. 9 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, and a terminal device such as an MID (Mobile Internet Devices), a PAD, etc. Fig. 9 The structure of the electronic device is not limited. Fig. 9 More or fewer components (such as network interfaces, etc.) as shown in, or with Fig. 9 in different configurations.

[0216] Among them, the memory 902 can be used to store software programs and modules, such as the program instructions / modules corresponding to the information query method and device in the embodiment of the present application, or the program instructions / modules corresponding to the information synchronization method and device. The processor 904 executes various functional applications and data processing by running the software programs and modules stored in the memory 902, that is, realizing the above-mentioned information query method or information synchronization method. The memory 902 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 902 may further include a memory remotely arranged relative to the processor 904, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0217] The memory 902 may be specifically but not limited to being used to store data change record information of one or more objects.

[0218] As an example, Fig. 9 As shown, the memory 902 may include but is not limited to the first receiving unit 72, the searching unit 74 and the first sending unit 76 in the information query device. In addition, other module units in the information query device may also be included but are not limited to, which will not be repeated in this example.

[0219] As another example, the memory 902 may include but is not limited to the detection unit 82, the first determination unit 84 and the first synchronization unit 86 in the synchronization device of the above information. In addition, other module units in the synchronization device of the above information may also be included but are not limited to, which will not be repeated in this example.

[0220] Optionally, the transmission device 906 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wired network and a wireless network. In one example, the transmission device 906 includes a NIC (Network Interface Controller), which can be connected to other network devices and a router via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 906 is an RF (Radio Frequency) module, which is used to communicate with the Internet wirelessly.

[0221] In addition, the electronic device may further include: a connection bus 908 for connecting various module components in the electronic device.

[0222] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0223] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a ROM (Read-Only Memory), a RAM (Random Access Memory), a disk or an optical disk, etc.

[0224] According to another aspect of the embodiment of the present application, a storage medium is also provided. Optionally, in this embodiment, the storage medium can be used to execute the program code of the information query method or the information synchronization method.

[0225] Optionally, in this embodiment, the storage medium may be located on at least one network device among a plurality of network devices in the network shown in the above embodiment.

[0226] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps:

[0227] S1, receiving a query request sent by a client, wherein the query request is used to request to query the data change record information of the target object on the blockchain;

[0228] S2, in response to the query request, searching for data change record information of the target object from the target database, wherein the target database is used to synchronously store data change record information of one or more objects on the blockchain, and the one or more objects include the target object;

[0229] S3: When target data change record information corresponding to the target object is found, the target data change record information is sent to the client.

[0230] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps:

[0231] S1, detecting that the record information corresponding to the target key value on the blockchain is updated, wherein the target key value is the identification information of the target object in the blockchain, and the record information corresponding to the target key value is used to record the transaction information of the target object;

[0232] S2, determining that the record information corresponding to the target key value is updated to the first transaction record information;

[0233] S3, synchronizing the first transaction record information as the first data change record information of the target object in the target database, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, and the one or more objects include the target object.

[0234] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0235] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a ROM, a RAM, a mobile hard disk, a magnetic disk, or an optical disk.

[0236] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0237] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.

[0238] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0239] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0240] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0241] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0242] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for querying information, characterized in that: include: The query request sent by the client is received through the system chain code deployed in the Hyperledger framework Fabric, wherein the query request is used to request to query the data change record information of the target object on the blockchain; In response to the query request, the system chain code searches for data change record information of the target object from a target database, wherein the target database is used to synchronously store data change record information of one or more objects on the blockchain, and the one or more objects include the target object; When the target data change record information corresponding to the target object is found, the system chain code sends the target data change record information to the client; Wherein, before receiving the query request sent by the client, the system chain code automatically tracks the changes of the target key value in each transaction record of the blockchain, and when it is detected that the record information corresponding to the target key value on the blockchain is updated, it is determined that the record information corresponding to the target key value is updated to the first transaction record information and the first transaction record information is synchronized as the first data change record information of the target object in the target database, wherein the first data change record information is composed of a key-value pair, the key of the key-value pair is the hash value of the target object, and the value of the key-value pair is the transaction identifier of the first transaction record information, the transaction timestamp, and the block height; After synchronizing the first transaction record information as the first data change record information in the target database, the method further includes: when detecting that the record information corresponding to the target key value on the blockchain is updated, determining that the record information corresponding to the target key value is updated to second transaction record information; adding the transaction identifier, transaction timestamp, and block height of the second transaction record information in the second transaction record as second data change record information after the transaction identifier, transaction timestamp, and block height of the first transaction record information in the key-value pair.

2. The method according to claim 1, characterized in that Before receiving the query request sent by the client, the method further includes: In the case where it is detected that the record information corresponding to the target key value on the blockchain is updated, determining that the record information corresponding to the target key value is updated to the first transaction record information, wherein the target key value is the identification information of the target object in the blockchain, and the record information corresponding to the target key value is used to record the transaction information of the target object; The first transaction record information is synchronized as first data change record information in the target database, wherein the target data change record information includes the first data change record information.

3. The method according to claim 2, characterized in that Synchronizing the first transaction record information as the first data change record information in the target database includes: Obtaining target record information in the first transaction record information, wherein the target record information includes: a transaction identifier, a transaction timestamp, and a block height where the first transaction record information is located; The target record information is synchronized with the first data change record information in the target database.

4. The method according to claim 1, characterized in that Searching the target database for data change record information of the target object includes: Obtaining a target key value carried in the query request, wherein the target key value is identification information of a target object in the blockchain; The data change record information of the target object is searched from the target database using the hash value of the target key value.

5. The method according to claim 1, characterized in that: Searching the target database for data change record information of the target object includes: Acquire the time period information carried in the query request, wherein the time period information is used to indicate querying the data change record information of the target object within the target time period; According to the time period information, the data change record information of the target object within the target time period is searched from the target database.

6. The method according to claim 1, characterized in that The target data change record information corresponds to the target transaction record information of the target object on the blockchain, and the target data change record information includes: the target transaction identifier of the target transaction record information, the target transaction timestamp of the target transaction record information, and the target block height where the target transaction record information is located. After sending the target data change record information to the client, the method further includes: Receiving a verification request sent by the client, wherein the verification request is used to request verification of the target data change record information, and the verification request carries the target transaction identifier, the target transaction timestamp and the target block height; According to the target transaction identifier and the target transaction timestamp, obtaining the target transaction record information from a block corresponding to the target block height on the blockchain; When the target transaction record information is obtained, verify the target data change record information using the target transaction record information to obtain a first verification result; and send the first verification result to the client; In the case where the target transaction record information is not obtained, a second verification result is sent to the client, wherein the second verification result is used to indicate that the verification of the target data change record information has failed.

7. The method according to any one of claims 1 to 6, characterized in that After searching the target database for data change record information of the target object, the method further includes: In the case that the data change record information corresponding to the target object is not found, prompt information is sent to the client, wherein the prompt information is used to prompt that the data change record information corresponding to the target object is not found.

8. A method for synchronizing information, characterized in that: include: Detecting whether the record information corresponding to the target key value on the blockchain is updated through the system chain code in the Hyperledger framework Fabric, wherein the target key value is the identification information of the target object in the blockchain, and the record information corresponding to the target key value is used to record the transaction information of the target object; When an update is detected, the system chain code determines that the record information corresponding to the target key value is updated to the first transaction record information; The system chain code synchronizes the first transaction record information as the first data change record information of the target object in the target database, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, the one or more objects include the target object, and the first data change record information consists of a key-value pair, the key of the key-value pair is the hash value of the target object, and the value of the key-value pair is the transaction identifier of the first transaction record information, the transaction timestamp, and the block height; After synchronizing the first transaction record information as the first data change record information in the target database, it also includes: when it is detected that the record information corresponding to the target key value on the blockchain is updated, determining that the record information corresponding to the target key value is updated to second transaction record information; adding the transaction identifier, transaction timestamp, and block height of the second transaction record information in the second transaction record as second data change record information after the transaction identifier, transaction timestamp, and block height of the first transaction record information in the key-value pair.

9. The method according to claim 8, characterized in that Synchronizing the first transaction record information as the first data change record information of the target object in the target database includes: Obtaining target record information in the first transaction record information, wherein the target record information includes: a transaction identifier, a transaction timestamp, and a block height where the first transaction record information is located; The target record information is synchronized as the first data change record information of the target object in the target database.

10. The method according to any one of claims 8 to 9, characterized in that: Synchronizing the first transaction record information as the first data change record information of the target object in the target database includes: Acquire a target hash value corresponding to the target key value, where the target hash value is identification information of the target object in the target database; Determine the first data change record information according to the first transaction record information; The first data change record information is written into the target database according to the target hash value.

11. An information query device, characterized in that: include: A first receiving unit is configured to receive a query request sent by a client by a system chain code in the hyperledger framework Fabric, wherein the query request is used to request to query data change record information of a target object on the blockchain; A search unit, configured to respond to the query request by the system chain code and search for data change record information of the target object from a target database, wherein the target database is used to synchronously save data change record information of one or more objects on the blockchain, and the one or more objects include the target object; A first sending unit, configured to send the target data change record information to the client when the system chain code finds the target data change record information corresponding to the target object; Wherein, before receiving the query request sent by the client, the system chain code automatically tracks the changes of the target key value in each transaction record of the blockchain, and when it is detected that the record information corresponding to the target key value on the blockchain is updated, it is determined that the record information corresponding to the target key value is updated to the first transaction record information and the first transaction record information is synchronized as the first data change record information of the target object in the target database, wherein the first data change record information is composed of a key-value pair, the key of the key-value pair is the hash value of the target object, and the value of the key-value pair is the transaction identifier of the first transaction record information, the transaction timestamp, and the block height; After synchronizing the first transaction record information as the first data change record information in the target database, it also includes: when it is detected that the record information corresponding to the target key value on the blockchain is updated, determining that the record information corresponding to the target key value is updated to second transaction record information; adding the transaction identifier, transaction timestamp, and block height of the second transaction record information in the second transaction record as second data change record information after the transaction identifier, transaction timestamp, and block height of the first transaction record information in the key-value pair.

12. An information synchronization device, characterized in that: include: A detection unit, configured to detect whether the record information corresponding to the target key value on the blockchain is updated through the system chain code in the hyperledger framework Fabric, wherein the target key value is the identification information of the target object in the blockchain, and the record information corresponding to the target key value is used to record the transaction information of the target object; A first determining unit, configured to, when an update is detected, determine by the system chain code that the record information corresponding to the target key value is updated to the first transaction record information; A first synchronization unit is configured to synchronize the first transaction record information as the first data change record information of the target object in the target database by the system chain code, wherein the target database is used to synchronously save the data change record information of one or more objects on the blockchain, wherein the one or more objects include the target object, and the first data change record information is composed of a key-value pair, wherein the key of the key-value pair is the hash value of the target object, and the value of the key-value pair is the transaction identifier of the first transaction record information, the transaction timestamp, and the block height where the transaction is located; After synchronizing the first transaction record information as the first data change record information in the target database, it also includes: when it is detected that the record information corresponding to the target key value on the blockchain is updated, determining that the record information corresponding to the target key value is updated to second transaction record information; adding the transaction identifier, transaction timestamp, and block height of the second transaction record information in the second transaction record as second data change record information after the transaction identifier, transaction timestamp, and block height of the first transaction record information in the key-value pair.

13. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 10 when executed.

14. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 10 through the computer program.

Citation Information

Patent Citations

  • Information query system, method and device, electronic equipment and storage medium

    CN109741060A

  • Block chain data processing method, device and system and electronic equipment

    CN110633389A