WO2018112805A1 - 区块链存储方法、装置及节点设备 - Google Patents

区块链存储方法、装置及节点设备 Download PDF

Info

Publication number
WO2018112805A1
WO2018112805A1 PCT/CN2016/111360 CN2016111360W WO2018112805A1 WO 2018112805 A1 WO2018112805 A1 WO 2018112805A1 CN 2016111360 W CN2016111360 W CN 2016111360W WO 2018112805 A1 WO2018112805 A1 WO 2018112805A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
block
cluster
stored
virtual cluster
Prior art date
Application number
PCT/CN2016/111360
Other languages
English (en)
French (fr)
Inventor
么文琦
张跃洋
Original Assignee
深圳前海达闼云端智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳前海达闼云端智能科技有限公司 filed Critical 深圳前海达闼云端智能科技有限公司
Priority to PCT/CN2016/111360 priority Critical patent/WO2018112805A1/zh
Priority to CN201680003223.0A priority patent/CN107079059B/zh
Publication of WO2018112805A1 publication Critical patent/WO2018112805A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1044Group management mechanisms 
    • H04L67/1046Joining mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1044Group management mechanisms 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Definitions

  • the present invention relates to the field of blockchain technology, and in particular, to a blockchain storage method, device and node device.
  • the blockchain network is based on a P2P (Peer to Peer) network, and each P2P network node participating in transactions, block storage, block verification or forwarding is a node in a blockchain network. Data exchange between nodes is verified by digital signature technology, without mutual trust. As long as the rules are established according to the system, nodes cannot and cannot deceive other nodes.
  • P2P Peer to Peer
  • the amount of data in the blockchain will increase as the number of blocks generated every ten minutes.
  • the size of the complete data of the Bitcoin blockchain has reached tens of GB. If users use the bitcoin core client for data synchronization, it may not be possible for several days and nights. The synchronization is complete.
  • the amount of data in the blockchain is constantly increasing, which brings a big threshold for the operation of the Bitcoin core client.
  • the ordinary users are not suitable to use the bitcoin core client, which also causes the running bit.
  • the number of full nodes is not increased or decreased, and in the past few years all nodes (that is, have a complete, up-to-date blockchain copy, can independently verify all transactions without borrowing There is a significant drop in the number of any external references).
  • the entire node stores the first block (creation block) up to the latest block in the network.
  • the blockchain becomes In order to truly decentralize the structure. But because of this, the space occupied by the entire node to save data is very large. Over time, such contradictions will become more prominent.
  • a new full node joins the network and needs to synchronize data with the peer nodes in the network. Such synchronization will become unstable due to network conditions, synchronization time is unpredictable, and a large amount of network bandwidth is required to complete synchronization. .
  • the present invention provides a blockchain storage method, apparatus, and node device.
  • the first aspect provides a blockchain storage method, which is applied to a node in a blockchain network, including:
  • One or more blocks in the blockchain are stored according to a preset first block allocation rule, so that the blocks stored by the nodes in the virtual cluster can form a complete blockchain.
  • a blockchain storage device for a node in a blockchain network, including:
  • the virtual cluster join module is configured to join a virtual cluster by accepting a cluster setup invitation or sending a cluster setup invitation, where the virtual cluster includes a preset number of nodes;
  • a block storage module configured to store one or more blocks in the blockchain according to a preset first block allocation rule, so that the blocks stored by the nodes in the virtual cluster may be composed Complete blockchain.
  • a node device including:
  • a memory for storing processor executable instructions
  • the processor is configured to join a virtual cluster by accepting a cluster setup invitation or sending a cluster setup invitation, where the virtual cluster includes a preset number of nodes; according to a preset first block allocation rule, One or more blocks in the blockchain are stored such that the blocks stored by the nodes in the virtual cluster can form a complete blockchain.
  • a computer program product comprising a computer program executable by a programmable device, the computer program having a method for performing the method described above when executed by the programmable device Code section.
  • a non-transitory computer readable storage medium comprising one or more programs for performing the method described above.
  • a node device comprising: the non-transitory computer readable storage medium described above; and one or more processors for executing a program in the non-transitory computer readable storage medium.
  • the blocks in the blockchain are redundantly stored in each node in the virtual cluster, thereby reducing the storage capacity of the node, and since each block is redundantly stored, the security of the storage can be ensured. Improve the synchronization speed of the block and improve the query efficiency.
  • FIG. 1 is a schematic structural diagram of a blockchain network according to an embodiment of the present invention.
  • FIG. 2 is a schematic flow chart of a blockchain storage method according to an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of a node joining a virtual cluster in a blockchain network according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram of storing and distributing blocks according to a block allocation rule according to an embodiment of the present invention
  • FIG. 5 is a schematic diagram of storing and distributing a block according to a block allocation rule according to another embodiment of the present invention.
  • FIG. 6 is a schematic diagram of storing and distributing a block according to a block allocation rule according to still another embodiment of the present invention.
  • FIG. 7 is a schematic diagram of a node in a virtual cluster confirming whether a node is online by maintaining a heartbeat according to an embodiment of the present invention
  • FIG. 8 is a schematic diagram of a new node in a virtual cluster according to an embodiment of the present invention.
  • FIG. 9 is a schematic diagram of a node in a virtual cluster storing a new block according to an embodiment of the present invention.
  • FIG. 10 is a schematic diagram of a node in a virtual cluster performing a transaction query according to an embodiment of the present invention.
  • FIG. 11 is a schematic diagram of a node execution contract in a virtual cluster in an embodiment of the present invention.
  • FIG. 12 is a schematic structural diagram of a blockchain storage device according to an embodiment of the present invention.
  • FIG. 13 is a block diagram of an apparatus for a blockchain storage method, according to an exemplary embodiment.
  • the embodiment of the present invention performs the storage processing of the blockchain by multiple nodes in a distributed storage manner, and blocks the entire block chain. Decentralized storage on each node.
  • FIG. 1 is a schematic structural diagram of a blockchain network according to an embodiment of the present invention.
  • the blockchain network 100 includes a plurality of nodes 101.
  • Each P2P network node participating in the transaction, block storage, block verification or forwarding can be used as a node in the blockchain.
  • the node 101 can be a smart phone, a tablet, a server, an electronic device with an embedded system, a mining machine (a device that can perform a PoW (Proof Of Work) consensus competition mechanism, and the like).
  • PoW Proof Of Work
  • All nodes in the blockchain network 100 are self-organized into several virtual clusters according to predetermined rules. At least two nodes in the blockchain network form a virtual cluster, and nodes in the virtual cluster store one or more blocks in the blockchain according to a preset block allocation rule, so that at least two The blocks stored by the nodes can form a complete blockchain.
  • each node can completely participate in other functions in the blockchain (for example, mining, wallet, etc.), but the storage blockchain is distributed, that is, one The blocks in the complete blockchain are redundantly stored in each node in the virtual cluster.
  • each node stores only a part of the blockchain, the storage capacity can be reduced, the speed of the node synchronization blockchain can be increased, the query efficiency can be improved, and the storage security can be ensured because each block is redundantly stored. Sex.
  • a blockchain storage method is applied to a node in a blockchain network, and includes the following steps:
  • a virtual cluster is joined by accepting a cluster formation invitation or sending a cluster formation invitation.
  • step 202 one or more blocks in the blockchain are stored according to a preset first block allocation rule.
  • the blocks stored by the nodes in the virtual cluster can form a complete blockchain.
  • FIG. 3 is a schematic flowchart of a node joining a virtual cluster in a blockchain network according to an embodiment of the present invention.
  • nodes in a blockchain network are isolated nodes when they are not joined to a virtual subnetwork (virtual cluster).
  • a node A Since the blockchain network is based on the P2P network protocol, a node A will be connected to multiple nodes after being uplinked and stable for a certain period of time in the blockchain network.
  • the node A When the node A is connected to the other node of the first preset number, the node A has the condition for establishing the virtual cluster, and can enter the node discovery state, accept the cluster formation invitation sent by other nodes, or connect to other connected nodes.
  • the node sends a cluster creation invitation to form a virtual cluster.
  • step 301 when node A is connected to the first predetermined number of other nodes, node A sends a cluster formation invitation to the other nodes.
  • the node A selects a first preset number of nodes from the m nodes according to the node status, and sends a cluster formation invitation thereto.
  • the status of the node includes whether a new block has been generated, the network status of the node, and the like. Since the new block can be used to measure the credibility of the node, whether a new block has been generated is the basis for considering the node. Whether a node has generated a new block can be obtained by querying the block in the blockchain. The network status of the node has an impact on the interaction between the nodes. Therefore, the network status of the node is also used as the basis for considering the node. Network status can be obtained by sending a test packet (for example, an empty packet or a ping packet).
  • a test packet for example, an empty packet or a ping packet
  • the cluster formation invitation may be a data packet containing specific information, for example, including the IP address of the node sending the invitation, the number of new blocks generated, the computing power, and the like.
  • step 302 when the node exceeding the second preset number replies with the confirmation information, the node with the reply information is grouped into a virtual cluster. After the virtual cluster is built, each node joins the virtual cluster.
  • a node may receive a cluster formation invitation sent by multiple nodes. Please, according to the information in the cluster formation invitation, determine the node to respond, and return response information to the determined node to determine to join the virtual cluster.
  • the size of the virtual cluster is also limited.
  • the number of nodes in the virtual cluster reaches a second preset number, the new one will no longer be accepted.
  • the node enters.
  • the reason for this is to avoid degrading the entire blockchain network into a virtual cluster.
  • the number of nodes in the virtual cluster meets certain conditions (that is, the second preset number is met), and the second preset is determined according to the network status, protocol, and the like. The number is adjusted (increase or decrease).
  • the cluster label (ID) of the virtual cluster is determined according to the first preset negotiation mechanism.
  • the cluster label is used to identify the virtual cluster.
  • the cluster label can be a string, which can include information such as the number of nodes in the cluster, the IP address of each node, and the node status of each node.
  • the cluster label is corresponding to the time. After the preset time expires, and the cluster ID is invalid after the preset time expires, the node in the virtual cluster is restored to the normal node (that is, the isolated node), and the cluster formation invitation can be accepted or sent. .
  • each node in the virtual cluster identifies itself to enter the virtual cluster state and no longer accepts to join the new virtual cluster. That is, if the node has joined a virtual cluster, it will no longer respond to the cluster formation request sent by other nodes.
  • determining the cluster label (Id) of the virtual cluster according to the first preset negotiation mechanism may be performed in the following manner:
  • Mode 1 The node whose ID is the ID is broadcasted to other nodes in the virtual cluster, and each node verifies the ID. After the verification passes, it is determined that the ID is the ID of the virtual cluster.
  • Method 2 The ID generated by the node with the strongest computing power can be used as the ID of the virtual cluster, or the ID generated by the node with the smallest IP address can be used as the ID of the virtual cluster according to the IP address.
  • the number of each node is determined by the second preset negotiation mechanism, whereby the block that the node needs to store is determined according to the number.
  • each node After determining the number of each node, each node determines and stores one or more blocks to be stored according to its own number and the hash value corresponding to each block in the blockchain.
  • the node divides the hash value corresponding to each block by a preset number of constants, and divides the remainder obtained by the division and its own number to meet preset conditions (for example, The block corresponding to the hash value of the remainder and the same number is stored.
  • the hash value corresponding to each block includes at least one of the following: a hash value of the block header of each block, a hash value of the block header of each block plus a fixed value, and each The block header of a block and the hash value of the block body.
  • the hash value of the block header of a block B may be divided by the first constant, the second constant, and the third constant, and the block B is stored in half according to the remainders m1, m2, and m3 obtained by dividing.
  • the hash value of the block header of the block B may be added to a fixed value, divided by the fourth preset constant, and then the block B is stored to the node numbered m4 according to the remainder m4.
  • each block is redundantly stored on multiple nodes according to the first block allocation rule (for example, P nodes, P ⁇ K, K is the total number of nodes in the virtual cluster, and the value of P can be According to the total number of nodes in the virtual cluster, for example, P is one-third of the total number of nodes in the virtual cluster K, and thus, when a node is offline due to a failure or the like, in turn, the online node is according to the A block allocation rule can learn from which nodes can obtain the blocks that have been stored on this offline node.
  • the first block allocation rule for example, P nodes, P ⁇ K, K is the total number of nodes in the virtual cluster, and the value of P can be According to the total number of nodes in the virtual cluster, for example, P is one-third of the total number of nodes in the virtual cluster K, and thus, when a node is offline due to a failure or the like, in turn, the online node is according to the A block allocation rule can learn from which nodes can obtain the blocks that
  • the first block allocation rule may further perform an average allocation according to the number of blocks and the number of nodes in the virtual cluster, and allocate the blocks in the blockchain to each.
  • the node is stored.
  • the blocks are redundantly stored, that is, the blocks stored on one node are stored on the other node or nodes.
  • blocks 1 to 3 are stored in nodes numbered 1, n+k, ..., and blocks 4 to 6 are stored in nodes numbered 2, n+2k, ..., where n and k is a positive integer.
  • the first block allocation rule may further be: determining, according to the network segment to which the node belongs, the block that needs to be stored. For example, each block is simultaneously stored on the nodes of network segment 1 to network segment 10. According to the network segment, the block that the node needs to store is determined. When the node of the same network segment has network problems at the same time, the block in the block chain can also be obtained from the nodes of other network segments.
  • the first block allocation rule can also be determined according to the distance between the nodes, the computing power, etc., to ensure the security of the block storage.
  • the nodes in the virtual cluster respectively store a part of the blocks in the blockchain, whether the node is in a normal working state affects the integrity and security of the block storage, and needs to be virtualized.
  • the state of the nodes in the cluster is maintained.
  • nodes in the virtual cluster determine whether each other is online by maintaining a heartbeat. Maintaining a heartbeat can be achieved in two ways:
  • a node in the virtual cluster periodically sends online confirmation information to other nodes; and determines whether other nodes are online according to whether feedback information of other nodes is received.
  • the online confirmation information may be an empty data packet or a data packet including preset information; the feedback information may also be an empty data packet or a data packet including preset information. If the feedback information is not received within the preset time, it is determined that the node is offline, and the blocks in the blockchain need to be allocated and stored and/or other isolated nodes are added to the virtual cluster.
  • Mode 2 A node in the virtual cluster periodically sends online confirmation information to a node adjacent to its own number (a node that is numbered first and/or a node that is later); and according to whether information received by the node adjacent to the number is received, Determine if the node adjacent to the number is online.
  • the nodes confirm whether the nodes are online by mutual confirmation.
  • This mutual confirmation in addition to the above method of “sending online confirmation information-receiving feedback information”, can also be performed by “receiving online confirmation information”.
  • the node C in the virtual cluster periodically sends online confirmation information to other nodes or nodes adjacent to the number. If other nodes or nodes adjacent to the number do not receive the online confirmation information sent by the node C when the time is up, then Make sure that node C goes offline.
  • the node still online may know the block stored by the offline node according to the first block allocation rule of the block. Thus, the node still online can obtain the block stored by the offline node from the redundantly stored node according to the first block allocation rule. Any node in the virtual cluster may re-determine the node for storing the block stored by the offline node according to the preset second block allocation rule, and send the block stored by the offline node to the determined node. Receive for storage.
  • the newly added node may pass the "active invitation” or "receive join request” manner.
  • Active invitation When a node in the virtual cluster goes offline, the node in the virtual cluster actively sends a cluster join invitation to the node outside the virtual cluster to invite nodes outside the virtual cluster to join the virtual cluster.
  • the ID of the virtual cluster may be included in the invitation sent.
  • the node When receiving the confirmation information of the reply from the node outside the virtual cluster, the node is added to the virtual cluster.
  • the nodes in the virtual cluster can send the cluster join invitation.
  • the node When receiving the acknowledgement information of the reply of the multiple nodes, the node can be added to the virtual cluster according to the chronological order of the reply confirmation information. The node; or the node that can be added to the virtual cluster based on the computing power of the node replying to the confirmation information, the network status, and the like.
  • the nodes in the virtual cluster After the node is added to the virtual cluster, the nodes in the virtual cluster re-determine the number of each node through the third preset negotiation mechanism; and the third block allocation rule according to its own number and preset. Then, determine the block to store.
  • the blocks stored by other online nodes may be kept unchanged, and the nodes adjacent to the number of the newly added nodes determine the blocks that the newly added nodes need to store according to the allocation rules of the blocks.
  • the "received join request” means that the node outside the virtual cluster actively sends a cluster join request to the node in the virtual cluster.
  • the cluster join request may include: address information, computing power, network status, and the like of the node. If any node in the virtual cluster receives the cluster join request, it sends a cluster join invitation to the node that sends the cluster join request. When the node that sends the cluster join request replies with the confirmation information, the node is added to the virtual cluster.
  • the node in the virtual cluster that includes the newly added node re-determines the number of each node through the fourth preset negotiation mechanism; if the number of the newly added node is adjacent to its own number, the fourth block according to the preset
  • the allocation rule determines the block that the newly added node needs to store; and sends the block that needs to be stored by the newly added node to the newly added node for storage.
  • the node is added to replace the node of the offline line within a preset time.
  • the reallocation of all the blocks may not be performed, and only the blocks stored by the offline node are stored in the newly added node.
  • the node stored by the offline node may be obtained from other nodes in the virtual cluster by the node adjacent to the number of the newly added node, and sent to the newly added node for storage.
  • the block stored by the offline node may also be obtained by the designated node and sent to the newly added node.
  • the number of newly added nodes is the same as the number of nodes on the offline. It should be understood that, in some embodiments, when the number of nodes that can be included in the virtual cluster is adjusted (for example, the number of nodes is increased), the node may be added based on the number of nodes of the original virtual cluster, or The number of newly added nodes is greater than the number of nodes on the offline.
  • the blocks in the original blockchain are allocated to the respective nodes in the virtual cluster.
  • any node in the virtual cluster discovers a new block.
  • the node that finds the new block determines the node for storing the new block according to the preset fifth block allocation rule.
  • the node of the new block is found, and the new block is sent to the node to be stored for storage.
  • the node broadcasts the information of the successfully saved block to other nodes in the virtual cluster.
  • a node for storing a new block may be determined by a node that first discovers a new block or a designated node according to a preset fifth block allocation rule.
  • the nodes in the virtual cluster since the nodes in the virtual cluster perform new block discovery, after discovering the new block, according to the preset sixth block allocation rule, it is determined whether it is necessary to save the new block, and if necessary, to store the new block. , then store the new block, if you do not need to store the new block, it will not be processed.
  • the node in the virtual cluster broadcasts information of the successfully saved block, indicating that the storage has been successfully completed. If you do not need to store it yourself, you will not save the new block and wait for the information stored successfully by other storage nodes.
  • any node in the virtual cluster receives a transaction query sent by the query end (for example, a node outside the virtual cluster)
  • a transaction query sent by the query end for example, a node outside the virtual cluster
  • requesting for example, verifying a hash of a transaction
  • At least one node that queries the block corresponding to the transaction query request may return the query result returned by the node that returns the query result first. Give the query side.
  • embodiments of the present invention can complete any transaction query request for a blockchain, for example, verifying any transaction.
  • a node in a virtual cluster needs to execute a contract of a target block, it is determined whether the target block is stored; if the target block is stored, And executing a contract of the target block; if the target block is not stored, acquiring the target block from a node storing the target block; and executing a contract according to the obtained target block .
  • the nodes in the virtual cluster after deleting a stored block, store the target block and execute the contract according to the stored target block.
  • the deleted block can be any unused block.
  • the second preset negotiation mechanism, the third preset negotiation mechanism, and the fourth preset negotiation mechanism in the embodiment of the present invention may be the same as the first preset negotiation mechanism, or may be other negotiation mechanisms, and the present invention is implemented. This example does not limit this.
  • the second block allocation rule, the third block allocation rule, the fourth block allocation rule, the fifth block allocation rule, and the sixth block allocation rule may be the same as the second block allocation rule, or may be allocated to other blocks.
  • the rules of the present invention are not limited thereto.
  • the blocks in the blockchain are redundantly stored in each node in the virtual cluster to reduce the storage capacity of the node, and since each block is redundantly stored, It can ensure the security of storage; improve the synchronization speed of blocks and improve query efficiency.
  • FIG. 12 is a schematic structural diagram of a blockchain storage device according to an embodiment of the present invention.
  • the device 120 is applied to a node in a blockchain network, and includes:
  • the virtual cluster joining module 1201 is configured to join a virtual cluster by accepting a cluster setup invitation or sending a cluster setup invitation, where the virtual cluster includes a preset number of nodes;
  • the block storage module 1202 is configured to store one or more blocks in the blockchain according to a preset first block allocation rule, so that the blocks stored by the nodes in the virtual cluster are Form a complete blockchain.
  • the virtual cluster joining module 1201 includes:
  • An invitation sending sub-module is configured to send a cluster formation invitation to other nodes when the node is connected to the first preset number of other nodes;
  • the virtual cluster construction sub-module is configured to, when the node exceeding the second preset number replies with the confirmation information, form the virtual cluster with the node that replies with the confirmation information.
  • the virtual cluster joining module 1201 includes:
  • the receiving and joining sub-modules are configured to receive the cluster creation invitation sent by other nodes, and reply the confirmation information to join the virtual cluster.
  • the device 120 further includes:
  • the cluster label determining module 1203 is configured to determine a cluster label by using a first preset negotiation mechanism with the node in the virtual cluster, where the cluster identifier is invalid after a preset time, and the cluster identifier is After the preset time expires, the nodes in the virtual cluster are restored to ordinary nodes, and the cluster formation invitation can be accepted or sent.
  • the block storage module 1202 includes:
  • a number determining submodule configured to determine, with a node in the virtual cluster, a number of each node by using a second preset negotiation mechanism
  • a block storage determining submodule configured to determine the one or more blocks to be stored according to their own number and a hash value corresponding to each block in the blockchain
  • a storage submodule configured to store the one or more blocks.
  • the block storage determining submodule is configured to divide the hash value corresponding to each block by a preset number of constants, and to divide the remainder obtained by the division and the number of the self to satisfy the pre-
  • the block corresponding to the hash value of the condition is stored, wherein the hash value corresponding to each block is Less includes one of the following: the hash value of the block header of each block, the hash value of the block header of each block plus the value after the fixed value, the block header of each block, and the block body Hash value.
  • the device 120 further includes:
  • the first online confirmation module 1204 is configured to periodically send online confirmation information to other nodes in the virtual cluster; and determine whether other nodes in the virtual cluster are online according to whether feedback information of other nodes is received.
  • the device 120 further includes:
  • the second online confirmation module 1205 is configured to periodically send the online confirmation information to the node adjacent to the own number; and determine whether the node adjacent to the number is online according to whether the information fed back by the node adjacent to the number is received.
  • the device 120 further includes:
  • the block obtaining module 1206 is configured to: when a node in the virtual cluster goes offline, obtain the area stored by the offline node from the corresponding online node according to the preset first block allocation rule Piece;
  • the first block storage determining module 1207 is configured to re-determine a node for storing the block stored by the offline node according to a preset second block allocation rule; and store the offline node The block is sent to the determined node for storage.
  • the device 120 further includes:
  • the cluster join invitation sending module 1208 is configured to send a cluster join invitation to a node outside the virtual cluster to invite a node outside the virtual cluster to join the virtual cluster when a node is offline in the virtual cluster;
  • the first node number re-determination module 1209 is configured to: when receiving the confirmation information of the reply of the node outside the virtual cluster, the node in the virtual cluster after joining the newly added node is re-determined by the third preset negotiation mechanism. The number of each node;
  • the second block storage determining module 1210 is configured to be based on its own number and a preset third zone A block allocation rule that determines which blocks to store.
  • the device 120 further includes:
  • the cluster join request receiving module 1211 is configured to have a node offline in the virtual cluster, and when receiving a cluster join request sent by a node outside the virtual cluster, send a cluster join to the node that sends the cluster join request invite;
  • the second node number re-determination module 1212 is configured to: when the node that sends the cluster join request replies with the confirmation information, the node in the virtual cluster after joining the newly added node re-determines each through the fourth preset negotiation mechanism. The number of the node;
  • the third block storage determining module 1213 is configured to determine, if the number of the newly added node is adjacent to the number of the new node, the block to be stored by the newly added node according to the preset fourth block allocation rule. And sending the block to be stored by the newly added node to the newly added node for storage.
  • the device 120 further includes:
  • a fourth block storage determining module 1214 configured to, when generating a new block in the blockchain network, determine a node for storing the new block according to a preset fifth block allocation rule; and the new area The block is sent to the determined node for storage.
  • the device 120 further includes:
  • the fifth block storage determining module 1215 is configured to: when the new block is generated in the blockchain network, determine whether the new block needs to be stored according to a preset sixth block allocation rule; if the new block needs to be stored The new block is stored, and if the new block does not need to be stored, no processing is performed.
  • the device 120 further includes:
  • the transaction query request receiving module 1216 is configured to, when receiving the transaction query request sent by the querying end, determine whether a block corresponding to the transaction query request is stored;
  • the query result obtaining module 1217 is configured to: if the block corresponding to the transaction query request is stored, obtain the query result according to the transaction query request;
  • the transaction query request sending module 1218 is configured to: if not stored with the transaction query request Corresponding blocks, the transaction query request is sent to other nodes in the virtual cluster;
  • the transaction query result receiving module 1219 is configured to receive a transaction query result returned by a node storing a block related to the transaction query request;
  • the query result sending module 1220 is configured to send the query result to the query end.
  • the device 120 further includes:
  • the target block determining module 1221 is configured to determine whether to store the target block when a contract of a target block needs to be executed;
  • the first execution module 1222 is configured to execute the contract of the target block if the target block is stored;
  • the target block obtaining module 1223 is configured to acquire the target block from a node storing the target block if the target block is not stored;
  • the second execution module 1224 is configured to execute the contract according to the target block acquired by the target block acquisition module.
  • the second execution module 1224 includes:
  • a block deletion submodule configured to delete the stored block and store the target block
  • An execution submodule configured to execute a contract based on the stored target block.
  • the tile storage module 1202 is configured to determine the tiles to be stored according to the network segment to which it belongs.
  • FIG. 13 is a block diagram of an apparatus 130 for a blockchain storage method, which may be a node device in a blockchain, according to an exemplary embodiment.
  • the apparatus 130 can include a processor 1301, a memory 1302, a multimedia component 1303, an input/output (I/O) interface 1304, and a communication component 1305.
  • the processor 1301 is configured to control the overall operation of the device 130 to complete the foregoing area. All or part of the steps in the blockchain storage method.
  • Memory 1302 is for storing operating systems, various types of data to support operations at the device 130, such as instructions that may include any application or method for operation on the device 130, and application-related data.
  • the memory 1302 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read only memory ( Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read Only Read-Only Memory (ROM), magnetic memory, flash memory, disk or optical disk.
  • SRAM static random access memory
  • EEPROM Electrically Erasable Programmable Read-Only Memory
  • EPROM Erasable Programmable Read-Only Memory
  • PROM Programmable Read-Only Memory
  • ROM Read Only Read-Only Memory
  • the multimedia component 1303 can include a screen and an audio component.
  • the screen may be, for example, a touch screen, and the audio component is used to output and/or input an audio signal.
  • the audio component can include a microphone for receiving an external audio signal.
  • the received audio signal may be further stored in memory 1302 or transmitted via communication component 1305.
  • the audio component also includes at least one speaker for outputting an audio signal.
  • the I/O interface 1304 provides an interface between the processor 1301 and other interface modules, such as a keyboard, a mouse, a button, and the like. These buttons can be virtual buttons or physical buttons.
  • Communication component 1305 is used for wired or wireless communication between the device 130 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G or 4G, or a combination of one or more of them, so the corresponding communication component 1305 can include: Wi-Fi module, Bluetooth module, NFC module.
  • the device 130 may be configured by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), and digital signal processing devices (Digital Signal Processing Devices).
  • ASICs Application Specific Integrated Circuits
  • DSPs Digital Signal Processors
  • Digital Signal Processing Devices Digital Signal Processing Devices
  • Processing Device DSPD
  • Programmable Logic Device Programmable Logic Device, referred to as PLD
  • Field Programmable Gate Array FPGA
  • controller microcontroller, microprocessor or other electronic component implementation for performing the blockchain storage method described above.
  • a computer program product comprising a computer program executable by a programmable device, the computer program having when executed by the programmable device A code portion for performing the blockchain storage method described above.
  • non-transitory computer readable storage medium comprising instructions, such as a memory 1302 comprising instructions executable by processor 1301 of apparatus 130 to perform the blockchain described above Storage method.
  • the non-transitory computer readable storage medium can be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device.
  • Any process or method description in the flowcharts or otherwise described in the embodiments of the invention may be understood to represent code that includes one or more executable instructions for implementing the steps of a particular logical function or process. Modules, segments or portions, and the scope of the embodiments of the invention includes additional implementations, in which the functions may be performed in a substantially simultaneous manner or in an inverse order depending on the functions involved, in the order shown or discussed. This should be understood by those skilled in the art of the embodiments of the present invention.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Theoretical Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种区块链存储方法、装置及节点设备,所述方法包括:通过接受集群组建邀请或发送集群组建邀请,加入一虚拟集群(201),所述虚拟集群中包括预设个数的节点;按照预设的第一区块分配规则,对区块链中的一个或多个区块进行存储(202),以使得所述虚拟集群中的节点所存储的区块可组成完整的区块链。所述方法通过将区块链中的区块分别冗余存储到虚拟集群中的各节点中,减轻节点的存储量,且由于每个区块都被冗余存储,可保证存储的安全性;提高区块的同步速度,提高查询效率。

Description

区块链存储方法、装置及节点设备 技术领域
本发明涉及区块链技术领域,尤其涉及一种区块链存储方法、装置及节点设备。
背景技术
目前,区块链技术正在越来越广泛的被应用,不管是货币,虚拟物品,房产,股票等等都正在尝试用区块链来记录,使交易变得发明透明,去中心化。
区块链网络基于P2P(Peer to Peer,对等网络)网络,每个参与交易、区块存储、区块验证或转发的P2P网络节点都是一个区块链网络中的节点。节点之间的数据交换通过数字签名技术进行验证,无需互相信任,只要按照系统既定的规则进行,节点之间不能也无法欺骗其它节点。
由于区块链中存储了所有的交易,随着交易的增加,按照每十分钟产生一个区块的速度,区块链的数据量会越来越大。以比特币区块链为例,比特币区块链完整数据的大小,当前已经达到了几十GB,用户如果使用比特币核心(bitcoin core)客户端进行数据同步的话,可能几个昼夜都无法同步完成。并且,区块链的数据量还在不断地增加,这给比特币核心客户端的运行带来了很大的门槛,普通用户并不适合去使用bitcoin core客户端,这些,也就造成了运行比特币全节点(full nodes)的数量,不增反减,并且在过去的几年中全节点(即保存有完整的、最新的区块链拷贝,能独立自主地校验所有交易,而不需借由任何外部参照)的数量有明显的下降。
在目前的区块链网络中,全节点存储了第一区块(创世区块)一直到网络中最新的区块。正因为区块链的全节点保存了完整的区块链,区块链才成 为了真正意义上的去中心化结构。但也因为这样,全节点保存数据所占用的空间十分巨大。随时间的推移,这样的矛盾会越发凸显。同时,一个新的全节点加入网络,需要与网络中的对等节点做数据同步,这样的同步会因为网络状况变得不稳定,同步时间不可预期,以及完成同步需消耗大量的网络带宽等问题。
发明内容
为克服相关技术中存在的问题,本发明提供一种区块链存储方法、装置及节点设备。
其中,第一方面,提供一种区块链存储方法,应用于区块链网络中的节点,包括:
通过接受集群组建邀请或发送集群组建邀请,加入一虚拟集群,所述虚拟集群中包括预设个数的节点;
按照预设的第一区块分配规则,对区块链中的一个或多个区块进行存储,以使得所述虚拟集群中的节点所存储的区块可组成完整的区块链。
第二方面,提供一种区块链存储装置,应用于区块链网络中的节点,包括:
虚拟集群加入模块,被配置为通过接受集群组建邀请或发送集群组建邀请,加入一虚拟集群,所述虚拟集群中包括预设个数的节点;
区块存储模块,被配置为按照预设的第一区块分配规则,对区块链中的一个或多个区块进行存储,以使得所述虚拟集群中的节点所存储的区块可组成完整的区块链。
第四方面,提供一种节点设备,包括:
处理器;
用于存储处理器可执行指令的存储器;
其中,所述处理器,被配置为通过接受集群组建邀请或发送集群组建邀请,加入一虚拟集群,所述虚拟集群中包括预设个数的节点;按照预设的第一区块分配规则,对区块链中的一个或多个区块进行存储,以使得所述虚拟集群中的节点所存储的区块可组成完整的区块链。
第五方面,提供一种计算机程序产品,所述计算机程序产品包含能够由可编程的装置执行的计算机程序,所述计算机程序具有当由所述可编程的装置执行时用于执行上述的方法的代码部分。
第六方面,提供一种非临时性计算机可读存储介质,所述非临时性计算机可读存储介质中包括一个或多个程序,所述一个或多个程序用于执行上述的方法。
第七方面,提供一种节点设备,包括:上述的非临时性计算机可读存储介质;以及一个或者多个处理器,用于执行所述非临时性计算机可读存储介质中的程序。
本发明实施例通过将区块链中的区块分别冗余存储到虚拟集群中的各节点中,减轻节点的存储量,且由于每个区块都被冗余存储,可保证存储的安全性;提高区块的同步速度,提高查询效率。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本发明。
本发明的其他特征和优点将在随后的具体实施方式部分予以详细说明。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本发明的实施例,并与说明书一起用于解释本发明的原理。
图1是本发明一实施例的区块链网络的结构示意图;
图2是本发明一实施例的区块链存储方法的流程示意图;
图3是本发明一实施例的区块链网络中节点加入虚拟集群的流程示意图;
图4是本发明一实施例中根据区块分配规则对区块进行存储分配的示意图;
图5是本发明又一实施例中根据区块分配规则对区块进行存储分配的示意图;
图6是本发明再一实施例中根据区块分配规则对区块进行存储分配的示意图;
图7是本发明一实施例的虚拟集群中的节点通过维持心跳确认节点是否在线的示意图;
图8是本发明一实施例的虚拟集群中的新增节点的示意图;
图9是本发明一实施例的虚拟集群中的节点对新区块进行存储的示意图;
图10是本发明一实施例中虚拟集群中的节点进行交易查询时的示意图;
图11是本发明一实施例中虚拟集群中的节点执行合约的示意图;
图12是本发明一实施例提供的区块链存储装置的结构示意图;
图13是根据一示例性实施例示出的一种用于区块链存储方法的装置的框图。
具体实施方式
以下结合附图对本发明的具体实施方式进行详细说明。应当理解的是,此处所描述的具体实施方式仅用于说明和解释本发明,并不用于限制本发明。
为解决全节点的区块链存储数据量大的问题,本发明实施例通过分布式存储的方式,由多个节点协同进行区块链的存储处理,将整个区块链中区块 分散的存储在各个节点上。
参见图1,为本发明一实施例的区块链网络的结构示意图。该区块链网络100包括:多个节点101。每个参与交易,区块存储,区块验证或转发等的P2P网络节点都可作为区块链中的节点。例如,节点101可为智能电话、平板电脑、服务器、具有嵌入式系统的电子设备、矿机(即可执行PoW(Proof Of Work,工作证明)共识竞争机制的设备)等。
区块链网络中100的所有节点根据预定规则,自组织成若干虚拟集群。区块链网络中的至少两个节点组建虚拟集群,虚拟集群中的节点,根据预设的区块分配规则,分别对区块链中的一个或多个区块进行存储,以使得至少两个节点存储的区块可组成完整的区块链。
如图1所示,虚线内部的节点组成一个虚拟集群,各个节点可完全独立参与区块链中的其它功能(例如,挖矿、钱包等)、但存储区块链采用分布式方式,即一个完整的区块链中的区块,被分别冗余存储到虚拟集群中的各个节点中。
由于,每个节点只存储区块链的部分区块,可减少存储量,提高节点同步区块链的速度;提高查询效率;且由于每个区块都被冗余存储,可保证存储的安全性。
参见图2,为本发明一实施例的区块链存储方法,应用于区块链网络中的节点,其包括以下步骤:
在步骤201中,通过接受集群组建邀请或发送集群组建邀请,加入一虚拟集群。
在步骤202中,按照预设的第一区块分配规则,对区块链中的一个或多个区块进行存储。由此,使得虚拟集群中的节点所存储的区块可组成完整的区块链。
虚拟集群的建立和加入
参见图3,为本发明实施例的区块链网络中节点加入虚拟集群的流程示意图。
区块链网络中的多个节点,在未加入到虚拟子网络(虚拟集群)中时,为孤立节点。
由于区块链网络是基于P2P网络协议的,一个节点A在区块链网络中上线且稳定一定时间后,会与多个节点产生连接。当节点A与第一预设个数的其它节点两两相连时,则节点A具备建立虚拟集群的条件,可进入节点发现状态,接受其它节点发送的集群组建邀请,也可以向相连接的其它节点发送集群组建邀请,组建虚拟集群。
在步骤301中,当节点A与第一预设个数的其它节点两两相连时,节点A向其它节点发送集群组建邀请。
在一个实施例中,当与节点A相连接的节点数超过一定阈值m时,节点A从这m个节点中,根据节点状况选择第一预设个数的节点,向其发送集群组建邀请。节点状况包括:是否产生过新区块、节点的网络状况等。由于是否产生过新区块可以衡量节点的可信性,因此,将是否产生过新区块作为考量节点的依据。一节点是否产生过新区块,可以通过查询区块链中的区块获得。节点的网络状况对节点间的交互产生影响,因此,将节点的网络状况也作为考量节点的依据。网络状况,可通过发送测试数据包(例如,空数据包或ping包)获取。
在一个实施例中,集群组建邀请可为包含特定信息的数据包,例如,包括发送邀请的节点的IP地址、产生过的新区块数量、算力等。
在步骤302中,当超过第二预设个数的节点回复确认信息时,则与回复信息的节点,组建成虚拟集群。组建成虚拟集群后,即各个节点加入到了该虚拟集群中。
在本发明的实施例中,一节点可能会接收到多个节点发送的集群组建邀 请,其可根据集群组建邀请中的信息,确定要响应的节点,以及向确定的节点返回响应信息,确定加入虚拟集群。
在本发明的实施例中,由于虚拟集群中每个节点都是对等的,虚拟集群的规模也是有限的,当虚拟集群的节点个数达到第二预设个数时,将不再接受新的节点进入。这样做的原因是避免整个区块链网络会退化成一个虚拟集群。且为了保证区块存储的稳定性和安全性,虚拟集群中节点的个数满足一定的条件(即满足第二预设个数),且根据网络的状况、协议等,对第二预设个数进行调整(增加或减少)。
在本发明的一实施例中,多个节点组成了虚拟集群后,根据第一预设协商机制,确定虚拟集群的集群标号(ID)。集群标号用于对虚拟集群进行标识,在一个实施例中,集群标号可为字符串,其可包括集群中的节点数量、每个节点的IP地址、每个节点的节点状况等信息。集群标号是与时间相对应的,在预设时间后失效,且集群标识号在预设时间失效后,在虚拟集群中的节点恢复为普通节点(即孤立节点),可接受或发送集群组建邀请。
在一个实施例中,当有第二预设个数互联的节点建立虚拟集群后,虚拟集群中的各个节点标识自己进入虚拟集群状态,不再接受加入新的虚拟集群。即节点已加入到一个虚拟集群,则不再响应其它节点发送的集群组建请求。
在本发明的实施例中,根据第一预设协商机制,确定虚拟集群的集群标号(Id),可通过以下方式进行:
方式1:最先生成ID的节点,将ID广播给虚拟集群中的其它节点,各个节点对ID进行验证,验证通过,就确定该ID为虚拟集群的ID。
方式2:可将算力最强的节点产生的ID作为虚拟集群的ID,或根据IP地址,将IP地址最小的节点产生的ID作为虚拟集群的ID。
在本发明的一实施例中,为了便于实现区块的分配,虚拟集群中的节点, 通过第二预设协商机制,确定每个节点的编号,由此,根据编号来确定节点需要存储的区块。
区块的存储分配
确定了每个节点的编号后,各个节点根据自己的编号和区块链中每一区块对应的哈希值,确定并存储所要存储的一个或多个区块。
参见图4,在一个实施例中,节点将每一区块对应的哈希值分别与预设个数的常数相除,并将相除所得的余数和自身的编号满足预设条件(例如,余数和自身编号相同)的哈希值对应的区块进行存储。其中,每一区块对应的哈希值至少包括以下其中之一:每一区块的区块头的哈希值、每一区块的区块头的哈希值加上固定值后的值、每一区块的区块头和区块主体的哈希值。
例如,可将一区块B的区块头的哈希值与第一常数、第二常数和第三常数相除,根据相除所得的余数m1、m2、m3,将该区块B分半存储到的编号为m1的节点、编号为m2的节点和编号为m3的节点。此外,还可将该区块B的区块头的哈希值加上一固定值后,与第四预设常数相除,然后根据余数m4,将该区块B存储到编号为m4的节点。
由此,每个区块被按照第一区块分配规则被冗余存储到多个节点上(例如,P个节点上,P<K,K为虚拟集群中的节点总数,P的取值可根据虚拟集群中的节点总数设定,例如,P为虚拟集群中节点总数K的三分之一),由此,当某个节点因为故障等原因下线时,反过来,在线的节点根据第一区块分配规则,可获知从哪些节点可获取到这个下线节点上曾存储的区块。
参见5,在本发明的一些实施例中,第一区块分配规则还可为,按照区块的数量和虚拟集群中节点的数量,进行平均分配,将区块链中的区块分配到各个节点进行存储。同时,为了确保区块存储的安全性,对区块进行冗余存储,即在一个节点上存储的区块,会在其它一个或多个节点上再进行存储。 由此,当一个节点丢失区块时,可在其它节点上得到区块,而不会导致区块的缺失。如图5所示,区块1~3存储在编号为1、n+k……的节点中,区块4~6存储在编号为2、n+2k……的节点中,其中,n和k为正整数。
参见图6,在本发明的一些实施例中,第一区块分配规则还可为:根据节点所属的网段,确定其需要存储的区块。例如,每个区块都同时被存储到网段1~网段10的节点上。根据网段,确定节点需要存储的区块,是为了避免同一网段的节点同时出现网络问题时,区块链中的区块还可从其它网段的节点上获得。
此外,第一区块分配规则,还可根据节点之间的距离、算力等确定,以保证区块存储的安全性。
虚拟集群中的节点的维持
在本发明的实施例中,由于虚拟集群中的节点分别存储有区块链中的一部分区块,因此,节点是否处于正常工作状态,影响到区块存储的完整性和安全性,需要对虚拟集群中的节点的状态进行维护。
在本发明的一实施例中,虚拟集群中的节点通过维持心跳的方式,确定彼此是否在线。维持心跳可通过以下两种方式实现:
方式1:参见图7,虚拟集群中的一节点定时向其它节点发送在线确认信息;以及根据是否接收到其它节点的反馈信息,确定其它节点是否在线。
在线确认信息可为空数据包,或包括预设信息的数据包;反馈信息也可为空数据包,或包括预设信息的数据包。若预设时间内未收到反馈信息,则确定节点下线,需要重新对区块链中的区块进行分配存储和/或邀请其它的孤立节点加入到虚拟集群中。
方式2:虚拟集群中的一节点定时向与自己的编号邻近的节点(编号在前的节点和/或在后的节点)发送在线确认信息;以及根据是否接收到编号邻近的节点反馈的信息,确定编号邻近的节点是否在线。
应理解,节点间通过相互确认的方式,确定节点是否在线,这种相互确认,除了上面的“发送在线确认信息-接收反馈信息”的方式外,还可通过“接收在线确认信息”的方式进行,即虚拟集群中的节点C,定时向其它节点或编号相邻的节点发送在线确认信息,若其它节点或编号相邻的节点在定时时间到时未接收到节点C发送的在线确认信息,则确定该节点C下线。
节点下线后的区块分配及新节点补充
当虚拟集群中有节点下线时,仍在线的节点,可以根据区块的上述第一区块分配规则,获知该下线节点所存储的区块。从而,仍在线的节点可根据第一区块分配规则,从冗余存储的节点中获得下线节点所存储的区块。虚拟集群中的任一节点,可根据预设的第二区块分配规则,重新确定用于存储下线节点所存储的区块的节点,并将下线节点所存储的区块发送给确定的接收进行存储。
参见图8,当虚拟集群中有节点下线时,需要增加新的节点来“平衡网络”,保证区块的存储。在本发明的实施例中,新增节点可通过“主动邀请”或“接收加入请求”的方式。
“主动邀请”:即当虚拟集群中有节点下线时,虚拟集群中的节点主动向虚拟集群外的节点发送集群加入邀请,以邀请虚拟集群外的节点加入虚拟集群。发送的邀请中可包括虚拟集群的ID信息。
当接收到所述虚拟集群外的节点回复的确认信息时,则将该节点加入到虚拟集群中。在本发明的实施例中,虚拟集群中的节点均可发送集群加入邀请,当接收到多个节点的回复的确认信息时,可根据回复确认信息的时间先后顺序,确定可以加入到虚拟集群中的节点;或者根据回复确认信息的节点的算力、网络状况等确定可以加入到虚拟集群中的节点。
当虚拟集群中新增节点后,虚拟集群中的节点通过第三预设协商机制,重新确定每个节点的编号;以及根据自己的编号和预设的第三区块分配规 则,确定要存储的区块。
此外,还可保持其它在线节点存储的区块不变,而由与新增节点的编号相邻的节点,根据区块的分配规则确定该新增节点需要存储的区块。
“接收加入请求”:即虚拟集群外的节点,主动向虚拟集群中的节点发送集群加入请求,集群加入请求中可包括:节点的地址信息、算力、网络状况等信息。虚拟集群中的任一节点若接收到集群加入请求,则向发送集群加入请求的节点发送集群加入邀请;当发送集群加入请求的节点回复确认信息时,即将该节点加入到虚拟集群中。
包含了新增节点后的虚拟集群中的节点通过第四预设协商机制,重新确定每个节点的编号;若新增节点的编号与自己的编号相邻,则根据预设的第四区块分配规则,确定新增节点需要存储的区块;以及将新增节点需要存储的区块发送给新增节点进行存储。
在一个实施例中,虚拟集群中有下线的节点后,在预设的时间内,即补充了新的节点来替代下线的节点。则在这种情况下,可不进行全部区块的重新分配,而仅将下线节点存储的区块存储到该新增节点中。可由与新增节点的编号相邻的节点从虚拟集群中其它节点中获取下线节点存储的区块,从而发送给新增节点进行存储。
应理解,也可由指定节点获取下线节点存储的区块并发送给新增节点。
在本发明的一实施例中,新增的节点数和下线的节点数相同。应理解,在一些实施例中,当对虚拟集群中可包括的节点数进行调整(例如,增大节点数)时,也可在原有虚拟集群的节点数的基础上,进行节点新增,或使得新增的节点数大于下线的节点数。
在本发明的实施例中,正因为虚拟集群节点的对等性与自修复性,无需担心区块链分布式存储的数据会因某些节点的损毁而消失。同时因为区块链自身的去中心化的特殊属性,虚拟集群的各个节点存储的区块都可以很容易 的重建。
区块链中新区块的存储
参见图9,原区块链中的区块被分配到虚拟集群中的各个节点存储,当有新的区块被发现需要追加到区块链时,虚拟集群内任意一节点发现新区块,则发现新区块的节点按照预设的第五区块分配规则,确定用于存储新区块的节点。在一个实施例中,发现新区块的节点,将新区块发送给需进行存储的节点,由其进行保存。为了确保新区块的正确保存,新区块保存成功后,节点向虚拟集群中的其它节点广播成功保存区块的信息。
在一个实施例中,可由首先发现新区块的节点或指定的节点按照预设的第五区块分配规则,确定用于存储新区块的节点。
在另一些实施例中,由于虚拟集群中的节点都进行新区块发现,因此,发现新区块后,按照预设的第六区块分配规则,确定自己是否需要保存新区块,若需要存储新区块,则存储新区块,若不需要存储新区块,则不作处理。在一个实施例中,当节点成保存新区块后,向虚拟集群中的节点广播成功保存区块的信息,表明已经成功存储。若不需自己存储,则不保存新区块,并等待其它存储节点广播的成功存储的信息。
交易查询
参见图10,在本发明的一实施例中,区块分布式存储到虚拟集群中的各个节点后,当虚拟集群内任意节点收到查询端(例如,虚拟集群外的节点)发送的交易查询请求(例如,验证一个交易的hash)时,确定自己是否存储有与交易查询请求相对应的区块。若存储有与交易查询请求相对应的区块,则根据交易查询请求获取查询结果后返回给查询端。若未存储与交易查询请求相对应的区块,则将交易查询请求给虚拟集群中的其它节点;接收存储有与交易查询请求相关的区块的节点返回的交易查询结果;并将查询结果发送给查询端。
在本发明的实施例中,由于区块是冗余存储的,因此,查询到交易查询请求相对应的区块的节点至少为一个,可将最先返回查询结果的节点,返回的查询结果返回给查询端。
由此,本发明实施例可完成针对区块链的任何交易查询请求,例如,对任何交易进行验证。
执行合约
参见图11,在本发明的一实施例中,当虚拟集群中的一节点,需要执行一目标区块的合约时,确定是否存储有所述目标区块;若存储有所述目标区块,则执行所述目标区块的合约;若未存储有所述目标区块,则从存储所述目标区块的一节点中获取所述目标区块;以及根据获取的所述目标区块执行合约。
在一个实施例中,虚拟集群中的节点,删除一存储的区块后,存储目标区块,根据存储的目标区块执行合约。删除的区块可为任一未使用的区块。
应理解,本发明实施例中的上述第二预设协商机制、第三预设协商机制和第四预设协商机制可与第一预设协商机制相同,或为其它的协商机制,本发明实施例对此不作限制。第二区块分配规则、第三区块分配规则、第四区块分配规则、第五区块分配规则和第六区块分配规则可与第二区块分配规则相同,或为其它区块分配规则,本发明实施例对此不作限制。
本发明实施例的区块链存储方法,将区块链中的区块分别冗余存储到虚拟集群中的各节点中,减轻节点的存储量,且由于每个区块都被冗余存储,可保证存储的安全性;提高区块的同步速度,提高查询效率。
参见图12,为本发明一实施例提供的区块链存储装置的结构示意图,该装置120应用于区块链网络中的节点,包括:
虚拟集群加入模块1201,被配置为通过接受集群组建邀请或发送集群组建邀请,加入一虚拟集群,所述虚拟集群中包括预设个数的节点;
区块存储模块1202,被配置为按照预设的第一区块分配规则,对区块链中的一个或多个区块进行存储,以使得所述虚拟集群中的节点所存储的区块可组成完整的区块链。
在一个实施例中,所述虚拟集群加入模块1201包括:
邀请发送子模块,被配置为在所述节点与第一预设个数的其它节点两两相连时,则向其它节点发送集群组建邀请;
虚拟集群组建子模块,被配置为当超过第二预设个数的节点回复确认信息时,则与回复确认信息的节点,组建成所述虚拟集群。
在一个实施例中,所述虚拟集群加入模块1201包括:
接收及加入子模块,被配置为接收到其它节点发送的集群组建邀请时,回复确认信息,以加入到一虚拟集群中。
在一个实施例中,装置120还包括:
集群标号确定模块1203,被配置为与所述虚拟集群中的节点,通过第一预设协商机制,确定集群标号;其中,所述集群标识号在预设时间后失效,且所述集群标识号在预设时间失效后,在所述虚拟集群中的节点恢复为普通节点,可接受或发送集群组建邀请。
在一个实施例中,区块存储模块1202包括:
编号确定子模块,被配置为与所述虚拟集群中的节点,通过第二预设协商机制,确定每个节点的编号;
区块存储确定子模块,被配置为根据自己的编号和区块链中每一区块对应的哈希值,确定所要存储的所述一个或多个区块;
存储子模块,被配置为对所述一个或多个区块进行存储。
在一个实施例中,区块存储确定子模块,被配置为将每一区块对应的哈希值分别与预设个数的常数相除,并将相除所得的余数和自身的编号满足预设条件的哈希值对应的区块进行存储,其中,所述每一区块对应的哈希值至 少包括以下其中之一:每一区块的区块头的哈希值、每一区块的区块头的哈希值加上固定值后的值、每一区块的区块头和区块主体的哈希值。
在一个实施例中,装置120还包括:
第一在线确认模块1204,被配置为定时向所述虚拟集群中的其它节点发送在线确认信息;以及根据是否接收到其它节点的反馈信息,确定所述虚拟集群中的其它节点是否在线。
在一个实施例中,装置120还包括:
第二在线确认模块1205,被配置为定时向与自己的编号邻近的节点发送在线确认信息;以及根据是否接收到所述编号邻近的节点反馈的信息,确定所述编号邻近的节点是否在线。
在一个实施例中,装置120还包括:
区块获取模块1206,被配置为当所述虚拟集群中有节点下线时,根据所述预设的第一区块分配规则,从相应的在线节点中获取所述下线节点所存储的区块;
第一区块存储确定模块1207,被配置为根据预设的第二区块分配规则,重新确定用于存储所述下线节点所存储的区块的节点;以及将所述下线节点所存储的区块发送给所确定的节点进行存储。
在一个实施例中,装置120还包括:
集群加入邀请发送模块1208,被配置为在所述虚拟集群中有节点下线时,向所述虚拟集群外的节点发送集群加入邀请,以邀请所述虚拟集群外的节点加入所述虚拟集群;
第一节点编号重新确定模块1209,被配置为当接收到所述虚拟集群外的节点回复的确认信息时,与加入新增节点后的虚拟集群中的节点通过第三预设协商机制,重新确定每个节点的编号;
第二区块存储确定模块1210,被配置为根据自己的编号和预设的第三区 块分配规则,确定要存储的区块。
在一个实施例中,装置120还包括:
集群加入请求接收模块1211,被配置为在所述虚拟集群中有节点下线,且接收到所述虚拟集群外的节点发送的集群加入请求时,向所述发送集群加入请求的节点发送集群加入邀请;
第二节点编号重新确定模块1212,被配置为在所述发送集群加入请求的节点回复确认信息时,与加入新增节点后的虚拟集群中的节点通过第四预设协商机制,重新确定每个节点的编号;
第三区块存储确定模块1213,被配置为若所述新增节点的编号与自己的编号相邻,则根据预设的第四区块分配规则,确定所述新增节点需要存储的区块;以及将所述新增节点需要存储的区块发送给所述新增节点进行存储。
在一个实施例中,装置120还包括:
第四区块存储确定模块1214,被配置为在区块链网络中产生新区块时,根据预设的第五区块分配规则,确定用于存储所述新区块的节点;以及将所述新区块发送给确定的节点进行存储。
在一个实施例中,装置120还包括:
第五区块存储确定模块1215,被配置为在区块链网络中产生新区块时,按照预设的第六区块分配规则,确定是否需要存储所述新区块;若需要存储所述新区块,则存储所述新区块,若不需要存储所述新区块,则不作处理。
在一个实施例中,装置120还包括:
交易查询请求接收模块1216,被配置为在接收到查询端发送的交易查询请求时,确定是否存储有与所述交易查询请求相对应的区块;
查询结果获取模块1217,被配置为若存储有与所述交易查询请求相对应的区块,则根据所述交易查询请求获取查询结果;
交易查询请求发送模块1218,被配置为若未存储与所述交易查询请求相 对应的区块,则将所述交易查询请求发送给虚拟集群中的其它节点;
交易查询结果接收模块1219,被配置为接收存储有与所述交易查询请求相关的区块的节点返回的交易查询结果;
查询结果发送模块1220,被配置为将查询结果发送给所述查询端。
在一个实施例中,装置120还包括:
目标区块确定模块1221,被配置为在需要执行一目标区块的合约时,确定是否存储有与所述目标区块;
第一执行模块1222,被配置为若存储有所述目标区块,则执行所述目标区块的合约;
目标区块获取模块1223,被配置为若未存储有所述目标区块,则从存储所述目标区块的一节点中获取所述目标区块;
第二执行模块1224,被配置为根据所述目标区块获取模块获取的所述目标区块执行合约。
在一个实施例中,第二执行模块1224包括:
区块删除子模块,被配置为删除一存储的区块后,存储所述目标区块;
执行子模块,被配置为根据存储的目标区块执行合约。
在一个实施例中,区块存储模块1202,被配置为根据自己所属的网段,确定需要存储的区块。
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。
图13是根据一示例性实施例示出的一种用于区块链存储方法的装置130的框图,该装置130可以是区块链中的节点设备。如图13所示,该装置130可以包括:处理器1301,存储器1302,多媒体组件1303,输入/输出(I/O)接口1304,以及通信组件1305。
其中,处理器1301用于控制该装置130的整体操作,以完成上述的区 块链存储方法中的全部或部分步骤。存储器1302用于存储操作系统,各种类型的数据以支持在该装置130的操作,这些数据的例如可以包括用于在该装置130上操作的任何应用程序或方法的指令,以及应用程序相关的数据。该存储器1302可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,例如静态随机存取存储器(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),磁存储器,快闪存储器,磁盘或光盘。
多媒体组件1303可以包括屏幕和音频组件。其中屏幕例如可以是触摸屏,音频组件用于输出和/或输入音频信号。例如,音频组件可以包括一个麦克风,麦克风用于接收外部音频信号。所接收的音频信号可以被进一步存储在存储器1302或通过通信组件1305发送。音频组件还包括至少一个扬声器,用于输出音频信号。I/O接口1304为处理器1301和其他接口模块之间提供接口,上述其他接口模块可以是键盘,鼠标,按钮等。这些按钮可以是虚拟按钮或者实体按钮。通信组件1305用于该装置130与其他设备之间进行有线或无线通信。无线通信,例如Wi-Fi,蓝牙,近场通信(Near Field Communication,简称NFC),2G、3G或4G,或它们中的一种或几种的组合,因此相应的该通信组件1305可以包括:Wi-Fi模块,蓝牙模块,NFC模块。
在一示例性实施例中,装置130可以被一个或多个应用专用集成电路(Application Specific Integrated Circuit,简称ASIC)、数字信号处理器(Digital Signal Processor,简称DSP)、数字信号处理设备(Digital Signal Processing Device,简称DSPD)、可编程逻辑器件(Programmable Logic Device,简称 PLD)、现场可编程门阵列(Field Programmable Gate Array,简称FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述的区块链存储方法。
在另一示例性实施例中,还提供了一种计算机程序产品,所述计算机程序产品包含能够由可编程的装置执行的计算机程序,所述计算机程序具有当由所述可编程的装置执行时用于执行上述的区块链存储方法的代码部分。
在另一示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器1302,上述指令可由装置130的处理器1301执行以完成上述的区块链存储方法。示例地,该非临时性计算机可读存储介质可以是ROM、随机存取存储器(Random Access Memory,简称RAM)、CD-ROM、磁带、软盘和光数据存储设备等。
流程图中或在本发明的实施例中以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现特定逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本发明实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本发明的实施例所述技术领域的技术人员所理解。
以上结合附图详细描述了本发明的优选实施方式,但是,本发明并不限于上述实施方式中的具体细节,在本发明的技术构思范围内,可以对本发明的技术方案进行多种简单变型,这些简单变型均属于本发明的保护范围。

Claims (39)

  1. 一种区块链存储方法,应用于区块链网络中的节点,其特征在于,包括:
    通过接受集群组建邀请或发送集群组建邀请,加入一虚拟集群,所述虚拟集群中包括预设个数的节点;
    按照预设的第一区块分配规则,对区块链中的一个或多个区块进行存储,以使得所述虚拟集群中的节点所存储的区块可组成完整的区块链。
  2. 根据权利要求1所述的方法,其特征在于,通过接受集群组建邀请或发送集群组建邀请,加入一虚拟集群的步骤包括:
    当所述节点与第一预设个数的其它节点两两相连时,则向其它节点发送集群组建邀请;
    当超过第二预设个数的节点回复确认信息时,则与回复确认信息的节点,组建成所述虚拟集群。
  3. 根据权利要求1所述的方法,其特征在于,通过接受集群组建邀请或发送集群组建邀请,加入一虚拟集群的步骤包括:
    接收到其它节点发送的集群组建邀请时,回复确认信息,以加入到一虚拟集群中。
  4. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    与所述虚拟集群中的节点,通过第一预设协商机制,确定集群标号;
    其中,所述集群标识号在预设时间后失效,且所述集群标识号在预设时间失效后,在所述虚拟集群中的节点恢复为普通节点,可接受或发送集群组建邀请。
  5. 根据权利要求1所述的方法,其特征在于,所述按照预设的第一区块分配规则,对区块链中的一个或多个区块进行存储的步骤包括:
    与所述虚拟集群中的节点,通过第二预设协商机制,确定每个节点的编号;
    根据自己的编号和区块链中每一区块对应的哈希值,确定所要存储的所述一个或多个区块;
    对所述一个或多个区块进行存储。
  6. 根据权利要求5所述的方法,其特征在于,所述根据自己的编号和区块链中每一区块对应的哈希值,确定所要存储的所述一个或多个区块的步骤包括:
    将每一区块对应的哈希值分别与预设个数的常数相除,并将相除所得的余数和自身的编号满足预设条件的哈希值对应的区块进行存储,其中,所述每一区块对应的哈希值至少包括以下其中之一:每一区块的区块头的哈希值、每一区块的区块头的哈希值加上固定值后的值、每一区块的区块头和区块主体的哈希值。
  7. 根据权利要求5所述的方法,其特征在于,所述方法还包括:
    定时向所述虚拟集群中的其它节点发送在线确认信息;以及
    根据是否接收到其它节点的反馈信息,确定所述虚拟集群中的其它节点是否在线。
  8. 根据权利要求5所述的方法,其特征在于,所述方法还包括:
    定时向与自己的编号邻近的节点发送在线确认信息;以及
    根据是否接收到所述编号邻近的节点反馈的信息,确定所述编号邻近的节点是否在线。
  9. 根据权利要求7或8所述的方法,其特征在于,所述方法还包括:
    当所述虚拟集群中有节点下线时,根据所述预设的第一区块分配规则,从相应的在线节点中获取所述下线节点所存储的区块;
    根据预设的第二区块分配规则,重新确定用于存储所述下线节点所存储的区块的节点;以及
    将所述下线节点所存储的区块发送给所确定的节点进行存储。
  10. 根据权利要求9所述的方法,其特征在于,所述方法还包括:
    当所述虚拟集群中有节点下线时,向所述虚拟集群外的节点发送集群加入邀请,以邀请所述虚拟集群外的节点加入所述虚拟集群;
    当接收到所述虚拟集群外的节点回复的确认信息时,与加入新增节点后的虚拟集群中的节点通过第三预设协商机制,重新确定每个节点的编号;以及
    根据自己的编号和预设的第三区块分配规则,确定要存储的区块。
  11. 根据权利要求9所述的方法,其特征在于,所述方法还包括:
    当所述虚拟集群中有节点下线,且接收到所述虚拟集群外的节点发送的集群加入请求时,向所述发送集群加入请求的节点发送集群加入邀请;
    当所述发送集群加入请求的节点回复确认信息时,与加入新增节点后的虚拟集群中的节点通过第四预设协商机制,重新确定每个节点的编号;
    若所述新增节点的编号与自己的编号相邻,则根据预设的第四区块分配规则,确定所述新增节点需要存储的区块;以及
    将所述新增节点需要存储的区块发送给所述新增节点进行存储。
  12. 根据权利要求11所述的方法,其特征在于,所述新增节点需要存储的区块为所述下线节点所存储的区块。
  13. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    当区块链网络中产生新区块时,根据预设的第五区块分配规则,确定用于存储所述新区块的节点;以及
    将所述新区块发送给确定的节点进行存储。
  14. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    当区块链网络中产生新区块时,按照预设的第六区块分配规则,确定是否需要存储所述新区块;
    若需要存储所述新区块,则存储所述新区块,若不需要存储所述新区块,则不作处理。
  15. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    当接收到查询端发送的交易查询请求时,确定是否存储有与所述交易查询请求相对应的区块;
    若存储有与所述交易查询请求相对应的区块,则根据所述交易查询请求获取查询结果;
    若未存储与所述交易查询请求相对应的区块,则将所述交易查询请求发送给虚拟集群中的其它节点;
    接收存储有与所述交易查询请求相关的区块的节点返回的交易查询结果;
    将查询结果发送给所述查询端。
  16. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    当需要执行一目标区块的合约时,确定是否存储有与所述目标区块;
    若存储有所述目标区块,则执行所述目标区块的合约;
    若未存储有所述目标区块,则从存储所述目标区块的一节点中获取所述目标区块;以及
    根据获取的所述目标区块执行合约。
  17. 根据权利要求16所述的方法,其特征在于,所述根据获取的所述目标区块执行合约的步骤包括:
    删除一存储的区块后,存储所述目标区块;
    根据存储的目标区块执行合约。
  18. 根据权利要求1所述的方法,其特征在于,所述按照预设的第一区块分配规则,对区块链中的一个或多个区块进行存储的步骤包括:
    根据自己所属的网段,确定需要存储的区块。
  19. 一种区块链存储装置,应用于区块链网络中的节点,其特征在于,包括:
    虚拟集群加入模块,被配置为通过接受集群组建邀请或发送集群组建邀请,加入一虚拟集群,所述虚拟集群中包括预设个数的节点;
    区块存储模块,被配置为按照预设的第一区块分配规则,对区块链中的一个或多个区块进行存储,以使得所述虚拟集群中的节点所存储的区块可组成完整的区块链。
  20. 根据权利要求19所述的装置,其特征在于,所述虚拟集群加入模块包括:
    邀请发送子模块,被配置为在所述节点与第一预设个数的其它节点两两相连时,则向其它节点发送集群组建邀请;
    虚拟集群组建子模块,被配置为当超过第二预设个数的节点回复确认信息时,则与回复确认信息的节点,组建成所述虚拟集群。
  21. 根据权利要求19所述的装置,其特征在于,所述虚拟集群加入模块包括:
    接收及加入子模块,被配置为接收到其它节点发送的集群组建邀请时,回复确认信息,以加入到一虚拟集群中。
  22. 根据权利要求19所述的装置,其特征在于,所述装置还包括:
    集群标号确定模块,被配置为与所述虚拟集群中的节点,通过第一预设协商机制,确定集群标号;
    其中,所述集群标识号在预设时间后失效,且所述集群标识号在预设时间失效后,在所述虚拟集群中的节点恢复为普通节点,可接受或发送集群组建邀请。
  23. 根据权利要求19所述的装置,其特征在于,所述区块存储模块包括:
    编号确定子模块,被配置为与所述虚拟集群中的节点,通过第二预设协商机制,确定每个节点的编号;
    区块存储确定子模块,被配置为根据自己的编号和区块链中每一区块对应的哈希值,确定所要存储的所述一个或多个区块;
    存储子模块,被配置为对所述一个或多个区块进行存储。
  24. 根据权利要求23所述的装置,其特征在于,所述区块存储确定子模块,被配置为将每一区块对应的哈希值分别与预设个数的常数相除,并将相除所得的余数和自身的编号满足预设条件的哈希值对应的区块进行存储,其中,所述每一区块对应的哈希值至少包括以下其中之一:每一区块的区块头的哈希值、每一区块的区块头的哈希值加上固定值后的值、每一区块的区块头和区块主体的哈希值。
  25. 根据权利要求23所述的装置,其特征在于,所述装置还包括:
    第一在线确认模块,被配置为定时向所述虚拟集群中的其它节点发送在线确认信息;以及根据是否接收到其它节点的反馈信息,确定所述虚拟集群中的其它节点是否在线。
  26. 根据权利要求23所述的装置,其特征在于,所述装置还包括:
    第二在线确认模块,被配置为定时向与自己的编号邻近的节点发送在线确认信息;以及根据是否接收到所述编号邻近的节点反馈的信息,确定所述编号邻近的节点是否在线。
  27. 根据权利要求25或26所述的装置,其特征在于,所述装置还包括:
    区块获取模块,被配置为当所述虚拟集群中有节点下线时,根据所述预设的第一区块分配规则,从相应的在线节点中获取所述下线节点所存储的区块;
    第一区块存储确定模块,被配置为根据预设的第二区块分配规则,重新确定用于存储所述下线节点所存储的区块的节点;以及将所述下线节点所存 储的区块发送给所确定的节点进行存储。
  28. 根据权利要求27所述的装置,其特征在于,所述装置还包括:
    集群加入邀请发送模块,被配置为在所述虚拟集群中有节点下线时,向所述虚拟集群外的节点发送集群加入邀请,以邀请所述虚拟集群外的节点加入所述虚拟集群;
    第一节点编号重新确定模块,被配置为当接收到所述虚拟集群外的节点回复的确认信息时,与加入新增节点后的虚拟集群中的节点通过第三预设协商机制,重新确定每个节点的编号;
    第二区块存储确定模块,被配置为根据自己的编号和预设的第三区块分配规则,确定要存储的区块。
  29. 根据权利要求27所述的装置,其特征在于,所述装置还包括:
    集群加入请求接收模块,被配置为在所述虚拟集群中有节点下线,且接收到所述虚拟集群外的节点发送的集群加入请求时,向所述发送集群加入请求的节点发送集群加入邀请;
    第二节点编号重新确定模块,被配置为在所述发送集群加入请求的节点回复确认信息时,与加入新增节点后的虚拟集群中的节点通过第四预设协商机制,重新确定每个节点的编号;
    第三区块存储确定模块,被配置为若所述新增节点的编号与自己的编号相邻,则根据预设的第四区块分配规则,确定所述新增节点需要存储的区块;以及将所述新增节点需要存储的区块发送给所述新增节点进行存储。
  30. 根据权利要求19所述的装置,其特征在于,所述装置还包括:
    第四区块存储确定模块,被配置为在区块链网络中产生新区块时,根据 预设的第五区块分配规则,确定用于存储所述新区块的节点;以及将所述新区块发送给确定的节点进行存储。
  31. 根据权利要求19所述的装置,其特征在于,所述装置还包括:
    第五区块存储确定模块,被配置为在区块链网络中产生新区块时,按照预设的第六区块分配规则,确定是否需要存储所述新区块;若需要存储所述新区块,则存储所述新区块,若不需要存储所述新区块,则不作处理。
  32. 根据权利要求19所述的装置,其特征在于,所述装置还包括:
    交易查询请求接收模块,被配置为在接收到查询端发送的交易查询请求时,确定是否存储有与所述交易查询请求相对应的区块;
    查询结果获取模块,被配置为若存储有与所述交易查询请求相对应的区块,则根据所述交易查询请求获取查询结果;
    交易查询请求发送模块,被配置为若未存储与所述交易查询请求相对应的区块,则将所述交易查询请求发送给虚拟集群中的其它节点;
    交易查询结果接收模块,被配置为接收存储有与所述交易查询请求相关的区块的节点返回的交易查询结果;
    查询结果发送模块,被配置为将查询结果发送给所述查询端。
  33. 根据权利要求19所述的装置,其特征在于,所述装置还包括:
    目标区块确定模块,被配置为在需要执行一目标区块的合约时,确定是否存储有与所述目标区块;
    第一执行模块,被配置为若存储有所述目标区块,则执行所述目标区块的合约;
    目标区块获取模块,被配置为若未存储有所述目标区块,则从存储所述 目标区块的一节点中获取所述目标区块;
    第二执行模块,被配置为根据所述目标区块获取模块获取的所述目标区块执行合约。
  34. 根据权利要求33所述的装置,其特征在于,所述第二执行模块包括:
    区块删除子模块,被配置为删除一存储的区块后,存储所述目标区块;
    执行子模块,被配置为根据存储的目标区块执行合约。
  35. 根据权利要求19所述的装置,其特征在于,所述区块存储模块,被配置为根据自己所属的网段,确定需要存储的区块。
  36. 一种节点设备,其特征在于,包括:
    处理器;
    用于存储处理器可执行指令的存储器;
    其中,所述处理器,被配置为通过接受集群组建邀请或发送集群组建邀请,加入一虚拟集群,所述虚拟集群中包括预设个数的节点;按照预设的第一区块分配规则,对区块链中的一个或多个区块进行存储,以使得所述虚拟集群中的节点所存储的区块可组成完整的区块链。
  37. 一种计算机程序产品,其特征在于,所述计算机程序产品包含能够由可编程的装置执行的计算机程序,所述计算机程序具有当由所述可编程的装置执行时用于执行权利要求1至18中任一项所述的方法的代码部分。
  38. 一种非临时性计算机可读存储介质,其特征在于,所述非临时性计算机可读存储介质中包括一个或多个程序,所述一个或多个程序用于执 行权利要求1至18中任一项所述的方法。
  39. 一种节点设备,其特征在于,包括:
    权利要求38中所述的非临时性计算机可读存储介质;以及
    一个或者多个处理器,用于执行所述非临时性计算机可读存储介质中的程序。
PCT/CN2016/111360 2016-12-21 2016-12-21 区块链存储方法、装置及节点设备 WO2018112805A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2016/111360 WO2018112805A1 (zh) 2016-12-21 2016-12-21 区块链存储方法、装置及节点设备
CN201680003223.0A CN107079059B (zh) 2016-12-21 2016-12-21 区块链存储方法、装置及节点设备

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2016/111360 WO2018112805A1 (zh) 2016-12-21 2016-12-21 区块链存储方法、装置及节点设备

Publications (1)

Publication Number Publication Date
WO2018112805A1 true WO2018112805A1 (zh) 2018-06-28

Family

ID=59624272

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/111360 WO2018112805A1 (zh) 2016-12-21 2016-12-21 区块链存储方法、装置及节点设备

Country Status (2)

Country Link
CN (1) CN107079059B (zh)
WO (1) WO2018112805A1 (zh)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110221938A (zh) * 2019-05-06 2019-09-10 深圳壹账通智能科技有限公司 电子装置、区块链共识的方法及存储介质
CN110263035A (zh) * 2019-05-31 2019-09-20 阿里巴巴集团控股有限公司 基于区块链的数据存储、查询方法及装置和电子设备
CN110493060A (zh) * 2019-08-28 2019-11-22 北京浪潮数据技术有限公司 一种虚拟ip分配方法及相关装置
CN111033491A (zh) * 2019-08-01 2020-04-17 阿里巴巴集团控股有限公司 基于纠错编码存储共享的区块链数据
CN111339089A (zh) * 2020-02-21 2020-06-26 联动优势(北京)数字科技有限公司 一种应用于区块链的数据存储与获取方法及装置
CN111767427A (zh) * 2019-04-02 2020-10-13 浙江宇视科技有限公司 视频信息存储方法及数据存储域
CN111833189A (zh) * 2018-10-26 2020-10-27 创新先进技术有限公司 数据处理方法及装置
CN111858520A (zh) * 2020-07-21 2020-10-30 杭州溪塔科技有限公司 一种区块链节点数据分离存储的方法和装置
CN112162698A (zh) * 2020-09-17 2021-01-01 北京浪潮数据技术有限公司 一种缓存分区重建方法、装置、设备及可读存储介质
CN113037497A (zh) * 2021-03-15 2021-06-25 中国工商银行股份有限公司 一种基于区块链的风险数据共享方法及系统
CN113111392A (zh) * 2021-04-12 2021-07-13 浙江永旗区块链科技有限公司 一种区块链数据同步系统及其控制方法
CN113590638A (zh) * 2021-07-20 2021-11-02 南京国准数据有限责任公司 一种基于区块链的分布式数据存储系统
CN114095240A (zh) * 2021-11-17 2022-02-25 东南大学 一种基于区块链的分布式节点协同方法
WO2023109627A1 (zh) * 2021-12-17 2023-06-22 深圳先进技术研究院 一种分布式系统的分片方法、装置、电子设备及存储介质
CN117424912A (zh) * 2023-12-14 2024-01-19 湖北省楚天云有限公司 基于区块链的物联网节点集群数据存储方法、系统及介质

Families Citing this family (42)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107733855B (zh) * 2017-08-31 2019-11-05 中国科学院信息工程研究所 一种可同时支持公有链、联盟链及私有链的区块链系统及应用方法
CN107608826A (zh) * 2017-09-19 2018-01-19 郑州云海信息技术有限公司 一种存储集群的节点的故障恢复方法、装置及介质
CN107734021B (zh) 2017-09-30 2020-04-07 深圳壹账通智能科技有限公司 区块链数据上传方法、系统、计算机系统及存储介质
CN107819829B (zh) * 2017-10-17 2020-07-07 上海点融信息科技有限责任公司 访问区块链的方法、系统、区块链节点设备及用户终端
CN107947940B (zh) * 2017-11-29 2020-12-25 树根互联技术有限公司 一种数据交换的方法及装置
CN108307000A (zh) * 2018-02-06 2018-07-20 武汉康慧然信息技术咨询有限公司 基于时间调度的区块链生成方法
CN108200203B (zh) * 2018-02-06 2020-11-06 北京奇虎科技有限公司 基于双层网络的区块链系统
CN108632386B (zh) * 2018-05-15 2021-06-08 众安信息技术服务有限公司 一种区块链节点集群搭建方法及装置
CN108777710B (zh) * 2018-05-31 2021-06-08 中国联合网络通信集团有限公司 区块链节点间通信方法、装置及区块链节点
CN108769230B (zh) * 2018-06-06 2021-06-18 腾讯科技(深圳)有限公司 交易数据存储方法、装置、服务器及存储介质
CN109005208B (zh) * 2018-06-11 2021-03-30 北京京东尚科信息技术有限公司 用于推送信息的方法和装置
CN110727391A (zh) * 2018-07-16 2020-01-24 北京京东尚科信息技术有限公司 交易数据存储方法及装置、区块链系统、介质和电子设备
CN110738472B (zh) * 2018-07-20 2023-10-03 北京航空航天大学 区块链的存储方法和区块链的节点
CN109104472B (zh) * 2018-07-26 2021-06-29 北京京东尚科信息技术有限公司 区块链网络组网方法、装置、设备及计算机可读存储介质
CN108924252B (zh) * 2018-07-31 2021-06-04 泰链(厦门)科技有限公司 区块链系统中减轻节点存储负荷的方法、介质及区块链系统
CN108650333B (zh) * 2018-07-31 2021-02-02 泰链(厦门)科技有限公司 区块链系统的分散节点负荷方法、介质、装置和区块链系统
CN109145053B (zh) 2018-08-01 2021-03-23 创新先进技术有限公司 数据处理方法和装置、客户端、服务器
CN109032803B (zh) 2018-08-01 2021-02-12 创新先进技术有限公司 数据处理方法和装置、客户端
EP3609120B1 (en) 2018-08-09 2022-04-13 Nokia Technologies Oy Distributed data storage
CN108900364B (zh) * 2018-08-22 2021-11-26 泰康保险集团股份有限公司 区块链网络的管理方法、装置、介质及电子设备
CN109068149B (zh) * 2018-09-14 2022-05-06 深圳Tcl新技术有限公司 节目推荐方法、终端以及计算机可读存储介质
CN109213901B (zh) * 2018-09-18 2020-12-01 百度在线网络技术(北京)有限公司 一种区块链的数据同步方法、装置、设备及介质
CN109377364A (zh) * 2018-09-27 2019-02-22 中国联合网络通信集团有限公司 一种建组方法和装置、交易方法和系统
CN109522362B (zh) * 2018-10-17 2020-09-15 北京瑞卓喜投科技发展有限公司 基于区块链数据的非完全数据同步方法、系统及设备
CN109522462B (zh) * 2018-10-18 2021-06-04 上海达家迎信息科技有限公司 一种基于区块链的云查询方法、装置、设备及存储介质
CN110175178B (zh) * 2018-11-01 2022-06-07 花瓣云科技有限公司 一种数据处理的方法、节点设备和系统
CN111898139B (zh) 2018-12-20 2024-04-16 创新先进技术有限公司 数据读写方法及装置、电子设备
CN109756566B (zh) * 2018-12-27 2020-01-03 重庆小雨点小额贷款有限公司 基于区块链的数据存储方法、相关设备及存储介质
CN109857805B (zh) * 2018-12-27 2020-10-02 重庆小雨点小额贷款有限公司 基于区块链的数据存储方法、相关设备及存储介质
CN111447055B (zh) * 2019-01-17 2022-02-25 华为技术有限公司 区块链账本的存储方法及装置
CN110009180B (zh) * 2019-01-23 2020-12-22 曲阜师范大学 一种基于区块链的准时生产控制方法
CN113098907B (zh) * 2019-03-05 2023-07-11 深圳前海微众银行股份有限公司 一种区块链的群组划分方法与装置
CN109862135B (zh) * 2019-03-19 2021-06-01 全链通有限公司 基于域名区块链的群组通信方法、区块链节点及介质
CN109949160A (zh) * 2019-03-27 2019-06-28 上海优扬新媒信息技术有限公司 一种区块链的分片方法及装置
CN110224839B (zh) * 2019-06-17 2020-10-30 北京瑞策科技有限公司 应用于区块链上的验证方法及装置
CN110851445B (zh) * 2019-11-07 2022-05-03 浪潮云信息技术股份公司 一种基于区块链技术的安全存储数据的方法
CN110989934B (zh) * 2019-12-05 2023-08-25 达闼机器人股份有限公司 区块链节点数据存储方法、区块链系统及区块链节点
CN111431728B (zh) * 2020-03-30 2024-02-09 腾讯科技(深圳)有限公司 一种分布式应用程序的用户群组管理方法
CN111683120A (zh) * 2020-05-22 2020-09-18 哈尔滨工程大学 一种支持验证节点动态变化的联盟节点存储方法
CN112685420A (zh) * 2020-12-31 2021-04-20 北京存金所贵金属有限公司 一种区块链数据的扩容方法、装置、调度控制器及系统
CN113260188B (zh) * 2021-05-11 2022-06-07 信安租赁(深圳)有限公司 一种区块链数据监管存储机
CN113612810B (zh) * 2021-05-18 2023-06-27 中国信息通信研究院 基于dht的集群节点间性能优化方法、电子设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7649992B2 (en) * 2006-01-06 2010-01-19 Fujitsu Limited Apparatuses for encoding, decoding, and authenticating data in cipher block chaining messaging authentication code
CN105653315A (zh) * 2015-12-23 2016-06-08 北京工业大学 一种基于区块链技术的节点化操作系统下载方法
CN105790954A (zh) * 2016-03-02 2016-07-20 布比(北京)网络技术有限公司 一种构建电子证据的方法和系统
CN105912618A (zh) * 2016-04-07 2016-08-31 浙江万马新能源有限公司 基于区块链的充电桩充电交易通讯方法及装置
CN106100981A (zh) * 2016-08-22 2016-11-09 布比(北京)网络技术有限公司 社交网络数据交互方法及装置
CN106209947A (zh) * 2015-05-07 2016-12-07 中兴通讯股份有限公司 一种去中心化自治组织的数据处理方法及系统

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140007004A1 (en) * 2012-06-29 2014-01-02 Nokia Corporation Method and apparatus for task chaining
CN105976231A (zh) * 2016-06-24 2016-09-28 深圳前海微众银行股份有限公司 基于区块链智能合约的资产管理方法及节点

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7649992B2 (en) * 2006-01-06 2010-01-19 Fujitsu Limited Apparatuses for encoding, decoding, and authenticating data in cipher block chaining messaging authentication code
CN106209947A (zh) * 2015-05-07 2016-12-07 中兴通讯股份有限公司 一种去中心化自治组织的数据处理方法及系统
CN105653315A (zh) * 2015-12-23 2016-06-08 北京工业大学 一种基于区块链技术的节点化操作系统下载方法
CN105790954A (zh) * 2016-03-02 2016-07-20 布比(北京)网络技术有限公司 一种构建电子证据的方法和系统
CN105912618A (zh) * 2016-04-07 2016-08-31 浙江万马新能源有限公司 基于区块链的充电桩充电交易通讯方法及装置
CN106100981A (zh) * 2016-08-22 2016-11-09 布比(北京)网络技术有限公司 社交网络数据交互方法及装置

Cited By (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111833189A (zh) * 2018-10-26 2020-10-27 创新先进技术有限公司 数据处理方法及装置
CN111767427A (zh) * 2019-04-02 2020-10-13 浙江宇视科技有限公司 视频信息存储方法及数据存储域
CN111767427B (zh) * 2019-04-02 2024-04-05 浙江宇视科技有限公司 视频信息存储方法及数据存储域
CN110221938A (zh) * 2019-05-06 2019-09-10 深圳壹账通智能科技有限公司 电子装置、区块链共识的方法及存储介质
CN110263035B (zh) * 2019-05-31 2023-10-27 创新先进技术有限公司 基于区块链的数据存储、查询方法及装置和电子设备
CN110263035A (zh) * 2019-05-31 2019-09-20 阿里巴巴集团控股有限公司 基于区块链的数据存储、查询方法及装置和电子设备
CN111033491A (zh) * 2019-08-01 2020-04-17 阿里巴巴集团控股有限公司 基于纠错编码存储共享的区块链数据
CN111033491B (zh) * 2019-08-01 2023-06-30 创新先进技术有限公司 基于纠错编码存储共享的区块链数据
CN110493060A (zh) * 2019-08-28 2019-11-22 北京浪潮数据技术有限公司 一种虚拟ip分配方法及相关装置
CN111339089B (zh) * 2020-02-21 2023-09-22 联动优势科技有限公司 一种应用于区块链的数据存储与获取方法及装置
CN111339089A (zh) * 2020-02-21 2020-06-26 联动优势(北京)数字科技有限公司 一种应用于区块链的数据存储与获取方法及装置
CN111858520A (zh) * 2020-07-21 2020-10-30 杭州溪塔科技有限公司 一种区块链节点数据分离存储的方法和装置
CN111858520B (zh) * 2020-07-21 2024-03-22 杭州溪塔科技有限公司 一种区块链节点数据分离存储的方法和装置
CN112162698A (zh) * 2020-09-17 2021-01-01 北京浪潮数据技术有限公司 一种缓存分区重建方法、装置、设备及可读存储介质
CN112162698B (zh) * 2020-09-17 2024-02-13 北京浪潮数据技术有限公司 一种缓存分区重建方法、装置、设备及可读存储介质
CN113037497A (zh) * 2021-03-15 2021-06-25 中国工商银行股份有限公司 一种基于区块链的风险数据共享方法及系统
CN113037497B (zh) * 2021-03-15 2023-08-01 中国工商银行股份有限公司 一种基于区块链的风险数据共享方法及系统
CN113111392A (zh) * 2021-04-12 2021-07-13 浙江永旗区块链科技有限公司 一种区块链数据同步系统及其控制方法
CN113111392B (zh) * 2021-04-12 2022-08-30 浙江永旗区块链科技有限公司 一种区块链数据同步系统及其控制方法
CN113590638A (zh) * 2021-07-20 2021-11-02 南京国准数据有限责任公司 一种基于区块链的分布式数据存储系统
CN114095240B (zh) * 2021-11-17 2023-12-01 东南大学 一种基于区块链的分布式节点协同方法
CN114095240A (zh) * 2021-11-17 2022-02-25 东南大学 一种基于区块链的分布式节点协同方法
WO2023109627A1 (zh) * 2021-12-17 2023-06-22 深圳先进技术研究院 一种分布式系统的分片方法、装置、电子设备及存储介质
CN117424912A (zh) * 2023-12-14 2024-01-19 湖北省楚天云有限公司 基于区块链的物联网节点集群数据存储方法、系统及介质
CN117424912B (zh) * 2023-12-14 2024-04-05 湖北省楚天云有限公司 基于区块链的物联网节点集群数据存储方法、系统及介质

Also Published As

Publication number Publication date
CN107079059B (zh) 2019-12-10
CN107079059A (zh) 2017-08-18

Similar Documents

Publication Publication Date Title
WO2018112805A1 (zh) 区块链存储方法、装置及节点设备
WO2022105498A1 (zh) 一种基于区块链网络的数据处理方法、装置、计算机设备以及计算机可读存储介质
US7978631B1 (en) Method and apparatus for encoding and mapping of virtual addresses for clusters
CN113259455B (zh) 跨子网交互方法及装置
US9191219B2 (en) Network multicast peer discovery methods
CN113259460B (zh) 跨链交互方法及装置
US10749949B2 (en) Dynamic content distribution protocol for an enterprise environment
CN111338806B (zh) 一种业务控制方法及装置
WO2010127618A1 (zh) 一种实现流媒体内容服务的系统和方法
CN112995211B (zh) 基于区块链网络的数据处理方法、装置、设备及存储介质
CN112200681B (zh) 区块链网络的业务处理方法、信息处理方法及节点设备
CN113067902B (zh) 区块链消息的传输方法及装置
US9871754B2 (en) Communicating messages between publishers and subscribers in a mesh routing network
CN113098982B (zh) 区块链消息的传输方法及装置
CN113259457B (zh) 区块链子网的信息同步方法及装置
Cherupally et al. Lightweight and Scalable DAG based distributed ledger for verifying IoT data integrity
CN108933804B (zh) 一种对等网络构建方法和装置
WO2023124743A1 (zh) 区块同步
WO2023124744A1 (zh) 跨子网交互
CN101605094B (zh) 基于点对点网络的环模型及其路由算法
WO2023082883A1 (zh) 跨区块链处理事务的方法、装置、计算机设备、计算机存储介质及计算机程序产品
WO2023184917A1 (zh) 算力信息的处理方法、处理系统及算力网关
JP2008269141A (ja) オーバレイ検索装置、オーバレイ検索システム、オーバレイ検索方法およびオーバレイ検索用プログラム
CN113067838B (zh) 跨链交互方法及装置
JP2009230686A (ja) コンテンツ管理サーバ及びコンテンツ管理プログラム

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16924498

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC , EPO FORM 1205A DATED 16.10.19.

122 Ep: pct application non-entry in european phase

Ref document number: 16924498

Country of ref document: EP

Kind code of ref document: A1