Blockchain-based archive query method and device
By calculating hash values in the blockchain to query file numbers and data content, the problem of limited file query methods is solved, enabling diverse and efficient file queries and improving user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2023-06-12
- Publication Date
- 2026-06-05
AI Technical Summary
The existing file storage method restricts users to using only pre-set unique identifiers as search criteria, resulting in a single search method and low flexibility. When users forget their unique identifiers, they have to go through a complicated process to reset them, which reduces the efficiency of file search and the user experience.
By receiving user-submitted file query requests, calculating hash values to query file numbers, and retrieving data content based on file numbers, the system leverages the correspondence between hash values and file numbers stored in the blockchain to support query methods across multiple query dimensions, thereby improving query flexibility and efficiency.
It has enabled diverse and flexible methods for retrieving archives, improved the efficiency of archive retrieval, and enhanced the user experience.
Smart Images

Figure CN116737754B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, and in particular to a method and apparatus for file retrieval based on blockchain. Background Technology
[0002] This section is intended to provide background or context for the embodiments of the invention set forth in the claims. The description herein is not an admission that it is prior art simply because it is included in this section.
[0003] The existing file storage method limits users to using only pre-defined unique identifiers as search criteria, resulting in a single and inflexible file search method. If a user forgets their unique identifier, they need to go through a complicated process to reset it before they can search for files, which reduces the efficiency of file search and affects the user experience.
[0004] There is currently no effective solution to the above problems. Summary of the Invention
[0005] This invention provides a blockchain-based document retrieval method to improve the diversity and flexibility of document retrieval methods, increase document retrieval efficiency, and enhance user experience. The method includes:
[0006] Receive a file query request submitted by a user. The file query request includes: a query dimension of the file to be queried, and the actual data information corresponding to the query dimension, wherein the file to be queried corresponds to multiple query dimensions.
[0007] Based on the actual data information corresponding to the query dimension and the smart contract address information of the blockchain, a first hash value is calculated. The file number of the file to be queried is then queried based on the first hash value. The blockchain stores the file numbers of different files and the first correspondence between multiple first hash values.
[0008] When the file number of the file to be queried is found based on the first hash value, the data content of the file to be queried is retrieved based on the file number of the file to be queried. The blockchain stores a second correspondence between the file numbers and data content of different files.
[0009] This invention also provides a blockchain-based document retrieval device to improve the diversity and flexibility of document retrieval methods, increase document retrieval efficiency, and enhance user experience. The device includes:
[0010] The file query request receiving module is used to receive file query requests submitted by users. The file query request includes: a query dimension of the file to be queried, and the actual data information corresponding to the query dimension, wherein the file to be queried corresponds to multiple query dimensions.
[0011] The file number query module is used to calculate a first hash value based on the actual data information corresponding to the query dimension and the smart contract address information of the blockchain, and to query the file number of the file to be queried based on the first hash value. The blockchain stores the first correspondence between the file numbers of different files and multiple first hash values.
[0012] The data content query module is used to query the data content of the file to be queried when the file number of the file to be queried is found according to the first hash value. The blockchain stores a second correspondence between the file numbers and data content of different files.
[0013] This invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the above-described blockchain-based file query method.
[0014] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned blockchain-based file retrieval method.
[0015] This invention also provides a computer program product, which includes a computer program that, when executed by a processor, implements the aforementioned blockchain-based file query method.
[0016] In this embodiment of the invention, a file query request submitted by a user is received. The file query request includes: a query dimension of the file to be queried, and the actual data information corresponding to the query dimension, wherein the file to be queried corresponds to multiple query dimensions; a first hash value is calculated based on the actual data information corresponding to the query dimension and the smart contract address information of the blockchain; the file number of the file to be queried is queried based on the first hash value; when the file number of the file to be queried is found based on the first hash value, the data content of the file to be queried is queried based on the file number of the file to be queried. This can improve the diversity and flexibility of file query methods, improve file query efficiency, and improve user experience. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings:
[0018] Figure 1This is a flowchart illustrating the blockchain-based file retrieval method in an embodiment of the present invention.
[0019] Figure 2 This is a flowchart of the method for creating a query template in an embodiment of the present invention;
[0020] Figure 3 This is a flowchart illustrating the method for uploading new files to the blockchain in an embodiment of the present invention.
[0021] Figure 4 A flowchart of a method for sending prompt information to a user in an embodiment of the present invention;
[0022] Figure 5 This is a schematic diagram of the structure of the blockchain-based file retrieval device in an embodiment of the present invention;
[0023] Figure 6 This is a schematic diagram of a computer device structure according to an embodiment of the present invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0025] First, let's introduce the technical terms used in the embodiments of this invention:
[0026] Blockchain: Blockchain is essentially a decentralized chain-like storage structure that achieves a reliable data storage method through mutual trust and sharing among multiple blockchain nodes.
[0027] Smart contracts: A smart contract is a piece of computer code designed to disseminate, verify, or execute contracts in an informational manner. Smart contracts allow for trusted transactions without the need for a third party; these transactions are traceable and irreversible. The purpose of smart contracts is to provide a security approach superior to traditional contracts and to reduce other transaction costs associated with contracts.
[0028] Figure 1 This is a flowchart illustrating the blockchain-based file retrieval method in an embodiment of the present invention. Figure 1 As shown, the blockchain-based file retrieval method in this embodiment of the invention may include:
[0029] Step 101: Receive a file query request submitted by the user. The file query request includes: a query dimension of the file to be queried, and the actual data information corresponding to the query dimension, wherein the file to be queried corresponds to multiple query dimensions.
[0030] Step 102: Calculate a first hash value based on the actual data information corresponding to the query dimension and the smart contract address information of the blockchain. Query the file number of the file to be queried based on the first hash value. The blockchain stores the file numbers of different files and the first correspondence between multiple first hash values.
[0031] Step 103: When the file number of the file to be queried is found based on the first hash value, the data content of the file to be queried is queried based on the file number of the file to be queried. The blockchain stores a second correspondence between the file numbers and data content of different files.
[0032] The following describes the specific execution steps of the blockchain-based file retrieval method in this embodiment of the invention:
[0033] First, the system can receive file query requests submitted by users. These requests can include: a query dimension for the file to be queried, and the actual data information corresponding to that query dimension. The file to be queried can correspond to multiple query dimensions. In specific implementation, in step 101, the user can arbitrarily select one query dimension from the multiple query dimensions corresponding to the file to be queried. To accurately retrieve the corresponding file, the user can also select multiple query dimensions simultaneously, and execute the query steps sequentially according to the selected query dimensions.
[0034] Figure 2 This is a flowchart illustrating the template creation process in an embodiment of the present invention. Figure 2 As shown, in one embodiment, before receiving a user-submitted file query request, the process may further include:
[0035] Step 201: Determine multiple query dimensions based on file attributes;
[0036] Step 202: Calculate the second hash value for each query dimension. Based on each query dimension and the second hash value of each query dimension, create multiple query templates so that users can select a query dimension of the file to be queried based on the multiple query templates. The second hash value serves as the index for each query template.
[0037] In practice, multiple query dimensions can be determined based on the inherent attributes of the archives, such as the archive document number, archive title, archive user name, and the department to which the archives belong. Query dimensions can also be defined based on the unique attributes of different types of archives.
[0038] The following example illustrates the process of creating a query template:
[0039] 1. Select a field that represents the file itself as the query dimension, such as the file number, with the field name: fileNo;
[0040] 2. Assemble the fields of each query dimension into query dimension metadata in the form of {key:value}, and form a query dimension parameter template for each query dimension.
[0041] Taking the document number as an example, calculate the second hash value (hash2) of the document number field name fileNo and use it as an index. The document number field name: fileNo is used as the value to form the metadata of the document number query dimension, namely {hash2, fileNo}. {hash2, fileNo} can be stored in the query template configuration center as the query dimension parameter template of the document number.
[0042] Based on the established query templates, the following describes the process of uploading new files to the blockchain. Figure 3 This is a flowchart illustrating the method for uploading a new file to the blockchain in an embodiment of the present invention. Figure 3 As shown, in one embodiment, it may further include:
[0043] Step 301: When a new file is uploaded to the blockchain, obtain the data content of the new file and assign a file number to the new file;
[0044] Step 302: Based on multiple query templates, extract the data information that the new file actually corresponds to in multiple query dimensions; based on the data information that the new file actually corresponds to in each query dimension and the smart contract address information of the blockchain, calculate multiple first hash values of the new file;
[0045] Step 303: Establish a first correspondence between multiple first hash values of the new file and the file number of the new file, and store the first correspondence in the blockchain;
[0046] Step 304: Establish a second correspondence between the file number of the new file and the data content of the new file, and store the second correspondence in the blockchain.
[0047] For example, when a new file is uploaded to the blockchain, the data content of the new file can be obtained first, and a file number can be randomly assigned to it. Each file on the blockchain has a unique file number. Then, based on multiple established query templates, multiple attribute values corresponding to the new file can be extracted. Taking the file number as an example again, assuming the attribute value of fileNo is 123, for the query dimension of file number, the first hash value (hash1) can be calculated based on the combination of "123 + smart contract address information". Using hash1 as the index and the file number as the value, the correspondence between this query field (file number) and the unique identifier of the new file (file number) can be established, i.e., {hash1, file number}, and stored in the local cache.
[0048] In practice, multiple first hash values for a new file can be calculated based on multiple query dimensions, with each first hash value corresponding to a unique identifier for the new file. Furthermore, a mapping between file numbers and the file data content itself can be established for querying. In the smart contract, this data can be stored in a map format, i.e., {file number, file data content}.
[0049] After receiving the file query request submitted by the user, step 102 is executed. A first hash value is calculated based on the actual data information corresponding to the query dimension and the smart contract address information of the blockchain. The file number of the file to be queried is queried based on the first hash value. The blockchain stores the first correspondence between the file numbers of different files and multiple first hash values.
[0050] Next, step 103 is executed. When the file number of the file to be queried is found based on the first hash value, the data content of the file to be queried can be queried based on the file number of the file to be queried. The blockchain stores a second correspondence between the file numbers and data content of different files.
[0051] Figure 4 A flowchart illustrating a method for sending prompts to a user in an embodiment of the present invention. (See attached flowchart.) Figure 4 As shown, in one embodiment, it may further include:
[0052] Step 401: When the file number of the file to be queried cannot be found based on the first hash value, calculate the second hash value of the query dimension, and query multiple query templates based on the second hash value of the query dimension;
[0053] Step 402: If the corresponding template cannot be found based on the second hash value of the query dimension, send a prompt message to the user that querying files based on this query dimension is not supported.
[0054] In practice, if the corresponding template is found by querying the second hash value of the query dimension, it indicates that the query of files by the query dimension is supported. This may be because the data entered by the user is incorrect or there is no file containing the data.
[0055] For example, when querying a file, if the user enters the query condition: {fileNo, 321}, the program obtains the value of the corresponding query dimension, which is 321. Then, it calculates the hash value based on the combination of "321 + smart contract address information". If the calculated result is hash3, querying the local cache based on hash3 will find no corresponding record, i.e., the query fails. At this time, the hash value is calculated again based on the query dimension fileNo, resulting in hash2. Using hash2 to query the template configuration center, if {hash2, fileNo} can be found, it means that the query condition is supported, but there is no file with fileNo 321. If the corresponding configuration template {hash2, fileNo} is not found in the template configuration center, it means that this query dimension is not supported as a file query condition.
[0056] In one embodiment, the query dimensions include: document number, document title, document username, and the department to which the document belongs.
[0057] The following example illustrates the specific implementation steps for querying files in an embodiment of the present invention:
[0058] (1) When searching for files, the user enters the search criteria, i.e., {fileNo,123}.
[0059] (2) The program obtains the corresponding value, 123, and then calculates the hash value based on "123 + smart contract address information". The first hash value hash1 calculated when the new file is uploaded to the chain will be obtained.
[0060] (3) By querying the local cache based on hash1, we can retrieve {hash1, file number};
[0061] (4) You can obtain {archive number, archive data content} by querying the blockchain based on the archive number.
[0062] In practice, different types of archives may have different archive attributes. To improve the accuracy of archive retrieval, you can also query based on the unique archive attributes of different types of archives. You can re-establish the query dimension parameter template according to the archive category and repeat the above steps.
[0063] This invention also provides a blockchain-based document retrieval device, as described in the following embodiments. Since the principle by which this device solves the problem is similar to that of the blockchain-based document retrieval method, the implementation of this device can refer to the implementation of the blockchain-based document retrieval method; repeated details will not be elaborated further.
[0064] Figure 5 This is a schematic diagram of the structure of a blockchain-based file retrieval device according to an embodiment of the present invention. Figure 5As shown, the blockchain-based file retrieval device in this embodiment of the invention may specifically include:
[0065] The file query request receiving module 501 is used to receive file query requests submitted by users. The file query request includes: a query dimension of the file to be queried, and the data information actually corresponding to the query dimension, wherein the file to be queried corresponds to multiple query dimensions.
[0066] The file number query module 502 is used to calculate a first hash value based on the actual data information corresponding to the query dimension and the smart contract address information of the blockchain, and to query the file number of the file to be queried based on the first hash value. The blockchain stores the first correspondence between the file numbers of different files and multiple first hash values.
[0067] The data content query module 503 is used to query the data content of the file to be queried based on the file number of the file to be queried when the file number of the file to be queried is found based on the first hash value. The blockchain stores a second correspondence between the file numbers and data content of different files.
[0068] In one embodiment, a query template creation module is also included, used before the file query request receiving module 501 receives the file query request submitted by the user:
[0069] Determine multiple query dimensions based on file attributes;
[0070] Calculate the second hash value for each query dimension. Based on each query dimension and its second hash value, create multiple query templates so that users can select a query dimension of the file to be queried based on the multiple query templates. The second hash value serves as the index for each query template.
[0071] In one embodiment, a new file upload module is also included, for:
[0072] When a new file is uploaded to the blockchain, its data content is retrieved and a file number is assigned to it.
[0073] Based on multiple query templates, extract the data information that the new file actually corresponds to in multiple query dimensions; based on the data information that the new file actually corresponds to in each query dimension and the smart contract address information of the blockchain, calculate multiple first hash values of the new file;
[0074] Establish a first correspondence between multiple first hash values of the new file and the file number of the new file, and store the first correspondence in the blockchain;
[0075] Establish a second correspondence between the file number of the new file and the data content of the new file, and store the second correspondence in the blockchain.
[0076] In one embodiment, a notification message sending module is further included, for:
[0077] If the file number of the file to be queried cannot be found based on the first hash value, calculate the second hash value of the query dimension, and query multiple query templates based on the second hash value of the query dimension;
[0078] If no corresponding template can be found based on the second hash value of this query dimension, a message will be sent to the user indicating that querying files based on this query dimension is not supported.
[0079] In one embodiment, the query dimensions include: document number, document title, document username, and the department to which the document belongs.
[0080] Based on the aforementioned inventive concept, such as Figure 6 As shown, the present invention also proposes a computer device 600, including a memory 610, a processor 620, and a computer program 630 stored in the memory 610 and executable on the processor 620. When the processor 620 executes the computer program 630, it implements the aforementioned blockchain-based file query method.
[0081] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned blockchain-based file retrieval method.
[0082] This invention also provides a computer program product, which includes a computer program that, when executed by a processor, implements the aforementioned blockchain-based file query method.
[0083] In summary, in this embodiment of the invention, a user-submitted file query request is received. The file query request includes: a query dimension of the file to be queried, and the actual data information corresponding to the query dimension, wherein the file to be queried corresponds to multiple query dimensions; a first hash value is calculated based on the actual data information corresponding to the query dimension and the smart contract address information of the blockchain; the file number of the file to be queried is queried based on the first hash value; when the file number of the file to be queried is found based on the first hash value, the data content of the file to be queried is queried based on the file number of the file to be queried. This can improve the diversity and flexibility of file query methods, improve file query efficiency, and enhance user experience.
[0084] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0085] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations 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, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0086] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0087] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0088] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A blockchain-based method for retrieving archives, characterized in that, include: Receive a file query request submitted by a user. The file query request includes: a query dimension of the file to be queried, and the actual data information corresponding to the query dimension, wherein the file to be queried corresponds to multiple query dimensions. Based on the actual data information corresponding to the query dimension and the smart contract address information of the blockchain, a first hash value is calculated. The file number of the file to be queried is then queried based on the first hash value. The blockchain stores the file numbers of different files and the first correspondence between multiple first hash values. When the file number of the file to be queried is found based on the first hash value, the data content of the file to be queried is retrieved based on the file number of the file to be queried. The blockchain stores a second correspondence between the file numbers and data content of different files. Before receiving a user's submitted file query request, the process also includes: determining multiple query dimensions based on file attributes; calculating the second hash value for each query dimension; and creating multiple query templates based on each query dimension and the second hash value for each query dimension, so that the user can select a query dimension of the file to be queried based on the multiple query templates, wherein the second hash value serves as the index for each query template. The process of creating a query template includes: selecting fields of the file's own attributes as query dimensions; assembling the fields of each query dimension into query dimension metadata in the form of {key: value}, and forming a query dimension parameter template for each query dimension.
2. The method as described in claim 1, characterized in that, Also includes: When a new file is uploaded to the blockchain, its data content is retrieved and a file number is assigned to it. Based on multiple query templates, extract the actual data information corresponding to the new file across multiple query dimensions; Based on the actual data information corresponding to each query dimension of the new archive and the smart contract address information of the blockchain, multiple first hash values of the new archive are calculated; Establish a first correspondence between multiple first hash values of the new file and the file number of the new file, and store the first correspondence in the blockchain; Establish a second correspondence between the file number of the new file and the data content of the new file, and store the second correspondence in the blockchain.
3. The method as described in claim 1, characterized in that, Also includes: If the file number of the file to be queried cannot be found based on the first hash value, calculate the second hash value of the query dimension, and query multiple query templates based on the second hash value of the query dimension; If no corresponding template can be found based on the second hash value of this query dimension, a message will be sent to the user indicating that querying files based on this query dimension is not supported.
4. The method as described in claim 1, characterized in that, The query dimensions include: document number, document title, document username, and the department to which the document belongs.
5. A blockchain-based document retrieval device, characterized in that, include: The file query request receiving module is used to receive file query requests submitted by users. The file query request includes: a query dimension of the file to be queried, and the actual data information corresponding to the query dimension, wherein the file to be queried corresponds to multiple query dimensions. The file number query module is used to calculate a first hash value based on the actual data information corresponding to the query dimension and the smart contract address information of the blockchain, and to query the file number of the file to be queried based on the first hash value. The blockchain stores the first correspondence between the file numbers of different files and multiple first hash values. The data content query module is used to query the data content of the file to be queried based on the file number of the file to be queried when the file number of the file to be queried is found based on the first hash value. The blockchain stores a second correspondence between the file numbers and data content of different files. It also includes a query template creation module, which is used before the file query request receiving module receives the file query request submitted by the user: determine multiple query dimensions based on file attributes; calculate the second hash value of each query dimension; and create multiple query templates based on each query dimension and the second hash value of each query dimension, so that the user can select a query dimension of the file to be queried based on the multiple query templates, wherein the second hash value serves as the index of each query template; The process of creating a query template includes: selecting fields of the file's own attributes as query dimensions; assembling the fields of each query dimension into query dimension metadata in the form of {key: value}, and forming a query dimension parameter template for each query dimension.
6. The apparatus as claimed in claim 5, characterized in that, It also includes a new file upload module, used for: When a new file is uploaded to the blockchain, its data content is retrieved and a file number is assigned to it. Based on multiple query templates, extract the actual data information corresponding to the new file across multiple query dimensions; Based on the actual data information corresponding to each query dimension of the new archive and the smart contract address information of the blockchain, multiple first hash values of the new archive are calculated; Establish a first correspondence between multiple first hash values of the new file and the file number of the new file, and store the first correspondence in the blockchain; Establish a second correspondence between the file number of the new file and the data content of the new file, and store the second correspondence in the blockchain.
7. The apparatus as claimed in claim 5, characterized in that, It also includes a notification message sending module, used for: If the file number of the file to be queried cannot be found based on the first hash value, calculate the second hash value of the query dimension, and query multiple query templates based on the second hash value of the query dimension; If no corresponding template can be found based on the second hash value of this query dimension, a message will be sent to the user indicating that querying files based on this query dimension is not supported.
8. The apparatus as claimed in claim 5, characterized in that, The query dimensions include: document number, document title, document username, and the department to which the document belongs.
9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method of any one of claims 1 to 4.
11. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the method of any one of claims 1 to 4.