Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that, if not conflicted, the various features of the embodiments of the invention may be combined with each other within the scope of protection of the invention. Additionally, while functional block divisions are performed in apparatus schematics, with logical sequences shown in flowcharts, in some cases, steps shown or described may be performed in sequences other than block divisions in apparatus or flowcharts. The terms "first", "second", "third", and the like used in the present invention do not limit data and execution order, but distinguish the same items or similar items having substantially the same function and action.
Fig. 1 is a schematic view of an application scenario of a distributed blockchain system according to an embodiment of the present invention, as shown in fig. 1, a distributedblockchain system 100 includes aclient 11 and ablockchain network 12, where theclient 11 is in communication connection with theblockchain network 12, where the communication mode includes a wireless communication mode or a wired communication mode supporting any suitable communication protocol.
Theclients 11 are used to communicate with theblockchain network 12 to complete relevant business logic, such as transactions, synchronizing data, retrieving query data, uploading data, and the like. In some embodiments, theclient 11 comprises a smartphone, tablet, laptop or desktop computer, or the like.
Theblockchain network 12 includes various nodes serving as various service roles in a blockchain system, as shown in fig. 1, the various nodes include ablock exit node 121, anauthoritative node 122 and acommon node 123, and theblock exit node 121, theauthoritative node 122 and thecommon node 123 are in communication connection with each other.
The out-block nodes 121 are configured to recognize the superblock, and when the common knowledge passes through the superblock, the superblock is written into theauthority nodes 122, where the number of the out-block nodes 121 may be multiple, and the out-block nodes 121 may use any suitable common knowledge algorithm to complete the common knowledge of the superblock, such as a long-old community common knowledge mechanism, a workload certification (Proof of Work, PoW), a rights and interests certification (Proof of behaviour, POS), a shares certification (release of behaviour, DPoS), a Practical Bypath Fault Tolerance (PBFT), a licensed bypath Fault Tolerance (DBFT), and the like.
The superblocks described herein may be blocks of any suitable data type, any suitable data size, and no undue restrictions are imposed on the data type and/or data size of the superblocks herein.
Theauthoritative node 122 is used for storing the super blocks passed by the consensus of the block-outnodes 121, and generally, theauthoritative node 122 is written into the super blocks earliest and is a node determined by the consensus algorithm of each block-outnode 121, so that the super blocks locally stored by theauthoritative node 122 have the highest authenticity, wherein the number of theauthoritative nodes 122 may be multiple.
Thecommon node 123 is a node with an accounting function, and can initiate an accounting book transaction and record a block, and can also record a super block from other nodes synchronously to update a local accounting book.
It will be appreciated that in some embodiments, some nodes in theblockchain network 12 may concurrently assume multiple business roles, e.g., the out-of-blockchain node 121 may not only commonly identify superblocks, but may also have accounting or transaction functions, and therefore, in this context, no undue restrictions are made on the business logic that the blockchain node is capable of performing. In some embodiments, a tile link point may comprise a smartphone, tablet, laptop, desktop, or server, among others.
As an aspect of the embodiments of the present invention, an embodiment of the present invention provides a method for generating a block distributed block chain. Referring to fig. 2, the block distributed block chain generating method S200 includes:
s21, packing the service data into candidate blocks;
in this embodiment, the service data may be data in any suitable service scenario, and the data content may be content in any form, for example, in the transaction scenario, the service data is transaction data of both parties, and the data content is content of a payer, a payee, a payment amount, and the like, or in order to prevent a certain technical data from being lost and unable to effectively restore a certain technology, in the important data storage scenario, the service data is important technical data of an industry, and the data content is technical content capable of restoring the industry or a certain technical segment. In this embodiment, the candidate block is a block to be identified.
In some embodiments, before packing the service data into the candidate block, it may be determined whether the service data meets a preset packing condition, if so, the service data is packed into the candidate block, if not, another group of service data is continuously obtained or the service data is waited to meet the preset packing condition. For another example, if the data amount of the current service data is smaller than the preset data threshold, the service data needs to be waited for to be equal to or larger than the preset data threshold, so that the service data can be packed into the candidate block.
S22, identifying the candidate blocks in a consensus mode to obtain a super block;
in this embodiment, any suitable consensus algorithm may be used to consensus the candidate blocks, which is similar to the above-mentioned consensus algorithms, and is not described herein again.
In this embodiment, the super block includes a block header and a block body, wherein, as mentioned above, the super block may be a block of any suitable data type and any suitable data size.
And S23, writing a specified number of superblocks into at least one authoritative node, wherein superblocks of different block heights can form a block distributed block chain.
In this embodiment, the block chain network defines the number of super blocks written into the authority node by the block node as a designated number, and the block node writes the designated number of super blocks into the same authority node according to the convention rule, where the designated number may be one or more than two, and the block heights of the super blocks written into the same authority node may be different.
In this embodiment, in the blockchain network, the number of authoritative nodes may be multiple, and super blocks with different block heights may be stored in different authoritative nodes, or may be stored in the same authoritative node.
It can be understood that the number of authoritative nodes written into a given number of superblocks may be one or more than two, and when more than two authoritative nodes are written into, the superblocks can be stored more safely, the risk that a certain authoritative node is maliciously attacked and the superblocks cannot be provided normally is reduced, and the efficiency of synchronizing the superblocks is also improved.
In this embodiment, superblocks stored by different authoritative nodes or superblocks of the same authoritative node are interlocked, so as to form a block distributed block chain.
For example, referring to fig. 3a, authority node 1-1 writes a super block with a block height of 1, authority node 2-1 writes a super block with a block height of 2, authority node 3-1 writes a super block with a block height of 3, and so on, so in fig. 3a, each authority node writes one super block, and the super blocks of each authority node form an interlocking relationship with each other, thereby forming a block distributed block chain.
For another example, referring to fig. 3b, the authority node 1-1, the authority node 1-2, and the authority node 1-3 all write a super block with a block height of 1, the authority node 2-2, and the authority node 2-3 all write a super block with a block height of 2, the authority node 3-1, the authority node 3-2, and the authority node 3-3 all write a super block with a block height of 3, and so on, so in fig. 3b, the super blocks with the same block height are respectively written into a plurality of authority nodes, each authority node writes into a super block, and the super blocks of each authority node form an interlocking relationship with each other, thereby forming a block distributed block chain.
For example, referring to fig. 3c, the authority node 1-1 writes superblocks with block heights of 1 and 2, the authority node 2-1 writes superblocks with block heights of 3 and 4, the authority node 3-1 writes superblocks with block heights of 5 and 6, and so on, so that in fig. 3c, each authority node writes two superblocks with consecutive block heights, and the superblocks of each authority node and the superblocks of the same authority node form an interlocking relationship with each other, thereby forming a block distributed block chain.
For example, referring to fig. 3d, a plurality of authority nodes 1-1 all write super blocks with block heights of 1 and 2, a plurality of authority nodes 2-1 all write super blocks with block heights of 3 and 4, a plurality of authority nodes 3-1 all write super blocks with block heights of 5 and 6, and so on, so in fig. 3d, a plurality of authority nodes write two super blocks with continuous block heights, and the super blocks of each authority node and the super blocks of the same authority node form an interlocking relationship with each other, thereby forming a block distributed block chain.
It is understood that the super block written into the authority node may be multiple, and multiple authority nodes 1-1 write the super blocks with block heights of 1, 2 and 3 respectively.
It is further understood that the block heights of the superblocks written to the same authoritative node may be continuous or discontinuous, the block chain network may self-agree on block writing rules, and each out-block node may complete writing of the superblock according to the block writing rules. As shown in fig. 3e, a plurality of authority nodes 1-1 write super blocks with block heights of 1 and 3, a plurality of authority nodes 2-1 write super blocks with block heights of 2 and 4, a plurality of authority nodes 3-1 write super blocks with block heights of 5 and 7, and so on, so in fig. 3e, a plurality of authority nodes write two super blocks with discontinuous block heights, and the super blocks of each authority node and the super blocks of the same authority node form an interlocking relationship with each other, thereby forming a block distributed block chain.
According to the embodiments, compared with the existing block chain, the method can break the existing block chain, dispersedly store the super blocks, the dispersed super blocks can form the block distributed block chain, when the block distributed block chain is synchronized by the following related accounting nodes, the whole block chain does not need to be synchronized as in the prior art, and only the corresponding super blocks need to be accounted according to the self requirements, so that the use efficiency of the block chain is improved. And on the premise of improving the flexibility of the storage blocks, the distributed block chain of the blocks provided by the embodiment can be ensured to have the characteristics of decentralization, transparency and no tampering. Even along with the increase of the service time of the block chain, the embodiment can balance and coordinate the storage capacity of the accounting node, and avoid the situation that the accounting node stores too much block data to cause breakdown or quit accounting.
In addition, the existing block chain depends on the timed block output of the accounting content, so that the block is idle and full, and the operation benefit is poor.
In some embodiments, after each authority node stores a specified number of superblocks, configured in a closed mode in which it is prohibited from receiving other superblocks, the superblocks are in read-only mode.
The read-only mode is a mode that the data of the super block can only be read but modification, deletion or updating is forbidden.
In some embodiments, after each authoritative node enters the closed mode, although it prohibits writing other blocks, it may also receive writing of auxiliary data other than blocks, for example, the auxiliary data includes address information of other authoritative nodes and the block height of the super block.
Therefore, as the authority node enters the closed mode, the super blocks can be prevented from being added or deleted due to malicious attack on the authority node, and the order, the safety and the stability of the block distributed block chain are favorably maintained. And moreover, the super block enters a read-only mode after being written into the authority node, so that malicious nodes are prevented from tampering or deleting the super block, and the data stability and the security of the super block are maintained.
In some embodiments, the number of superblocks with different block heights is 1, and the superblocks with different block heights are distributed in different authoritative nodes to form a block distribution type block chain, that is, the block chain structure is as shown in fig. 3a, and by adopting the block chain structure, the real-time performance of the block chain can be improved, which is beneficial to enhancing the safety and transparency of the block chain.
For more secure and reliable shaping of the block distributed block chain, please refer to table 1 in some embodiments:
TABLE 1
As shown in table 1, the super block includes a block body including service data and a parent node list, the block header includes a block height, a parent block hash and a block body hash, and the parent node list includes node information of each parent node at the same block height.
In this embodiment, the parent node list is a list including node information of each parent node at the same block height, where the block height is an arrangement height of the current superblock in the bdl, the parent block hash is a hash of a block arranged in the bdl and ahead of the current superblock, and the block hash is used to anchor each data in the block, and in some embodiments, the block hash may be a hash of all data in the block, and may also include the service data hash and the parent node list hash, please refer to table 2:
TABLE 2
As shown in table 2, the service data hash is a hash of the service data in the zone block, and the parent node list hash is a hash of the parent node list in the zone block. Since the block hash is divided into the service data hash and the parent node list hash, when the super block is verified subsequently, the method can be beneficial to other nodes to reliably and safely verify the validity of the super block in a multi-dimensional manner.
As shown in table 1 or table 2, the father node is the authority node where the parent superblock of the current superblock is located, that is, in some embodiments, the block height difference between the parent superblock and the current superblock is 1, for example, referring to fig. 3b, the second superblock with block height of 1 is the parent superblock of the first superblock with block height of 2, that is, the second superblock and the first superblock are in a parent-child relationship, and therefore, the authority node 1-1 is the father node of the authority node 2-1.
In some embodiments, since the parent node list includes node information of each supernode at the same block height, when the validity of the current super block is verified at a later stage, the block link point may extract node information of each supernode in the parent node list from the current super block, obtain the parent super block according to the node information of the supernode, calculate a parent block hash of the parent super block, compare the parent block hash with the parent block hash of the current super block, if the parent block hash is consistent with the parent block hash of the current super block, the current super block is legal at the point, and if the parent block hash is inconsistent with the parent block hash, the current super block is illegal. Therefore, by adopting the method, the block distributed block chain can be shaped more safely and reliably.
In some embodiments, the node information of each authoritative node includes a node hash and/or a node public key, the node hash of the authoritative node is used for identifying the authoritative node, the node hash may be a hash of a device serial number of the authoritative node, or may be calculated according to a hash algorithm from a character or a character string representing the device information of the authoritative node, or may be a hash representing an address of the authoritative node, and at a later stage, other block chain nodes may access the authoritative node according to the node information of the authoritative node. The node public key is used for assisting in verifying the validity of the related service participated by the authoritative node, wherein the node public key of the authoritative node can be broadcasted in the block chain network, and the node public key of the authoritative node can be obtained by the related block chain node.
In some embodiments, the block header of the superblock includes a node signature of the out-of-block node, and subsequent related nodes may verify the validity of the superblock based on the node signature of the out-of-block node.
Typically, the data in the blocks of an existing blockchain is consistent, e.g., in an existing blockchain, both block chain node a1 and block link point a2 hold the same block book, which includes block S with a block height of 100, wherein, the block S withblock height 100 at block link point a1 and the block S withblock height 100 at block link point a2 are the same, i.e. the data of both blocks are identical, however, because superblocks of the block distributed block chain are stored in different authoritative nodes in a scattered manner, the authoritative nodes do not store all blocks on the block chain as in the existing block chain, the relationship between a current block and a local node or a father node cannot be effectively reflected in the block distributed block chain by the block structure, and the superblocks are easily attacked by subsequent blocks or malicious nodes which cannot be verified efficiently.
Thus, in some embodiments, the superblock block further includes a data variable area, the data of the data variable area in each superblock may be inconsistent at the same block height, and the data of the data variable area may be variable before the superblock is linked and may not be variable after the superblock is linked, for example, superblock B1 is written to authoritative node C1, which includes data variable area D1. Superblock B2 writes to authority node C2, which includes data variable region D2.
Superblock B3 writes to authority node C3, which includes data variable region D3. The block heights of superblocks B1, B2 and B3 are all 150, the data in data variable region D1 is consistent with the data in data variable region D2, and the data in data variable region D1 is inconsistent with the data in data variable region D3.
Data in data variable region D1 may be modified, updated or deleted before superblock B1 is written to authority node C1, i.e., superblock B1 is linked to the block-distributed blockchain, and after being written to authority node C1, i.e., superblock B1 is linked to the block-distributed blockchain, at which time the data in data variable region D1 is immutable, e.g., superblock B1 is configured to enter a read-only mode. For superblocks B2 and B3, the data change of the data variable region can be deduced according to the reasoning described above, and will not be described herein.
Therefore, the super block is additionally provided with the data variable area, so that the forming relationship of the super block in the block distributed block chain can be more flexibly and comprehensively described, and the use efficiency, the operation efficiency and the safety of the block distributed block chain are improved.
It will be appreciated that the content representation of the data variable regions in each superblock can be logically derived and self-determined by those skilled in the art in light of the disclosure herein.
In some embodiments, the data variable region includes local feature data associated with the local node, the local feature data being used to represent features of the local superblock and/or the local node, wherein the local node may be not only a local authority node, but also any role node that holds the superblock, for example, in a normal node holding superblock, the data variable region includes the local feature data.
In some embodiments, please refer to table 3:
TABLE 3
In table 3, the chunk hash is a hash of the service data, a hash of the parent node list, or a hash calculated by the service data and the parent node list together.
As shown in table 3, the local feature data includes a local node field for indicating local node information for storing the superblock and/or a local block source field for indicating source node information for the superblock.
For example, superblock E1 is stored in regular node F1, and its local node field is used to indicate node information of regular node F1. Superblock E2 is stored in authoritative node F2, and its local node field is used to represent the node information for authoritative node F2.
Assuming that the normal node F1 synchronizes superblock E2 from the daughtercard F2 to obtain a local superblock E1, since superblock E1 is derived from superblock E2, the authoritative node F2 is the source node of the normal node F1, and thus, the local block source field is used to represent node information of the authoritative node F2.
Further assuming that the superblock E3 is stored in the regular node F3, wherein the regular node F3 synchronizes the superblock E1 from the regular node F1, thereby obtaining the local superblock E3, since the superblock E3 is originated from the superblock E1, the regular node F1 is a source node of the regular node F3, and thus, the local block source field is used to indicate node information of the regular node F1. It will be appreciated that when the local node is an authoritative node, the local block source field is empty.
Therefore, by adopting the method, when the number of synchronization times of a certain super block is more, each super block can also form a certain degree of interlocking relation based on the local characteristic data, if the data of the local super block is maliciously modified by a certain block chain node, the next block chain node of the super block is synchronized, except for the verification according to the method provided above, the super block can also be verified through the local characteristic data, if the super block is verified to be illegal, the related block chain node having inheritance relation with the super block can be easily locked through the local characteristic data, the investigation is carried out from the related block chain node, and the investigation result is broadcasted in the block chain network, so that the corresponding block chain node can execute corresponding safe operation, and the block distributed block chain can be effectively and safely maintained and operated.
In some embodiments, the local node field comprises a local node hash and/or a local block priority and/or a local node public key and/or a local signature field of the local node.
The local node hash includes a hash of the device information and/or the node address of the local node.
The local block priority is used to indicate the priority of each super block with the same block height stored by the corresponding node, wherein the local block priorities of different super blocks with the same block height at different nodes may be the same or different.
For example, the super block G1 is stored in the authority node H1, the super block G2 is stored in the normal node H2, the super block G3 is stored in the normal node H3, and the super block G4 is stored in the normal node H4, wherein the super block G2 and the super block G3 are obtained by synchronizing the super block G3 of the authority node H3 with the normal node H3 respectively, and the super block G3 is obtained by synchronizing the super block G3 of the normal node H3 with the normal node H3, so that, although the block heights of the super block G3, the super block G3 and the super block G3 are the same, the local block priority of the super block G3 is higher than that of the super block G3 and the super block G3, the local block priority of the super block G3 is the same as that of the super block G3, and the super block G3 needs synchronization with the super block H3, superblock G1 of authority node H1 may be prioritized for synchronization.
The local node public key is used for assisting in verifying the validity of a related service participated by the local node, wherein the node public key of the local node can be broadcasted in the block chain network, and the node public key of the local node can be obtained by the related block chain node.
The local signature field is the signature of the local node on the data in the data variable area except the local signature field, and other subsequent block chain nodes can verify whether the data in the data variable area is tampered or not through the local signature field, so that the method is favorable for efficiently and safely checking the data in the data variable area on the premise that the data variable area is added to the super block.
In some embodiments, the local superblock origin field includes an inheritance field for indicating node information of an inheritance node corresponding to the superblock to be inherited and/or a root origin field for indicating node information of a root origin node corresponding to the local superblock, the root origin node being the node that retroactively stores the local superblock earliest.
For example, as previously described, for superblock G2 or superblock G3, superblock G1 is the superblock that is inherited, and thus authority node H1 is the successor of normal node H2 and normal node H3. Similarly, for superblock G4, superblock G3 is the inherited superblock, so ordinary node H3 is the inherited node of ordinary node H4, and therefore, in superblock G4 of ordinary node H4, the node information written in the inherited field is the node information of ordinary node H3.
For another example, assume that regular node H5 synchronizes superblock G1 of authoritative node H1, resulting in superblock G5. The ordinary node H6 synchronizes the super block G4 of the ordinary node H4 to obtain a super block G6, the ordinary node H7 synchronizes the super block G6 of the ordinary node H6 to obtain a super block G7, and the ordinary node H8 synchronizes the super block G7 of the ordinary node H7 to obtain a super block G8. For the normal node H8, the superblock G8 is a local superblock, the synchronization path of the superblock G8 is G8-G7-G6-G4-G3-G1, and the superblock G1 is stored in the authoritative node H1, so that the node that can retroactively store the superblock G8 is the authoritative node H1, that is, the authoritative node H1 is the root node, and therefore, in the superblock G8 of the normal node H8, the node information written in the root field is the node information of the authoritative node H1.
Assuming that the normal node H4 storing the superblock G4 disappears in the blockchain network, for example, the normal node H4 is crashed off-line by malicious attack or lost by physical destruction, and therefore, the superblock G4 also disappears following the disappearance of the normal node H4, and as for the superblock G8, when the normal node H8 traces back to the superblock G6 of the normal node H6, the origin of the superblock G8 cannot be traced back, and therefore, the normal node H8 can trace back that the node storing the superblock G8 earliest is the normal node H6, that is, the normal node H6 is the root node, and therefore, in the superblock G8 of the normal node H8, the node information written in the root field is the node information of the normal node H6.
Therefore, by adding the inheritance field and/or the root field, the synchronization path of the corresponding superblock can be simply, reliably, comprehensively and safely restored under the block distributed storage form, and the block distributed block chain can be more effectively and safely maintained.
In some embodiments, the node information of the inheritance node comprises the inheritance node hash and/or the inheritance node priority and/or the inheritance node public key and/or the local signature field of the inheritance node, and the local signature field of the inheritance node is a signature of the local node on data in the data variable region except the local signature field of the inheritance node. And/or the node information of the root node comprises the hash of the root node and/or the priority of the root node and/or the public key of the root node and/or the local signature field of the root node, and the local signature field of the root node is the signature of the local node on the data except the local signature field of the root node in the data variable region.
In some embodiments, a block synchronization method may also be provided herein based on a block distributed block chain. Referring to fig. 4a, the block synchronization method S400 includes:
s41, sending a data synchronization command to a plurality of nodes, wherein each node stores super blocks with the same block height;
s42, acquiring local block priority returned by each node;
s43, determining a target node according to the local block priority of each node;
and S44, synchronizing the superblock of the target node.
In this embodiment, the data synchronization command is used to request the plurality of nodes to return the local block priority of the local superblock, so as to synchronize the corresponding superblocks. And each node receives the data synchronization instruction, analyzes the data synchronization instruction, extracts the local block priority of the local super block according to the analysis result and returns the local block priority. Here, the node may be a node of any suitable role, such as a normal node or an out-of-block node.
In this embodiment, the local block priority may be represented by any suitable character or character string, for example, the local block priority is represented by an arabic numeral, wherein the smaller the number, i.e., the smaller the local block priority, the higher the priority of the super block synchronized by the corresponding node, e.g., the local block priority is 0, and the highest priority of the first super block synchronized is. If the local block priority is 1, the priority of the synchronized second super block is lower than that of the first super block, and although the block heights of the first super block and the second super block are the same, if the electronic device needs to synchronize the super blocks, the first super block can be preferentially selected for synchronization according to the local block priority of the first super block or the second super block.
Typically, the superblock stored in the authoritative node is highest in priority, e.g., the local block written to the local node field has a priority of 0.
In this embodiment, the electronic device may determine the target nodes according to the local zone priorities of the nodes, in combination with any suitable rule or algorithm, where the number of the target nodes may be one or more than two.
In this embodiment, when synchronizing the superblock of the target node, the electronic device may synchronize all or part of the data of the superblock.
Generally, the electronic device selects the super block with high security as much as possible for synchronization through the local block priority, and avoids the existence of tampering behavior and unsafe super blocks in synchronization as much as possible, so that the security and reliability of data synchronization of the distributed block chain are improved.
In addition, the electronic equipment can select the storage quantity of the super blocks according to the storage capacity of the electronic equipment, all the super blocks do not need to be stored, and the hidden danger that the current system breaks down in time is solved. The electronic equipment can select the super block with the corresponding block height for storage according to the self requirement, does not need to start storage from the head, and can centralize the resource service and the related direction thereof.
In some embodiments, referring to fig. 4b, S43 includes:
s431, judging whether the super block with the highest priority exists in each node according to the local block priority of each node;
s432, if yes, selecting the node of the super block with the highest priority as a target node;
and S433, if not, continuously determining the target node according to the local block priority returned by each node.
For example, referring to fig. 4c, the electronic device 4-0 broadcasts a data synchronization command to the blockchain network, wherein the data synchronization command encapsulates a target block height of the super block to be synchronized, for example, the target block height is 120, i.e., the electronic device 4-0 needs the super block with the synchronization block height of 120. And the corresponding node in the block chain network receives the data synchronization instruction and analyzes the data synchronization instruction to obtain the height of the target block. And the corresponding node searches whether the super block highly matched with the target block is stored locally or not, responds to the data synchronization instruction if the super block is stored, returns the priority of the local block to the electronic equipment 4-0, and does not respond to the data synchronization instruction if the super block is not stored.
As shown in fig. 4c, the authoritative node 4-1, the normal node 4-2, the normal node 4-3, and the normal node 4-4 all return local block priorities to the electronic device, where the local block priority of the authoritative node 4-1 is 0, the local block priorities of the normal node 4-2 and the normal node 4-3 are 1, and the local block priority of the normal node 4-4 is 2.
The electronic device traverses the superblock with the highest priority according to the local block priority of each node, that is, the node corresponding to the superblock with the highest priority is the authoritative node 4-1, so that the electronic device selects the authoritative node 4-1 as the target node and synchronizes the superblock of the authoritative node 4-1.
It can be understood that, different from the above embodiment, the electronic device may locally maintain a synchronization node list, where the synchronization node list includes block heights and node addresses of each node, and when the electronic device needs to synchronize a super block with a certain block height, the electronic device may query the synchronization node list, extract the node addresses of the nodes with the same block height from the synchronization node list, and send a data synchronization instruction to a plurality of nodes, where the plurality of nodes all store the super block with the same block height.
It can be understood that, considering that the authoritative node or the high-priority node is in an offline state and fails to respond to the data synchronization instruction in time, or is attacked by a malicious attack and shielded outside the blockchain network, when the electronic device sends the data synchronization instruction, the authoritative node or the high-priority node also fails to return the local block priority in time, and therefore, the local block priority of the authoritative node or the local block priority of the high-priority node may not exist in the local block priorities of the nodes received by the electronic device.
Assuming that the authoritative node 4-1 is in the offline state and cannot return thelocal tile priority 0 to the electronic device in fig. 4c, in order to continue synchronizing the superblocks normally and orderly, the electronic device continues to determine the target node according to the local tile priorities returned by the normal node 4-2, the normal node 4-3 and the normal node 4-4, for example, the electronic device may select the normal node 4-2 and/or the normal node 4-3 as the target node.
In some embodiments, referring to fig. 4d, S433 includes:
s4331, arranging the nodes according to the priority order of the priority of each local block;
s4332, selecting the nodes with the priorities closest to the highest priority as target nodes.
For example, referring to FIG. 4e, as mentioned above, the authoritative node 4-1 is offline and cannot return thelocal block priority 0 to the electronic device, but the regular nodes 4-2 and 4-3 … … all return the local block priority to the electronic device, the regular nodes 4-1, 4-2 and 4-3 … … all store super blocks with the same block height, the local block priorities of the regular nodes 4-2 and 4-3 are all 1, the local block priority of the regular nodes 4-4 is 2, the local block priority of the regular nodes 4-5 is 3, the local block priorities of the regular nodes 4-6 and 4-7 are all 4, and the local block priorities of the regular nodes 4-8 and 4-7 are all 4, The local tile priorities of 4-9 are all 5.
The electronic device arranges the common node 4-2 and the common node 4-3 … … according to the priority order from high to low (or from low to high), to obtain:
{(4-2,1),(4-3,1),(4-4,2),(4-5,3),(4-6,4),(4-7,4),(4-8,5),(4-9,5),}。
assuming that the designated number is 1, since the priorities of the normal node 4-2 and the normal node 4-3 are the priorities closest to the authority node 4-1, the electronic device may select the normal node 4-2 or the normal node 4-3 as the target node, and then the electronic device may select the superblock of the normal node 4-2 or the normal node 4-3 for synchronization.
Assuming that the designated number is 4, since the priorities of the ordinary node 4-2, the ordinary node 4-3, the ordinary node 4-4, and the ordinary node 4-5 are all the priorities closest to the authoritative node 4-1 in sequence, the electronic device selects the ordinary node 4-2, the ordinary node 4-3, the ordinary node 4-4, and the ordinary node 4-5 as target nodes, and thus the electronic device can select a superblock of any one of the ordinary node 4-3, the ordinary node 4-4, and the ordinary node 4-5 for synchronization.
In some embodiments, in order to synchronize the superblock more securely, when the number of target nodes is at least two or more, before performing S44, referring to fig. 4f, the block synchronization method S400 further includes:
s45, judging whether the block head hashes of the superblocks in the target nodes are consistent, if yes, entering S44, and if not, executing S46;
and S46, continuously determining the target node.
In this embodiment, the block header hash may be a hash obtained by performing a hash operation on all data of the block header in the super block, or may be a parent block hash, a block hash, or the like in the block header.
In this embodiment, when the hash of the block headers of the superblocks in the target nodes is inconsistent, it indicates that the block data of one or more target nodes is tampered, and since the electronic device cannot acquire the data of the safe and reliable area blocks, the electronic device cannot synchronize the superblocks of the target nodes at this time.
For example, please refer to fig. 4e, the designated number is 4, if the hash of the block headers of the normal node 4-2, the normal node 4-3, the normal node 4-4, and the normal node 4-5 are not consistent, the electronic device does not select the normal node 4-2, the normal node 4-3, the normal node 4-4, and the normal node 4-5 as the target node, which is helpful to enhance the security and reliability of the block synchronization on the premise that the electronic device cannot acquire the super block with the highest priority, i.e., cannot directly access the authoritative node.
In some embodiments, referring to fig. 4g, S44 includes:
s441, synchronizing the block height, the parent block hash and the block hash of the block head in the super block to the block head of the local super block;
s442, synchronizing the service data of the block in the super block and the father node list in the block of the local super block;
s443, updating the data variable area of the local superblock, so that the priority of the local block priority of the updated local superblock is lower than the priority of the local block priority of the target node.
For example, in superblock Q1 of the target node, the block height, parent block hash, and block hash are H0, W0, and W1, respectively, and when the electronic device generates local superblock Q2, the block height, parent block hash, and block hash { H0, W0, and W1} of superblock Q1 are written into the corresponding locations in the block header of local superblock Q2, respectively. And, the electronic device also synchronizes the traffic data of the partition block in superblock Q1 and the parent node list { Z0, Z1} in the corresponding position in the partition block of local superblock Q2.
In addition, since the local block priority of superblock Q1 is 0, when the electronic device updates the data variable of the superblock in the local superblock, the local block priority of the local superblock is updated to 1, that is, the priority of the local block priority of the updated local superblock is lower than the priority of the local block priority in the target node, so that, based on the consideration that the more the synchronization sequence is, the higher the risk of superblock being tampered, with this approach, it is beneficial to effectively select a superblock with high security and high reliability for synchronization when the superblock is synchronized by the following nodes, thereby reducing the existence possibility of illegal superblocks, and further effectively maintaining the block distributed block chain.
In some embodiments, referring to fig. 4h, S44 includes S444, S444: and updating the inheritance field and/or the root cause field of the data variable area in the local super block.
In some embodiments, when updating the legacy field of the data variable region in the local superblock, the electronic device fills the legacy field of the local superblock with node information of the target node.
In some embodiments, when updating the root field of the data variable area in the local block, when the target node is an authoritative node, the root field is filled with the node information of the authoritative node, for example, the target node I1 is an authoritative node, and the electronic device fills the root field of the local super block with the node information of the target node I1.
When the target node is a non-authoritative node and the root field thereof is the node information of the authoritative node, the node information of the authoritative node is filled in the root field of the local super block, for example, the target node I2 is a normal node, and the root field of the target node I2 is the node information of the authoritative node I3, and the electronic device fills the node information of the authoritative node I3 in the root field of the local super block.
When the target node is a non-authoritative node and the root field thereof is node information of the non-authoritative node, the node information of the non-authoritative node is filled in the root field of the local super block, for example, the target node I4 is a normal node and the root field of the target node I4 is node information of a normal node I5, and the electronic device fills the node information of the normal node I5 in the root field of the local super block.
As described above, by continuously updating and recording the inheritance field and/or the root field in each superblock, the method can simply, reliably, comprehensively and safely restore the synchronization path of the corresponding superblock in the block distributed storage mode, and can more effectively and safely maintain the block distributed block chain.
In order to prevent a malicious node from impersonating an authoritative node or performing other malicious attacks on the authoritative node, the electronic device may verify the validity of the authoritative node when synchronizing the superblock of the authoritative node or accessing the authoritative node, and therefore, in some embodiments, referring to fig. 4i, the block synchronization method S400 further includes:
s47, sending the random code to a first authority node so that the first authority node signs the random code by using a private key and returns a signing result, wherein the first authority node stores a first super block;
s48, extracting the node public key of the first authoritative node from a second super block after the first super block is adjacent to the block height;
s49, using the node public key of the first authoritative node to verify whether the signature result is legal, if so, the first authoritative node is a legal authoritative node, and if not, the first authoritative node is an illegal authoritative node.
In this embodiment, the random code is a character or string of characters in any suitable form.
For a detailed understanding of the present embodiment, this is explained in detail below with reference to fig. 4 j:
as shown in fig. 4j, the first authority node j1 stores a first super-block Q3 with a block height of 101, and the second authority node j2 stores a second super-block Q4 with a block height of 102, so that the first super-block Q3 and the second super-block Q4 are adjacent to each other on the block distributed block chain, and the first authority node j1 is a parent power node of the second authority node j 2.
Since the parent node list of the second superblock Q4 records the node information of the first authoritative node j1, that is, the parent node list of the second superblock Q4 records the node public key of the first authoritative node j1, the node public key of the first authoritative node j1 can be used to verify the validity of the first authoritative node j1 in a later period.
For example, the electronic device j0 randomly generates a random code and sends the random code to the firstauthoritative node j 1. According to the service logic, the first authority node j1 needs to sign the random code by using its own private key to obtain a signature result, and then the first authority node j1 sends the signature result to the electronic device.
The electronic device j0 knows that the node public key of the first authority node j1 is stored in the second super block Q4 of the second authority node j2, so that the electronic device j0 extracts the node public key of the first authority node j1 from the second super block Q4, and verifies whether the signature result is legal or not by using the node public key of the first authority node j1, if so, the first authority node j1 is a legal authority node, and if not, the first authority node j1 is an illegal authority node.
Therefore, by adopting the method, the validity of the authority node can be effectively verified in the block distributed blockchain, so that the information security of the block distributed blockchain is effectively maintained.
In some embodiments, each node may query for data in a block distributed blockchain. Generally, each node may maintain a synchronization node list locally, which includes the block height and node address of each node, and a local cache, which stores some data caches. When a node needs to acquire target data, the node can inquire whether the target data is in a local super block, and if so, the node directly acquires the target data from the local super block. If not, the node queries whether the index field of the target data is cached in a local cache, and if the index field of the target data is cached in the local cache, the node can extract a target super block for storing the target data and a node corresponding to the target super block from the local cache according to the index field of the target data, and then the target data can be extracted from the corresponding node.
If not, the node may broadcast a data query instruction to the blockchain network, where the data query instruction includes a height of a block to be queried. In the block chain network, each other node inquires whether a super block which is matched with the height of a block to be inquired is locally stored or not according to data, if so, the data inquiry instruction is responded, the block height and the node address of the super block are returned to the node, and then the node also records the node address and the block height thereof in a local synchronous list. And if not, not responding to the data query instruction.
In the block distributed block chain, the block chain is broken up, each super block is stored in each authority node in a scattered mode, other nodes can synchronize corresponding super blocks according to the needs of the nodes, and different nodes can store super blocks with the same block height. Generally, if block data is obtained from a node in a centralized manner, the data transmission method is slow, and particularly, the advantages of the block distributed blockchain cannot be fully utilized.
Based on this, in some embodiments, based on the block distributed block chain, an embodiment of the present invention provides a data transmission method. Referring to fig. 5a, the data transmission method S500 includes:
s51, determining each node storing block data required by the local node;
s52, determining target nodes for transmitting data and the decomposition proportion of each target node from each node according to the distance between each node and the local node;
s53, determining that each target node needs to extract target data corresponding to the decomposition ratio from the block data;
and S54, requesting each target node to return target data.
In this embodiment, the execution subject is any suitable electronic device, and the electronic device may be equivalent to a local node with respect to the need to obtain the tile data from the relevant node.
In this embodiment, the block data may be data of any suitable form and content, for example, the block data is all/part of service data, all/part of block header data, or all data of super block.
In some embodiments, as described above, each node may locally maintain a synchronization node list including the block height and the node address of each node, and a local cache storing some data caches, so that the electronic device may query the synchronization node list or the local cache to extract each node storing the block data.
Or, when the electronic device determines each node storing the block data required by the local node, the electronic device may broadcast a data request instruction to the blockchain network, where the data request instruction includes a tag of the block data, for example, when the block data is all data of the super block, the tag may be a block height, or when the block data is partial service data, the tag is index information of the partial service data. In the block chain network, after each node receives a data request instruction, the label of the block data is analyzed, whether the corresponding block data is stored locally or not is searched according to the label of the block data, if yes, the node address is sent to the electronic equipment, and the electronic equipment determines each node storing the block data required by the local node according to the node address sent by each node.
In this embodiment, although each node stores the block data required by the local node, all the nodes in the nodes do not necessarily select the transmission data finally, and therefore, the target node is the node that can select the transmission data finally in the nodes.
In this embodiment, the decomposition ratio is used to indicate that the target node extracts data of a corresponding ratio at a corresponding position of the locally stored data as the target data, and the subsequent target node may return the target data to the electronic device.
Referring to FIG. 5b, the authoritative nodes 5-1, 5-2, 5-3, 5-4, 5-5, 5-6 and 5-7 all maintain superblocks of the same block height, where the block height is 60. The electronic device 5-0 needs a super block with a block height of 60, and the electronic device 5-0 determines each node storing the super block with the block height of 60 by using the method described above, that is, each node is an authoritative node 5-1, 5-2, 5-3, 5-4, 5-5, 5-6 and 5-7 in sequence.
The electronic equipment 5-0 determines that the authoritative nodes 5-1, 5-2, 5-3, 5-4 and 5-5 are all used as target nodes according to the distance between each authoritative node and the electronic equipment, and excludes the authoritative nodes 5-6 and the authoritative nodes 5-7 from being used as the target nodes.
Then, the electronic device 5-0 determines the decomposition ratio of each target node according to a decomposition algorithm, wherein the decomposition ratios of the authoritative nodes 5-1, 5-2, 5-3, 5-4 and 5-5 are respectively P1, P2, P3, P4 and P5 in sequence.
Then, the electronic device 5-0 determines that each target node needs to extract target data corresponding to the decomposition ratio from the superblock, wherein the target data of the authoritative node 5-1 is W11, the target data of the authoritative node 5-2 is W12, the target data of the authoritative node 5-3 is W13, the target data of the authoritative node 5-4 is W14, the target data of the authoritative node 5-5 is W15, and the target data W11 to W15 form all data of the superblock.
And finally, the electronic equipment 5-0 sequentially returns target data W11-W15 by the authoritative nodes 5-1, 5-2, 5-3, 5-4 and 5-5.
Therefore, the block data is segmented into a plurality of proportional quantities, and each target node is requested to cooperatively transmit the data of the corresponding proportional quantity, so that the data transmission efficiency and the real-time performance are improved, the situation that the transmission efficiency is low easily caused by single-point transmission is avoided, and particularly under the scene mode of a block distributed block chain, the method can effectively utilize the characteristic of block dispersed storage to achieve the aim of quickly transmitting the data.
It will be appreciated that the electronic device may select any suitable algorithm or construct a rapid transmission model to select the target node for the purpose of rapidly transmitting data.
In some embodiments, in S52, the electronic device may screen out, from each node, a node satisfying the fast transmission model as a target node according to the distance between each node and the local node.
In some embodiments, referring to fig. 5c, S52 includes:
s521, calculating first transmission time according to the size of the block data and the communication bandwidth;
s522, arranging each node in a sequence from near to far according to the distance between each node and the local node;
s523, assigning n =1, and setting the first node as a first target node;
and S524, judging whether the n +1 th node exists, if so, executing S525, and if not, executing S528.
S525, if yes, judging t according to the sequence from near to farn+1-tnWhether or not greater than TnIf yes, go to step S526, and if no, go to step S527.
Wherein, tnFor the communication time from the nth node to the local node, TnFor the nth transmission time, when n is greater than or equal to 2, Tn=[Tn-1-(tn-tn-1)](n-1)/n, when n =1, T1Is a first transmission time;
s526, if the number of the target nodes is larger than the preset number, extracting all the target nodes;
s527, if the value is not larger than the preset value, n = n +1 is assigned, the nth node is selected as the nth target node, and the step returns to S524;
s528, if the node does not exist, all target nodes are extracted;
for example, referring to FIG. 5b, the size of the block data is W0Communication bandwidth of M0Then the first transmission time T1= W0/M0。
The electronic equipment is gradually far away from the authoritative nodes 5-1, 5-2, 5-3, 5-4, 5-5, 5-6 and 5-7, after the authoritative nodes are arranged in the sequence from near to far, the authoritative node 5-1 is a first node, the authoritative node 5-2 is a second node, the authoritative node 5-3 is a third node, the authoritative node 5-4 is a fourth node, the authoritative node 5-5 is a fifth node, the authoritative node 5-6 is a sixth node, and the authoritative node 5-7 is a seventh node.
The electronic device judges t2-t1Whether or not greater than T1,t1And t2The communication time from the authoritative node 5-1 to the electronic equipment and the communication time from the authoritative node 5-2 to the electronic equipment are respectively.
If t2-t1Greater than T1And extracting all target nodes, wherein the electronic equipment only requests the first node to return target data because only the first node is the first target node.
If t2-t1Less than or equal to T1The value n =1+1=2, the second node is selected as the second target node, and the process returns to S524.
Let t be assumed here2-t1Less than T1The process returns to step S524.
When S524 is executed, it is apparent that a third node exists.
The electronic device judges t3-t2Whether or not greater than T2,t2And t3Respectively communication time from the authoritative node 5-2 and the authoritative node 5-3 to the electronic equipment, wherein T2=[T1-(t2-t1)](2-1)/2。
Let t3-t2Less than T2If yes, assigning a value of 3=2+1, selecting a third node as a third target node, and returning to the step S524;
when S524 is executed, it is apparent that a fourth node exists.
The electronic device judges t4-t3Whether or not greater than T3,t3And t4Respectively communication time from the authoritative node 5-3 and the authoritative node 5-4 to the electronic equipment, wherein T3=[T2-(t3-t2)](3-1)/3。
Let t4-t3Less than T3Then 4=3+1 is assigned, and the fourth node is selected as the fourth target node, and the process returns to S524.
By analogy, it is assumed that the electronic device selects the fourth node and the fifth node as the fourth target node and the fifth target node, respectively.
After determining the fifth node as the fifth target node, the process returns to step S524.
When S524 is executed, it is apparent that a sixth node exists.
The electronic device judges t6-t5Whether or not greater than T5,t5And t6Respectively communication time from the authoritative node 5-5 and the authoritative node 5-6 to the electronic equipment, wherein T6=[T5-(t6-t5)](5-1)/6。
Let t6-t5Greater than T5Then the electronic device extracts all target nodes, i.e. extracts the first target node, the second target node … … and the fifth target node.
Therefore, the method can effectively determine each target node by combining the distance, thereby improving the data transmission efficiency.
In some embodiments, referring to fig. 5d, determining the decomposition ratio of each target node comprises:
s529, according to Pi=(TM+tM-ti)/T1Calculating the decomposition ratio of the ith target node, wherein i is less than or equal to M-1, and i and M are positive integers, PiThe decomposition proportion of the ith target node;
s5210, according to PM=TM/T1Obtaining the decomposition ratio, P, of the farthest target nodeMIs the resolution ratio of the farthest target node.
In this embodiment, the farthest target node is a target node farthest from the electronic device (local node) among all the target nodes.
In this embodiment, for example, as described above, if the electronic device determines that the authoritative nodes 5-1, 5-2, 5-3, 5-4, and 5-5 are all target nodes, M =5, and the decomposition ratio of each target node is as follows:
authoritative node 5-1 is the first target node, i =1, P1=(T5+t5-t1)/T1。
Authoritative node 5-2 is the second target node, i =2, P2=(T5+t5-t2)/T1。
The authoritative node 5-3 is a third target node, i =3, P3=(T5+t5-t3)/T1。
The authoritative node 5-4 is a fourth target node, i =4, P4=(T5+t5-t4)/T1。
The authoritative node 5-5 is a fifth target node, i =5, P5=T5/T1。
P1+P2+P3+P4+P5=1。
From the distance relationship, P can be known1>P2>P3>P4>P5The subsequent electronic equipment determines the target data of each target node according to the decomposition proportion of each target node, so that the method adoptsThe method fully combines the distance between each target node and the electronic equipment, the communication time with each target node and the transmission time, when data are transmitted, the data are not transmitted by a single near node due to the close distance, and the data are transmitted through the cooperation of a plurality of target nodes, so that the data transmission efficiency is improved.
In some embodiments, the block data is stored in superblocks, each target node storing superblocks of the same block height.
As mentioned above, the block data to be transmitted may include a header data and a block data, and in some embodiments, referring to fig. 5e, S54 includes:
s541, controlling each target node to extract data from the local block data;
and S542, requesting each target node to package the local block header data and the extracted data into target data, and returning the target data.
In this embodiment, the electronic device may control the target node to extract all data or a specified part of data from the local tile volume data, for example, extract service data, or extract service data and data of the data variable area.
In the present embodiment, the block header data includes any data located in the block header.
By adopting the method, the electronic equipment can quickly obtain the super block by cooperatively transmitting the data of the super block by the target nodes.
In order to ensure the integrity and the reliability of the data transmitted by each target node, in some embodiments, referring to fig. 5f, the data transmission method S500 further includes:
s55, returning target data according to each target node to generate block data to be checked;
s56, calculating the data hash of the block data to be checked;
and S57, determining whether the block data to be checked is legal or not according to the data hash and the standard hash.
In this embodiment, the target data may be any part of data in the super block or a combination of multiple parts of data, for example, the target data is partial service data or partial service data + block header data.
In this embodiment, for example, the electronic device needs the service data of the super block Q5, wherein the electronic device divides the service data into five parts, which are K1, K2, K3, K4 and K5 in sequence according to the decomposition algorithm in the foregoing embodiments, and controls the first target node to the fifth target node to send the corresponding target data with K1 to K5 as the target data.
When the electronic device receives the target data K1-K5, the target data K1-K5 are combined in sequence to obtain the data of the block to be verified. And then, the electronic equipment calculates the data of the block to be checked according to a hash algorithm to obtain the data hash of the data of the block to be checked. And finally, the electronic device compares the data hash with the standard hash to determine whether the block data to be verified is legal, wherein the block head of the super block Q5 stores the service data hash which can be used as the standard hash, so that whether the target node transmits wrong target data or whether the target node is legal or whether the target data is tampered at the target node can be determined by comparing the data hash with the standard hash, and therefore, by adopting the method, under the transmission mode that the multi-target node participates in the data cooperatively, the electronic device can effectively verify the integrity and the legality of the data.
As mentioned above, in order to ensure that the data transmitted by the legitimate target node is obtained, in some embodiments, referring to fig. 5g, the target data includes block header data and block volume data, before performing S55, the data transmission method S500 further includes:
and S58, judging whether the block header data returned by each target node are all consistent or all matched with the standard block header data, if so, entering S55, and if not, executing S59.
And S59, executing preset operation.
In this embodiment, the block header data is usually consistent data in the block chain, that is, for superblocks stored in different nodes but having the same block height, their block header data are all consistent, and the standard block header data is the block header data of the superblock with the highest reliability, for example, the block header data of the legal authority node is the standard block header data.
In this embodiment, if the block header data returned by each target node are consistent with each other, or if the block header data returned by each target node are matched with the standard block header data, it indicates that each target node is a legal node, and if the block header data returned by each target node are inconsistent or not matched with each other, one or more target nodes are attacked and become illegal.
In this embodiment, the preset operation may be any operation with any suitable rule, for example, performing a troubleshooting operation, or notifying this in a blockchain network.
Therefore, the method is favorable for improving the safety of data transmission and the credibility of the obtained data.
It should be noted that, in the foregoing embodiments, a certain order does not necessarily exist between the foregoing steps, and those skilled in the art can understand, according to the description of the embodiments of the present invention, that in different embodiments, the foregoing steps may have different execution orders, that is, may be executed in parallel, may also be executed interchangeably, and the like.
As another aspect of the embodiments of the present invention, the embodiments of the present invention provide a block chain generating apparatus with distributed blocks. The block distributed blockchain generation device may be a software module, where the software module includes a plurality of instructions, and the instructions are stored in a memory, and the processor may access the memory and call the instructions to execute the instructions, so as to complete the block distributed blockchain generation method described in each of the above embodiments.
In some embodiments, the block distributed block chain generating device may also be built by hardware devices, for example, the block distributed block chain generating device may be built by one or more than two chips, and each chip may work in coordination with each other to complete the block distributed block chain generating method described in each of the above embodiments. For another example, the block-distributed block chain generating apparatus may also be constructed by various logic devices, such as a general processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), a single chip, an arm (acorn RISC machine) or other programmable logic devices, discrete gate or transistor logic, discrete hardware components, or any combination of these components.
Referring to fig. 6, the block distributed blockchain generating apparatus 600 includes a packing module 61, a consensus module 62 and a block uplink module 63.
The packing module 61 is configured to pack service data into candidate blocks, the consensus module 62 is configured to consensus the candidate blocks to obtain super blocks, the block uplink module 63 is configured to write a specified number of super blocks into at least one authoritative node, and the super blocks with different block heights may form a block distributed block chain.
On one hand, the super blocks can be stored in a distributed manner, and the super blocks with different block heights can form a block distributed block chain, so that the use efficiency of the block chain can be improved, and the block distributed block chain provided by the embodiment can be guaranteed to have the characteristics of decentralization, transparency and non-falsification on the premise of improving the flexibility of the storage blocks. On the other hand, even along with the increase of the service time of the blockchain, the embodiment can balance and coordinate the storage capacity of the accounting node, and avoid the situation that the accounting node is broken down or exits accounting due to the fact that the accounting node stores too many blockdata.
In some embodiments, after each authority node stores a specified number of superblocks, configured in a closed mode in which it is prohibited from receiving other superblocks, the superblocks are in read-only mode.
In some embodiments, the given number is 1, superblocks of different block heights are distributed to different authoritative nodes to form a block distributed block chain.
In some embodiments, the block of the super block includes the traffic data and a parent node list, the block header includes the block height, the parent block hash, and the parent node list includes node information for each father node at the same block height.
In some embodiments, the super block further includes a data variable area, data of the data variable area in each super block may be inconsistent under the same block height, and data of the data variable area is variable before super block is linked up and is not variable after super block is linked up.
In some embodiments, the data variable region includes local characteristic data associated with a local node.
In some embodiments, the local characteristic data comprises a local node field for indicating local node information for storing the superblock and/or a local block source field for indicating source node information for the superblock.
In some embodiments, the local node field comprises a local node hash and/or a local block priority and/or a local node public key of the local node and/or a local signature field, the local signature field being a signature by the local node of data in the data variable region other than the local signature field.
In some embodiments, the local superblock origin field includes an inheritance field for indicating node information of an inheritance node corresponding to the superblock to be inherited and/or a root origin field for indicating node information of a root origin node corresponding to the local superblock, the root origin node being the node that retroactively stores the local superblock earliest.
In some embodiments, the node information of the inherited node comprises the inherited node hash and/or the inherited node priority and/or the inherited node public key and/or the local signature field of the inherited node, and/or the node information of the root node comprises the root node hash and/or the root node priority and/or the root node public key and/or the local signature field of the root node.
It should be noted that the block distributed block chain generating apparatus described above can execute the block distributed block chain generating method provided in the embodiments of the present invention, and has functional modules and beneficial effects corresponding to the execution method. For technical details that are not described in detail in the embodiments of the block distributed blockchain generation apparatus, reference may be made to the block distributed blockchain generation method provided in the embodiments of the present invention.
Referring to fig. 7, fig. 7 is a schematic circuit diagram of an electronic device according to an embodiment of the present invention, where the electronic device may be any suitable type of device or electronic product. As shown in fig. 7, theelectronic device 700 includes one or more processors 71 and memory 72. Fig. 7 illustrates an example of one processor 71.
The processor 71 and the memory 72 may be connected by a bus or other means, such as the bus connection in fig. 7.
The memory 72, which is a non-volatile computer-readable storage medium, may be used for storing non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions/modules corresponding to the block distributed block chain generating method in the embodiment of the present invention. The processor 71 executes various functional applications and data processing of the block distributed blockchain generation apparatus by running the nonvolatile software program, instructions and modules stored in the memory 72, that is, the functions of the blocks distributed blockchain generation method provided by the above method embodiment and the modules or units of the above apparatus embodiment are realized.
The memory 72 may include high speed random access memory and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, the memory 72 may optionally include memory located remotely from the processor 71, and such remote memory may be connected to the processor 71 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The program instructions/modules are stored in the memory 72 and, when executed by the one or more processors 71, perform the block distributed blockchain generation method of any of the method embodiments described above.
Embodiments of the present invention further provide a storage medium storing computer-executable instructions, which are executed by one or more processors, such as the processor 71 in fig. 7, so that the one or more processors can execute the block distributed block chain generating method in any of the above method embodiments.
Embodiments of the present invention also provide a computer program product, which includes a computer program stored on a non-volatile computer-readable storage medium, where the computer program includes program instructions, and when the program instructions are executed by an electronic device, the electronic device is caused to execute any one of the block-distributed block chain generation methods.
The above-described embodiments of the apparatus or device are merely illustrative, wherein the unit modules described as separate parts may or may not be physically separate, and the parts displayed as module units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network module units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a general hardware platform, and certainly can also be implemented by hardware. Based on such understanding, the above technical solutions substantially or contributing to the related art may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; within the idea of the invention, also technical features in the above embodiments or in different embodiments may be combined, steps may be implemented in any order, and there are many other variations of the different aspects of the invention as described above, which are not provided in detail for the sake of brevity; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.