Disclosure of Invention
The purpose of the present disclosure is to provide a block chain link point data storage method, a block chain system and a block chain node which are safe and reduce data redundancy.
In order to achieve the above object, according to a first aspect of the present disclosure, there is provided a block link point data storage method applied to a block chain node group, where the block link point group includes M block chain nodes and N storage modules for storing a block chain, N being a positive integer smaller than M and M being a positive integer greater than 2, the method including:
determining a block to be written according to a block writing request received by each block chain node;
and respectively storing the blocks to be written into each storage module.
Optionally, the determining, according to the block write request received by each block link node, a block to be written includes:
if each block link node in the block link node group receives a unique block write request for requesting to write a first block, taking the first block as the block to be written;
and if each block link node in the block link node group receives a plurality of block write requests for requesting to write a second block and the data in each second block are consistent, taking the second block as the block to be written.
Optionally, the M block link points are connected with the N memory modules through an IO controller;
the storing the block to be written into each storage module respectively comprises:
generating copy blocks of the blocks to be written in through the IO controller, wherein the number of the copy blocks is consistent with the number of the storage modules which are connected with the IO controller currently;
and storing the copy blocks into each storage module connected with the IO controller one by one.
Optionally, the method further comprises:
when any block chain node in the block chain node group receives a data reading instruction, determining a target storage module according to the load of each storage module;
and establishing a data reading channel between the block chain node and the target storage module so that the block chain node reads data from the target storage module according to the data reading instruction.
According to a second aspect of the present disclosure, there is provided a blockchain system comprising:
the block chain node group comprises M block chain nodes and N storage modules for storing the block chain, wherein N is a positive integer smaller than M, and M is a positive integer larger than 2;
and the block chain node group is used for determining a block to be written according to a block writing request received by each block chain node, and respectively storing the block to be written into each storage module.
Optionally, the M block link points are connected with the N memory modules through an IO controller;
the IO controller is configured to, if each block link point in the block link node group receives a unique block write request for requesting writing to a first block, take the first block as the block to be written; and if each block link node in the block link node group receives a plurality of block write requests for requesting to write a second block and the data in each second block are consistent, taking the second block as the block to be written.
Optionally, the M block link points are connected with the N memory modules through an IO controller;
the IO controller is used for generating copy blocks of the blocks to be written, wherein the number of the copy blocks is consistent with the number of the storage modules which are connected with the IO controller currently; and storing the copy blocks into each storage module connected with the IO controller one by one.
Optionally, the M block link points are connected with the N memory modules through an IO controller;
the IO controller is used for determining a target storage module according to the load of each storage module when any block chain node in the block chain node group receives a data reading instruction; and establishing a data reading channel between the block chain node and the target storage module so that the block chain node reads data from the target storage module according to the data reading instruction.
Optionally, the block chain node group is composed of block chain link points belonging to the same mechanism.
According to a third aspect of the present disclosure, there is provided a blockchain node, which is any blockchain node in the blockchain node group in any of the blockchain systems of the second aspect.
In the above technical solution, the computing capability and the storage capability of the block chain node are decoupled, and the number of the storage modules in the block chain link point group is less than the number of the block chain nodes, so that a plurality of block chain nodes can share the storage module. Therefore, when each block link receives a block writing request, the block to be written is stored in the storage module, so that the storage module can store the full amount of data. By the technical scheme, the integrity and the reliability of block chain storage can be ensured, data redundancy can be effectively reduced, and storage resources can be saved. In addition, the performance requirements on the block link points can be reduced in the block link, and new block link points can be expanded on the basis of the corresponding storage modules of the block link point group without increasing new storage resources, so that the expansion of the block link nodes is facilitated and the computing power of the block link node group is improved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
Blockchain nodes, typically refer to computers that download the relevant cryptocurrency (bitcoin, Ethereum, Monero, etc.) software to participate in the peer-to-peer network. In addition, in the blockchain network, not all nodes participate in mining, and some nodes may only have functions of querying and issuing transactions. The nodes involved in mining are referred to as miner nodes, and all the block link nodes described below are miner nodes.
The disclosure provides a block link point data storage method, which is applied to a block link node group, wherein the block link node group comprises M block link nodes and N storage modules for storing block links, N is a positive integer smaller than M, and M is a positive integer larger than 2.
As described in the background, existing blockchain nodes require a large amount of computation and require a full amount of blockchain, which can present a large amount of data redundancy. Based on this, the computing power and the storage power of the block chain nodes are decoupled in the present disclosure, that is, the block chain link points described in the present disclosure may only include the computing power, so that mining may be performed without a need to store a block chain. Of course, some of the block link points in this disclosure may include both computing power and memory modules to store the block chain. The storage module may be an independent storage module or a local storage module of a certain blockchain node.
Fig. 1 is a flowchart of a block link point data storage method according to an embodiment of the present disclosure, and as shown in fig. 1, the method includes:
in S11, the block to be written is determined according to the block write request received by each block link node.
Wherein a certain number of block link points are interconnected by a p2p network to form a basic network of block chains. In order to find out who has stronger computing power, the system can generate a mathematical question every time, and only a computer which solves the question most quickly can carry out accounting. When any blockchain node in the blockchain network obtains the accounting right and creates a block, the blockchain node broadcasts in the network to inform other blockchain nodes, the other blockchain nodes verify the accounting validity of the blockchain nodes, and after the block is verified and determined to be legal, the block can be stored and synchronized.
Illustratively, a broadcast message sent by a block link node of a block is created, and each block link node in a block link node group receives the broadcast message, analyzes and verifies the broadcast message to obtain a block write request, so as to determine a block to be written corresponding to the block write request. For example, a block chain is a chain data structure formed by combining data blocks in a sequential manner, a block header stores header information of a block, including a reference of a previous block, a hash value of a block of the block, a timestamp, and the like, and the block to be written can be determined based on the block header.
In S12, the blocks to be written are stored in each memory module, respectively.
In the above technical solution, the computing capability and the storage capability of the block chain node are decoupled, and the number of the storage modules in the block chain link point group is less than the number of the block chain nodes, so that a plurality of block chain nodes can share the storage module. Therefore, when each block link receives a block writing request, the block to be written is stored in the storage module, so that the storage module can store the full amount of data. By the technical scheme, the integrity and the reliability of block chain storage can be ensured, data redundancy can be effectively reduced, and storage resources can be saved. In addition, the performance requirements on the block link points can be reduced in the block link, and new block link points can be expanded on the basis of the corresponding storage modules of the block link point group without increasing new storage resources, so that the expansion of the block link nodes is facilitated and the computing power of the block link node group is improved.
Optionally, an exemplary implementation manner of determining a block to be written according to a block write request received by each block link node is as follows, and this step may include:
and if each block link node in the block link node group receives a unique block write request for requesting to write a first block, taking the first block as the block to be written.
As shown in fig. 2, a schematic diagram of a blockchain node group is provided for an embodiment of the present disclosure, where a1, a2, A3 are respectively used to represent 3 blockchain nodes, and B1 and B2 are respectively used to represent 2 memory modules.
In one embodiment, when a block-linked point in the network broadcasts, it may be that due to network problems, the broadcast message is not necessarily received by each block-linked point in the set of block-linked points. For example, as described above, the block to be written may be determined according to the block header, for example, if a reference to the last block requested to be written to the block (i.e., the first block) in the block write request received by a1 is 03, and if only a1 in the block link point group receives a block write request for the first block (i.e., the next block to the block referenced to be 03), the first block may be directly used as the block to be written.
And if each block link node in the block link node group receives a plurality of block write requests for requesting to write a second block and the data in each second block are consistent, taking the second block as the block to be written.
Illustratively, the reference to the last chunk requested to be written to in the chunk write request received by a1 is 13, and the reference to the last chunk requested to be written to in the chunk write request received by a2 is 33. Since the block chain is a chain data structure formed by combining data blocks in a sequential connection manner, the requested write block in the block write requests received by a1 and a2 is the next block of the block referenced 13, which means that the requested write block in the block write requests of a1 and a2 is the same block (i.e. the second block), i.e. each block link point in the block chain node group receives a plurality of block write requests for requesting to write the second block.
When a block request for writing a second block to each user is received, the consistency of the written data needs to be ensured, and therefore, the data in the second block needs to be checked in this case. The block head comprises a Merkle tree, all transaction information in the block is summarized and summarized by the Merkle tree, and the efficiency of the block chain is greatly improved. Therefore, whether the Merkle trees in the second blocks respectively corresponding to a1 and a2 are the same or not can be checked, if so, the data in each second block are determined to be consistent, the second block is used as the block to be written, and if not, the block can be discarded because the data written in the same block are different, so as to avoid storing error data. In addition, the data can be synchronized with other stored block chain nodes to store the accurate data corresponding to the block into the storage module, so as to ensure the integrity of the data.
By the technical scheme, the consistency of data written by the plurality of block chain nodes can be ensured under the condition that the plurality of block chain nodes receive the block writing request requesting to be written into the same block, and meanwhile, the block writing request aiming at the same block can be deduplicated without synchronizing block data aiming at the block writing request received by each block chain node, so that the resource utilization rate is improved.
Optionally, the M block link points are connected with the N memory modules through an IO (Input/Output) controller (as shown in C in fig. 2);
an exemplary embodiment of storing the blocks to be written into each memory module respectively is as follows, which may include:
generating copy blocks of the blocks to be written in through the IO controller, wherein the number of the copy blocks is consistent with the number of the storage modules which are connected with the IO controller currently;
and storing the copy blocks into each storage module connected with the IO controller one by one.
In this embodiment, since the number of the storage modules is less than the number of the block chain nodes, when the block to which writing is performed is stored, the number of the generated copy blocks may be determined by the IO controller based on the number of the storage modules, so that the number of the copy blocks may be dynamically configured according to the number of the storage modules, which may ensure integrity of data stored in each storage module, and may effectively reduce data redundancy, and save storage space.
Optionally, the group of blockchain nodes is composed of blockchain link points belonging to the same mechanism, so that management of the blockchain nodes of the mechanism and expansion of computing capacity can be facilitated.
Optionally, the method further comprises:
and when any block chain node in the block chain node group receives a data reading instruction, determining a target storage module according to the load of each storage module.
When data needs to be read from a block link point, a data reading instruction can be sent to the block link point, and for any block link node in the block link node group, when the block link point receives the data reading instruction, a target storage block is determined from the N storage blocks of the block link point group.
For example, the target storage module may be determined according to the load of each storage module, for example, the current access amount of each storage module is obtained, and the storage module with the smallest access amount is determined as the target storage module. For another example, the current available bandwidth of each storage module may be obtained, and the storage module with the largest available bandwidth may be determined as the target storage module.
After the target storage module is determined, a data reading channel between the block link point and the target storage module is established, so that the block link point reads data from the target storage module according to the data reading instruction.
For example, establishing a data reading channel between the blockchain node and the target storage module may be controlling the blockchain node to access the target storage module, for example, the access may be performed based on an ID of the target storage module, so that the blockchain node may read data from the target storage module. As shown in FIG. 3, data read channel L1 between block chain node A1 and memory module B1, and data read channel L2 between block chain node A3 and memory module B2.
Alternatively, the validity time of the data read channel may be set. After the effective time is exceeded, when a data reading instruction is received at the block link point, the target storage module can be determined again through the load of each storage module, and therefore the data reading efficiency is guaranteed.
In the above technical scheme, when any block link point in the block link point group receives a data reading instruction, the memory module accessed by the block link point can be determined according to the load of the memory module, so that the load balance of the memory module is ensured, the read data bandwidth of each memory module can be fully utilized, and the concurrent data reading performance and the data reading efficiency are improved.
The present disclosure also provides a block chain system, comprising:
the block chain node group comprises M block chain nodes and N storage modules for storing the block chain, wherein N is a positive integer smaller than M, and M is a positive integer larger than 2;
and the block chain node group is used for determining a block to be written according to a block writing request received by each block chain node, and respectively storing the block to be written into each storage module.
Optionally, the M block link points are connected with the N memory modules through an IO controller;
the IO controller is configured to, if each block link point in the block link node group receives a unique block write request for requesting writing to a first block, take the first block as the block to be written; and if each block link node in the block link node group receives a plurality of block write requests for requesting to write a second block and the data in each second block are consistent, taking the second block as the block to be written.
Optionally, the M block link points are connected with the N memory modules through an IO controller;
the IO controller is used for generating copy blocks of the blocks to be written, wherein the number of the copy blocks is consistent with the number of the storage modules which are connected with the IO controller currently; and storing the copy blocks into each storage module connected with the IO controller one by one.
Optionally, the M block link points are connected with the N memory modules through an IO controller;
the IO controller is used for determining a target storage module according to the load of each storage module when any block chain node in the block chain node group receives a data reading instruction; and establishing a data reading channel between the block chain node and the target storage module so that the block chain node reads data from the target storage module according to the data reading instruction.
Optionally, the block chain node group is composed of block chain link points belonging to the same mechanism.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
The present disclosure also provides a block chain node, where the block chain node is any one of the block chain node groups in the block chain system.
Optionally, the block link point may send the block write request to the IO controller when receiving the block write request, so as to generate, by the IO controller, copy blocks of the block to be written, and store the copy blocks in each storage module connected to the IO controller one by one.
Fig. 4 is a block diagram illustrating a block link point 700 according to an exemplary embodiment. As shown in fig. 4, the block link point 700 may include: a processor 701 and a memory 702. The block link node 700 may also include one or more of a multimedia component 703, an input/output (I/O) interface 704, and a communication component 705.
The processor 701 is configured to control the overall operation of the block link point 700 to complete all or part of the steps in the above-described block link point data storage method. Memory 702 is used to store various types of data to support operations at the tile link point 700, which may include, for example, instructions for any application or method operating on the tile link point 700, as well as application-related data such as contact data, messaging, pictures, audio, video, and so forth. The Memory 702 may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk, or optical disk. The multimedia components 703 may include screen and audio components. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 702 or transmitted through the communication component 705. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 704 provides an interface between the processor 701 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. Communication component 705 is used for wired or wireless communication between the block link point 700 and other devices. Wireless communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, which is not limited herein. The corresponding communication component 705 may thus include: Wi-Fi module, Bluetooth module, NFC module, etc.
In an exemplary embodiment, the block link points 700 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above-described block link point data storage method.
In another exemplary embodiment, there is also provided a computer readable storage medium comprising program instructions which, when executed by a processor, implement the steps of the above-described block-link data storage method. For example, the computer readable storage medium may be the memory 702 described above including program instructions that are executable by the processor 701 of the block link point 700 to perform the block link point data storage method described above.
Fig. 5 is a block diagram illustrating a block link point 1900 in accordance with an exemplary embodiment. For example, block link point 1900 may be provided as a server. Referring to fig. 5, block link point 1900 includes a processor 1922, which may be one or more in number, and a memory 1932 for storing computer programs executable by processor 1922. The computer program stored in memory 1932 may include one or more modules that each correspond to a set of instructions. Further, the processor 1922 may be configured to execute the computer program to perform the above-described block link data storage method.
Additionally, tile link point 1900 may further include a power component 1926 and a communication component 1950, the power component 1926 may be configured to perform power management of tile link point 1900, and the communication component 1950 may be configured to enable communication, e.g., wired or wireless communication, of tile link point 1900. In addition, the block link point 1900 may also include an input/output (I/O) interface 1958. Block chain node 1900 may operate based on an operating system stored in memory 1932, such as Windows Server, Mac OS XTM, UnixTM, Linux, etc.
In another exemplary embodiment, there is also provided a computer readable storage medium comprising program instructions which, when executed by a processor, implement the steps of the above-described block-link data storage method. For example, the computer readable storage medium may be the memory 1932 described above that includes program instructions that are executable by the processor 1922 of block-link points 1900 to perform the block-link point data storage methods described above.
In another exemplary embodiment, there is also provided a computer program product comprising a computer program executable by a programmable apparatus, the computer program having code portions for performing the block-link point data storage method described above when executed by the programmable apparatus.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that the various features described in the above embodiments may be combined in any suitable manner without departing from the scope of the invention. In order to avoid unnecessary repetition, various possible combinations will not be separately described in this disclosure.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.