Data storage and query method and device, and computer-readable storage medium

By storing data to full and light nodes in the blockchain system, and using smart contracts for classification and load balancing management, the problem of inefficient data query in the blockchain system is solved, and more efficient data query is achieved.

CN114020838BActive Publication Date: 2025-08-26ZALL INTELLIGENCE (WUHAN) RES INST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111271521.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-29
Publication Date
2025-08-26
Estimated Expiration
2041-10-29

AI Technical Summary

Technical Problem

In the prior art, the data query efficiency of blockchain systems is inefficient, mainly due to data traversing all blockchain records.

Method used

The data to be queried is stored in the full node and light node of the blockchain system, and classified and load balancing are managed through smart contracts, and query tasks are assigned.

Benefits of technology

By alleviating the storage and query pressure of the entire node, the efficiency of data query is improved and the problem of inefficient query is avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114020838B_ABST
    Figure CN114020838B_ABST
Patent Text Reader

Abstract

Embodiments of the present invention disclose a data storage and query method and device, as well as a computer-readable storage medium. The method comprises: obtaining data to be queried; storing the data to be queried in full nodes and light nodes of a blockchain system respectively; assigning query tasks to the full nodes and light nodes via smart contracts; and performing queries based on the query tasks to obtain query data. Using the above scheme, data is stored in full nodes and light nodes of a blockchain system; based on the query load of the full nodes and light nodes, the smart contract assigns query tasks to the full nodes or light nodes. This allows full utilization of the query functions of the full nodes and light nodes, avoiding excessive query pressure on the full nodes or light nodes, which could lead to low query efficiency, thereby improving data query efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain, and in particular to a data storage and query method and device, and a computer-readable storage medium. Background Art

[0002] A data block typically consists of two parts: a block header and a block body. The block header encapsulates information such as the current version number, the previous block address, the target hash value of the current block, the nonce used in the consensus process, and a timestamp. The block body includes the number of transactions in the current block and all verified transaction records generated during the block creation process. This data contained in the block body becomes the block data. This storage method, which includes all data from the block creation process, requires traversing all relevant records stored in the blockchain system when performing data queries, resulting in inefficient queries. Summary of the Invention

[0003] The embodiments of the present invention are intended to provide a data storage and query method and device, and a computer-readable storage medium, which can improve query efficiency when querying blockchain system data.

[0004] The technical solution of the present invention is achieved as follows:

[0005] An embodiment of the present invention provides a data storage and query method, the method comprising:

[0006] Get the data to be queried;

[0007] Storing the data to be queried in the full node and light node of the blockchain system respectively;

[0008] Allocate query tasks between the full node and the light node through a smart contract;

[0009] Based on the query task, a query is performed to obtain query data.

[0010] In the above solution, the step of storing the data to be queried in the full node and light node of the blockchain system respectively includes:

[0011] Storing the data to be queried in the full node of the blockchain system through smart contracts;

[0012] Classifying the data to be queried to obtain different types of data to be queried;

[0013] The different types of data to be queried are stored in different light nodes of the blockchain system in sequence.

[0014] In the above solution, the data to be queried includes: different types of user tables and business keyword tables;

[0015] In the above solution, the storing of the different types of to-be-queried data in different light nodes of the blockchain system in sequence includes:

[0016] Storing the user table in the different types of data to be queried in a first light node in the blockchain system; wherein the first light node is any one of the different light nodes;

[0017] The business keyword table in the different types of data to be queried is stored in a second light node in the blockchain system; wherein the second light node is any light node among the different light nodes except the first light node.

[0018] In the above solution, after storing the data to be queried in the full node and light node of the blockchain system, the method further includes:

[0019] Based on the data on the newly generated block, the data to be queried in the full node is updated to obtain new data to be queried;

[0020] Based on the data on the newly generated block, the user table in the first light node and the service keyword table in the second light node are updated respectively to obtain a new user table and a new service keyword table.

[0021] In the above solution, the allocation of query tasks between the full node and the light node through smart contracts includes:

[0022] Set up a query gateway through smart contracts;

[0023] Obtaining the load balancing status of the full node and the different light nodes of the blockchain system through the query gateway;

[0024] According to the load balancing situation, the query task is allocated to the full node and the different light nodes.

[0025] In the above solution, allocating the query task to the full node and the different light nodes according to the load balancing situation includes:

[0026] Classify the query keywords and determine the type of query task;

[0027] Allocate the query task to the first light node or the second light node according to the type of the query task;

[0028] If the query rate of the first light node or the second light node is greater than a preset value, the query task is assigned to a full node.

[0029] In the above solution, before allocating the query tasks of the full node and the light node through the smart contract, the method further includes:

[0030] Through smart contracts, verify the access rights of objects and determine whether the objects have access rights;

[0031] If the object has the access permission, the query task is generated;

[0032] If the object does not have the access rights in question, no query is performed.

[0033] An embodiment of the present invention provides a data storage and query device, characterized in that the data storage and query device includes: an acquisition unit, a storage unit and an allocation unit, wherein:

[0034] The acquisition unit is used to acquire the data to be queried;

[0035] The storage unit is used to store the data to be queried in the full node and light node of the blockchain system respectively;

[0036] The allocation unit is used to allocate the query tasks of the full nodes and light nodes through the query gateway;

[0037] The acquisition unit is further configured to perform a query based on the query task and acquire query data.

[0038] An embodiment of the present invention provides a data storage and query device, the data storage and query device comprising:

[0039] A memory for storing executable data instructions;

[0040] The processor is used to execute the executable instructions stored in the memory. When the executable instructions are executed, the processor executes the data storage and query method.

[0041] An embodiment of the present invention provides a computer-readable storage medium, characterized in that executable instructions are stored therein. When the executable instructions are executed by one or more processors, the processors execute the data storage and query method.

[0042] Embodiments of the present invention provide a data storage and access method and device, as well as a computer-readable storage medium. The method comprises: obtaining data to be queried; storing the data to be queried in full nodes and light nodes of a blockchain system respectively; assigning query tasks to the full nodes and light nodes via a smart contract; and performing a query based on the query tasks to obtain query data. Using the above scheme, data is stored in full nodes and light nodes of a blockchain system, and light nodes are configured to store the data, which can alleviate the subsequent query pressure on full nodes. Based on the query load of full nodes and light nodes, the smart contract assigns query tasks to full nodes or light nodes, fully utilizing the query functions of full nodes and light nodes, avoiding excessive query pressure on full nodes or light nodes that could lead to low query efficiency, thereby improving query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 An optional process diagram of a data storage and query method provided in an embodiment of the present invention Figure 1 ;

[0044] Figure 2 An optional process diagram of a data storage and query method provided in an embodiment of the present invention Figure 2 ;

[0045] Figure 3 An optional process diagram of a data storage and query method provided in an embodiment of the present invention Figure 3 ;

[0046] Figure 4 An optional process diagram of a data storage and query method provided in an embodiment of the present invention Figure 4 ;

[0047] Figure 5 A schematic diagram of a data storage and query device provided by an embodiment of the present invention Figure 1 ;

[0048] Figure 6 A schematic diagram of a data storage and query device provided by an embodiment of the present invention Figure 2 . DETAILED DESCRIPTION

[0049] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.

[0050] Before further explaining the embodiments of the present invention in detail, the nouns and terms involved in the embodiments of the present invention are explained. The nouns and terms involved in the embodiments of the present invention are subject to the following interpretations.

[0051] 1) Block: A data structure that records user table data and business keyword table data updated by the exchange over a period of time. It is marked with a timestamp and a unique identifier of the previous block (such as a digital fingerprint). After the block is verified by consensus among the nodes in the blockchain system, it will be appended to the end of the blockchain and become a new block.

[0052] 2) Blockchain system: a chain data structure composed of sequentially connected blocks. Each block references the hash value of the previous block or its subset, thereby cryptographically ensuring that the recorded data cannot be tampered with or forged.

[0053] 3) Smart Contracts, also known as chaincode, are programs deployed in blockchain systems that are triggered and executed based on conditions.

[0054] In order to enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation methods. Figure 1 This is an optional process diagram of a data storage and query method provided by an embodiment of the present invention. Figure 1 , will combine Figure 1 The steps shown are explained.

[0055] S101: Obtain the data to be queried.

[0056] In some embodiments of the present invention, the data to be queried includes a user table and a business keyword table.

[0057] It should be noted that the business keyword table includes keyword tables for different businesses and data attribute tables corresponding to the keyword tables.

[0058] In some embodiments of the present invention, the terminal may obtain the data to be queried through the data on the block.

[0059] S102. Store the data to be queried in the full node and light node of the blockchain system respectively.

[0060] In some embodiments of the present invention, a full node is a node that synchronizes all data in the blockchain system, including various blocks, transaction lists, and other related information. A light node does not store the full transaction list and other information, but only stores a portion of it.

[0061] In some embodiments of the present invention, the terminal may store all the data to be queried in a full node, and at the same time store the data to be queried in different light nodes.

[0062] In some embodiments of the present invention, Figure 2 This is an optional process diagram of a data storage and query method provided by an embodiment of the present invention. Figure 2 , step S102 can be implemented by S1021-S1023, combining Figure 2 The steps shown are explained.

[0063] S1021. Through smart contracts, the data to be queried is stored in the full node of the blockchain system.

[0064] In some embodiments of the present invention, a smart contract is a set of digitally defined promises, including protocols that allow the parties to execute these promises. It is a contract in which the terms are recorded in computer language, rather than legal language, and automatically executed by a program. The relationship between the blockchain system and smart contracts can be abstracted as follows: "The blockchain system is responsible for data storage," while "the smart contract is responsible for business logic."

[0065] In some embodiments of the present invention, the terminal may store the data to be queried in a full node of the blockchain system through a smart contract.

[0066] S1022: Classify the data to be queried to obtain different types of data to be queried.

[0067] In some embodiments of the present invention, the terminal may obtain different types of data to be queried by classifying the data to be queried.

[0068] Exemplarily, the data to be queried is divided into a user table and a business keyword table.

[0069] It should be noted that the business keyword table is a collection of business keyword tables in many different fields, such as an insurance business keyword table, a medical business keyword table, and an education business keyword table, etc., but the embodiment of the present invention is not limited thereto.

[0070] S1023. Store different types of to-be-queried data in different light nodes of the blockchain system in sequence.

[0071] In some embodiments of the present invention, the terminal may store the same type of data of different types of to-be-queried data in the same light node, and store each type of to-be-queried data in a different light node in turn.

[0072] It can be understood that in some embodiments of the present invention, the terminal can store the data to be queried in the full node of the blockchain system through a smart contract; classify the data to be queried to obtain different types of data to be queried; and store different types of data to be queried in different light nodes of the blockchain system in turn, thereby alleviating the data storage pressure of the full node, further alleviating the query pressure of the full node, and improving the efficiency of data query.

[0073] In some embodiments of the present invention, step S1023 may be implemented by S10231 and S10232 as follows:

[0074] In some embodiments of the present invention, the data to be queried includes different types of user tables and business keyword tables.

[0075] S10231. Store the user tables in different types of to-be-queried data in a first light node in the blockchain system; wherein the first light node is any one of the different light nodes.

[0076] In some embodiments of the present invention, the user table is some user information, including user ID, user name, password, user mobile phone number, gender, birthday, user email, number of logins, user status, etc., but the embodiments of the present invention are not limited to this.

[0077] In some embodiments of the present invention, the terminal may store the user table in the data to be queried in the first light node in the blockchain system.

[0078] S10232. Store the business keyword table in different types of to-be-queried data in a second light node in the blockchain system; wherein the second light node is any light node among the different light nodes except the first light node.

[0079] In some embodiments of the present invention, the business keyword table includes an insurance business keyword table, a medical business keyword table, an education business keyword table, etc. For example, the insurance business keyword table includes the object of insurance, the insurance date, the insurance contract effective date, etc. The embodiments of the present invention are not limited to this.

[0080] In some embodiments of the present invention, the terminal may store the business keyword table in the data to be queried in a second light node in the blockchain system. The insurance business keyword table, the medical business keyword table, and the education business keyword table may be stored in different light nodes.

[0081] It can be understood that in some embodiments of the present invention, the terminal can store the user table in different types of data to be queried in the first light node in the blockchain system; and store the business keyword table in different types of data to be queried in the second light node in the blockchain system, which can alleviate the storage pressure of the full node and thus improve the efficiency of data query.

[0082] S103. Allocate query tasks to full nodes and light nodes through smart contracts.

[0083] In some embodiments of the present invention, the query task is generated by a user requesting to query data.

[0084] In some embodiments of the present invention, the terminal can set up a query gateway through a smart contract, obtain the query load of the full node and different light nodes of the blockchain system through the query gateway, and assign query tasks to the full node and different light nodes based on the obtained query load.

[0085] In some embodiments of the present invention, Figure 3 This is an optional process diagram of a data storage and query method provided by an embodiment of the present invention. Figure 3 , step S103 can be implemented by S1031-S1033, combining Figure 3 The steps shown are explained.

[0086] S1031. Set up a query gateway through a smart contract.

[0087] In some embodiments of the present invention, the function of the query gateway is to obtain the current query load of full nodes and light nodes.

[0088] In some embodiments of the present invention, the terminal can set up a query gateway through a smart contract to obtain the current query load of full nodes and light nodes.

[0089] S1032. Obtain the load balancing status of the full nodes and different light nodes of the blockchain system by querying the gateway.

[0090] In some embodiments of the present invention, the terminal can obtain the load balancing status of the full nodes and different light nodes of the current blockchain system by querying the gateway.

[0091] Exemplarily, the query rates of different light nodes are 30% and 40% respectively, and the query rate of full nodes is 80%.

[0092] It should be noted that the load balancing situation is equivalent to the query rate.

[0093] S1033. Allocate query tasks to full nodes and different light nodes based on the load balancing situation.

[0094] In some embodiments of the present invention, the terminal may allocate query tasks according to the query rates of full nodes and different light nodes, and prioritize allocating query tasks to light nodes. When the query rate of light nodes is too high, the query tasks are allocated to full nodes.

[0095] It is understandable that in some embodiments of the present invention, the terminal can set up a query gateway through a smart contract, and obtain the load balancing status of the full node and different light nodes of the blockchain system through the query gateway. According to the load balancing status, query tasks are assigned to the full node and different light nodes, thereby improving the efficiency of data query.

[0096] In some embodiments of the present invention, step S1033 may be implemented by S10331, S10332, and S10333 as follows:

[0097] S10331. Classify the query keywords and determine the type of the query task.

[0098] In some embodiments of the present invention, keywords are search terms input by users when performing queries.

[0099] In some embodiments of the present invention, the terminal may judge and classify the keywords of the user's query to determine the type of the query task.

[0100] For example, if the keyword is user account, the query task is the user table; if the keyword is insurance day, the query task is the insurance business keyword table.

[0101] S10332. Allocate the query task to the first light node or the second light node according to the type of the query task.

[0102] In some embodiments of the present invention, the terminal may assign the user table query task to the first light node and assign the service keyword table query task to the second light node.

[0103] S10333. If the query rate of the first light node or the second light node is greater than a preset value, the query task is assigned to the full node.

[0104] In some embodiments of the present invention, when the query rate of the first light node or the second light node is greater than a preset value, the terminal may assign the query task to the full node, and the full node may execute the query task.

[0105] Exemplarily, when the current query rate of the first light node storing the user table is greater than a preset value (eg, 60%), the query gateway sends the user query request to the full node for processing.

[0106] Exemplarily, when the current query rate of the second light node storing the service keyword table is greater than a preset value (eg, 80%), the query gateway sends the user query request to the full node for processing.

[0107] It should be noted that the query rate is the total number of user query requests N in the previous preset query period, divided by the number of query requests n processed by the first light node in the previous preset query period (for example, 1 hour or 10 minutes); query rate = n / N. N and n are both positive integers.

[0108] It can be understood that in some embodiments of the present invention, the terminal can classify the query keywords and determine the type of query task; according to the type of query task, the query task is assigned to the first light node or the second light node; if the query rate of the first light node or the second light node is greater than the preset value, the query task is assigned to the full node, which improves the query efficiency of the full node and the light node, and thereby improves the efficiency of data query.

[0109] S104: Based on the query task, perform a query and obtain query data.

[0110] In some embodiments of the present invention, the terminal may execute a query task through a full node or a light node to obtain query data corresponding to the query task.

[0111] For example, the user can scan the QR code on the product or directly access the blockchain system browser to conduct a query and obtain the query data, but the embodiments of the present invention are not limited thereto.

[0112] It can be understood that in some embodiments of the present invention, the terminal can store data in full nodes and light nodes. Setting light nodes to store data can alleviate the query pressure of subsequent full nodes; according to the query load of full nodes and light nodes, query tasks are assigned to full nodes or light nodes, which can avoid causing excessive query pressure on full nodes or light nodes and resulting in low query efficiency, thereby improving data query efficiency.

[0113] In some embodiments of the present invention, after step S102, steps S105-S106 are further performed as follows:

[0114] S105. Based on the data on the newly generated block, update the data to be queried in the full node to obtain new data to be queried.

[0115] In some embodiments of the present invention, the terminal can update the data to be queried in the full node through the data on the newly generated block to obtain new data to be queried. The new data to be queried includes historically stored data and newly generated data.

[0116] S106 . Based on the data on the newly generated block, update the user table in the first light node and the business keyword table in the second light node respectively to obtain a new user table and a new business keyword table.

[0117] In some embodiments of the present invention, the terminal can update the user table in the first light node through the data on the newly generated block to obtain a new user table; update the service keyword table in the second light node to obtain a new service keyword table.

[0118] It can be understood that in some embodiments of the present invention, the terminal can update the data to be queried in the full node through the data on the newly generated block to obtain new data to be queried; through the data on the newly generated block, the user table in the first light node and the business keyword table in the second light node are updated respectively to obtain a new user table and a new business keyword table. Timely data updates can improve the efficiency and accuracy of data queries.

[0119] In some embodiments of the present invention, Figure 4 This is an optional process diagram of a data storage and query method provided by an embodiment of the present invention. Figure 4 Before step S103, S107-S109 are also executed to combine Figure 4 The steps shown are explained.

[0120] S107. Verify the access rights of the object through the smart contract to determine whether the object has the access rights.

[0121] In some embodiments of the present invention, access rights are a mechanism for limiting access to certain information items or certain controls based on the user's identity and membership in various predefined groups.

[0122] In some embodiments of the present invention, the terminal can determine whether the user has access rights by judging whether there is a resource transaction between the user and the full node or light node; it can also determine whether the user has access rights by verifying the user's permission identifier through a smart contract.

[0123] It should be noted that the object is a user, and the embodiment of the present invention does not impose any limitation.

[0124] In some embodiments of the present invention, step S107 may be implemented by S1071 as follows:

[0125] S1071. Through the smart contract, determine whether there is a resource transaction between the object and the full node or light node, so as to determine whether the object has access rights.

[0126] In some embodiments of the present invention, resource trading is the exchange of resources between a user and a full node or a light node.

[0127] In some embodiments of the present invention, the terminal can use a smart contract to determine whether there is a resource transaction between the user and the full node or light node. If there is a resource transaction, the user has access rights; if there is no resource transaction, the user does not have access rights.

[0128] It is understandable that in some embodiments of the present invention, the terminal can improve the efficiency of data query by setting access rights.

[0129] In some embodiments of the present invention, step S1071 may be implemented by S10711 as follows:

[0130] S10711. Through smart contracts, verify whether the object has paid points to the full node or light node, thereby determining whether the object has access rights.

[0131] In some embodiments of the present invention, the terminal can determine whether the user pays points to the full node or light node through a smart contract. If the user pays points to the full node or light node, the user has access rights; if the user does not pay points to the full node or light node, the user does not have access rights.

[0132] It is understandable that in some embodiments of the present invention, the terminal can improve the efficiency of data query by setting access rights.

[0133] In some embodiments of the present invention, step S107 may also be implemented by S1072-S1074 as follows:

[0134] S1072: Receive the object's pre-application permission request.

[0135] In some embodiments of the present invention, the pre-application permission request is a command for the user to obtain permission from the terminal before performing a query access.

[0136] In some embodiments of the present invention, the terminal receives a user's pre-application permission request.

[0137] S1073. In response to the pre-application permission request, the full node or light node assigns a permission identifier to the object.

[0138] In some embodiments of the present invention, the permission identifier is a credential for a user to access, including two situations: access is allowed and access is not allowed.

[0139] In some embodiments of the present invention, the terminal allocates a permission identifier to the user by a full node or a light node in response to a pre-application permission request.

[0140] S1074. Verify the permission identifier through the smart contract to determine whether the object has access rights.

[0141] In some embodiments of the present invention, the terminal can verify the permission identifier through a smart contract. If the permission identifier indicates that the user can access the device, then the user has access rights; if the permission identifier indicates that the user cannot access the device, then the user does not have access rights.

[0142] It can be understood that in some embodiments of the present invention, the terminal can receive a pre-application permission request for an object; in response to the pre-application permission request, the full node or light node assigns a permission identifier to the object; the permission identifier is verified through the smart contract to determine whether the object has access rights, and by setting access rights, unnecessary queries are reduced and the efficiency of data queries is improved.

[0143] S108: If the object has access rights, a query task is generated.

[0144] In some embodiments of the present invention, the terminal may allow a user with access rights to perform a query, thereby generating a query task.

[0145] S109. If the object does not have access rights, no query is performed.

[0146] In some embodiments of the present invention, the terminal may prohibit querying for users who do not have access rights, so that no query task is generated.

[0147] It can be understood that in some embodiments of the present invention, the terminal verifies the access rights of the object through a smart contract to determine whether the object has access rights; if the object has access rights, a query task is generated; if the object does not have access rights, no query is performed. By verifying the access rights, the conditions for user queries are improved, unnecessary queries are reduced, and the efficiency of data queries is improved.

[0148] Based on the data storage and query method of the above embodiment, the embodiment of the present invention also provides a data storage and query device, such as Figure 5 As stated, Figure 5 A schematic diagram of a data storage and query structure provided by an embodiment of the present invention Figure 1 The device includes: an acquisition unit 501, a storage unit 502 and an allocation unit 503; wherein,

[0149] The acquisition unit 501 is used to acquire the data to be queried;

[0150] The storage unit 502 is used to store the data to be queried in the full node and light node of the blockchain system respectively;

[0151] The allocation unit 503 is used to allocate query tasks of the full node and the light node through a smart contract;

[0152] The acquisition unit 501 is further configured to perform a query based on the query task and acquire query data.

[0153] In some embodiments of the present invention, the storage unit 502 is used to store the data to be queried in a full node of the blockchain system through a smart contract;

[0154] The acquisition unit 501 is used to classify the data to be queried to obtain different types of data to be queried;

[0155] The storage unit 502 is used to store the different types of to-be-queried data in different light nodes of the blockchain system in sequence.

[0156] In some embodiments of the present invention, the data to be queried includes: different types of user tables and business keyword tables;

[0157] In some embodiments of the present invention, the storage unit 502 is used to store the user table in the different types of data to be queried in a first light node in the blockchain system; wherein the first light node is any one of the different light nodes; and store the business keyword table in the different types of data to be queried in a second light node in the blockchain system; wherein the second light node is any one of the different light nodes except the first light node.

[0158] In some embodiments of the present invention, the acquisition unit 501 is used to update the data to be queried in the full node based on the data on the newly generated block to obtain new data to be queried; based on the data on the newly generated block, the user table in the first light node and the business keyword table in the second light node are updated respectively to obtain a new user table and a new business keyword table.

[0159] In some embodiments of the present invention, the data storage and query device further includes a setting unit 504; wherein,

[0160] The setting unit 504 is used to set a query gateway through a smart contract;

[0161] The acquisition unit 501 is configured to obtain, through the query gateway, the load balancing status of the full node and the different light nodes of the blockchain system;

[0162] The allocating unit 503 is configured to allocate the query task to the full node and the different light nodes according to the load balancing situation.

[0163] In some embodiments of the present invention, the data storage and query device further includes a determination unit 505; wherein,

[0164] The determining unit 505 is used to classify the query keywords and determine the type of the query task;

[0165] The allocating unit 503 is configured to allocate the query task to the first light node or the second light node according to the type of the query task;

[0166] The allocating unit 503 is configured to allocate the query task to the full node if the query rate of the first light node or the second light node is greater than a preset value.

[0167] In some embodiments of the present invention, the data storage and query device further includes a judgment unit 506; wherein,

[0168] The determining unit 505 is used to verify the access rights of the object through the smart contract and determine whether the object has the access rights;

[0169] The determining unit 506 is configured to generate the query task if the object has the access permission; and not perform the query if the object does not have the access permission.

[0170] In some embodiments of the present invention, the determination unit 505 is used to determine whether there is a resource transaction between the object and the full node or the light node through the smart contract, thereby determining whether the object has the access permission.

[0171] In some embodiments of the present invention, the determination unit 505 is used to verify whether the object pays points to the full node or the light node through the smart contract, thereby determining whether the object has the access right.

[0172] In some embodiments of the present invention, the data storage and query device further includes a receiving unit 507; wherein,

[0173] The receiving unit 507 is configured to receive a request from an object for pre-application permission;

[0174] The determining unit 505 is configured to, in response to the pre-application permission request, assign a permission identifier to the object by the full node or the light node; and verify the permission identifier through the smart contract to determine whether the object has the access permission.

[0175] Based on the data storage and query method of the above embodiment, the embodiment of the present invention also provides a data storage and query device, such as Figure 6 As shown, Figure 6 A schematic diagram of a data storage and query device provided by an embodiment of the present invention Figure 2The device includes: a processor 601 and a memory 602; the memory 601 stores one or more programs executable by the processor, and when one or more programs are executed, the processor 602 executes any one of the data storage and query methods in the above-described embodiments.

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

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

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

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

[0180] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention.

Claims

1. A data storage and query method, characterized in that: include: Get the data to be queried; Storing the data to be queried in the full node and light node of the blockchain system respectively; Allocate query tasks between the full node and the light node through a smart contract; Based on the query task, perform a query and obtain query data; The storing of the data to be queried in the full node and light node of the blockchain system respectively includes: Storing the data to be queried in the full node of the blockchain system through smart contracts; Classifying the data to be queried to obtain different types of data to be queried; Storing the different types of data to be queried in different light nodes of the blockchain system in sequence; The data to be queried includes: different types of user tables and business keyword tables; The storing of the different types of to-be-queried data in different light nodes of the blockchain system in sequence includes: Storing the user table in the different types of data to be queried in a first light node in the blockchain system; wherein the first light node is any one of the different light nodes; The business keyword table in the different types of data to be queried is stored in a second light node in the blockchain system; wherein the second light node is any light node among the different light nodes except the first light node.

2. The method according to claim 1, wherein After storing the data to be queried in the full node and the light node of the blockchain system, the method further includes: Based on the data on the newly generated block, the data to be queried in the full node is updated to obtain new data to be queried; Based on the data on the newly generated block, the user table in the first light node and the service keyword table in the second light node are updated respectively to obtain a new user table and a new service keyword table.

3. The method according to claim 1 or 2, characterized in that The allocating query tasks of the full node and the light node through a smart contract includes: Set up a query gateway through smart contracts; Obtaining the load balancing status of the full node and different light nodes of the blockchain system through the query gateway; According to the load balancing situation, the query task is allocated to the full node and different light nodes.

4. The method according to claim 3, wherein Allocating the query task to the full node and different light nodes according to the load balancing situation includes: Classify the query keywords and determine the type of query task; Allocate the query task to the first light node or the second light node according to the type of the query task; If the query rate of the first light node or the second light node is greater than a preset value, the query task is assigned to the full node.

5. The method according to claim 1 or 2, characterized in that Before allocating the query tasks of the full node and the light node through the smart contract, the method further includes: Through smart contracts, verify the access rights of objects and determine whether the objects have access rights; If the object has the access permission, the query task is generated; If the object does not have the access rights in question, no query is performed.

6. A data storage and query device, characterized in that: include: Acquisition unit, storage unit and allocation unit, wherein, The acquisition unit is used to acquire the data to be queried; The storage unit is used to store the data to be queried in the full node and light node of the blockchain system respectively; The allocation unit is used to allocate query tasks of the full node and the light node through a smart contract; The acquisition unit is further configured to perform a query based on the query task and acquire query data; The storage unit is further configured to store the data to be queried in a full node of the blockchain system through a smart contract; The acquisition unit is further configured to classify the data to be queried to obtain different types of data to be queried; The storage unit is further configured to sequentially store the different types of to-be-queried data in different light nodes of the blockchain system; The data to be queried includes: different types of user tables and business keyword tables; the storage unit is further used to store the user tables in the different types of data to be queried in a first light node in the blockchain system; wherein the first light node is any one of the different light nodes; and the business keyword tables in the different types of data to be queried are stored in a second light node in the blockchain system; wherein the second light node is any one of the different light nodes except the first light node.

7. A data storage and query device, characterized in that: include: A memory for storing executable data instructions; A processor, configured to implement the data storage and query method according to any one of claims 1 to 5 when executing the executable instructions stored in the memory.

8. A computer-readable storage medium, characterized in that Executable instructions are stored, which are used to cause a processor to execute and implement the data storage and query method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Blockchain-based data storage and query method and device

    CA3048741A1

  • Cloud query method, device and appartaus and storage medium based on block chain

    CN109522462A