CN109300032A - Block generation method, device, equipment and computer readable storage medium - Google Patents
Block generation method, device, equipment and computer readable storage medium Download PDFInfo
- Publication number
- CN109300032A CN109300032A CN201810948611.7A CN201810948611A CN109300032A CN 109300032 A CN109300032 A CN 109300032A CN 201810948611 A CN201810948611 A CN 201810948611A CN 109300032 A CN109300032 A CN 109300032A
- Authority
- CN
- China
- Prior art keywords
- transaction
- node
- comparison
- transaction information
- transaction node
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
Landscapes
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- Engineering & Computer Science (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- Strategic Management (AREA)
- Technology Law (AREA)
- Physics & Mathematics (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
It includes: reception Transaction Information that the present invention, which provides a kind of block generation method, device, equipment and computer readable storage medium, method, is ranked up according to the priority for including in Transaction Information to received Transaction Information;After obtaining book keeping operation power, target transaction information is determined in Transaction Information according to ranking results, and block is generated according to target transaction information.Method, apparatus, equipment and computer readable storage medium provided by the invention, before network node obtains book keeping operation power, just received Transaction Information is ranked up, to after network node obtains book keeping operation power, directly can determine target transaction information according to ranking results, and block is generated according to target transaction information, solve in the prior art network node after obtaining book keeping operation power, the problem of Transaction Information is ranked up again, causes the long time for generating block, low efficiency.
Description
Technical field
The present invention relates to block chain technology more particularly to a kind of block generation method, device, equipment and computer-readable deposit
Storage media.
Background technique
Block chain technology has the characteristics that anti-tamper and traceable, and more and more data are deposited in the form of block chain
Storage, such as the storage of Transaction Information.
Network based on block chain building includes many network nodes, and after each node receives Transaction Information, transaction is believed
Breath write-in present node buffer area, node obtain book keeping operation power after, according to ordering strategy to the Transaction Information in buffer area into
Row sequence, then the Transaction Information generation block of needs is obtained, and broadcast to other nodes.
But in the scheme of the prior art, block is generated every time and requires to be ranked up Transaction Information, works as Transaction Information
When quantity is larger, sorting time is longer, the problem for causing the efficiency for generating block lower.
Summary of the invention
The present invention provides a kind of block generation method, device, equipment and computer readable storage medium, to solve existing skill
When Transaction Information quantity is larger in art, according to the lower problem of the efficiency of Transaction Information generation block.
The first aspect of the invention is to provide a kind of block generation method, comprising:
Transaction Information is received, the received Transaction Information is arranged according to the priority for including in the Transaction Information
Sequence;
After obtaining book keeping operation power, target transaction information is determined in the Transaction Information according to ranking results, and according to described
Target transaction information generates block.
Another aspect of the present invention is to provide a kind of block generating means, comprising:
Receiving module, for receiving Transaction Information, according to the priority for including in the Transaction Information to received described
Transaction Information is ranked up;
Determining module determines target transaction letter according to ranking results after obtaining book keeping operation power in the Transaction Information
Breath;
Generation module, for generating block according to the target transaction information.
An additional aspect of the present invention is to provide a kind of block generating device, comprising:
Memory;
Processor;And
Computer program;
Wherein, the computer program stores in the memory, and is configured to be executed by the processor to realize
Block generation method as described in above-mentioned first aspect.
Another aspect of the invention is to provide a kind of computer readable storage medium, is stored thereon with computer program,
The computer program is executed by processor to realize the block generation method as described in above-mentioned first aspect.
Block generation method provided by the invention, device, equipment and computer readable storage medium have the technical effect that
Block generation method, device, equipment and computer readable storage medium provided by the invention, comprising: receive transaction
Information is ranked up received Transaction Information according to the priority for including in Transaction Information;After obtaining book keeping operation power, according to sequence
As a result target transaction information is determined in Transaction Information, and block is generated according to target transaction information.Method provided by the invention,
Device, equipment and computer readable storage medium, before network node obtains book keeping operation power, just to received Transaction Information
It is ranked up, so that after network node obtains book keeping operation power target transaction information directly can be determined according to ranking results, and
According to target transaction information generate block, solve in the prior art network node obtain book keeping operation power after, then to Transaction Information into
Row sequence causes the problem of generating the time length of block, low efficiency.
Detailed description of the invention
Fig. 1 is the flow chart of the block generation method shown in an exemplary embodiment of the invention;
Fig. 2 is the flow chart of the block generation method shown in another exemplary embodiment of the present invention;
Fig. 2A is the flow chart of the method for the building binary tree shown in an exemplary embodiment of the invention;
Fig. 2 B is the flow chart of the method for the building binary tree shown in another exemplary embodiment of the present invention;
Fig. 2 C is the flow chart of the method for the building binary tree shown in another exemplary embodiment of the present invention;
Fig. 2 D is the binary tree structure figure that the building shown in an exemplary embodiment of the invention is completed;
Fig. 2 E is the binary tree structure figure after the reconstruct shown in an exemplary embodiment of the invention;
Fig. 2 F is the binary tree structure figure after the reconstruct shown in another exemplary embodiment of the present invention;
Fig. 2 G is the binary tree structure figure after the reconstruct shown in another exemplary embodiment of the present invention;
Fig. 3 is the structure chart of the block generating means shown in an exemplary embodiment of the invention;
Fig. 4 is the structure chart of the block generating means shown in another exemplary embodiment of the present invention;
Fig. 5 is the structure chart of the block generating device shown in an exemplary embodiment of the invention.
Specific embodiment
Fig. 1 is the flow chart of the block generation method shown in an exemplary embodiment of the invention.
As shown in Figure 1, block generation method provided in this embodiment includes:
Step 101, Transaction Information is received, received Transaction Information is arranged according to the priority for including in Transaction Information
Sequence.
Scheme provided in this embodiment be based on block chain technology store transaction information, block chain be Distributed Storage,
The new application mode of the computer technologies such as point-to-point transmission, common recognition mechanism, Encryption Algorithm.So-called common recognition mechanism is block linkwork
The mathematical algorithm established between different nodes and trust, obtain equity is realized in system.
Wherein, include multiple network nodes in block chain network, can carry out data transmission between these network nodes.
In a kind of real-time mode, network node can be both the node and reception Transaction Information for sending Transaction Information
Node.For example, Transaction Information can be generated in network node A, then the Transaction Information of generation is broadcasted to block chain network, so that
Each network node receives the Transaction Information, for example, network node B can receive the Transaction Information.Network node B can also give birth to
It broadcasts at Transaction Information, then by the Transaction Information of generation to block chain network, so that other network nodes can receive the friendship
Easy information, for example, network node A can receive the Transaction Information.
In another real-time mode, network node can only receive Transaction Information.It can be by being arranged in user terminal
Client generates Transaction Information, then the Transaction Information is sent in block chain network by user terminal, to make each net
Network node can receive the Transaction Information.
Specifically, the priority of transaction can be carried in Transaction Information, to make network node according to priority to each
A Transaction Information is ranked up.It, can be according to the generation time of transaction, type of transaction, transaction amount when generating Transaction Information
Equal various dimensions information determines priority, and the present embodiment is limited not to this.
Further, in method provided in this embodiment, after network node receives Transaction Information, Transaction Information is stored
Transaction existing in buffer area is believed at buffer area (also referred to as trading pit or pond to be transacted), and according to the priority of Transaction Information
Breath is ranked up.
When practical application, if when network node receives Transaction Information, without Transaction Information, then received friendship in buffer area
Easy information sequence is 1.If having Transaction Information when network node receives Transaction Information in buffer area, then handing over based on the received
Existing Transaction Information is ranked up in easy information and buffer area.For example, in buffer area have 10 Transaction Informations, and this 10
A Transaction Information has ordinal relation, after receiving Transaction Information again, then new received Transaction Information is stored in buffer area, and
Again this 11 Transaction Informations are ranked up.
Wherein, specific sortord is not limited.For example, can be traversed existing after receiving Transaction Information
Transaction Information priority, and Transaction Information and existing Transaction Information are determined and are sorted based on the received.
Specifically, the received Transaction Information of network node can be for 1 or multiple.
Optionally, network node can also verify Transaction Information, and verification is passed through after receiving Transaction Information
Transaction Information be put into buffer area.
Step 102, obtain book keeping operation power after, according to ranking results in Transaction Information determine target transaction information, and according to
Target transaction information generates block.
Specifically, including multiple network nodes in block chain network, each network node can be set and obtain book keeping operation power
Rule can also be distributed to each network node according to polling algorithm and be kept accounts for example, each network node can compete book keeping operation power
Permission.
Further, after network node obtains book keeping operation power, target transaction letter is determined in Transaction Information according to ranking results
Breath.
When practical application, the rule that target transaction information is determined according to Transaction Information ranking results, example can be preset
Such as, preceding 5 Transaction Informations that sort are obtained.Due to being sorted to received All Activity information in step 101, because
This, can directly determine target transaction information according to ranking results in Transaction Information.Without after obtaining book keeping operation power, then to friendship
Easy information is ranked up, to solve the problems, such as that block formation efficiency is lower.
After target transaction information has been determined, block, specific generation area can be generated according to determining target transaction information
The mode of block can use mode in the prior art.
Wherein, network node can also broadcast the block of generation to block chain network, so that other network nodes can
Block is received, and block chain is written into received block.
Method provided in this embodiment is for generating block, equipment of this method by being equipped with method provided in this embodiment
It executes, which realizes usually in a manner of hardware and/or software.
Block generation method provided in this embodiment, comprising: Transaction Information is received, it is preferential according to include in Transaction Information
Grade is ranked up received Transaction Information;After obtaining book keeping operation power, target transaction is determined in Transaction Information according to ranking results
Information, and block is generated according to target transaction information.Method provided in this embodiment, before network node obtains book keeping operation power,
Just received Transaction Information is ranked up, thus after network node obtains book keeping operation power, it can be directly according to sequence
As a result it determines target transaction information, and block is generated according to target transaction information, solve network node in the prior art and obtaining
The problem of after book keeping operation power, then Transaction Information being ranked up, causing the long time for generating block, low efficiency.
Fig. 2 is the flow chart of the block generation method shown in another exemplary embodiment of the present invention.
As shown in Fig. 2, block generation method provided in this embodiment, comprising:
Step 201, Transaction Information is received.
Step 201 is similar with the concrete principle of step 101 and implementation, and details are not described herein again.
Step 202, judge in buffer area whether to include root transaction node.
Wherein, in method provided in this embodiment, Transaction Information can be ranked up based on binary tree structure.It is calculating
In machine science, binary tree is the tree construction that each node is up to two subtrees.Usual subtree is referred to as " left subtree " (left
) and " right subtree " (right subtree) subtree.Binary tree is commonly used for realizing binary search tree and Binary Heap.This implementation
In example, each node in binary tree structure is a Transaction Information, i.e., each node is transaction node.
Further, binary tree can be constructed in the buffer area (also referred to as trading pit or pond to be transacted) of network node.
The buffer area can be pre-set region, can be used to store transaction information and binary tree structure.
When practical application, binary tree structure includes root node, and bifurcated obtains subtree, each subtree on the basis of root node
New subtree can be obtained with bifurcated again, to constitute binary tree structure, therefore, root node is the start node of binary tree structure.
The priority relationship in binary tree between each node location can also be pre-defined, for example, the priority of left subtree is higher than the right side
The priority of subtree.
It may determine that in buffer area whether include that root transaction node illustrates in buffer area if not including without binary tree
Structure thens follow the steps 203.If including root transaction node in buffer area, illustrate there is binary tree structure in buffer area, at this point,
Step 204 can be executed.
Step 203, received Transaction Information is determined as root transaction node.
Wherein, in method provided in this embodiment, the form based on binary tree structure is ranked up Transaction Information.When slow
It rushes in area when there is no root node, it is believed that binary tree structure not yet in buffer area, at this point it is possible to directly by received transaction
Information is determined as the root transaction node of binary tree.It, can be true based on current root transaction node after receiving Transaction Information again
The node location of fixed new received Transaction Information.
Step 204, root transaction node is determined as comparing transaction node.
Specifically, the structure of binary tree also can be more complicated when Transaction Information is more, it therefore, can be by y-bend tree root
Node is determined as comparing transaction node, then the comparison transaction node determines position of the Transaction Information in binary tree.
Step 205, the priority for comparing comparison transaction node and Transaction Information constructs binary tree knot according to comparison result
Structure.
Further, each node in binary tree is a Transaction Information, and therefore, comparison transaction node has corresponding
Priority, comparison transaction and the priority of received Transaction Information height can be compared, transaction letter is determined according to comparison result
The position in binary tree is ceased, to construct binary tree structure.For example, the binary tree structure in buffer area only includes that a root is handed over
The root transaction node is then determined as comparing transaction node, and determines Transaction Information relative to right according to comparison result by easy node
Than the positional relationship of transaction node.
When practical application, it can be determined according to the priority relationship between node location each in pre-defined binary tree
Positional relationship of the Transaction Information relative to comparison transaction node.For example, the priority of left subtree is higher than in pre-defined binary tree
The priority of right subtree can determine transaction letter if then the priority of Transaction Information is higher than the priority of comparison transaction node
Breath is located in the left subtree structure of comparison transaction.
Wherein, comparison result is different, and the specific implementation for constructing binary tree is also different.
Fig. 2A is the flow chart of the method for the building binary tree shown in an exemplary embodiment of the invention.
As shown in Figure 2 A, it if the priority of Transaction Information is identical as the comparison priority of transaction node, executes and walks
It is rapid:
Step 2051, Transaction Information is determined as comparing the sane level node of transaction node.
If Transaction Information is identical as the comparison priority of transaction node, then it is assumed that the two is sane level node, i.e. rank is identical
Node.
Step 2052, according to comparison transaction node left subtree and/or right subtree determine Transaction Information left subtree and/or
Right subtree.
Since comparison transaction node is identical as the rank of Transaction Information, it can will compare the left subtree of transaction node
And/or right subtree is also used as the left subtree and/or right subtree of Transaction Information.The son of transaction node will can not be directly compared herein
Tree is connected on Transaction Information, but the relationship for comparing transaction node and Transaction Information is determined as to the relationship of the brother of node.When
After comparison transaction node is deleted, its subtree can be connected on its brother of node.
It wherein, can be according to the time sequencing for being added to binary tree if comparison transaction node includes multiple brother of nodes
These brother of nodes are ranked up, for example comparison transaction node is A, first brother of node determined can be A1, really
Second fixed brother of node can be A2, and so on.When comparison transaction node A is deleted, the subtree of A is connected to together
On grade node A1, after A1 is deleted, then the subtree of A1 is connected on A2, and so on.
Fig. 2 B is the flow chart of the method for the building binary tree shown in another exemplary embodiment of the present invention.
As shown in Figure 2 B, it if the priority of the Transaction Information is higher than the priority of the comparison transaction node, executes
Following steps:
Step 2053, judge to compare whether transaction node has left subtree.
Wherein, left subtree herein can only include a transaction node, also may include multiple transaction nodes, for example,
The left subtree for comparing transaction node A can only include transaction node A1, and A is connect with A1.The left subtree for comparing transaction node A can also
To include tri- transaction nodes of B, C, D, wherein B is connect with A, and C, D are the left subtree and right subtree of B respectively.
Specifically, the priority of left subtree is higher than the priority of right subtree, i.e., for right in method provided in this embodiment
For transaction node, the priority for the transaction node that left subtree includes is higher than the priority of the comparison transaction node, comparison
The priority of transaction node is higher than the priority for the transaction node that its right subtree includes.
Further, since the priority of Transaction Information is higher than the priority of comparison transaction node, it tentatively can be true
Determine the left subtree part that Transaction Information belongs to comparison transaction node.
When practical application, it can be determined that whether comparison transaction node has left subtree, if so, 2054 are thened follow the steps, otherwise,
Execute step 2056.
Step 2054, new comparison transaction node is determined according to the left subtree of comparison transaction node.
Wherein, it when the priority of Transaction Information is higher than the priority of comparison transaction node, is merely able to determine Transaction Information
One is included at least in the left subtree if comparison transaction node has left subtree positioned at the position of comparison transaction node left subtree
A transaction node, at this point it is possible to determine new comparison transaction node according to the left subtree of comparison transaction node, and based on new pair
The position of determining Transaction Information more further than transaction node.
It is handed over specifically, the transaction node directly connecting with comparison transaction node in left subtree can be determined as new comparison
Easy node.Such as the left subtree of comparison transaction node A includes tri- transaction nodes of B, C, D, wherein B is connect with A, and C, D are respectively
Transaction node B is then determined as new comparison transaction node by the left subtree and right subtree of B.
Further, for the left subtree, wherein can recognize with the transaction node of comparison transaction node direct neighbor
It can further be determined for the root node for being the left subtree at this point, this root node to be determined as to new comparison transaction node
The position of Transaction Information.
When practical application, above-mentioned steps are based on, each comparison transaction node only has a left subtree connected to it, and
The priority for the transaction node for including in the left subtree is higher than the priority of the comparison transaction node.
Step 2055, it is continued to execute according to new comparison transaction node and compares comparison transaction and the priority of Transaction Information
Step.
Step 2055 is identical as the alignments in step 205, and continues to construct binary tree structure based on comparison result.
Step 2056, Transaction Information is determined as comparing the left subtree of transaction node.
Since comparison transaction node does not have left subtree, then explanation compares in the subtree of transaction node in binary tree structure,
Transaction node not bigger than its priority, and Transaction Information belongs to the left subtree part of comparison transaction node, and letter of trading
The priority of breath is greater than the priority of the transaction node, therefore, Transaction Information can be determined as comparing the left son of transaction node
Tree.
Fig. 2 C is the flow chart of the method for the building binary tree shown in another exemplary embodiment of the present invention.
As shown in Figure 2 C, if the priority of Transaction Information executes following lower than the priority of the comparison transaction node
Step:
Step 2057, judge to compare whether transaction node has right subtree.
Wherein, right subtree herein can only include a transaction node, also may include multiple transaction nodes.
Specifically, the priority of left subtree is higher than the priority of right subtree, i.e., for right in method provided in this embodiment
For transaction node, the priority for the transaction node that left subtree includes is higher than the priority of the comparison transaction node, comparison
The priority of transaction node is higher than the priority for the transaction node that its right subtree includes.
Further, the priority due to the priority of Transaction Information lower than comparison transaction node, it tentatively can be true
Determine the right subtree part that Transaction Information belongs to comparison transaction node.
When practical application, it can be determined that whether comparison transaction node has right subtree, if so, 2058 are thened follow the steps, otherwise,
Execute step 2060.
Step 2058, new comparison transaction node is determined according to the right subtree of comparison transaction node.
Wherein, it when the priority of Transaction Information is lower than the priority for comparing transaction node, is merely able to determine Transaction Information
One is included at least in the right subtree if comparison transaction node has right subtree positioned at the position of comparison transaction node right subtree
A transaction node, at this point it is possible to determine new comparison transaction node according to the right subtree of comparison transaction node, and based on new pair
The position of determining Transaction Information more further than transaction node.
It is handed over specifically, the transaction node directly connecting with comparison transaction node in right subtree can be determined as new comparison
Easy node.
Further, for the right subtree, wherein can recognize with the transaction node of comparison transaction node direct neighbor
It can further be determined for the root node for being the right subtree at this point, this root node to be determined as to new comparison transaction node
The position of Transaction Information.
When practical application, above-mentioned steps are based on, each comparison transaction node only has a right subtree connected to it, and
The priority for the transaction node for including in the right subtree is lower than the priority of the comparison transaction node.
Step 2059, the priority for comparing comparison transaction node and Transaction Information is continued to execute according to new comparison transaction
Step.
Step 2055 is identical as the alignments in step 205, and continues to construct binary tree structure based on comparison result.
Step 2060, Transaction Information is determined as comparing the right subtree of transaction node.
Since comparison transaction node does not have right subtree, then explanation compares in the subtree of transaction node in binary tree structure,
Transaction node more not smaller than its priority, and Transaction Information belongs to the right subtree part of comparison transaction node, and letter of trading
The priority of breath is less than the priority of the transaction node, therefore, Transaction Information can be determined as comparing the right son of transaction node
Tree.
Based on step 2051-2060, can the priority of Transaction Information based on the received construct binary tree structure so that two
Pitch the information in tree construction including priority height.It, can be according to true according to priority size also, after receiving Transaction Information
Determine position range described in Transaction Information, be such as located at left subtree or right subtree, without traversing by the institute in binary tree structure
There is transaction node, to reduce data processing amount, the position of Transaction Information can be quickly determined in binary tree.
Step 206, after obtaining book keeping operation power, target transaction node is determined in binary tree structure according to preset algorithm.
Wherein it is possible to preset algorithm, it is used for after network node obtains book keeping operation power, from the y-bend built in advance
Target transaction node is directly determined in tree construction.Due to including the information of priority height in binary tree structure, and based on preferential
Grade information determines the left subtree of each transaction node, right subtree, so that network node is not necessarily to after obtaining book keeping operation power to transaction
Information is ranked up, it will be able to determine target transaction node based on the ranking results for including in binary tree.
Specifically, the preset algorithm can be the combination algorithm of the inorder traversal algorithm of binary tree and the traversal of chained list.Two
The inorder traversal method of fork tree traverses left subtree first, then accesses root node, finally traverses right subtree.Due to the present embodiment provides
Method in, the priority of left subtree is higher than root node priority, and root node priority is higher than right subtree priority therefore can
It, can be according to the order traversal transaction node from high in the end of priority to use inorder traversal method.
Further, the strategy of determining target transaction node can also be set, for example, obtaining 10 target transaction sections every time
Point then can traverse 10 target transaction nodes according to preset algorithm, without traversing whole nodes.
When practical application, if in binary tree structure including sane level node, when traversing sane level node according to preset algorithm,
It is traversed according to the sequence that binary tree is added in sane level node.It is obtained every time for example, being limited in the strategy of determining target transaction node
10 destination nodes are taken, are A in the 9th transaction node of traversal, transaction node A has first sane level node A1, and second
Sane level node A2, at this point, the 10th transaction node of traversal is first sane level node A1 of A, i.e., by first sane level node
A1 is determined as target transaction node.
Step 207, block is generated according to target transaction information.
Step 207 is similar to the mode of block is generated in step 102, repeats no more.
Optionally, method provided in this embodiment can also include:
Step 208, the target transaction node in binary tree structure is deleted, and reconstructs remaining transaction node in binary tree
Connection relationship.
Wherein, in order to avoid generating multiple block according to same transaction node, then the mesh in binary tree structure can be deleted
Mark transaction node.It can specifically be deleted in binary tree structure by the relationship between contact target transaction node and other transaction nodes
Target transaction node.
Specifically, can still store the corresponding Transaction Information of target transaction node in buffer area, two are only deleted
Pitch the target transaction node in tree construction.
Further, after target transaction node is deleted, then other transaction relevant to the target transaction node are reconstructed
The connection relationship of node.
When practical application, if target transaction node has the brother of node, by the left subtree of the target transaction node, right son
Tree is connected on its brother of node;If target transaction node does not have the brother of node, the right subtree of the target transaction is connected to
On the root node of the target transaction node.It is that sequence determines that target is handed over according to the priority in method provided in this embodiment
Easy node, therefore, the priority of remaining transaction node is centainly lower than target transaction node, and the left son of target transaction node
Therefore node priority in tree, which is higher than target transaction node, not will include target transaction node in remaining transaction node
Left subtree.
In the following, block generation method illustrated in fig. 2 is described in detail with a specific embodiment.
Assuming that network node receives the sequence of Transaction Information are as follows: 5-3-1-6-8-9-7-8-2-4, wherein number represents every
The priority of a Transaction Information represents each Transaction Information with priority for ease of description.
It receives Transaction Information " 5 ".
Judge in buffer area whether to include root transaction node, judging result is no.
Received Transaction Information " 5 " is determined as root transaction node.
It receives Transaction Information " 3 ".
Judge in buffer area whether to include root transaction node, judging result is yes.
Root transaction node " 5 " is determined as to compare transaction node.
The priority of comparison transaction node " 5 " and Transaction Information " 3 " is compared, comparison result is that the priority of Transaction Information is low
In the priority of comparison transaction node.
Judge to compare whether transaction node " 5 " have right subtree, judging result is no.
Transaction Information " 3 " is determined as to compare the right subtree of transaction node " 5 ".
It receives Transaction Information " 1 ".
Judge in buffer area whether to include root transaction node, judging result is yes.
Root transaction node " 5 " is determined as to compare transaction node.
The priority of comparison transaction node " 5 " and Transaction Information " 1 " is compared, comparison result is that the priority of Transaction Information is low
In the priority of comparison transaction node.
Judge to compare whether transaction node " 5 " have right subtree, judging result is yes.
Determine that new comparison transaction node, new comparison transaction node are according to the right subtree of comparison transaction node " 5 "
“3”。
The priority of comparison transaction node " 3 " and Transaction Information " 1 " is compared, comparison result is that the priority of Transaction Information is low
In the priority of comparison transaction node.
Judge to compare whether transaction node " 3 " have right subtree, judging result is no.
Transaction Information " 1 " is determined as to compare the right subtree of transaction node " 3 ".
The circulation of above-mentioned steps is excessively taken turns, binary tree structure can be constructed according to above-mentioned Transaction Information, it can be with reference to figure
2D, Fig. 2 D are the binary tree structure figure that the building shown in an exemplary embodiment of the invention is completed.
When deleting the target transaction node in binary tree structure and reconstructing the connection relationship of remaining transaction node in binary tree,
There are three situations:
The first, only releases the connection relationship of target transaction node.
For example, in above-mentioned example, only determine a target transaction node, then target transaction node is " 9 ", release " 9 " with
Relationship between other transaction nodes, can refer to Fig. 2 E, and Fig. 2 E is two after the reconstruct shown in an exemplary embodiment of the invention
Pitch tree structure diagram.
Second, target transaction node has sane level node.
For example, in above-mentioned example, it is thus necessary to determine that two target transaction nodes, then target transaction node is " 8,9 ", at this point,
Target transaction node 8 has sane level node 8 (1).At this point, the connection relationship between transaction node 8,9 and other transaction nodes is released,
Also, it is connected to the remaining node connecting with transaction node 8 on sane level node 8 (1), Fig. 2 F can be referred to, Fig. 2 F is this
Binary tree structure figure after reconstruct shown in invention another exemplary embodiment.
The third, target transaction node has right subtree.
When target transaction node has right subtree, since target transaction node is deleted, the right subtree is caused to be detached from y-bend
Tree construction, at this point it is possible to the upper layer node of target transaction node, the i.e. root node of target transaction node be determined, by the right subtree
It is connected on determining root node.For example, in above-mentioned example, it is thus necessary to determine that three target transaction nodes, then target transaction node
For " 8,8 (1), 9 ", at this point, target transaction node " 8 " has right subtree node " 7 ", then by the root of right subtree node " 7 " and " 8 "
Node " 6 " connection, can refer to Fig. 2 G, and Fig. 2 G is the binary tree structure after the reconstruct shown in another exemplary embodiment of the present invention
Figure.
Fig. 3 is the structure chart of the block generating means shown in an exemplary embodiment of the invention.
As shown in figure 3, block generating means provided in this embodiment, comprising:
Receiving module 31, for receiving Transaction Information, according to the priority for including in the Transaction Information to received institute
Transaction Information is stated to be ranked up;
Determining module 32 determines target transaction according to ranking results after obtaining book keeping operation power in the Transaction Information
Information;
Generation module 33, for generating block according to the target transaction information.
Block generating means provided in this embodiment, including receiving module, for receiving Transaction Information, according to Transaction Information
In include priority received Transaction Information is ranked up;Determining module, after obtaining book keeping operation power, according to ranking results
Target transaction information is determined in Transaction Information;Generation module, for generating block according to target transaction information.The present invention provides
Device, network node obtain book keeping operation power before, just received Transaction Information is ranked up, thus in network node
After obtaining book keeping operation power, target transaction information directly can be determined according to ranking results, and according to target transaction information generation area
Block solves network node in the prior art and then is ranked up to Transaction Information after obtaining book keeping operation power, cause to generate block when
Between long, low efficiency the problem of.
The concrete principle and implementation of block generating means provided in this embodiment with embodiment class shown in FIG. 1
Seemingly, details are not described herein again.
Fig. 4 is the structure chart of the block generating means shown in another exemplary embodiment of the present invention.
As shown in figure 4, on the basis of the above embodiments, block generating means provided in this embodiment,
The receiving module 31, comprising:
Judging unit 311, for judging in buffer area whether to include root transaction node, if so, described transaction is saved
Point is determined as comparing transaction node;
Comparing unit 312, for comparing the priority of the comparison transaction node and the Transaction Information;
Construction unit 313, for constructing binary tree structure according to comparison result.
Optionally, the construction unit 313 is specifically used for:
If the priority of the Transaction Information is identical as the comparison priority of transaction node:
The Transaction Information is determined as to the sane level node of the comparison transaction node, and according to the comparison transaction node
Left subtree and/or right subtree determine the left subtree and/or right subtree of the Transaction Information;
If the priority of the Transaction Information is higher than the priority of the comparison transaction node:
Judge whether the comparison transaction node has left subtree;
If the comparison transaction node has left subtree, new comparison is determined according to the left subtree of the comparison transaction node
Transaction node, the comparing unit continue to execute according to the new comparison transaction node and compare the comparison transaction node and institute
The step of stating the priority of Transaction Information;
If the comparison transaction node does not have left subtree, the Transaction Information is determined as the comparison transaction node
Left subtree;
If the priority of the Transaction Information is lower than the priority of the comparison transaction node:
Judge whether the comparison transaction node has right subtree;
If the comparison transaction node has right subtree, new comparison is determined according to the right subtree of the comparison transaction node
Transaction node, the comparing unit continue to execute according to the new comparison transaction node and compare the comparison transaction node and institute
The step of stating the priority of Transaction Information;
If the comparison transaction node does not have right subtree, the Transaction Information is determined as the comparison transaction node
Right subtree.
Optionally, the determining module 32, comprising:
Determination unit 321, for determining target transaction node in the binary tree structure according to preset algorithm.
Optionally, the block generating means further include removing module 34, are used for:
The target transaction node in the binary tree structure is deleted, and reconstructs remaining transaction section in the binary tree
The connection relationship of point.
The concrete principle and implementation of block generating means provided in this embodiment with embodiment class shown in Fig. 2
Seemingly, details are not described herein again.
Fig. 5 is the structure chart of the block generating device shown in an exemplary embodiment of the invention.
As shown in figure 5, block generating device provided in this embodiment includes:
Memory 51;
Processor 52;And
Computer program;
Wherein, the computer program is stored in the memory 51, and be configured to by the processor 52 execute with
Realize any block generation method as described above.
The present embodiment also provides a kind of computer readable storage medium, is stored thereon with computer program,
The computer program is executed by processor to realize any block generation method as described above.
Those of ordinary skill in the art will appreciate that: realize that all or part of the steps of above-mentioned each method embodiment can lead to
The relevant hardware of program instruction is crossed to complete.Program above-mentioned can be stored in a computer readable storage medium.The journey
When being executed, execution includes the steps that above-mentioned each method embodiment to sequence;And storage medium above-mentioned include: ROM, RAM, magnetic disk or
The various media that can store program code such as person's CD.
Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention., rather than its limitations;To the greatest extent
Pipe present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: its according to
So be possible to modify the technical solutions described in the foregoing embodiments, or to some or all of the technical features into
Row equivalent replacement;And these are modified or replaceed, various embodiments of the present invention technology that it does not separate the essence of the corresponding technical solution
The range of scheme.
Claims (16)
1. a kind of block generation method characterized by comprising
Transaction Information is received, the received Transaction Information is ranked up according to the priority for including in the Transaction Information;
After obtaining book keeping operation power, target transaction information is determined in the Transaction Information according to ranking results, and according to the target
Transaction Information generates block.
2. the method according to claim 1, wherein described according to the priority pair for including in the Transaction Information
The received Transaction Information is ranked up, comprising:
Judge in buffer area whether to include root transaction node, if so, described transaction node is determined as to compare transaction node;
The priority for comparing the comparison transaction node and the Transaction Information, constructs binary tree structure according to comparison result.
3. according to the method described in claim 2, it is characterized in that, described construct the binary tree according to the comparison result,
Include:
If the priority of the Transaction Information is identical as the comparison priority of transaction node:
The Transaction Information is determined as to the sane level node of the comparison transaction node, and according to a left side for the comparison transaction node
Subtree and/or right subtree determine the left subtree and/or right subtree of the Transaction Information.
4. according to the method described in claim 2, it is characterized in that, described construct the binary tree according to the comparison result,
Include:
If the priority of the Transaction Information is higher than the priority of the comparison transaction node:
Judge whether the comparison transaction node has left subtree, if so, determining according to the left subtree of the comparison transaction node
New comparison transaction node, and continued to execute according to the new comparison transaction node compare the comparison transaction node with it is described
The step of priority of Transaction Information.
5. according to the method described in claim 4, it is characterized in that, if the comparison transaction node does not have left subtree, by institute
State the left subtree that Transaction Information is determined as the comparison transaction node.
6. according to the method described in claim 2, it is characterized in that, described construct the binary tree according to the comparison result,
Include:
If the priority of the Transaction Information is lower than the priority of the comparison transaction node:
Judge whether the comparison transaction node has right subtree, if so, determining according to the right subtree of the comparison transaction node
New comparison transaction node, and continued to execute according to the new comparison transaction node compare the comparison transaction node with it is described
The step of priority of Transaction Information.
7. according to the method described in claim 6, it is characterized in that, if the comparison transaction node does not have right subtree, by institute
State the right subtree that Transaction Information is determined as the comparison transaction node.
8. according to the method described in claim 2, it is characterized in that, determining target in the Transaction Information according to ranking results
Transaction Information, comprising:
Target transaction node is determined in the binary tree structure according to preset algorithm.
9. according to the method described in claim 8, it is characterized by further comprising:
The target transaction node in the binary tree structure is deleted, and reconstructs remaining transaction node in the binary tree
Connection relationship.
10. a kind of block generating means characterized by comprising
Receiving module, for receiving Transaction Information, according to the priority for including in the Transaction Information to the received transaction
Information is ranked up;
Determining module determines target transaction information according to ranking results after obtaining book keeping operation power in the Transaction Information;
Generation module, for generating block according to the target transaction information.
11. device according to claim 10, which is characterized in that the receiving module, comprising:
Judging unit, for judging in buffer area whether to include root transaction node, if so, described transaction node is determined as
Compare transaction node;
Comparing unit, for comparing the priority of the comparison transaction node and the Transaction Information;
Construction unit, for constructing binary tree structure according to comparison result.
12. device according to claim 11, which is characterized in that the construction unit is specifically used for:
If the priority of the Transaction Information is identical as the comparison priority of transaction node:
The Transaction Information is determined as to the sane level node of the comparison transaction node, and according to a left side for the comparison transaction node
Subtree and/or right subtree determine the left subtree and/or right subtree of the Transaction Information;
If the priority of the Transaction Information is higher than the priority of the comparison transaction node:
Judge whether the comparison transaction node has left subtree;
If the comparison transaction node has left subtree, determine that new comparison is traded according to the left subtree of the comparison transaction node
Node, the comparing unit continue to execute according to the new comparison transaction node and compare the comparison transaction node and the friendship
The step of priority of easy information;
If the comparison transaction node does not have left subtree, the Transaction Information is determined as to the left son of the comparison transaction node
Tree;
If the priority of the Transaction Information is lower than the priority of the comparison transaction node:
Judge whether the comparison transaction node has right subtree;
If the comparison transaction node has right subtree, determine that new comparison is traded according to the right subtree of the comparison transaction node
Node, the comparing unit continue to execute according to the new comparison transaction node and compare the comparison transaction node and the friendship
The step of priority of easy information;
If the comparison transaction node does not have right subtree, the Transaction Information is determined as to the right son of the comparison transaction node
Tree.
13. device according to claim 11, which is characterized in that the determining module, comprising:
Determination unit, for determining target transaction node in the binary tree structure according to preset algorithm.
14. device according to claim 11, which is characterized in that further include removing module, be used for:
The target transaction node in the binary tree structure is deleted, and reconstructs remaining transaction node in the binary tree
Connection relationship.
15. a kind of block generating device characterized by comprising
Memory;
Processor;And
Computer program;
Wherein, the computer program stores in the memory, and is configured to be executed by the processor to realize such as power
Benefit requires any method of 1-9.
16. a kind of computer readable storage medium, which is characterized in that it is stored thereon with computer program,
The computer program is executed by processor to realize the method as described in claim 1-9 is any.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810948611.7A CN109300032B (en) | 2018-08-20 | 2018-08-20 | Block generation method, device, equipment and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810948611.7A CN109300032B (en) | 2018-08-20 | 2018-08-20 | Block generation method, device, equipment and computer readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109300032A true CN109300032A (en) | 2019-02-01 |
CN109300032B CN109300032B (en) | 2022-12-02 |
Family
ID=65165302
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810948611.7A Active CN109300032B (en) | 2018-08-20 | 2018-08-20 | Block generation method, device, equipment and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109300032B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111080298A (en) * | 2019-12-26 | 2020-04-28 | 电子科技大学 | Block generation and transaction verification method suitable for energy source block chain |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1515098A (en) * | 2001-06-13 | 2004-07-21 | ��������λ�Ƽ���˾ | Binary-tree method and system for multiplexing scheduling |
CN102663061A (en) * | 2012-03-30 | 2012-09-12 | Ut斯达康通讯有限公司 | Quick sorting and searching device for high-capacity lookup table and method for implementing quick sorting and searching device |
CN106534085A (en) * | 2016-10-25 | 2017-03-22 | 杭州云象网络技术有限公司 | Privacy protection method based on block chain technology |
CN106991164A (en) * | 2017-03-31 | 2017-07-28 | 北京京东金融科技控股有限公司 | Method, device and electronic equipment that finance data is handled are used for based on block chain |
US20170278186A1 (en) * | 2016-03-23 | 2017-09-28 | Domus Tower, Inc. | Distributing work load of high-volume per second transactions recorded to append-only ledgers |
-
2018
- 2018-08-20 CN CN201810948611.7A patent/CN109300032B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1515098A (en) * | 2001-06-13 | 2004-07-21 | ��������λ�Ƽ���˾ | Binary-tree method and system for multiplexing scheduling |
CN102663061A (en) * | 2012-03-30 | 2012-09-12 | Ut斯达康通讯有限公司 | Quick sorting and searching device for high-capacity lookup table and method for implementing quick sorting and searching device |
US20170278186A1 (en) * | 2016-03-23 | 2017-09-28 | Domus Tower, Inc. | Distributing work load of high-volume per second transactions recorded to append-only ledgers |
CN106534085A (en) * | 2016-10-25 | 2017-03-22 | 杭州云象网络技术有限公司 | Privacy protection method based on block chain technology |
CN106991164A (en) * | 2017-03-31 | 2017-07-28 | 北京京东金融科技控股有限公司 | Method, device and electronic equipment that finance data is handled are used for based on block chain |
Non-Patent Citations (1)
Title |
---|
考试辅导用书编委会主编: "《大学生热门考试必备用书馆配经典系列 考研计算机考试大纲解析》", 30 April 2012, 高等教育出版社 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111080298A (en) * | 2019-12-26 | 2020-04-28 | 电子科技大学 | Block generation and transaction verification method suitable for energy source block chain |
CN111080298B (en) * | 2019-12-26 | 2023-12-29 | 电子科技大学 | Block generation and transaction verification method suitable for energy block chain |
Also Published As
Publication number | Publication date |
---|---|
CN109300032B (en) | 2022-12-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20200167366A1 (en) | Data processing method and device | |
CN107147735B (en) | Distributed account book system based on hierarchical structure | |
US9575809B2 (en) | Distributed stochastic clustering for automated formation of connected networks of agents | |
KR102254809B1 (en) | Distributed computing resources sharing system and computing apparatus thereof providing reward based on block chain | |
CN108985774A (en) | A kind of motivational techniques, device, equipment and the storage medium of block chain network | |
CN111062044A (en) | Model joint training method and device based on block chain | |
CN106991617B (en) | Microblog social relationship extraction algorithm based on information propagation | |
CN113973021B (en) | Network transmission optimization device and method for image block chain | |
CN109886693B (en) | Consensus realization method, device, equipment and medium for block chain system | |
Chattopadhyay et al. | QoS-aware automatic Web service composition with multiple objectives | |
Duarte et al. | Improved heuristics for the regenerator location problem | |
CN109194444A (en) | A kind of balanced binary tree restorative procedure based on network topology | |
CN112785408A (en) | Account checking method and device based on Hash | |
CN107885601A (en) | A kind of cloud computing method for scheduling task based on difference and ant group algorithm | |
Guidi et al. | Evaluating the decentralisation of filecoin | |
CN109300032A (en) | Block generation method, device, equipment and computer readable storage medium | |
CN105610879B (en) | Data processing method and device | |
CN113157981A (en) | Graph network relation diffusion method and device | |
CN113347238A (en) | Message partitioning method, system, device and storage medium based on block chain | |
CN109544329B (en) | Method, device and system for matching | |
CN108833477A (en) | Method for message transmission, system and device based on shared drive | |
CN105579966B (en) | Data processing equipment and computer-readable distribution medium | |
CN117311975A (en) | Large model parallel training method, system and readable storage medium | |
CN107274284A (en) | Bidirectinoally coupled method, device and transaction system | |
Hinge et al. | MuGDAD: Multilevel graph drawing algorithm in a distributed architecture |
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 |