Disclosure of Invention
The invention provides a block chain data storage device and a rapid storage method thereof, which are used for solving the problems of large storage pressure, low data confirmation efficiency, poor timeliness and the like of the existing block chain technology.
In order to achieve the purpose, the invention adopts the technical scheme that:
a blockchain data storage device, comprising:
the block is arranged in each node of the block chain system and used for storing block chain information data and business data or transaction data storage address pointers;
the authentication module is connected with the block in a data connection mode;
the logic storage management module is connected with the authentication module in a data connection mode;
the logic storage module is used for storing business data or transaction data in the blockchain system;
all the logic storage management modules in the block chain system can interact data with each logic storage module in a data connection mode;
the authentication module is used for verifying the information of the logic storage module.
Further, the service data or transaction data storage address pointer stored in the block includes: the IP address and the data address of the logic storage module where the related service data or the transaction data of the block are located and the data content Hash value of the logic storage module.
Further, the logical storage management module is used for managing processes of generating or eliminating logical storage in the blockchain system node and data storage processes.
Furthermore, the logic storage module is virtualized from the storage space of each node of the blockchain system.
A fast storage method of a block chain data storage device comprises the following steps:
s1 initializing the block chain data storage device and generating a logic storage module;
s2, the logic storage management module dynamically manages the logic storage module in the running process of the block chain system;
s3, storing and processing the service data;
and S4, reading the service data.
Further, the processing procedure of step S1 includes the following steps:
s101 the blockchain data storage device is initialized along with deployment of a blockchain system, where the initialization mainly includes: a storage space for ensuring the normal operation of the block, the authentication module and the logic storage management module 30 is arranged on each node;
s102, generating an initialization logic storage module;
after the initialization processing in step S101, the logical storage management modules of m nodes in the blockchain system set up independent physical storage records from the physical storage of each node, and the logical storage modules are partitioned during initialization and stored physically.
Further, in step S2, the logic storage management module performs dynamic management on the logic storage module according to a principle that a node with a busy service participates in less storage and a storage space is open in competition, and the specific processing procedure includes the following steps:
recording initialization logic storage corresponding to m nodes in the blockchain system, wherein a logic storage management module of each node counts the times of initiating storage requests of the node in a storage period, when a service data or transaction data storage request occurs in the system, the logic storage management modules of all the nodes broadcast the service data or transaction data storage times requested by the node to other logic storage management modules in the blockchain system, the logic storage management module of the node currently initiating the request obtains a sequence by sequencing according to the service data or transaction data storage times requested by each node in the storage period from less to more, and the node before ranking) is taken as a logic storage module, wherein c represents the total number of the nodes before ranking; the logic storage management module of the node which initiates the request currently broadcasts the selected logic storage module to other logic storage management modules in the system, and the block chain system is used as the logic storage module of the current node service data for storing the service data or the transaction data; then entering the dynamic management process of the logic storage module of the next storage period;
the storage period refers to a time period from the time when a node initiates a service data or transaction data storage request to the time when the next node initiates the service data storage request.
Further, the processing procedure of step S3 includes the following steps:
when a node j initiates a data storage request, a logic storage management module of the node j screens out a logic storage module which meets the condition according to the step S2 to form a preselected storage module set for storing service or transaction data of the node j, and sends an IP address, a data address and a data content Hash value in the logic storage module which meets the condition to an authentication module, on one hand, the authentication module verifies the information of the preselected storage module set according to the received data content Hash value in the logic storage module 4, and sends the IP address, the data address and the data content Hash value of the verified logic storage module to a block, and the block stores the received IP address, the data address and the data content Hash value of the data storage module in the block to be a pointer of the service data or the transaction data storage address, broadcasting the pointer information of the service data or transaction data storage address to blocks of all nodes in a block chain system for storage; on the other hand, the information of the logical storage modules passing the verification is sent to the logical storage management module, the logical storage management module stores the service or transaction data into all the logical storage modules passing the verification, and each logical storage module in the c logical storage modules in the block chain system has a copy of the service data requested to be stored by the node j, so that the storage of the service data is completed once.
Further, the processing procedure of step S4 includes the following steps:
when a node w of a block chain system initiates a data reading request, the requested data is called target data, the node w firstly broadcasts the target data reading request to all blocks of the block chain system, all the blocks inquire a self service data or transaction data storage address pointer recording table, and after the inquired service data or transaction data storage address pointer recording is judged by a consensus mechanism, a consensus storage address pointer of the target data is obtained; the node w sends the consensus storage address pointer to an authentication module of the node w, after the authentication module of the node w receives the consensus storage address pointer, whether a record of the consensus storage address pointer exists is determined from a historical record, if the record of the consensus storage address pointer is not inquired in the historical record, the authentication is regarded as failed, and the data reading request process is terminated; if the authentication is passed, forwarding the consensus storage address pointer information to the logic storage management module, reading the service and transaction information data from all authenticated logic storage modules by the logic storage management module according to the address pointer, sending the read data to the authentication module, carrying out consensus judgment on the received data by the authentication module, and sending the consensus result data to the node w initiating the request.
Compared with the prior art, the embodiment of the invention at least has the following beneficial effects:
1. the device and the method can greatly compress the occupation of the traditional block chain system on the storage resource on the premise of ensuring the data safety and reliability, improve the service data confirmation efficiency, further greatly improve the timeliness, and promote the block chain technology to be widely applied in the environment with normal non-stability, such as a local area network or an internet of things.
2. The block in the block chain system is used for storing the block chain information data and the service data or transaction data storage address pointer, and the block does not directly store the service data or transaction data but replaces the service data or transaction data storage address pointer, so that the occupation of redundant data records on the storage resources of the block chain system is greatly reduced, and the storage pressure of the block chain system is reduced.
3. The invention adopts a preselected storage module set and an authentication module to verify the preselected storage module, thereby ensuring that data is stored to a high-quality node in the whole block chain system on the premise of ensuring safety and greatly reducing the communication delay loss; more importantly, in the process of joint accounting, the pointer of the storage address of the business or transaction data is recorded, so that the storage efficiency of the blockchain system is greatly improved.
Drawings
FIG. 1 is a block chain data storage device according to the present invention;
FIG. 2 is a comparison of a block data structure of a block chain data storage device according to the present invention with the prior art;
fig. 3 is a flow chart of a storage method of the block chain data storage device according to the present invention.
Detailed Description
For a better understanding of the present invention, reference will now be made in detail to the embodiments illustrated in the accompanying drawings.
Referring to fig. 1, a block chain data storage device according to the present invention includes the following components:
block 10, authentication module 20, logical storage management module 30, and logical storage module 40.
The block chain system is provided with n nodes, each node is provided with one or more blocks 10, each block 10 is connected with an authentication module 20 in a data connection mode, and each authentication module 20 is connected with a logic storage management module 30 in a data connection mode; the block chain data storage device is also provided with a plurality of logic storage modules 40, and the logic storage modules 40 are virtualized from the storage space of each node of the block chain system; all logical storage management modules 30 in the system may interact with each logical storage module 40 via a data connection.
The block 10 is used for storing block chain information data and a service data or transaction data storage address pointer. Referring to fig. 2 (a), the prior art block needs to store blockchain information data and service data or transaction data records, and unlike the prior art block, referring to fig. 2 (b), the block 10 of the present invention does not directly store service data or transaction data, but instead stores service data or transaction data storage address pointers, thereby greatly reducing the occupation of redundant data records on system storage resources.
The block chain information data stored in the block 10 includes: hash pointer of previous block, block relative timestamp, Hash pointer of target block, other block header information. The service data or transaction data storage address pointer stored in the block 10 includes: the IP address and the data address of the logic storage module 40 where the relevant service data of the block is located and the data content Hash value of the logic storage module 40. The calculation method of the Hash value includes, but is not limited to, Hash algorithms such as MD5, SHA1, SHA2, SHA3 and the like.
The block 10 has a data connection with an authentication module 20, and can exchange data.
The authentication module 20 is used for verifying the information of the logic storage module 40. The authentication module 20 and the logic storage management module 30 have data connection therebetween, and can exchange data.
The logical storage management module 30 is configured to manage a process of generating or eliminating logical storage in the blockchain system node and a data storage process. The logic storage management module 30 is connected with a logic storage module 40 through data connection;
the logic storage module 40 is used for storing business or transaction data in the blockchain system.
Based on the block chain data storage device, the invention also provides a fast storage method, and with reference to fig. 3, the specific processing steps include:
s1 initializing the block chain data storage device and generating a logic storage module;
s101, initializing the block chain data storage device along with the deployment of the block chain system, wherein the initialization mainly comprises the following steps:
a memory space for ensuring the normal operation of the block 10, the authentication module 20, and the logical memory management module 30 is allocated to each node. The mode of dividing the storage space can be equal capacity division or unequal capacity division. Therefore, the storage space of each node can be optimally utilized, normal operation of the node can be ensured, and efficient data storage of a block chain system can be ensured in a local application scene.
As an embodiment of the present invention, each node is configured with 1M storage space for normal operation of the block 10, the authentication module 20 and the logical storage management module 30 of the node.
S102, generating an initialization logic storage module;
after the initialization process of step S101, the block chain system has m nodes, and the logical
storage management module 30 of the m nodes marks out the independent physical storage from the physical storage of each node
Blocking and physical storage of
logical storage module 40 at initialization
。
S2 dynamic management of logic storage module;
the logic storage management module 30 dynamically manages the logic storage module 40 in the system operation process, and the management adopts the principle that nodes with busy service participate in less storage and the storage space competition is open, and the specific processing process is as follows:
noting m nodes in the blockchain system
The corresponding initialization logic is stored as
The logic storage management module 30 of each node counts the number of times that the node initiates a storage request in a storage period, each time a service data or transaction data storage request occurs in the system, the logic storage management modules 30 of all nodes broadcast the service data or transaction data storage number of times requested by the node to other logic storage management modules 30 in the blockchain system, and the logic storage management module 30 of the node currently initiating the request is sorted according to the number of times that the service data or transaction data requested by each node in the storage period is stored from small to large to obtain a sequence
Before the rank is taken
) As a logical memory module
Wherein c represents pre-ranking
The total number of nodes of (c); the logical storage management module 30 of the node currently originating the request will select the logical storage module
Broadcast to other logical storage management modules 30 in the system that will be the blockchain system
Logic storage module 40 as current node service data for service numberAccording to or transaction data storage usage; then entering the dynamic management process of the logic storage module 40 of the next storage period; the storage period refers to a time period from the time when a node initiates a service data or transaction data storage request to the time when the next node initiates the service data storage request. Therefore, for the block chain system with larger service fluctuation, smooth data throughput can be ensured, and the scene adaptability and the response capability of the system are greatly improved.
As an embodiment of the invention, there are m nodes in the blockchain system
According to step S1, the set of logical storage modules is initialized to
(ii) a The logical
storage management module 30 of each node counts the number of times that the node initiates a storage request in one storage period, in this embodiment, the logical
storage management module 30 of the node i sets a counter
,
Counting the times of service data storage requests initiated by the node i in the current storage period, and recording m nodes
The corresponding statistical number is
Ordering the nodes in ascending order to obtain a sequence
The top 60% (i.e. ranking) of the rank is taken
) Section (A) ofThe point obtains a logic storage module corresponding to the point
I.e. c = ⌈ 60% x m ⌉ (integer upward) or ⌊ 60% x m ⌋ (integer downward), c being the total number of nodes 60% before the rank, then
Is the set of logical storage modules participating in storage in the current storage cycle of the system. After determining the set of logical storage modules currently participating in storage, the counter in the logical
storage management module 30 of each node
And clearing and restarting the counting of the next storage period.
And S3, storing the service data.
When the node j initiates a data storage request, the logic storage management module 30 of the node j screens out the logic storage modules 40 meeting the conditions according to the step S2 to form a pre-selected storage module set for storing the service or transaction data of the node j
On one hand, the authentication module 20 verifies the information of the preselected storage module set according to the received data content Hash value in the logic storage module 40, and sends the IP address, the data address and the Hash value of the data content of the verified logic storage module 40 to the block 10, the block 10 stores the received IP address, the data address and the Hash value of the data content of the data storage module 40 into the block 10 to become a pointer of a service data or transaction data storage address, and broadcasts the pointer information of the service data or transaction data storage address into the blocks 10 of all nodes in the chain block system for storage; on the other hand, the information of the verified logic storage module 40 is sent to the logic storage tubeThe management module 30, the logic storage management module 30 stores the business or transaction data to all verified logic storage modules
In the block chain system, each logic storage module 40 in the c logic storage modules 40 has one copy of service data requested to be stored by the node j, thereby completing the storage of the service data once.
The preselection storage module set and the authentication module 20 are adopted to verify the preselection storage module, so that the data are guaranteed to be stored to high-quality nodes in the whole block chain system on the premise of guaranteeing safety, and the communication delay loss is greatly reduced. More importantly, in the process of joint accounting, the pointer of the storage address of the business data or the transaction data is recorded, so that the storage efficiency of the blockchain system is greatly improved.
And S4, reading the service data.
When a node w of a block chain system initiates a data reading request, the requested data is called target data, the node w firstly broadcasts the target data reading request to all blocks 10 of the block chain system, all the blocks 10 inquire own service data or transaction data storage address pointer record tables, and after the inquired service data or transaction data storage address pointer record is judged by a consensus mechanism, a consensus storage address pointer of the target data is obtained; the node w sends the consensus storage address pointer to the authentication module 20 of the node w, after receiving the consensus storage address pointer, the authentication module 20 of the node w confirms whether the record of the consensus storage address pointer exists in the history record, if the record of the consensus storage address pointer is not inquired in the history record, the authentication is regarded as failed, and the data reading request process is terminated; if the authentication is passed, the consensus storage address pointer information is forwarded to the logic storage management module 30, the logic storage management module 30 reads the service and transaction information data from all the authenticated logic storage modules 40 according to the address pointer, and sends the read data to the authentication module 20, the authentication module 20 performs consensus judgment on the received data, and sends the consensus result data to the node w which initiates the request. In the process of consensus, after the consensus storage address pointer is added and is subjected to consensus, the data is authenticated by the authentication module 20, and the data security is further enhanced.
The working principle of the block chain data storage device and the rapid storage method thereof is as follows:
firstly, each node of the block chain is divided into a storage space, so that a logical storage space which is physically independent and can be managed and controlled together logically is obtained. The logic storage management module 30 divides the logic storage space into a plurality of dynamically changing logic storage modules 40 according to the fast storage method of the present invention, and dynamically manages the logic storage modules 40, and the logic storage module 30 in each node can detect the state from the node to all the logic storage modules 40 in real time, so as to store the information related to the blocks in the node into the logic storage modules 40 meeting the conditions, or read the related business or transaction data from the logic storage modules 40 meeting the conditions.
When a certain node generates new service or transaction data, the logic storage management module 30 of the node screens out the logic storage module 40 meeting the condition according to the fast storage method of the invention, forms a preselected storage module set for storing the service or transaction data of the node, and sends the IP address, the data address and the Hash value of the data content in the logic storage module 40 meeting the condition to the authentication module 20, the authentication module 20 verifies the information of the preselected storage module set according to the fast storage method of the invention on one hand, and sends the IP address, the data address and the Hash value of the data content of the verified logic storage module 40 to the block 10, the block 10 stores the received IP address, the data address and the Hash value of the data content of the data storage module 40 into the block to be a pointer of the service or transaction data storage address, broadcasting the pointer information of the service or transaction data storage address to all blocks 10 in the block chain system for storage; on the other hand, the information of the verified logical storage module 40 is sent to the logical storage management module 30, and the logical storage management module 30 stores the business or transaction data in all the verified logical storage modules 40, so that one-time data storage is completed.
When a certain node of the blockchain system initiates a data reading request, the node firstly broadcasts the data reading request to all the blocks 10 of the blockchain system, and after all the blocks 10 are judged by a consensus mechanism, a storage address pointer of target data is obtained, wherein the consensus mechanism is judged to be the prior art and is not described herein. The node initiating the data reading request sends the consensus storage address pointer to the authentication module 20, after receiving the consensus storage address pointer, the authentication module 20 confirms whether a record of the consensus storage address pointer exists in a history record, after authentication, the consensus storage address pointer information is forwarded to the logic storage management module 30, the logic storage management module 30 reads service and transaction information data from all authenticated logic storage modules 40 according to the address and sends the read data to the authentication module 20, the authentication module 20 performs consensus judgment on the received data, and sends consensus result data to the node initiating the request.
As an embodiment of the present invention, assuming that the whole blockchain system has n nodes, when node a of the blockchain system initiates a data read request, node a broadcasts the data read request to other (n-1) blocks, so that n nodes in the whole blockchain system all obtain a message that node a needs to read service data. All nodes find the storage address pointers of the target service data from the blocks of the nodes, then judge the storage address pointers through a consensus mechanism, for example, the invention adopts a 51% principle, namely n nodes vote the storage address pointers of the target service data, and when the storage address pointers of the target service data in more than 51% multiplied by n nodes are consistent, the storage address pointers of the target service data are considered as final storage address pointers of the target data and are recorded as the final storage address pointers of the target data
. Node A will
Sending to the
authentication module 20 in the node a, the
authentication module 20 first searches from its history whether there is any one
If not, record(s)
If so, terminating the data reading request; if it is confirmed that there is
The record is authenticated and the
authentication module 20 will authenticate the record
Sending the data to a logic
storage management module 30, reading service and transaction information data from all authenticated
logic storage modules 40 by the logic
storage management module 30 according to addresses, if the number of the authenticated
logic storage modules 40 is m, reading m service and transaction information data by the logic
storage management module 30, sending the m data to an
authentication module 20, and performing consensus confirmation on the m data by the
authentication module 20, which is taken as an example, a principle of 51% is still used here, that is, when 51% x m data are consistent, the obtained consistent data is considered to be the consensus service and transaction information data, and sending the consensus service and transaction information data to a node initiating a request by the
authentication module 20, so that the node initiating the request can obtain the requested data.
In conclusion, the device and the method for storing the block chain data can greatly compress the occupation of the traditional block chain system on the storage resources and improve the service data confirmation efficiency on the premise of ensuring the data safety and reliability, thereby greatly improving the timeliness and promoting the block chain technology to be widely applied to very stable environments such as a local area network or an internet of things.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.