CN110910242A - Block chain generation method and device, terminal equipment and storage medium - Google Patents

Block chain generation method and device, terminal equipment and storage medium Download PDF

Info

Publication number
CN110910242A
CN110910242A CN201811071960.1A CN201811071960A CN110910242A CN 110910242 A CN110910242 A CN 110910242A CN 201811071960 A CN201811071960 A CN 201811071960A CN 110910242 A CN110910242 A CN 110910242A
Authority
CN
China
Prior art keywords
layer
node
nodes
connectivity
block chain
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN201811071960.1A
Other languages
Chinese (zh)
Other versions
CN110910242B (en
Inventor
杨术
萧伟
明中行
潘岱
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Brocheng Technology Co Ltd
Original Assignee
Beijing Brocheng Technology Co Ltd
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 Beijing Brocheng Technology Co Ltd filed Critical Beijing Brocheng Technology Co Ltd
Priority to CN201811071960.1A priority Critical patent/CN110910242B/en
Publication of CN110910242A publication Critical patent/CN110910242A/en
Application granted granted Critical
Publication of CN110910242B publication Critical patent/CN110910242B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/604Tools and structures for managing or administering access control systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • General Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • Health & Medical Sciences (AREA)
  • Strategic Management (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • Development Economics (AREA)
  • Automation & Control Theory (AREA)
  • Technology Law (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a block chain generation method, a block chain generation device, terminal equipment and a storage medium, wherein the method comprises the following steps: calculating the forward connectivity of each node of each layer of the original block chain and the created nodes based on the formed original block chain in the directed acyclic graph structure; selecting the leaf node with the maximum forward connectivity in the last layer as a guide node; calculating the reverse connectivity of each node and the guide node in each layer; selecting a first preset number of nodes from large to small in each layer according to the preset maximum width of each layer and the reverse connectivity as candidate nodes of each layer; determining a target layer according to the number of the candidate nodes of each layer; selecting a second preset number of nodes as target nodes from large to small according to the forward connectivity of the candidate nodes of the target layer; and connecting the target node and the new block, updating the original block chain, and generating an updated block chain. The embodiment of the application can shorten the transaction confirmation time and improve the transaction throughput and safety.

Description

Block chain generation method and device, terminal equipment and storage medium
Technical Field
The present application belongs to the technical field of a block chain, and in particular, to a block chain generation method, an apparatus, a terminal device, and a computer-readable storage medium.
Background
As the block chain technology advances, the block chain is applied more and more widely.
Currently, a blockchain generally has a chain structure and a blockchain structure having a Directed Acyclic Graph (DAG) structure as a whole. For the blockchain with the chain structure, the transaction confirmation time is uncertain, the transaction confirmation time is often long, and in addition, the transaction throughput is small, so that the blockchain is not suitable for occasions with small amount of frequent transactions. For the block chain of the directed acyclic graph structure, the directed acyclic graph is randomly and disorderly expanded, the connection between nodes is loose, so that the difficulty of malicious nodes entering is low, and the safety of the block chain is low. In addition, the current blockchain generally has a Proof Of equity (POS) mechanism and a Delegated Proof Of equity (DPOS) mechanism, and centrally elects super nodes, so that the transaction confirmation time is long and the transaction throughput is low. In summary, the transaction of the current blockchain has a long validation time, a small transaction throughput and a low security.
Disclosure of Invention
In view of this, the present application provides a block chain generation method, apparatus, terminal device and computer-readable storage medium, so as to improve the transaction confirmation convergence speed and shorten the transaction confirmation time; transaction throughput and security are improved.
A first aspect of an embodiment of the present application provides a block chain generation method, including:
calculating the forward connectivity of each node of each layer of the original block chain and the created nodes based on the formed original block chain in a directed acyclic graph structure;
selecting a leaf node with the maximum forward connectivity in the last layer as a guide node of the last layer;
calculating the reverse connectivity of each node in each layer and the guide node;
according to the preset maximum width of the layer, selecting a first preset number of nodes from large to small in each layer according to the reverse connectivity as candidate nodes of each layer, wherein the first preset number is smaller than or equal to the maximum width of the layer;
determining a target layer needing to be subjected to new block connection according to the number of the candidate nodes of each layer;
selecting a second preset number of nodes as target nodes from large to small according to the forward connectivity of the candidate nodes of the target layer;
and connecting the target node and the new block, updating the original block chain, and generating an updated block chain.
Optionally, the determining, according to the number of candidate nodes of each layer, a target layer to which a new block connection needs to be performed includes:
judging whether the number of candidate nodes of the current layer is equal to the maximum width of the layer or not;
when the number of the candidate nodes of the current layer is equal to the maximum width of the layer, judging whether the number of the candidate nodes of the next layer is equal to the maximum width of the layer;
and when the number of the candidate nodes of the current layer is not equal to the maximum width of the layer, the previous layer of the current layer is the target layer.
Optionally, the calculating the forward connectivity between each node of each layer of the original block chain and a created-world node includes:
calculating the forward connectivity of each node in the first layer and the created generation node;
calculating the number of directed edges of each node of a current layer and each node of a previous layer by layer, wherein the current layer is a layer between a second layer and a maximum layer;
and adding the forward connectivity of each node of the previous layer to the sum of the number of the directed edges of any node of the current layer and each node of the previous layer to obtain the forward connectivity of any node of the current layer, and thus obtaining the forward connectivity of each node of the current layer.
Optionally, the calculating the forward connectivity between each node of each layer of the original block chain and a created-world node includes:
calculating the number of directed edges from each node of the last layer to each node of the previous layer of the last layer;
adding the forward connectivity of each node of the last layer to the sum of the number of directed edges of each node of the last layer to each node of the previous layer of the last layer to obtain the forward connectivity of each node of the last layer, and thus obtaining the forward connectivity of each node of the last layer;
wherein the forward connectivity of each node of the previous layer of the last layer is a value which is pre-calculated and used as a node parameter of each node of the previous layer of the last layer.
Optionally, the method further comprises:
selecting a third preset number of nodes of a preset layer as check nodes, wherein the preset layer is a layer except the last layer;
judging whether the forward connectivity parameter of the check node is correct or not;
and when the forward connectivity parameter of the check node is incorrect, recalculating the forward connectivity of all nodes of the original block chain, and assigning the recalculated forward connectivity as the forward connectivity parameter to each node.
Optionally, the selecting, according to a preset maximum width of each layer, a first preset number of nodes from large to small according to the magnitude of the reverse connectivity in each layer as candidate nodes of each layer includes:
sequencing the nodes in each layer from large to small according to the reverse connectivity;
and selecting a first preset number of nodes from each layer as the candidate nodes of each layer, wherein the first preset number is less than or equal to the maximum width of each layer.
Optionally, the second preset number is two; the connecting the target node and the new block, updating the original block chain, and generating an updated block chain includes:
and respectively connecting the new block with the two target nodes, merging the new block into a node set, merging the directed edges between the new block and the two target nodes into a directed edge set, and obtaining an updated block chain.
A second aspect of the embodiments of the present application provides a block chain generating apparatus, including:
the forward connectivity calculation module is used for calculating the forward connectivity of each node of each layer of the original block chain and the created nodes based on the formed original block chain in the directed acyclic graph structure;
the guide node selecting module is used for selecting the leaf node with the maximum forward connectivity in the last layer as the guide node of the last layer;
the reverse connectivity calculation module is used for calculating the reverse connectivity of each node in each layer and the guide node;
the candidate node selecting module is used for selecting a first preset number of nodes from large to small according to the reverse connectivity in each layer according to the preset maximum width of the layer, wherein the first preset number is smaller than or equal to the maximum width of the layer;
the target layer determining module is used for determining a target layer which needs to be subjected to new block connection according to the number of the candidate nodes of each layer;
the target node selection module is used for selecting a second preset number of nodes from large to small as target nodes according to the forward connectivity of the candidate nodes of the target layer;
and the generating module is used for connecting the target node and the new block, updating the original block chain and generating an updated block chain.
A third aspect of embodiments of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the method according to any one of the above first aspects or the steps of the method according to the above second aspect when executing the computer program.
A fourth aspect of embodiments of the present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the method of any one of the above first aspects or the steps of the method of the above second aspect.
Compared with the prior art, the embodiment of the application has the advantages that:
according to the embodiment of the application, the maximum layer width of each layer of the directed acyclic graph is set, namely, the upper limit is set for the width of each layer, so that the convergence rate of transaction confirmation is improved, the transaction confirmation time is more determined, and the transaction confirmation time is shortened; by setting the number of candidate nodes of each layer of the directed acyclic graph to be equal to the maximum width of the layer, namely, the number of node communication to be the maximum width of the layer, the transaction throughput is improved, the nodes and the whole graph are required to be closely connected, the access difficulty of malicious nodes is improved, and the safety is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a block chain diagram of a compact directed acyclic graph structure according to an embodiment of the present disclosure;
fig. 2 is a flowchart illustrating a block chain generating method according to an embodiment of the present disclosure;
fig. 3 is a schematic flowchart of step S205 provided in the embodiment of the present application;
fig. 4 is a schematic flowchart of step S201 provided in the embodiment of the present application;
fig. 5 is another schematic flow chart of step S201 provided in the embodiment of the present application;
fig. 6 is a block diagram schematically illustrating a structure of a block chain generating apparatus according to an embodiment of the present disclosure;
fig. 7 is a schematic diagram of a terminal device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
Before introducing the technical solution of the embodiment of the present application, a description is first given of a concept related to a compact directed Acyclic Graph (cogag) blockchain.
A directed acyclic graph is denoted by G ═ V, E, where V is a set of nodes or blocks and E is a set of directed edges. By means of IvThe number of layers of the node v in the graph is shown, and the longest distance from the node v to the creation node can be said. w is alThe width of the l-th layer is indicated, and the number of nodes included in the l-th layer can be understood, for example, when the number of nodes of a certain layer is 3, the number of w of the layerl3. When the width is 1, the whole block chain network becomes a linear chain structure of the bitcoin.
Setting the layer maximum width K, i.e. wl< K, the width of any layer needs to be less than K. The width of the entire graph is limited by a constant K. The value of K can be set by the whole blockchain network according to the transaction generation speed, and can also be adaptively adjusted.
The sum of different paths from any node v to the founding node is the forward connectivity or the forward connectivity quantity of the node v, which can be marked as Cv. All leaf nodes in the graph may be referred to as tip nodes, with the tip node with the greatest forward connectivity in each layer being the lead node. Since there may be multiple nodes with equal forward connectivity, there may be more than one bootstrap node per layer.
The sum of the number of different paths from any node v to all the guide nodes on each layer is the reverse connectivity or reverse connectivity number of the node, which can be denoted as Rv
To better describe the blockchain of the compact directed acyclic graph structure, the following description will be made in conjunction with a schematic diagram of a blockchain of the compact directed acyclic graph structure shown in fig. 1.
As shown in fig. 1, the system comprises 6 layers of Level 0-Level 5, wherein Level0 comprises node 0, and node 0 is an established node of a block chain; level1 includes node 1, node 2, node 3, node 4; level2 includes node 5, node 6, node 7, and node 8; level 3 includes nodes 9-12, Level4 includes nodes 13-16, and Level5 includes nodes 17-18. All the nodes are connected through directed edges. The other layers except the layer where the created nodes are located include 4 nodes, i.e., each layer has a width of 4.
It should be noted that fig. 1 is only an exemplary structure. In practice, the included nodes of each layer may be different, i.e., the width of each layer may be different, but the width of each layer should be constrained by the set maximum width K of the layer.
After introducing the concept related to the blockchain of the compact directed acyclic graph structure, the following describes the technical solutions provided by the embodiments of the present application in detail.
In order to explain the technical solution described in the present application, the following description will be given by way of specific examples.
Example one
Referring to fig. 2, a flow chart of a block chain generating method according to an embodiment of the present application is shown, where the method includes the following steps:
step S201, based on the formed original block chain with the directed acyclic graph structure, calculating the forward connectivity between each node of each layer of the original block chain and the created node.
The original block chain refers to a block chain that has been formed at present, and the number of layers included in the block chain and the number of nodes included in each layer are not particularly limited.
And S202, selecting the leaf node with the maximum forward connectivity in the last layer as a guide node of the last layer.
Specifically, after the forward connectivity number of each node in each layer of the block chain is calculated, the leaf node (tip node) with the maximum forward connectivity in the last layer is used as the guide node.
It is understood that, since there may be a plurality of leaf nodes with the largest forward connectivity, there may be a plurality of leading nodes in the last layer.
And step S203, calculating the reverse connectivity of each node in each layer and the guide node.
And S204, selecting a first preset number of nodes from large to small in each layer according to the preset maximum width of the layer as candidate nodes of each layer according to the reverse connectivity, wherein the first preset number is smaller than or equal to the maximum width of the layer.
It should be noted that the maximum width of the layer may be preset, or of course, an initial value may be preset, and the initial value may be set or adaptively adjusted according to the generation speed of the transaction. The maximum layer width of each layer of the blockchain may or may not be uniform. The maximum width of each layer is set, so that the convergence rate of transaction confirmation can be improved, the transaction confirmation time is more determined, and the transaction confirmation time is also reduced; the maximum width of the layer also specifies that the node communication number is the maximum width of the layer, and specifies that the nodes and the graph are required to be tightly connected, so that the access difficulty of malicious nodes is improved, and the safety performance is improved.
The first predetermined number may be smaller than or equal to the maximum layer width of the layer. When the first preset number is equal to the maximum width of the layer, the number of candidate nodes selected by each layer may be the same when the maximum widths of the layers of each layer are equal, and the number of candidate nodes selected by each layer should be the same as the maximum width of the layer when the maximum widths of the layers of each layer are not equal.
In the same layer, nodes with larger reverse connection quantity have higher priority and are more likely to be selected as candidate nodes. That is, the more nodes that are followers and the more nodes that are descendants are likely to be selected as candidates for the level.
In specific implementation, each layer may rank the nodes according to the magnitude of the reverse connectivity, and then select a first preset number of nodes as candidate nodes.
Therefore, in some embodiments of the present application, the process of this step may specifically include: sequencing the nodes in each layer from large to small according to the reverse connectivity; and selecting a first preset number of nodes from each layer as candidate nodes of each layer, wherein the first preset number is less than or equal to the maximum width of each layer. For example, when the first preset number is equal to the maximum width K of a layer, the nodes in each layer may be sorted from large to small, and then the first K nodes are selected as candidate nodes of the layer.
It can be understood that the nodes may also be sorted from small to large according to the inverse connectivity, and then the corresponding number of nodes may be selected as candidate nodes. Of course, the nodes can be directly selected as candidate nodes according to the reverse connectivity without sorting.
And step S205, determining a target layer needing to be subjected to new block connection according to the number of the candidate nodes of each layer.
The target layer is a layer in which a target node to which the new block (new node) is connected is located. For example, the target node to which the new node needs to be connected is a node n, the layer where the node n is located is the mth layer, and the target layer of the new node is the m layer.
The selection of the target layer is based on the number of candidate nodes of each layer, and specifically, whether the number of candidate nodes of each layer is equal to the set maximum width of the layer can be judged, if the number of candidate nodes of the current layer is equal to the maximum width of the layer, whether the number of candidate nodes of the next layer is equal to the maximum width of the layer can be judged, and recursion is performed in sequence until the number of candidate nodes is not consistent with the maximum width of the layer, and the previous layer of the layer is the target layer.
For example, based on the block structure described in fig. 1, it further includes a Level6 layer, the number of nodes in the Level6 layer is zero, and the maximum width of each layer is 4. Specifically, whether the number of candidate nodes at the Level1 layer is 4 or not can be judged, if yes, the number of layers is increased by one, whether the number of candidate nodes at the Level2 layer is 4 or not is judged, if yes, the number of layers is increased by one, the number of candidate nodes at the next layer is judged, and the like, and when the number of candidate nodes at the Level5 layer is 4, the Level6 layer is judged, because no node exists in the Level6 layer, the number of candidate nodes is zero, so that the number of candidate nodes in the Level6 layer is less than 4, and the previous layer at the Level6, namely, the Level5 needs to be a target layer for new block connection. If the number of the candidate nodes of the Level5 layer is less than 4, the previous layer of the Level5 layer, namely the Level4 layer, can be used as the target layer.
And S206, selecting a second preset number of nodes as target nodes from large to small according to the forward connectivity of the candidate nodes of the target layer.
Specifically, after the target layer is determined, a target node connected to the new block needs to be determined. The target node can be selected from candidate nodes of a target layer, and second preset nodes are selected from the candidate nodes from large to small as the target node according to the size of the forward connectivity.
It is understood that the second preset number may be set according to actual needs, and generally, the second preset number may be 2, that is, 2 candidate nodes with the maximum forward connectivity are selected from the target layer as the target nodes.
And step S207, connecting the target node and the new block, updating the original block chain, and generating an updated block chain.
Specifically, the new blocks are respectively connected with the target nodes, then the new blocks are merged into the node set of the graph, the directed edges between the new blocks and the target nodes are merged into the directed edge set of the graph, the block chains are updated, and a new block chain is obtained, wherein the new block chain is integrally in a compact directed acyclic graph structure.
In some embodiments of the application, the second preset number is two, the target node and the new block are connected, the original block chain is updated, and a specific process of generating the updated block chain is as follows: and respectively connecting the new block with the two target nodes, merging the new block into the node set, merging the directed edges between the new block and the two target nodes into the directed edge set, and obtaining the updated block chain.
There may be two target nodes, node z and node y, respectively, and the new node (new block) is x. The new node x is connected to y and z, respectively, and then the node x is merged into the node set V of the graph, and the directed edges (x, y) and (x, z) are merged into the directed edge set E of the graph. When the number of the target nodes is more than two, the process is similar, and the description is omitted here.
In the embodiment, the maximum layer width of each layer of the directed acyclic graph is set, that is, the upper limit is set for the width of the layer, so that the convergence rate of transaction confirmation is improved, the transaction confirmation time is more determined, and the transaction confirmation time is shortened; by setting the number of candidate nodes of each layer of the directed acyclic graph to be equal to the maximum width of the layer, namely, the number of node communication to be the maximum width of the layer, the transaction throughput is improved, the nodes and the whole graph are required to be closely connected, the access difficulty of malicious nodes is improved, and the safety is improved.
Example two
Based on the first embodiment, referring to the flowchart of step S205 provided in the embodiment of the present application shown in fig. 3, in step S205, that is, the specific process of determining the target layer to be newly connected according to the number of candidate nodes in each layer may include:
step S301, judging whether the number of candidate nodes of the current layer is equal to the maximum width of the layer or not;
step S302, if the number of candidate nodes of the current layer is equal to the maximum width of the layer, determine whether the number of candidate nodes of the next layer is equal to the maximum width of the layer, that is, the number of layers is increased by one, and return to step S301.
Step S303, if the number of candidate nodes of the current layer is not equal to the maximum width of the layer, the previous layer of the current layer is the target layer.
For example, the number of layers at present is denoted by L, and the maximum layer width of each layer is K. Judging whether the number of candidate nodes of the current layer L is equal to K, if so, judging that L is L +1, namely, adding one to the layer number, continuously judging whether the number of candidate nodes of the next layer is equal to K, and sequentially circulating; and if the number of the candidate nodes of the current layer is not equal to K, the previous layer of the current layer, namely the L-1 layer, is a target layer.
It should be noted that, in general, it may be directly determined whether the number of candidate nodes in the last layer of the current block chain is equal to the maximum layer width, if so, the last layer is the target layer, and if not, the previous layer of the last layer is the target layer.
Based on the first embodiment, referring to a flowchart of step S201 provided in the embodiment of the present application shown in fig. 4, in step S201, that is, the process of calculating the forward connectivity between each node of each layer of the original blockchain and the created node may specifically include:
and step S401, calculating the forward connectivity of each node in the first layer and the created-age node.
Step S402, calculating the number of directed edges of each node of the current layer and each node of the previous layer by layer, wherein the current layer is a layer between the second layer and the maximum layer. That is, the current layer starts with the second layer and ends with the largest layer.
And S403, adding the forward connectivity of each node in the previous layer to the sum of the directed edge numbers of any node in the current layer and each node in the previous layer to obtain the forward connectivity of any node in the current layer, and thus obtaining the forward connectivity of each node in the current layer.
Specifically, the forward connectivity between each node of the first layer and the created-world node is calculated, then the forward connectivity between each node of the second layer and each node of the first layer is calculated, the forward connectivity between each node of the first layer and the second layer is added with the forward connectivity between each node of the first layer and the created-world node, the forward connectivity of each node of the second layer is obtained, and the like is repeated until the forward connectivity of all the nodes of all the layers is calculated. That is, the forward connectivity of each node of each layer is obtained by accumulating the directed edges between each layer by layer.
Referring to another flow chart of step S201 provided in the embodiment of the present application shown in fig. 5, in step S201, that is, the process of calculating the forward connectivity between each node of each layer of the original blockchain and the created node may specifically include:
step S501, the number of directed edges from each node of the last layer to each node of the previous layer of the last layer is calculated.
Step S502, adding the sum of the number of the directed edges from any node of the last layer to each node of the previous layer of the last layer to the forward connectivity of each node of the previous layer of the last layer to obtain the forward connectivity of any node of the last layer, and thus obtaining the forward connectivity of each node of the last layer; wherein, the forward connectivity of each node of the previous layer of the last layer is a value which is calculated in advance and is used as a node parameter of each node of the previous layer of the last layer.
It is to be understood that the above embodiments describe a block chain generation method based on calculating the forward connectivity and the reverse connectivity of each layer. In a specific application, the forward connectivity and the reverse connectivity of each layer before the maximum layer are calculated, and need not to be calculated again. And the calculated forward connectivity can be used as the node parameter of each node, so that when calculation is needed later, the calculated node parameter of each node is directly read, the corresponding forward connectivity value is obtained, and the forward connectivity of the corresponding node is calculated. This process may be referred to as an incremental generation process. For example, taking the block chain shown in fig. 1 as an example, all the forward connectivity pre-calculated for each node of Level 11-Level 4 layers are used as node parameters, and at this time, when the forward connectivity of each node of the last layer, namely Level5 layer needs to be calculated, only the number of directed edges from each node of the last layer to each node of the previous layer of the last layer may be calculated, that is, after the number of directed edges between the nodes at the Level5 and Level4 is calculated and the number of directed edges is calculated, the node parameters in each node in the Level4 can be read, the forward connectivity of each node in the Level4 is obtained, then adding the sum of the number of directed edges of a node in the Level5 layer and each node of the Level4 to all the forward connectivity of the node connected with the node in the Level4 layer, the forward connectivity of the node can be obtained, and the forward connectivity of each node in the Level5 layer is calculated by analogy.
It can be seen that the processing efficiency can be improved to a certain extent by the incremental algorithm without calculating the forward connectivity of all the nodes every time.
The block-link structure may be maliciously damaged, resulting in a change of the block-link structure, and at this time, when the forward connectivity of the nodes is calculated, if the node parameters previously assigned to each node are also used as the forward connectivity, which is not consistent with the actual block-link structure, the forward connectivity of each node may not be the original value. At this moment, a certain number of nodes can be extracted at regular time to serve as check nodes, the forward connectivity of the check nodes is calculated, the calculated forward connectivity is compared with the node parameters given to the nodes before, whether the forward connectivity is consistent or not is judged, if the forward connectivity is not consistent, the block chain structure is changed, the forward connectivity of all the nodes needs to be recalculated, and then the forward connectivity is given to each node again; if the forward connectivity of all the nodes is consistent, the forward connectivity of all the nodes does not need to be recalculated.
Therefore, in some embodiments of the present application, the method may further include: selecting a third preset number of nodes of a preset layer as check nodes, wherein the preset layer is a layer except the last layer; judging whether the forward connectivity parameter of the check node is correct or not; and when the forward connectivity parameter of the check node is incorrect, recalculating the forward connectivity of all nodes of the original block chain, and assigning the recalculated forward connectivity as the forward connectivity parameter to each node.
It should be noted that the preset layer refers to a layer other than the last layer, and the number of layers to be selected may be arbitrary. The third preset number may be set according to actual needs, and the third preset number values of each layer may be different, that is, the nodes selected by each layer may be different. For example, with the blockchain shown in fig. 1, Level2 and Level4 are selected as preset layers, 2 nodes are selected as check nodes in the Level2 layer, and 3 nodes are selected as check nodes in the Level4 layer.
And calculating the forward connectivity of the check nodes by using a general forward connectivity calculation method, wherein the general forward connectivity calculation method refers to a non-incremental algorithm, and the general forward connectivity calculation method is used for sequentially calculating the forward connectivity of all nodes in all layers related to the check nodes and then obtaining the forward connectivity of the check nodes. Then, judging whether the calculated forward connectivity of the check node is consistent with the forward connectivity parameters given to the node before, if not, recalculating the forward connectivity of all the nodes, and then giving the calculated forward connectivity to the corresponding nodes again.
In the embodiment, the maximum layer width of each layer of the directed acyclic graph is set, that is, the upper limit is set for the width of the layer, so that the convergence rate of transaction confirmation is improved, the transaction confirmation time is more determined, and the transaction confirmation time is shortened; by setting the number of candidate nodes of each layer of the directed acyclic graph to be equal to the maximum width of the layer, namely, the number of node communication to be the maximum width of the layer, the transaction throughput is improved, the nodes and the whole graph are required to be closely connected, the access difficulty of malicious nodes is improved, and the safety is improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Example four
Referring to fig. 6, a block diagram schematically illustrates a block chain generating apparatus according to an embodiment of the present disclosure, where the block chain generating apparatus may include:
the forward connectivity calculating module 61 is configured to calculate, based on an original block chain having a formed directed acyclic graph structure, a forward connectivity between each node of each layer of the original block chain and a created node;
a guide node selection module 62, configured to select a leaf node with the largest forward connectivity at the last layer as a guide node at the last layer;
a reverse connectivity calculating module 63, configured to calculate a reverse connectivity between each node in each layer and the guidance node;
a candidate node selecting module 64, configured to select, according to a preset maximum layer width, a first preset number of nodes from large to small in each layer according to the magnitude of the reverse connectivity, where the first preset number is smaller than or equal to the maximum layer width;
a target layer determining module 65, configured to determine, according to the number of candidate nodes in each layer, a target layer to which new block connection is required;
the target node selection module 66 is configured to select a second preset number of nodes from large to small as target nodes according to the magnitude of the forward connectivity of the candidate nodes of the target layer;
and the generating module 67 is used for connecting the target node and the new block, updating the original block chain and generating an updated block chain.
In some embodiments of the present application, the target layer determining module is specifically configured to: judging whether the number of candidate nodes of the current layer is equal to the maximum width of the layer or not; if the number of the candidate nodes of the current layer is equal to the maximum width of the layer, judging whether the number of the candidate nodes of the next layer is equal to the maximum width of the layer or not; and if the number of the candidate nodes of the current layer is not equal to the maximum width of the layer, the previous layer of the current layer is the target layer.
In some embodiments of the present application, the forward connectivity calculating module is specifically configured to: calculating the forward connectivity of each node in the first layer and the created-world node; calculating the number of directed edges of each node of the current layer and each node of the previous layer by layer, wherein the current layer is a layer between the second layer and the maximum layer; and adding the forward connectivity of each node of the previous layer to the sum of the directed edge numbers of any node of the current layer and each node of the previous layer to obtain the forward connectivity of any node of the current layer, and thus obtaining the forward connectivity of each node of the current layer.
In some embodiments of the present application, the forward connectivity calculating module is specifically configured to: calculating the number of directed edges from each node of the last layer to each node of the previous layer of the last layer; adding the forward connectivity of each node of the last layer to the sum of the number of directed edges of each node of the last layer to each node of the previous layer of the last layer to obtain the forward connectivity of any node of the last layer, and thus obtaining the forward connectivity of each node of the last layer; wherein, the forward connectivity of each node of the previous layer of the last layer is a value which is calculated in advance and is used as a node parameter of each node of the previous layer of the last layer.
In some embodiments of the present application, the apparatus may further include:
the selecting module is used for selecting a third preset number of nodes of a preset layer as check nodes, wherein the preset layer is a layer except the last layer;
the judging module is used for judging whether the forward connectivity parameter of the check node is correct or not;
and the recalculation module is used for recalculating the forward connectivity of all the nodes of the original block chain when the forward connectivity parameter of the check node is incorrect, and assigning the recalculated forward connectivity as a forward connectivity parameter to each node.
In some embodiments of the present application, the candidate node selecting module is specifically configured to: sequencing the nodes in each layer from large to small according to the reverse connectivity; and selecting a first preset number of nodes from each layer as candidate nodes of each layer, wherein the first preset number is less than or equal to the maximum width of each layer.
In some embodiments of the present application, the second predetermined number is two; the generation module is specifically configured to: and respectively connecting the new block with the two target nodes, merging the new block into the node set, merging the directed edges between the new block and the two target nodes into the directed edge set, and obtaining the updated block chain.
In the embodiment, the maximum layer width of each layer of the directed acyclic graph is set, that is, the upper limit is set for the width of the layer, so that the convergence rate of transaction confirmation is improved, the transaction confirmation time is more determined, and the transaction confirmation time is shortened; by setting the number of candidate nodes of each layer of the directed acyclic graph to be equal to the maximum width of the layer, namely, the number of node communication to be the maximum width of the layer, the transaction throughput is improved, the nodes and the whole graph are required to be closely connected, the access difficulty of malicious nodes is improved, and the safety is improved.
EXAMPLE five
Fig. 7 is a schematic diagram of a terminal device according to an embodiment of the present application. As shown in fig. 7, the terminal device 7 of this embodiment includes: a processor 70, a memory 71 and a computer program 72 stored in said memory 71 and executable on said processor 70. The processor 70, when executing the computer program 72, implements the steps in the above-described embodiments of the block chain generation method, such as the steps S201 to S207 shown in fig. 2. Alternatively, the processor 70, when executing the computer program 72, implements the functions of the modules or units in the above-described device embodiments, such as the functions of the modules 61 to 67 shown in fig. 6.
Illustratively, the computer program 72 may be partitioned into one or more modules or units that are stored in the memory 71 and executed by the processor 70 to accomplish the present application. The one or more modules or units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 72 in the terminal device 7. For example, the computer program 72 may be divided into a forward connectivity calculation module, a guide node selection module, a reverse connectivity calculation module, a candidate node selection module, a target layer determination module, a target node selection module, and a generation module, each of which has the following specific functions:
the forward connectivity calculation module is used for calculating the forward connectivity of each node of each layer of the original block chain and the created nodes based on the formed original block chain in the directed acyclic graph structure; the guide node selection module is used for selecting the leaf node with the maximum forward connectivity of the last layer as the guide node of the last layer; the reverse connectivity calculation module is used for calculating the reverse connectivity of each node and the guide node in each layer; the candidate node selecting module is used for selecting a first preset number of nodes from large to small according to the reverse connectivity in each layer according to the preset maximum width of the layer, wherein the first preset number is smaller than or equal to the maximum width of the layer; the target layer determining module is used for determining a target layer which needs to be subjected to new block connection according to the number of the candidate nodes of each layer; the target node selection module is used for selecting a second preset number of nodes from large to small as target nodes according to the forward connectivity of the candidate nodes of the target layer; and the generating module is used for connecting the target node and the new block, updating the original block chain and generating an updated block chain.
The terminal device 7 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 70, a memory 71. It will be appreciated by those skilled in the art that fig. 7 is merely an example of a terminal device 7 and does not constitute a limitation of the terminal device 7 and may comprise more or less components than shown, or some components may be combined, or different components, for example the terminal device may further comprise input output devices, network access devices, buses, etc.
The Processor 70 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or a memory of the terminal device 7. The memory 71 may also be an external storage device of the terminal device 7, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the terminal device 7. The memory 71 is used for storing the computer program and other programs and data required by the terminal device. The memory 71 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus, terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus and the terminal device are merely illustrative, and for example, the division of the module or the unit is only one logical function division, and there may be another division in actual implementation, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules or units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should 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; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (10)

1. A method for generating a block chain, comprising:
calculating the forward connectivity of each node of each layer of the original block chain and the created nodes based on the formed original block chain in a directed acyclic graph structure;
selecting a leaf node with the maximum forward connectivity in the last layer as a guide node of the last layer;
calculating the reverse connectivity of each node in each layer and the guide node;
according to the preset maximum width of the layer, selecting a first preset number of nodes from large to small in each layer according to the reverse connectivity as candidate nodes of each layer, wherein the first preset number is smaller than or equal to the maximum width of the layer;
determining a target layer needing to be subjected to new block connection according to the number of the candidate nodes of each layer;
selecting a second preset number of nodes as target nodes from large to small according to the forward connectivity of the candidate nodes of the target layer;
and connecting the target node and the new block, updating the original block chain, and generating an updated block chain.
2. The method of claim 1, wherein determining a target layer for which a new block connection is required according to the number of candidate nodes in each layer comprises:
judging whether the number of candidate nodes of the current layer is equal to the maximum width of the layer or not;
when the number of the candidate nodes of the current layer is equal to the maximum width of the layer, judging whether the number of the candidate nodes of the next layer is equal to the maximum width of the layer;
and when the number of the candidate nodes of the current layer is not equal to the maximum width of the layer, the previous layer of the current layer is the target layer.
3. The method according to claim 1 or 2, wherein said calculating the forward connectivity between each node of each layer of the original blockchain and a created-world node comprises:
calculating the forward connectivity of each node in the first layer and the created generation node;
calculating the number of directed edges of each node of a current layer and each node of a previous layer by layer, wherein the current layer is a layer between a second layer and a maximum layer;
and adding the forward connectivity of each node of the previous layer to the sum of the number of the directed edges of any node of the current layer and each node of the previous layer to obtain the forward connectivity of any node of the current layer, and thus obtaining the forward connectivity of each node of the current layer.
4. The method according to claim 1 or 2, wherein said calculating the forward connectivity between each node of each layer of the original blockchain and a created-world node comprises:
calculating the number of directed edges from each node of the last layer to each node of the previous layer of the last layer;
adding the forward connectivity of each node of the last layer to the sum of the number of directed edges of each node of the last layer to each node of the previous layer of the last layer to obtain the forward connectivity of each node of the last layer, and thus obtaining the forward connectivity of each node of the last layer;
wherein the forward connectivity of each node of the previous layer of the last layer is a value which is pre-calculated and used as a node parameter of each node of the previous layer of the last layer.
5. The blockchain generation method of claim 4, further comprising:
selecting a third preset number of nodes of a preset layer as check nodes, wherein the preset layer is a layer except the last layer;
judging whether the forward connectivity parameter of the check node is correct or not;
and when the forward connectivity parameter of the check node is incorrect, recalculating the forward connectivity of all nodes of the original block chain, and assigning the recalculated forward connectivity as the forward connectivity parameter to each node.
6. The method according to claim 4, wherein the selecting a first predetermined number of nodes from large to small according to the magnitude of the reverse connectivity in each layer as the candidate nodes of each layer according to a predetermined maximum layer width comprises:
sequencing the nodes in each layer from large to small according to the reverse connectivity;
and selecting a first preset number of nodes from each layer as the candidate nodes of each layer, wherein the first preset number is less than or equal to the maximum width of each layer.
7. The method of claim 6, wherein the second predetermined number is two; the connecting the target node and the new block, updating the original block chain, and generating an updated block chain includes:
and respectively connecting the new block with the two target nodes, merging the new block into a node set, merging the directed edges between the new block and the two target nodes into a directed edge set, and obtaining an updated block chain.
8. An apparatus for generating a block chain, comprising:
the forward connectivity calculation module is used for calculating the forward connectivity of each node of each layer of the original block chain and the created nodes based on the formed original block chain in the directed acyclic graph structure;
the guide node selecting module is used for selecting the leaf node with the maximum forward connectivity in the last layer as the guide node of the last layer;
the reverse connectivity calculation module is used for calculating the reverse connectivity of each node in each layer and the guide node;
the candidate node selecting module is used for selecting a first preset number of nodes from large to small according to the reverse connectivity in each layer according to the preset maximum width of the layer, wherein the first preset number is smaller than or equal to the maximum width of the layer;
the target layer determining module is used for determining a target layer which needs to be subjected to new block connection according to the number of the candidate nodes of each layer;
the target node selection module is used for selecting a second preset number of nodes from large to small as target nodes according to the forward connectivity of the candidate nodes of the target layer;
and the generating module is used for connecting the target node and the new block, updating the original block chain and generating an updated block chain.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.
CN201811071960.1A 2018-09-14 2018-09-14 Block chain generation method and device, terminal equipment and storage medium Active CN110910242B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811071960.1A CN110910242B (en) 2018-09-14 2018-09-14 Block chain generation method and device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811071960.1A CN110910242B (en) 2018-09-14 2018-09-14 Block chain generation method and device, terminal equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110910242A true CN110910242A (en) 2020-03-24
CN110910242B CN110910242B (en) 2022-12-02

Family

ID=69813340

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811071960.1A Active CN110910242B (en) 2018-09-14 2018-09-14 Block chain generation method and device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110910242B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150134663A1 (en) * 2012-05-15 2015-05-14 Tencent Technology (Shenzhen) Company Limited Method, apparatus, and computer-readable storage medium for grouping social network nodes
CN108509615A (en) * 2018-03-30 2018-09-07 深圳市元征科技股份有限公司 Common recognition method for building up, device and readable storage medium storing program for executing based on lottery mechanism

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150134663A1 (en) * 2012-05-15 2015-05-14 Tencent Technology (Shenzhen) Company Limited Method, apparatus, and computer-readable storage medium for grouping social network nodes
CN108509615A (en) * 2018-03-30 2018-09-07 深圳市元征科技股份有限公司 Common recognition method for building up, device and readable storage medium storing program for executing based on lottery mechanism

Also Published As

Publication number Publication date
CN110910242B (en) 2022-12-02

Similar Documents

Publication Publication Date Title
CN108701250B (en) Data fixed-point method and device
CN109754359B (en) Pooling processing method and system applied to convolutional neural network
CN111159329B (en) Sensitive word detection method, device, terminal equipment and computer readable storage medium
Benchohra et al. Boundary value problems for nonlinear implicit Caputo–Hadamard-type fractional differential equations with impulses
WO2022017167A1 (en) Information processing method and system, electronic device, and storage medium
CN103309893A (en) Character string comparing method and device
US20210209690A1 (en) Order matching
CN108447103A (en) A kind of segmentation line segment approximating method and device
CN105528183A (en) Data storage method and storage equipment
CN110009048B (en) Method and equipment for constructing neural network model
CN110910242B (en) Block chain generation method and device, terminal equipment and storage medium
CN114138231B (en) Method, circuit and SOC for executing matrix multiplication operation
CN111178513B (en) Convolution implementation method and device of neural network and terminal equipment
CN111402958A (en) Method, system, equipment and medium for establishing gene comparison table
KR20150103644A (en) Method of cryptographic processing of data on elliptic curves, corresponding electronic device and computer program product
CN108062289B (en) Fast Fourier Transform (FFT) address order changing method, signal processing method and device
CN113905066B (en) Networking method of Internet of things, networking device of Internet of things and electronic equipment
WO2021037284A2 (en) Propeller airfoil design method and terminal device
CN111158757B (en) Parallel access device and method and chip
CN111191362B (en) Graph computation data preprocessing method, device, equipment and medium based on FPGA
US10761847B2 (en) Linear feedback shift register for a reconfigurable logic unit
CN111475135B (en) Multiplier unit
CN111126465B (en) Node classification method and device, terminal equipment and computer readable storage medium
TWI754970B (en) Device, method and storage medium for accelerating operation of an activation function
CN112596770B (en) Data processing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant