A storage device and storage method for blockchain
By using in-memory databases and solid-state drive buffers in blockchain storage, and rationally managing data writing to mechanical hard drives, the problem of overlapping content in blockchain storage is solved, achieving efficient and scalable data storage and reducing costs. effect.
Patent Information
- Application Number
- CN202011576360.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-28
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2040-12-28
AI Technical Summary
Blockchain technology is prone to content duplication during data storage, which reduces the utilization of storage technology.
Adopt a storage device and storage method for blockchain, use the memory database and solid-state drive database as buffers, write to the mechanical hard drive database, merge the old and new data blocks, and write the old data blocks from the network disk after the preset time is reached Mechanical hard disk database, marking unsuccessfully written data blocks to avoid loss.
It optimizes storage allocation, enhances the scalability of data storage capacity, reduces storage costs, improves the accuracy and stability of data processing, reduces network bandwidth pressure, and improves the storage utilization of mechanical hard disks.
Smart Images

Figure CN112596682B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of information technology, and in particular to a storage device and a storage method for blockchain. Background Art
[0002] Blockchain is a term in the field of information technology. In essence, it is a shared database. The data or information stored in it has the characteristics of "unforgeable", "leaving traces throughout the process", "traceable", "open and transparent", and "collectively maintained". Based on these characteristics, blockchain technology has laid a solid "trust" foundation, created a reliable "cooperation" mechanism, and has broad application prospects.
[0003] Each node in a blockchain network needs to store consistent blockchain data separately. The application of storage methods using blockchain technology for data storage is becoming more and more widespread. At present, the data storage method using blockchain technology is prone to content duplication when storing data, which reduces the utilization rate of storage technology. Therefore, at this stage, the market is in urgent need of a blockchain storage device and storage method to solve the above problems. Summary of the invention
[0004] The purpose of the present invention is to propose a storage device and storage method for blockchain in order to solve the problem that the current data storage method using blockchain technology is prone to content duplication during data storage, thereby reducing the utilization rate of storage technology.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] A storage device for blockchain, comprising:
[0007] The acquisition module is used to acquire the newly written new data block and upload it;
[0008] In-memory database, used to cache new data blocks uploaded by the acquisition module;
[0009] A first writing module is used to write new data blocks cached in the memory database into the solid state disk database;
[0010] A first receiving device is used for the solid state disk database to receive a new data block in the list of data to be transferred out of the memory database;
[0011] SSD database, used for short-term storage of new data blocks transferred from the memory database;
[0012] A retrieval module, used for searching whether there is original data about the new data block in the solid state drive database;
[0013] A first uploading module, configured to merge the new data block with the original data when there is original data about the new data block in the solid state disk database, and directly save the new data block to the solid state disk database when there is no original data about the new data block in the solid state disk database;
[0014] The second uploading module is used to upload an equal amount of old data blocks in the solid-state hard disk database to the network disk, and when the old data blocks in the network disk reach the preset clearing time of the solid-state hard disk database, the old data blocks are directly uploaded to the mechanical hard disk database, and when the old data blocks in the network disk database do not reach the preset clearing time of the solid-state hard disk database, they are temporarily stored in the network disk until the preset time is reached and then written into the mechanical hard disk database;
[0015] The second writing module is used to write the old data blocks cleared from the fixed hard disk database from the network disk into the mechanical hard disk database;
[0016] The second receiving device is used for the mechanical hard disk database to receive the old data blocks cleared by the solid state hard disk database.
[0017] As a further description of the above technical solution:
[0018] The second writing module is used to: when the writing of the old data block into the mechanical hard disk database fails, update the identification bit and make a first mark on the writing of the old data block.
[0019] As a further description of the above technical solution:
[0020] The second uploading module is used to: search whether the mechanical hard disk database has the first mark, and when the first mark is present, determine that the original data of the old data exists in the mechanical hard disk database, and clear the mark.
[0021] A storage method for blockchain: comprising:
[0022] Step 1: First, obtain the data of a blockchain node in a target blockchain network, and store it in the memory database after being processed by the node data processing center;
[0023] Step 2: Write the new data block generated in the memory database into the solid state disk database;
[0024] Processing the received new data block to obtain processed data;
[0025] Search the SSD database;
[0026] Whether there is original data of the new data module;
[0027] If yes, the new data module is merged with the corresponding original data and stored in the corresponding data list of the solid state drive database;
[0028] If not, the new data module is directly stored in the data list corresponding to the solid state drive database;
[0029] Step 3, obtaining the old data blocks to be transferred out of the fixed hard disk database;
[0030] First upload the old data block to the network disk;
[0031] Determine whether the old data block has reached the preset time;
[0032] If so, write the data directly from the network disk to the mechanical hard disk database;
[0033] If not, it will be temporarily stored in the network disk until the preset time is reached and then written into the mechanical hard disk database.
[0034] As a further description of the above technical solution:
[0035] Get the data of a blockchain node in a target blockchain network, including:
[0036] A block published to the blockchain and status update data for updating the blockchain network status determined based on the block are obtained as blockchain data to be stored.
[0037] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:
[0038] 1. In the present invention, by using the memory database and the solid-state hard disk database as buffers for the new data blocks entered into the blockchain network, and finally writing the data into the mechanical hard disk database, the storage allocation can be optimized to a very high degree, which not only solves the problem that a single blockchain is subject to the hardware limitations of the disk and has an upper limit on capacity, but also enhances the scalability of data storage capacity, and also reduces the storage cost of data information to a high degree, while also ensuring the high efficiency of data processing, which is beneficial to reducing the pressure on network bandwidth.
[0039] 2. In the present invention, by marking the old data blocks that cannot be written into the mechanical hard disk database, when writing the old data again, it is necessary to first verify by retrieval whether there is the same data content about the mark in the mechanical hard disk database. This can effectively avoid data loss, thereby improving the accuracy and stability of data processing by the entire system and enhancing the user experience. At the same time, it can also avoid the existence of the same data content in the mechanical hard disk database, effectively ensuring the utilization rate of the storage capacity of the mechanical hard disk database. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 This is a flow chart of a solid state hard disk database storage method provided in Embodiment 1 of a storage device and storage method for blockchain proposed by the present invention;
[0041] Figure 2 This is a flow chart of a solid state hard disk database storage method provided in Embodiment 2 of a storage device and storage method for blockchain proposed by the present invention;
[0042] Figure 3 This is a module block diagram of a storage device and storage method for blockchain proposed by the present invention. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0044] See also Figure 1-3 The present invention provides a technical solution: a storage device for blockchain, comprising:
[0045] The acquisition module is used to acquire the newly written new data block and upload it;
[0046] In-memory database, used to cache new data blocks uploaded by the acquisition module;
[0047] A first writing module is used to write new data blocks cached in the memory database into the solid state disk database;
[0048] A first receiving device is used for the solid state disk database to receive a new data block in the list of data to be transferred out of the memory database;
[0049] SSD database, used for short-term storage of new data blocks transferred from the memory database;
[0050] A retrieval module, used for searching whether there is original data about the new data block in the solid state drive database;
[0051] A first uploading module, configured to merge the new data block with the original data when there is original data about the new data block in the solid state disk database, and directly save the new data block to the solid state disk database when there is no original data about the new data block in the solid state disk database;
[0052] The second uploading module is used to upload an equal amount of old data blocks in the solid-state hard disk database to the network disk, and when the old data blocks in the network disk reach the preset clearing time of the solid-state hard disk database, the old data blocks are directly uploaded to the mechanical hard disk database, and when the old data blocks in the network disk database do not reach the preset clearing time of the solid-state hard disk database, they are temporarily stored in the network disk until the preset time is reached and then written into the mechanical hard disk database;
[0053] The second writing module is used to write the old data blocks cleared from the fixed hard disk database into the mechanical hard disk database;
[0054] The second receiving device is used for the mechanical hard disk database to receive the old data blocks cleared by the solid state hard disk database.
[0055] Specifically, Figure 1 As shown, the second writing module is used to: when the writing of the old data block fails, update the identification bit and make a first mark on the writing of the old data block.
[0056] Specifically, Figure 1 As shown, the second uploading module is used to: search whether the mechanical hard disk database has the first mark, and when the first mark is present, determine whether the original data of the old data exists in the mechanical hard disk database, and clear the mark.
[0057] Specifically, Figure 3 As shown, the data of a certain blockchain node in a certain target blockchain network is obtained, processed by a node data processing center, and then stored in a memory database;
[0058] Write the new data blocks generated in the memory database into the solid state disk database;
[0059] Processing the received new data block to obtain processed data;
[0060] Search the SSD database;
[0061] Whether there is original data of the new data module;
[0062] If yes, the new data module is merged with the corresponding original data and stored in the corresponding data list of the solid state drive database;
[0063] If not, the new data module is directly stored in the data list corresponding to the solid state drive database;
[0064] Obtain old data blocks to be transferred out of the fixed hard disk database;
[0065] Write new data blocks to the SSD database and upload old data blocks to the network disk;
[0066] Determine whether the old data block has reached the preset time;
[0067] If so, write it directly into the mechanical hard disk database;
[0068] If not, it will be temporarily stored in the network disk until the preset time is reached and then written into the mechanical hard disk database.
[0069] Specifically, Figure 3 As shown, obtaining the blockchain data to be stored in the memory database includes:
[0070] A block published to the blockchain and status update data for updating the blockchain network status determined based on the block are obtained as blockchain data to be stored.
[0071] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A storage device for blockchain, It is characterized in that include: The acquisition module is used to acquire the newly written new data block and upload it; In-memory database, used to cache new data blocks uploaded by the acquisition module; A first writing module is used to write new data blocks cached in the memory database into the solid state disk database; A first receiving device is used for the solid state disk database to receive a new data block in the list of data to be transferred out of the memory database; The solid state disk database is used to store new data blocks transferred from the memory database in the short term; A retrieval module, used for searching whether there is original data about the new data block in the solid state drive database; A first uploading module, configured to merge the new data block with the original data when there is original data about the new data block in the solid state disk database, and directly save the new data block in the solid state disk database when there is no original data about the new data block in the solid state disk database; The second uploading module is used to upload an equal amount of old data blocks in the solid-state hard disk database to the network disk, and when the old data blocks in the network disk reach the preset clearing time of the solid-state hard disk database, the old data blocks are directly uploaded to the mechanical hard disk database, and when the old data blocks in the network disk do not reach the preset clearing time of the solid-state hard disk database, they are temporarily stored in the network disk until the preset time is reached and then written into the mechanical hard disk database; The second writing module is used to write the old data blocks cleared from the solid state drive database into the mechanical hard drive database from the network disk; The second receiving device is used for the mechanical hard disk database to receive the old data blocks cleared by the solid state hard disk database.
2. A blockchain storage device according to claim 1, It is characterized in that The second writing module is used to: when the writing of the old data block into the mechanical hard disk database fails, update the identification bit and make a first mark on the writing of the old data block.
3. A blockchain storage device according to claim 2, It is characterized in that The second uploading module is used to: search whether the mechanical hard disk database has the first mark, and when the first mark is present, determine that the original data of the old data exists in the mechanical hard disk database, and clear the mark.
4. A storage method for blockchain, It is characterized in that The method is implemented by the blockchain storage device described in any one of claims 1 to 3, and includes the following steps: Step 1: First, obtain the data of a blockchain node in a target blockchain network, and store it in the memory database after being processed by the node data processing center; Step 2: Write the new data block generated in the memory database into the solid state disk database; Processing the received new data block to obtain processed data; Search the SSD database to confirm whether the original data of the new data block exists; If yes, the new data block is merged with the corresponding original data and stored in the corresponding data list of the solid state drive database; If not, the new data block is directly stored in the data list corresponding to the solid state drive database; Step 3, obtaining the old data blocks to be transferred out of the solid state drive database; First upload the old data block to the network disk; Determine whether the old data block has reached the preset time; If so, write the data directly from the network disk to the mechanical hard disk database; If not, it will be temporarily stored in the network disk until the preset time is reached and then written into the mechanical hard disk database.
5. A blockchain storage method according to claim 4, It is characterized in that The obtaining of data of a blockchain node in a target blockchain network specifically includes: A block published to the blockchain and status update data for updating the blockchain network status determined based on the block are obtained as blockchain data to be stored.
