Data storage method, device, electronic device and storage medium

Generating and storing academic data blocks through blockchain technology solves the security problem of centralized storage methods, achieves decentralized storage and efficient retrieval, and enhances the security and consistency of academic data.

CN115017226BActive Publication Date: 2024-10-18JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110247048.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-05
Publication Date
2024-10-18
Estimated Expiration
2041-03-05

AI Technical Summary

Technical Problem

The existing academic data storage management system uses a centralized data storage method, which results in a single point of failure or malicious attack on the centralized server. The academic data is easily tampered with or leaked, and the security of data storage is low.

Method used

Use blockchain technology to obtain the certificate data set, generate block headers and block bodies, combine them into certificate data blocks, and write them into the dat file of the blockchain node, and at the same time, block and certificate transactions Relevant metadata is written into the underlying database in the form of key-value pairs, and state data is written into the state database in the form of key-value pairs to achieve decentralized storage.

Benefits of technology

It improves the security and retrieval efficiency of academic qualification data, enhances the transparency and consistency of data, provides an untamperable and trustless storage environment, and ensures the security and effectiveness of electronic academic qualification data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115017226B_ABST
    Figure CN115017226B_ABST
Patent Text Reader

Abstract

The present invention relates to a data storage method, device, electronic device and storage medium, wherein the data storage method comprises: obtaining a stored data set, wherein the stored data set comprises a degree data file to be stored and stored information corresponding to the degree data file; generating a block header and a block body based on the stored data set; combining the block header and the block body to generate a stored data block; writing the data of the stored data block into a dat file, writing the block corresponding to the stored data block and metadata related to the stored transaction into an underlying database in the form of a key-value pair, and writing the status data corresponding to the stored data block into a status database in the form of a key-value pair. The embodiment of the present invention can realize the decentralized storage of the degree data file and stored information, and improve the security of the data; in addition, storing the metadata and status data related to the block and the stored transaction in the form of a key-value pair can facilitate rapid retrieval and improve retrieval efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] The exponential growth of electronic data in the Internet era has made digital life increasingly dependent on electronic evidence storage systems, especially in the storage of university academic data. With the development of academic data management systems, its relevant standards and electronic operation processes have become more perfect, and new computer technologies are constantly being integrated.

[0003] However, the existing academic data notarization management system adopts a centralized data storage method to organize and store academic data. Single point failure of the centralized server or malicious attack will inevitably lead to the tampering or leakage of academic data, and the security of data storage is relatively low. Summary of the invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a data storage method, device, electronic device and storage medium.

[0005] In a first aspect, the present application provides a data storage method, comprising:

[0006] Obtaining a stored evidence data set, wherein the stored evidence data set includes the academic qualification data file to be stored and the stored evidence information corresponding to the academic qualification data file;

[0007] Generate a block header and a block body based on the evidence data set;

[0008] Combining the block header and the block body to generate a proof data block;

[0009] Write the data of the evidence data block into the dat file of the blockchain node, write the block corresponding to the evidence data block and metadata related to the evidence transaction into the underlying database in the form of key-value pairs, and write the status data corresponding to the evidence data block into the status database in the form of key-value pairs;

[0010] Among them, the metadata related to the block and the evidence transaction is generated when the data of the evidence data block is written into the dat file, and the status data is the status data obtained by executing the evidence transaction in the evidence data block.

[0011] Optionally, writing the data of the evidence data block into a dat file of a blockchain node includes:

[0012] Serialize and encode the data in the evidence data block to obtain bytecode, and write the bytecode into a dat file;

[0013] Among them, in the process of writing bytecode into the dat file, if the sum of the data currently being written into the dat file and the data already written into the dat file is greater than the preset storage capacity of the dat file, a new dat file is generated and the data currently being written is written into the new dat file.

[0014] Optionally, writing the block corresponding to the evidence data block and metadata related to the evidence transaction into the underlying database in the form of key-value pairs includes:

[0015] The digest obtained by hashing the metadata related to the block is used as the key, and the block hash, the previous block hash, the root hash of the evidence transaction tree and the root hash of the state table of the evidence data block are serialized and encoded to generate data as the value, to obtain the key-value pair corresponding to the metadata related to the block;

[0016] The root hash obtained by hashing the Merkle root of the evidence transaction in the block header of the evidence data block is used as the key, and the data generated by serializing and encoding the evidence transaction hash, the evidence transaction type and the evidence transaction data of the evidence data block is used as the value to obtain a key-value pair corresponding to the metadata related to the evidence transaction;

[0017] The key-value pairs corresponding to the metadata related to the block and the key-value pairs corresponding to the metadata related to the evidence transaction are written into the underlying database.

[0018] Optionally, writing the state data corresponding to the evidence data block into the state database in the form of a key-value pair includes:

[0019] Generate a state object based on the state data, use a hash address corresponding to the state object as a key, and use the state object as a value to obtain a key-value pair corresponding to the state data;

[0020] The key-value pairs corresponding to the state data are written into the state database.

[0021] Optionally, the field structure of the evidence data block includes: a block size field and the size of the block size field, a block header field and the size of the block header field, an evidence transaction quantity field and the size of the evidence transaction quantity field, and an evidence transaction data list field and the size of the evidence transaction data list field.

[0022] Optionally, the field structure of the block header includes: a version number field and the size of the version number field, a previous block hash field and the size of the previous block hash field, a timestamp field and the size of the timestamp field, a difficulty target field and the size of the difficulty target field, a random number field and the size of the random number field, and a Merkle root field and the size of the Merkle root field.

[0023] Optionally, the field structure of the block body includes: a version number field and the size of the version number field, an input quantity field and the size of the input quantity field, an input field and the size of the input field, an output quantity field and the size of the output quantity field, an output field and the size of the output field, and a storage time field and the size of the storage time field.

[0024] In a second aspect, the present application provides a data storage device, comprising:

[0025] An acquisition module is used to acquire a stored evidence data set, wherein the stored evidence data set includes the academic qualification data file to be stored and the stored evidence information corresponding to the academic qualification data file;

[0026] A generation module, used to generate a block header and a block body based on the evidence data set;

[0027] A combination module, used to combine the block header and the block body to generate a proof data block;

[0028] A writing module, used to write the data of the evidence data block into the dat file of the blockchain node, write the block corresponding to the evidence data block and metadata related to the evidence transaction into the underlying database in the form of key-value pairs, and write the status data corresponding to the evidence data block into the status database in the form of key-value pairs;

[0029] Among them, the metadata related to the block and the evidence transaction is generated when the data of the evidence data block is written into the dat file, and the status data is the status data obtained by executing the evidence transaction in the evidence data block.

[0030] In a third aspect, the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0031] Memory, used to store computer programs;

[0032] The processor is used to implement any data storage method described in the first aspect when executing a program stored in the memory.

[0033] In a fourth aspect, the present application provides a computer-readable storage medium, on which a program of a data storage method is stored, and when the program of the data storage method is executed by a processor, the steps of any of the data storage methods described in the first aspect are implemented.

[0034] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:

[0035] The embodiment of the present invention first obtains a storage data set, wherein the storage data set includes the academic qualification data file to be stored and the storage information corresponding to the academic qualification data file, then generates a block header and a block body based on the storage data set, and then combines the block header and the block body to finally generate a storage data block, writes the data of the storage data block into the dat file of the blockchain node, writes the block corresponding to the storage data block and the metadata related to the storage transaction into the underlying database in the form of a key-value pair, and writes the status data corresponding to the storage data block into the status database in the form of a key-value pair.

[0036] The embodiments of the present invention can generate a storage data block based on the academic data file to be stored and the storage information, write the data of the storage data block into the blockchain node, write the metadata related to the block and the storage transaction into the underlying database, and write the status data into the status database, so as to realize the decentralized storage of the academic data file and the storage information and improve the security of the data; in addition, the metadata and status data related to the block and the storage transaction are stored in the form of key-value pairs, which can facilitate the rapid retrieval and improve the retrieval efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] 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.

[0038] 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.

[0039] Figure 1 An architectural diagram of a data storage method application provided in an embodiment of the present application;

[0040] Figure 2 A flowchart of a data storage method provided in an embodiment of the present application;

[0041] Figure 3 A schematic diagram of a data storage model provided in an embodiment of the present application;

[0042] Figure 4 A schematic diagram of storing status data provided in an embodiment of the present application;

[0043] Figure 5 A structural diagram of a data storage device provided in an embodiment of the present application;

[0044] Figure 6 A schematic diagram of a data storage method in a practical application provided by an embodiment of the present application;

[0045] Figure 7 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, 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 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 making creative work are within the scope of protection of this application.

[0047] Since the existing academic data notarization management system uses a centralized data storage method to organize and store academic data, a single point failure of the centralized server or a malicious attack will inevitably lead to academic data tampering or leakage, and the security of data storage is relatively low.

[0048] To this end, in view of the large number of files that need to be stored in the academic management work of colleges and universities, this method is aimed at the academic data storage scenario. The embodiment of the present invention provides a data storage method, device, electronic device and storage medium, which comprehensively uses core technologies such as block data storage, encryption algorithm and consensus algorithm, and studies the specific architecture and key technologies of the blockchain electronic evidence platform from the storage layer, network layer, consensus layer and application layer of the system structure. To achieve real-time, efficient and secure storage of academic evidence data, to ensure the security and effectiveness of academic electronic evidence data, the technical processing architecture adopted is as follows: Figure 1 This architecture uses the characteristics of the underlying blockchain model in terms of privacy protection, tamper resistance, and anti-attack, and technically realizes the authenticity, uniqueness, and integrity of the electronic data of academic qualifications stored in the blockchain.

[0049] like Figure 2 As shown, the data storage method comprises the following steps:

[0050] Step S101, obtaining a stored evidence data set, wherein the stored evidence data set includes the academic degree data file to be stored and the stored evidence information corresponding to the academic degree data file;

[0051] In an embodiment of the present invention, academic data files may include: transcripts, degree certificates, scientific research papers, grade certificates, award certificates and personal resumes, etc.; evidence information may include: identity information and data evidence transaction information, etc.; among which, identity information includes: name, student ID, ID number and telephone number, etc.; data evidence transaction information includes: user unique identity identification, record creation time, record update time and generation of evidence certificate, etc.

[0052] Before this step, the academic data file and evidence information uploaded by the user can be obtained, and the evidence data set can be constructed based on the academic data file and evidence information.

[0053] The academic data file can be an electronic file in various formats such as Word, PDF, or images; or, the user can perform hash calculation on the electronic file to be stored as evidence.

[0054] After the user uploads the academic data file and evidence information, the user's private key can be used to encrypt the academic data file and evidence information to verify whether the content of the evidence file has been tampered with and ensure the consistency of the user's identity and the evidence content. The encrypted academic data file and evidence information can then be signed using the evidence private key, and an evidence data set can be generated based on the signed academic data file and evidence information.

[0055] The user private key may refer to the one set by the evidence user (such as a student or school) or randomly generated for the evidence user, and is only known to the evidence user or the designated person of the evidence user; the evidence private key may refer to the one set by the evidence institution or randomly generated for the evidence institution, and is only known to the designated person in the evidence institution.

[0056] The encrypted academic data file and evidence information are privately signed using the private key of the evidence storage institution. In this way, each time the system issues and queries a digital certificate, it will trigger the corresponding signature verification in the smart contract. If the verification passes, the digital certificate will be output and issued to the evidence collecting party.

[0057] Step S102, generating a block header and a block body based on the evidence data set;

[0058] In the embodiment of the present invention, the block header may be generated according to a preset field structure of the block header, and the block body may be generated according to a preset field structure of the block body.

[0059] The field structure of the block header includes: a version number field and the size of the version number field, a previous block hash field and the size of the previous block hash field, a timestamp field and the size of the timestamp field, a difficulty target field and the size of the difficulty target field, a random number field and the size of the random number field, and a Merkle root field and the size of the Merkle root field.

[0060] Specifically, the block header can be constructed through the 6 fields (version + 5 metadata items) described in Table 2. The previous block hash is the core field used to link data blocks into chains. This field refers to the data summary obtained by performing SHA256 operation on the previous block linked to this block. It is connected with other fields to find a random number that meets the conditional target value after double hash calculation. After the calculation is completed, it can be constructed into a block.

[0061] Table 1 Block header field structure

[0062]

[0063] In an embodiment of the present invention, a difficulty target field and a random number field are added to the block header field structure. The difficulty target field may refer to the difficulty of generating the block. The higher the difficulty, the slower the block generation speed and the longer the time required to generate the block.

[0064] The field structure of the block body includes: a version number field and the size of the version number field, an input quantity field and the size of the input quantity field, an input field and the size of the input field, an output quantity field and the size of the output quantity field, an output field and the size of the output field, and a storage time field and the size of the storage time field.

[0065] The block body contains: a list of evidence-based evidence transaction data. A data evidence stored by an evidence-based user is a data structure containing input values ​​and output values, namely, a list of evidence-based evidence transaction data. The purpose of the code information written in this data structure is to transfer a set of evidence data of the evidence-based user from the initial point to the target address in the block. The lock time of a data evidence is set to 0, indicating immediate execution, that is, the set of evidence data is not included in the current block before the specified evidence time. The field structure of the evidence transaction data list is shown in Table 2.

[0066] Table 2 Evidence data field structure

[0067] Fields describe Size (bytes) Version Clarify the rules for one-time evidence reference 4 Input quantity Number of inputs included 1-9 enter One or more evidence inputs indefinite Output quantity Number of outputs included 1-9 Output One or more evidence outputs indefinite Evidence storage time A UNIX timestamp 4

[0068] Step S103, combining the block header and the block body to generate a proof data block;

[0069] The field structure of the evidence data block includes: a block size field and the size of the block size field, a block header field and the size of the block header field, an evidence transaction quantity field and the size of the evidence transaction quantity field, and an evidence transaction data list field and the size of the evidence transaction data list field.

[0070] In an embodiment of the present invention, the block structure field settings of the generated block are as shown in Table 3-1, which are composed of the block size, the evidence transaction counter, the block header containing metadata, and all the evidence data that subsequently constitute the block body, wherein the block header is composed of 5 metadata items, and the block body stores a complete list of evidence transaction data composed according to a specific data model, and then the data list is stored in groups.

[0071] Table 3 Block field structure

[0072]

[0073]

[0074] In an embodiment of the present invention, field size constraints and a counter for the number of evidence transactions are added to the block field structure, which can facilitate faster reading of data according to the field size; adding a counter for the number of evidence transactions can facilitate understanding of the number of evidence transactions, and further facilitate connecting the progress of the evidence transactions.

[0075] Step S104, writing the data of the evidence data block into the dat file of the blockchain node, writing the block corresponding to the evidence data block and metadata related to the evidence transaction into the underlying database in the form of key-value pairs, and writing the status data corresponding to the evidence data block into the status database in the form of key-value pairs;

[0076] Among them, the metadata related to the block and the evidence transaction is generated when the data of the evidence data block is written into the dat file, and the status data is the status data obtained by executing the evidence transaction in the evidence data block.

[0077] After step S104, the embodiment of the present invention further performs a hash operation on the evidence data block, and links the hashed evidence data block to the previous block to form a blockchain.

[0078] In order to ensure that academic record data cannot be tampered with, the embodiment of the present invention adopts a chain data structure, which aggregates all record data in the current time period with blocks as storage units. Any two adjacent blocks are linked into a chain in chronological order after SHA256 hash calculation.

[0079] The embodiment of the present invention first obtains a storage data set, wherein the storage data set includes the academic qualification data file to be stored and the storage information corresponding to the academic qualification data file, then generates a block header and a block body based on the storage data set, and then combines the block header and the block body to finally generate a storage data block, writes the data of the storage data block into the dat file of the blockchain node, writes the block corresponding to the storage data block and the metadata related to the storage transaction into the underlying database in the form of a key-value pair, and writes the status data corresponding to the storage data block into the status database in the form of a key-value pair.

[0080] The embodiment of the present invention can generate a storage data block based on the academic data file to be stored and the storage information, write the data of the storage data block into the blockchain node, write the metadata related to the block and the storage transaction into the underlying database, and write the status data into the status database, so as to realize the decentralized storage of the academic data file and the storage information and improve the security of the data; in addition, the metadata and status data related to the block and the storage transaction are stored in the form of key-value pairs, which can facilitate the rapid retrieval and improve the retrieval efficiency. Moreover, since the academic data file and the storage information are stored using blockchain technology, the transparency of the academic data storage management can be enhanced, the consistency of the academic data storage can be improved, and the advantages of blockchain technology in trustlessness and non-tamperability can be used to provide a safe and reliable storage environment for the electronic storage data of academic qualifications, enhance the mutual trust mechanism of nodes in the whole network, and ensure the consistency of data in the electronic storage network.

[0081] In the system design, all data related to evidence storage transactions and evidence storage are linked and stored on the blockchain in the form of blocks.<key,value> The key-value pairs are stored in the underlying database (LevelDB); the status of all evidence transactions or evidence results is represented by accounts, each account is represented by a state object (StateObject), and the state database (StateDB) is used to manage the collection of stored accounts. The hierarchical relationship between the above data structure units is described as follows Figure 3 In another embodiment of the present invention, the step of writing the data of the evidence data block into the dat file of the blockchain node includes:

[0082] Serialize and encode the data in the evidence data block to obtain bytecode, and write the bytecode into a dat file;

[0083] Among them, in the process of writing bytecode into the dat file, if the sum of the data currently being written into the dat file and the data already written into the dat file is greater than the preset storage capacity of the dat file, a new dat file is generated and the data currently being written is written into the new dat file.

[0084] In the embodiment of the present invention, in order to quickly retrieve block data, the data of each block and the evidence transaction data file in the block will be serialized and encoded into bytecode and written into the dat file. For example, the size of each dat file is preset to 128M. During the serialization process, when it is detected that the sum of the file being written and the block data file that has been written is greater than 128M, a new dat file will be generated.

[0085] In another embodiment of the present invention, writing the block corresponding to the evidence data block and metadata related to the evidence transaction into the underlying database in the form of key-value pairs includes:

[0086] The digest obtained by hashing the metadata related to the block is used as the key, and the block hash, the previous block hash, the root hash of the evidence transaction tree and the root hash of the state table of the evidence data block are serialized and encoded to generate data as the value, to obtain the key-value pair corresponding to the metadata related to the block;

[0087] The root hash obtained by hashing the Merkle root of the evidence transaction in the block header of the evidence data block is used as the key, and the data generated by serializing and encoding the evidence transaction hash, the evidence transaction type and the evidence transaction data of the evidence data block is used as the value to obtain a key-value pair corresponding to the metadata related to the evidence transaction;

[0088] The key-value pairs corresponding to the metadata related to the block and the key-value pairs corresponding to the metadata related to the evidence transaction are written into the underlying database.

[0089] In the embodiment of the present invention, metadata related to blocks and evidence transactions will be generated during the writing process of block data. The storage format of the metadata of a single evidence in the LevelDB database is shown in Table 4.

[0090] Table 4 Data storage method

[0091]

[0092] When storing block information, the digest obtained by SHA256 calculation of the block data is first used as the key, and the data items such as the block hash, previous block hash, evidence transaction tree root hash, state table root hash, etc. use the serialized data as the value, and then as<key,value> The key-value pairs are stored in the LevelDB database.

[0093] The specific way to store evidence transaction information is to use the Merkle root hash of the evidence transaction in the block header as the key, and the serialized data such as the evidence transaction hash, evidence transaction type, and evidence transaction data as the value, and store them in the LevelDB database. The serialization operation involved uses the binary serialization standard. When querying block data, the application layer only needs to provide the evidence transaction hash, block height, and hash value to obtain the key value, so as to query the relevant evidence data.

[0094] In another embodiment of the present invention, writing the state data corresponding to the evidence data block into the state database in the form of a key-value pair includes:

[0095] Generate a state object based on the state data, use a hash address corresponding to the state object as a key, and use the state object as a value to obtain a key-value pair corresponding to the state data;

[0096] The key-value pairs corresponding to the state data are written into the state database.

[0097] In the embodiment of the present invention, the state data records the result of the execution of the evidence transaction. The account state data includes the account address and its mapped ordinal, storage content and bytecode hash value, representing the state after accessing the block. The system can read the encoded account state information based on the state root hash. In the system design, Figure 4 As shown in the state data storage diagram, the state database (StateDB) manages all account state information by collecting a large number of state objects (stateObject). Each state object (stateObject) is stored with its 20-bit hash address as the key to insert into the node. When a state object (stateObject) is changed, that is, when the account information changes, the state object (stateObject) will be updated and marked. If the previously stored evidence data changes, the impact on the business module can be greatly reduced.

[0098] In another embodiment of the present invention, a data storage device is also provided. Figure 5 As shown, including:

[0099] The acquisition module 11 is used to acquire a stored evidence data set, wherein the stored evidence data set includes the academic degree data file to be stored and the stored evidence information corresponding to the academic degree data file;

[0100] A generation module 12, used to generate a block header and a block body based on the evidence data set;

[0101] A combination module 13, used to combine the block header and the block body to generate a storage data block;

[0102] A writing module 14 is used to write the data of the evidence data block into the dat file of the blockchain node, write the block corresponding to the evidence data block and metadata related to the evidence transaction into the underlying database in the form of key-value pairs, and write the status data corresponding to the evidence data block into the status database in the form of key-value pairs;

[0103] Among them, the metadata related to the block and the evidence transaction is generated when the data of the evidence data block is written into the dat file, and the status data is the status data obtained by executing the evidence transaction in the evidence data block.

[0104] For ease of understanding, the present invention also provides an embodiment of a data storage method in practical applications. The embodiment is based on a fault-tolerant evidence block consensus protocol, and uses a verifiable digital signature algorithm to verify the signature of the evidence file to complete data synchronization and confirm the generation of a unique evidence storage blockchain. Figure 6 As shown, it includes the following 4 specific steps.

[0105] (1) Hash operation: After the student’s basic identity information, transcripts, research papers, degree certificates and other evidence data are hashed, a unique feature summary of a fixed length is generated, so that users can access the original encrypted data through the feature summary. The summary has the following characteristics: ① The content of the original data cannot be deduced; ② If the original data is changed in any way, the regenerated “summary” is unpredictable.

[0106] (2) Digital Signature: Using a verifiable ring signature algorithm, the depository signs the data with a private key and sends it to the blockchain network for identity authentication. The purpose is to clarify the correctness of the data and the security of its source, and to ensure that the data cannot be tampered with during network transmission.

[0107] (3) Writing to the blockchain: The evidence data sent to the blockchain network is packaged into blocks after a consensus, and is linked to the previous block through SHA256 calculation to form a blockchain. It is then synchronized to each node in the network for verification. After verification, it is distributed and stored in each node.

[0108] (4) Evidence storage / retrieval: Complete the evidence storage for the data that the user needs to store. When the user needs to provide evidence proof, the system will provide an authoritative proof report to facilitate the evidence storage party to manage and use the stored data.

[0109] In another embodiment of the present invention, there is also provided an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0110] Memory, used to store computer programs;

[0111] The processor is used to implement the data storage method described in any of the aforementioned method embodiments when executing the program stored in the memory.

[0112] In the electronic device provided by the embodiment of the present invention, the processor executes the program stored in the memory by first acquiring a storage data set, wherein the storage data set includes the academic qualification data file to be stored and the storage information corresponding to the academic qualification data file, and then generates a block header and a block body based on the storage data set, and then combines the block header and the block body, and finally generates a storage data block, writes the data of the storage data block into the dat file of the blockchain node, writes the block corresponding to the storage data block and the metadata related to the storage transaction into the underlying database in the form of a key-value pair, and writes the status data corresponding to the storage data block into the status database in the form of a key-value pair. The embodiments of the present invention can generate a storage data block based on the academic data file to be stored and the storage information, write the data of the storage data block into the blockchain node, write the metadata related to the block and the storage transaction into the underlying database, and write the status data into the status database, so as to realize the decentralized storage of the academic data file and the storage information and improve the security of the data; in addition, the metadata and status data related to the block and the storage transaction are stored in the form of key-value pairs, which can facilitate the rapid retrieval and improve the retrieval efficiency.

[0113] The communication bus 1140 mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus 1140 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0114] The communication interface 1120 is used for communication between the above electronic device and other devices.

[0115] The memory 1130 may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0116] The above-mentioned processor 1110 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.

[0117] In another embodiment of the present invention, a computer-readable storage medium is provided, on which a program of a data storage method is stored. When the program of the data storage method is executed by a processor, the steps of the data storage method described in any of the aforementioned method embodiments are implemented.

[0118] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0119] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A data storage method, It is characterized in that include: Obtaining a stored evidence data set, wherein the stored evidence data set includes the academic qualification data file to be stored and the stored evidence information corresponding to the academic qualification data file; Generate a block header and a block body based on the evidence data set; Combining the block header and the block body to generate a proof data block; Write the data of the evidence data block into the dat file of the blockchain node, write the block corresponding to the evidence data block and metadata related to the evidence transaction into the underlying database in the form of key-value pairs, and write the status data corresponding to the evidence data block into the status database in the form of key-value pairs; The metadata related to the block and the evidence transaction is generated when the data of the evidence data block is written into the dat file, and the status data is the status data obtained by executing the evidence transaction in the evidence data block; The step of writing the block corresponding to the evidence data block and metadata related to the evidence transaction into the underlying database in the form of key-value pairs includes: The digest obtained by hashing the metadata related to the block is used as the key, and the block hash, the previous block hash, the root hash of the evidence transaction tree and the root hash of the state table of the evidence data block are serialized and encoded to generate data as the value, to obtain the key-value pair corresponding to the metadata related to the block; The root hash obtained by hashing the Merkle root of the evidence transaction in the block header of the evidence data block is used as the key, and the data generated by serializing and encoding the evidence transaction hash, the evidence transaction type and the evidence transaction data of the evidence data block is used as the value to obtain a key-value pair corresponding to the metadata related to the evidence transaction; The key-value pairs corresponding to the metadata related to the block and the key-value pairs corresponding to the metadata related to the evidence transaction are written into the underlying database.

2. The data storage method according to claim 1, It is characterized in that The step of writing the data of the evidence data block into the dat file of the blockchain node includes: Serialize and encode the data in the evidence data block to obtain bytecode, and write the bytecode into a dat file; Among them, in the process of writing bytecode into the dat file, if the sum of the data currently being written into the dat file and the data already written into the dat file is greater than the preset storage capacity of the dat file, a new dat file is generated and the data currently being written is written into the new dat file.

3. The data storage method according to claim 1, It is characterized in that Writing the state data corresponding to the evidence data block into the state database in the form of a key-value pair includes: Generate a state object based on the state data, use a hash address corresponding to the state object as a key, and use the state object as a value to obtain a key-value pair corresponding to the state data; The key-value pairs corresponding to the state data are written into the state database.

4. The data storage method according to claim 1, It is characterized in that The field structure of the evidence data block includes: a block size field and the size of the block size field, a block header field and the size of the block header field, an evidence transaction quantity field and the size of the evidence transaction quantity field, an evidence transaction data list field and the size of the evidence transaction data list field.

5. The data storage method according to claim 1, It is characterized in that The field structure of the block header includes: a version number field and the size of the version number field, a previous block hash field and the size of the previous block hash field, a timestamp field and the size of the timestamp field, a difficulty target field and the size of the difficulty target field, a random number field and the size of the random number field, and a Merkle root field and the size of the Merkle root field.

6. The data storage method according to claim 1, It is characterized in that The field structure of the block body includes: a version number field and the size of the version number field, an input quantity field and the size of the input quantity field, an input field and the size of the input field, an output quantity field and the size of the output quantity field, an output field and the size of the output field, and a storage time field and the size of the storage time field.

7. A data storage device, It is characterized in that include: An acquisition module is used to acquire a stored evidence data set, wherein the stored evidence data set includes the academic qualification data file to be stored and the stored evidence information corresponding to the academic qualification data file; A generation module, used to generate a block header and a block body based on the evidence data set; A combination module, used to combine the block header and the block body to generate a proof data block; A writing module, used to write the data of the evidence data block into the dat file of the blockchain node, write the block corresponding to the evidence data block and metadata related to the evidence transaction into the underlying database in the form of key-value pairs, and write the status data corresponding to the evidence data block into the status database in the form of key-value pairs; The metadata related to the block and the evidence transaction is generated when the data of the evidence data block is written into the dat file, and the status data is the status data obtained by executing the evidence transaction in the evidence data block; The step of writing the block corresponding to the evidence data block and metadata related to the evidence transaction into the underlying database in the form of key-value pairs includes: The digest obtained by hashing the metadata related to the block is used as the key, and the block hash, the previous block hash, the root hash of the evidence transaction tree and the root hash of the state table of the evidence data block are serialized and encoded to generate data as the value, to obtain the key-value pair corresponding to the metadata related to the block; The root hash obtained by hashing the Merkle root of the evidence transaction in the block header of the evidence data block is used as the key, and the data generated by serializing and encoding the evidence transaction hash, the evidence transaction type and the evidence transaction data of the evidence data block is used as the value to obtain a key-value pair corresponding to the metadata related to the evidence transaction; The key-value pairs corresponding to the metadata related to the block and the key-value pairs corresponding to the metadata related to the evidence transaction are written into the underlying database.

8. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor is used to implement the data storage method according to any one of claims 1 to 6 when executing a program stored in a memory.

9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a program of the data storage method, and when the program of the data storage method is executed by the processor, the steps of the data storage method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Data storage method, data rollback method, equipment and storage medium

    CN109933592A

  • Unmanned driving information storage method and device based on blockchain evidence storage

    CN110830547A