Block generation method and computer storage medium
Technical field
The present embodiments relate to field of computer technology more particularly to a kind of block generation methods and computer storage to be situated between
Matter.
Background technique
Block chain is that the computers such as Distributed Storage, point-to-point transmission, common recognition mechanism, Encryption Algorithm are utilized in one kind
The new application mode of technology.Block chain is divided into three classes, and is respectively: publicly-owned block chain, alliance's block chain (also referred to as joint block
Chain, industry block chain) and three kinds of privately owned block chain.
Wherein, in current alliance's block chain, in order to quickly and correctly inside block chain to the value of some data
Reach an agreement, will use common recognition mechanism, e.g., with PBFT (Practical Byzantine Fault Tolerance, it is practical to visit
It is fault-tolerant to account for front yard) algorithm is as common recognition mechanism.Under this common recognition mechanism, need to elect one by alliance's block chain whole node
Host node is responsible for generating new block by the host node when needing to generate new block.
But this existing alliance's block chain generates in the mode of new block, in some cases, host node such as occurs
Failure, or when generation host node election, can not all generate new block.Further resulting in as a result, not can guarantee in alliance's block
Reach data consistency inside chain.
Summary of the invention
In view of this, one of the technical issues of embodiment of the present invention is solved is to provide a kind of block generation method and meter
Calculation machine storage medium, to solve the above problems.
The embodiment of the present invention provides a kind of block generation method, is applied to alliance's block chain, and alliance's block chain does not have
There is host node, which comprises receive the new block that the node in alliance's block chain is initiated and generate request, wherein institute
It states new block and generates the information for carrying the number and corresponding block content of requested new block in request;To the new district
The number of block is verified, and is verified to the information for the corresponding block content of number for verifying the successfully new block, and
The pre-generatmg new block after verifying successfully;The number of the new block is verified again, and the Xiang Suoshu after verifying successfully
All nodes in alliance's block chain send confirmation message;Judge whether all nodes reach altogether the confirmation message
Know, if so, generating the new block for initiating the node that the new block generates request according to the new block of pre-generatmg.
The embodiment of the present invention also provides a kind of computer-readable medium, and the computer storage medium is stored with readable journey
Sequence, the readable program are applied to alliance's block chain, and alliance's block chain does not have host node, and the readable program includes:
New block for receiving the initiation of the node in alliance's block chain generates the instruction of request, wherein the new block generates
The number of requested new block and the information of corresponding block content are carried in request;For the number to the new block
Verified, the information for the corresponding block content of number for verifying the successfully new block verified, and verification at
The instruction of pre-generatmg new block after function;It is verified for the number again to the new block, and to institute after verifying successfully
State the instruction that all nodes in alliance's block chain send confirmation message;For judging all nodes to the confirmation message
Whether reach common understanding, generates the node requested if so, generating according to the new block of pre-generatmg and initiating the new block
The instruction of new block.
By above technical scheme as it can be seen that in block generation scheme provided in an embodiment of the present invention, no longer in alliance's block chain
Middle to use host node, to guarantee that the block in no host node normally generates, scheme provided in an embodiment of the present invention is used
Number verification scheme, the number after receiving new block and generating request, i.e., to block (the i.e. described new block) to be generated
It is verified, to determine the sequence of block to be generated according to number, avoids block chain bifurcated;In turn, in pre-generatmg new block
Afterwards, the number of block to be generated is verified again, to guarantee that the block in processing stage is still newest to be generated
Block.As a result, in the case where no host node, alliance's block chain it is also ensured that new block genesis sequence and uniqueness,
Also during efficiently solving existing alliance's block chain generation new block, when generation host node failure or host node occurs
When election, new block can not be generated, and then not can guarantee the problem of reaching data consistency inside alliance's block chain.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
The some embodiments recorded in inventive embodiments can also obtain according to these attached drawings for those of ordinary skill in the art
Obtain other attached drawings.
Fig. 1 shows a kind of step flow chart of according to embodiments of the present invention one block generation method;
Fig. 2 shows a kind of step flow charts of according to embodiments of the present invention two block generation method.
Specific embodiment
In order to make those skilled in the art more fully understand the technical solution in the embodiment of the present invention, below in conjunction with the present invention
Attached drawing in embodiment, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described reality
Applying example only is a part of the embodiment of the embodiment of the present invention, instead of all the embodiments.Based on the implementation in the embodiment of the present invention
The range of protection of the embodiment of the present invention all should belong in example, those of ordinary skill in the art's every other embodiment obtained.
Below with reference to attached drawing of the embodiment of the present invention the embodiment of the present invention will be further explained specific implementation.
Embodiment one
Referring to Fig.1, a kind of step flow chart of according to embodiments of the present invention one block generation method is shown.
The block generation method of the present embodiment is applied to alliance's block chain, this implementation different from traditional alliance's block chain
Alliance's block chain in example does not have host node, when generating new block, to reach data consistency, maintains alliance's block chain
Order, by the way of the verification of new district block number.
Specifically, the present embodiment block generation method the following steps are included:
Step S102: it receives the new block that the node in alliance's block chain is initiated and generates request.
Wherein, new block, which generates, carries the number of requested new block and the letter of corresponding block content in request
Breath.
Any node in alliance's block chain when needed, can issue new block and generate request, be generated with request new
Block.The new block generates request and broadcasts to the whole network, that is, all nodes into alliance's block chain include own node hair
The new block is given to generate request.
The present embodiment is illustrated block generation method, but ability from the angle of a node in alliance's block chain
Field technique personnel are it should be apparent that the node can be the arbitrary node in alliance's block chain, or it can be said that alliance's block
The processing that all nodes in chain generate request to new block all can refer to the embodiment of the present invention and realize.
The new block generates the volume that the i.e. described requested new block of number of block to be generated is carried in request
The information of number block content corresponding with new block.Each new block has a number, can determine this according to the number
Whether new block has generated, position and linking relationship in alliance's block chain etc., in practical applications, art technology
Personnel can use number that is any suitable, meeting block chain specification, unique identification block and can characterize it within a block
Position.And for the information of block content, those skilled in the art can also according to actual needs, using any appropriate
Mode realize, e.g., the summary info, etc. of the block content of new block, the embodiment of the present invention to this with no restriction.
Step S104: verifying the number of new block, in the corresponding block of number for verifying successful new block
The information of appearance is verified, and the pre-generatmg new block after verifying successfully.
It in this step, is verified by the number to new block, can both realize the verifying to the sequence of number, it can also be with
Prevent alliance's block chain bifurcated.When the number to new block verifies, can be deposited according to the number of new block with local
The relationship of number of newest block verified.After number verifies successfully, further, then the letter of block content is carried out
The verification of breath, to determine whether to meet the content requirement for generating block.
If number verification and content authentication are successful, can be with pre-generatmg new block.I.e. pre-generatmg is new after verifying successfully
Block can effectively promote the formation efficiency of new block, save new block and generate program.Wherein, the specific reality that new block generates
The generation and its specification for being now referred to block in Correlation block chain realize that details are not described herein.
Step S106: again verifying the number of new block, and the institute after verifying successfully into alliance's block chain
There is node to send confirmation message.
Because in block chain, what each node carried out generating at any time new block asks sum operation, to guarantee some
The accuracy that new block generates in this step, after pre-generatmg new block, again verifies the number of new block, to protect
It is still newest block to be generated that the block, which is demonstrate,proved, in processing stage.
After verifying successfully again, all nodes (including own node) of the present node into alliance's block chain send true
Recognize message, is prepared with indicating that this node has been carried out new block and generated.
Step S108: judging whether all nodes of alliance's block chain reach common understanding to confirmation message, if so, according to pre-
The new block of generation generates the new block for initiating the node that new block generates request.
Block chain solves asking in insincere channel reliable information as a kind of advanced distributed system
Topic.In block chain, since there are higher network delays under point to point network, so that thing of trading observed by each node
There is different in the sequencing of business (being specially that new block generates in the present embodiment), therefore a set of machine is also required in block chain
System, to reach common understanding within the regular hour to the sequencing that affairs occur, here it is common recognition mechanism.
Common recognition mechanism plays in block chain determines that who is responsible for generating new block and safeguards the unified effect of block chain, mesh
Preceding common recognition mechanism is based on Paxos evolution of algorithm.Paxos algorithm is a kind of consistency calculation based on Message-Passing Model
Method can ensure in a distributed data base system, if the original state of each node is consistent, each node executes phase
The same sequence of operation, then all nodes can finally obtain a consistent state.The common recognition mechanism of block chain substantially may be used at present
To be divided into PoW (proof of work), PoS (equity proves), PBFT (practical Byzantine failure tolerance algorithm) etc..
In this step, determine that all nodes have reached altogether the confirmation message in the common recognition mechanism by alliance's block chain
After knowledge, that is, new block is produced, specifically, the new block of pre-generatmg directly carries out new block and generates operation before can use.
Through this embodiment, host node is used, no longer in alliance's block chain to guarantee the area in no host node
Block normally generates, and has used number verification scheme, after receiving new block and generating request, i.e., to block (i.e. institute to be generated
State new block) number verified, to determine the sequence of block to be generated according to number, avoid block chain bifurcated;In turn,
After pre-generatmg new block, the number of block to be generated is verified again, to guarantee that the block is still in processing stage
Newest block to be generated.As a result, in the case where no host node, alliance's block chain it is also ensured that new block generation
Sequence and uniqueness, during also efficiently solving existing alliance's block chain generation new block, when generation host node failure
Or when host node election occurs, new block can not be generated, and then not can guarantee that reach data inside alliance's block chain consistent
The problem of property.
The block generation method of the present embodiment can be executed by any suitable electronic equipment with data-handling capacity,
Including but not limited to: server, mobile terminal (such as tablet computer, mobile phone) and PC machine etc..
Embodiment two
Referring to Fig. 2, a kind of step flow chart of according to embodiments of the present invention two block generation method is shown.
The present embodiment is illustrated block generation method provided in an embodiment of the present invention in the form of a specific example,
Similar with embodiment one, the block generation method of the present embodiment is also applied to alliance's block chain, uses in alliance's block chain
PBFT algorithm realizes common recognition mechanism, and alliance's block chain does not have host node.
It is similar with traditional PBFT, PBFT algorithm is also used in the present embodiment, and the generation of new block is logically divided into
Five stages are respectively as follows: the request stage, the pre-prepare stage, the prepare stage, the commit stage, execute simultaneously
The reply stage.
Based on the above scene, the block generation method of the present embodiment the following steps are included:
Step S202: it receives the new block that the node in alliance's block chain is initiated and generates request.
Wherein, new block, which generates, carries the number of requested new block and the letter of corresponding block content in request
Breath.
In a kind of feasible pattern, specific to each stage of PBFT, this step be may be implemented are as follows: generate processing in block
Second stage receives the new block that the node in alliance's block chain is initiated in the first stage and generates request and according to described new
Block generates the first state message that request generates;Wherein, first state message is used to indicate new block and is in first state, the
One state is used to indicate the state that new block is in the processing of pending pre-generatmg.By way of setting state and status message,
It can be consistent to greatest extent with PBFT algorithm, mitigate algorithm complexity, save new block manufacturing cost.Wherein, described
One stage was the request stage, and the first state is pre-prepare state, and the first state message is pre-
Prepare status message;The second stage is the pre-prepare stage.
It is integrated to the concrete application scene of the present embodiment, for example, some section in the request stage, in alliance's block chain
Point A initiates building new block Block request (i.e. new block generates request), and the state that the new block is arranged in node A is pre-
Prepare state (i.e. first state) broadcasts the status message (i.e. first state message) to the whole network.
And for other nodes in alliance's block chain, then the initial period in the pre-prepare stage receives the message, with
For one of node such as node B, node B, can the above-mentioned building new block initiated of receiving node A as other nodes
Block request, and the number of new block Block and the information of block content are carried in the request.It should be noted that above-mentioned
It describes by taking the other nodes for the node A for being different from issuing building new block Block request as an example, but those skilled in the art should
Clear, above-mentioned node B can be the arbitrary node in alliance's block chain, including node A itself.As it can be seen that in concrete application
In scene, this step betides the initial period in pre-prepare stage.
Step S204: new block is examined to generate whether request is repetitive requests;If so, to new block generation request into
Row processing;If it is not, thening follow the steps S206.
It is integrated to the concrete application scene of the present embodiment, for example, node B receives building new district in the pre-prepare stage
Whether block Block request, verification have received repetitive requests;If what is received is repetitive requests, refuse to handle the request;If not
Repetitive requests are new request, then are transferred to step S206 and are handled.As it can be seen that this step betides in concrete application scene
Intergrade after pre-prepare stage initial period.
Step S206: verifying the number of new block, in the corresponding block of number for verifying successful new block
The information of appearance is verified, and the pre-generatmg new block after verifying successfully.
In a kind of feasible pattern, this step be may be implemented are as follows: verification be numbered to the number of new block, if number school
Failure is tested, then request no longer is generated to new block and handled;If number verifies in the block for successfully verifying the new block
The information of appearance, and pre-generatmg new block no longer generate request to new block and handle if pre- life newly fails at block;If
The new block, then be added and prepare queue by the success of pre-generatmg block.It in this way, can be to avoid new block generating process
In fortuitous event cause block chain to fall into endless loop, and then entire block chain is caused abnormal or collapse occur.
Wherein, optionally, carrying out verification to the number of new block may include: to be traversed based on the corresponding hash value of new block
All vote informations of new block number verification failure if traversing result instruction new block has been voted;If the number of new block
Less than or equal to the number of current block, then verification failure is numbered;If the number of new block is greater than the number of current block, number
It verifies successfully.By the above-mentioned means, can effectively determine whether new block generates request effective.
The hash value (cryptographic Hash) of block chain can accurately and uniquely identify and identify a block, appointing in block chain
What node can obtain the cryptographic Hash of this block by simple Hash calculation.If the corresponding block of hash value was once
Ballot operation was carried out, then shows that the block had been established, request should not be handled again, number verification failure.
In block chain, block is serial number and generates, and current block is that successful newest block has been established,
Corresponding number is also newest number, if the number for the new block that request generates is also smaller than the number of current block or is equal to
The number of current block then illustrates that it should be the block (smaller than the number of current block) generated or the new block is raw
It is repetitive requests (equal to the number of current block) at request, number verification failure verifies successfully conversely, then numbering.
And it then can be by those skilled in the art according to actual needs, using any suitable to the verification of the information of block content
When mode realize, such as check code, redundancy check, etc., the embodiment of the present invention to this with no restriction.
It, then can be with pre-generatmg new block, wherein pre-generatmg after the information checking of number verification and block content is successful
New block specific implementation can by those skilled in the art referring in existing block chain new block generating mode realize, or
Person can also realize using other any appropriate ways, the embodiment of the present invention to this with no restriction.
Optionally, in addition, successful in the information checking of number verification and block content, and pre-generatmg new block it
Afterwards, namely after this step, the Block status of new block can also be set to the second state, and into alliance's block chain
All nodes send corresponding second status message, wherein the second state is used to indicate the new block and is in pending confirmation
The state of processing.It by way of setting state and status message, can be consistent to greatest extent with PBFT algorithm, mitigate and calculate
Method complexity saves new block manufacturing cost.
Specific to each stage of PBFT, this step be may be implemented are as follows: in the second stage to the number of the new block
It is verified, the information for the corresponding block content of number for verifying the successfully new block is verified, is being verified successfully
Pre-generatmg new block afterwards, and the second state is set by the Block status of the new block, the institute in Xiang Suoshu alliance block chain
There is node to send corresponding second status message, second state is used to indicate the new block and is in pending confirmation processing
State.Wherein, the second stage be the pre-prepare stage, second state be prepare state, described second
Status message is prepare status message.
It is integrated to the concrete application scene of the present embodiment, for example, node B is to request in the pre-prepare stage
The number of Block is verified;As current than having had already appeared and having authenticated the Block's in stage rearward in prepare stage
Verification failure is then numbered in the ballot of number, does not handle the building new block Block request of node A initiation;And if number verification at
Function then verifies the information of block content again, if information checking fails, the building new block Block for not handling node A initiation is asked
It asks, if information checking success, pre-generatmg new block;The building is not handled if the operation failure for executing pre-generatmg new block
If executing the operation success of pre-generatmg new block prepare team is added in the new block of pre-generatmg by new block Block request
Column, and it is prepare state (i.e. the second state) that new district bulk state, which is arranged, broadcasts status message (i.e. second state to the whole network
Message).As it can be seen that this step betided after pre-prepare intergrade in stage, it is believed that is in concrete application scene
The later period in pre-prepare stage.
It should be noted that above-mentioned with according to block, whether there is or not vote informations to verify to be numbered but as previously mentioned, unlimited
It, can be with when numbering verification in this kind of number verification mode: 1, all vote informations of new block state phase are traversed, if packet
The corresponding block of the value of hash containing new block has been voted, then numbers verification failure;2, if block number to be voted is less than or waits
In the number of current block, then verification failure is numbered;3, if block number to be voted is greater than the number of current block, number
It verifies successfully.It is verified by number, block chain bifurcated can be effectively prevented, realized the sequence verifying of block number, guarantee new district
The correctness and validity that block generates.
Step S208: again verifying the number of new block, and the institute after verifying successfully into alliance's block chain
There is node to send confirmation message.
Wherein, the mode verified again to the number of new block is identical with step S206, and details are not described herein.
In specific implementation, can the number again to the new block verification is numbered, if number verification failure,
No longer request is generated to the new block to handle;And if number verifies successfully, all nodes into alliance's block chain
It sends and submits message, to guarantee the validity and robustness of alliance's block chain.
In a kind of feasible pattern, all nodes after verifying successfully into alliance's block chain send confirmation message
It include: to set the third state for the Block status of the new block after verifying successfully, and by corresponding third state message
As confirmation message, all nodes into alliance's block chain are sent, wherein the third state is used to indicate the new block and is in
The pending state for submitting processing.By way of setting state and status message, it can be kept to greatest extent with PBFT algorithm
Unanimously, mitigate algorithm complexity, save new block manufacturing cost.
Specific to each stage of PBFT, this step be may be implemented are as follows: generate the phase III of processing again in the block
The number of the new block is verified, and after verifying successfully, sets third shape for the Block status of the new block
State, and using corresponding third state message as confirmation message, all nodes in Xiang Suoshu alliance block chain are sent, wherein
The third state is used to indicate the new block and is in the pending state for submitting processing.Wherein, the phase III is
Prepare stage, the third state are commit state, and the third state message is commit status message.
It is integrated to the concrete application scene of the present embodiment, for example, node B is again to the volume of Block in the prepare stage
Number verification is numbered;If number verification is unsuccessful, the building new block Block request is not handled;If number verification at
Function, then it is commit state (i.e. the third state) that Block state, which is arranged, and broadcasts status message (the i.e. third state to the whole network
Message).As it can be seen that this step betides the prepare stage in concrete application scene.
Step S210: judging whether all nodes of alliance's block chain reach common understanding to confirmation message, if so, according to pre-
The new block of generation generates the new block for initiating the node that new block generates request;If it is not, then being handled without new block generation.
In block chain, responded when all nodes generate request to new block, such as feeding back confirmation message, then it is assumed that
All nodes have reached common recognition.For each node in block chain, confirmation message (wraps all nodes into block chain
Include own node) it sends.
For present node, can by judging whether to receive the confirmation messages of all nodes in alliance's block chain,
To determine whether that all nodes in alliance's block chain have reached common recognition.
It is when the confirmation message is to submit status message, then described to judge all sections in a kind of feasible pattern
It may include: to judge whether to receive mentioning for all nodes in alliance's block chain that whether point, which reaches common understanding to the confirmation message,
Hand over status message;If so, determining that all nodes are reached common understanding;Otherwise, it is determined that do not reach common understanding.
And when generating the new block for initiating the node that the new block generates request according to the new block of pre-generatmg,
It can then verify whether present node had locally generated the new block;If so, not regenerating;If it is not, then from pre-generatmg
The new block in obtain metadata information and content-data, alliance's block chain is written into the metadata information, and at this
Ground saves the content-data.
Optionally, in addition, the node initiated the new block and generate request is being generated according to the new block of pre-generatmg
New block when, the Block status of the new block can also be set to the 4th state, and according to the 4th state and pre-generatmg
New block, generate the new block for initiating the node that the new block generates request, wherein the 4th state is used to indicate described new
Block is in the state for having been carried out and submitting processing.Setting state and status message by way of, can to greatest extent with
PBFT algorithm is consistent, and mitigates algorithm complexity, saves new block manufacturing cost.
Specific to each stage of PBFT, this step be may be implemented are as follows: generate the fourth stage judgement of processing in the block
Whether all nodes reach common understanding to the confirmation message, if so, setting for the Block status of the new block
Four states, and according to the new block of the 4th state and pre-generatmg, it generates and initiates the section that the new block generates request
The new block of point, and the information of the new block generated to all nodes transmissions, wherein the 4th state is for referring to
Show that the new block is in the state for having been carried out and submitting processing;In the 5th stage of block generation processing, described in reception
The information of new block, and according to the information of the new block, it is verified to locally the new block whether had been generated, according to
Check results carry out the processing that the new block generates request.Wherein, the fourth stage is commit stage, the 4th shape
State be committed state, the 4th status message be committed status message, the 5th stage be execute and
The reply stage.
It is integrated to the concrete application scene of the present embodiment, for example, each node receives commit state in the commit stage
It carries out counting after message accumulative;Because PBFT algorithm maximum can tolerate that the node of one third is problematic, that is, PBFT needs at least
The confirmation message of 2/3rds node is to reach common understanding, and therefore, if each node is received, more than 2f+1, (wherein, f indicates institute
Having a number of trouble node in node, 0≤f≤(N-1)/3, N is the quantity of all nodes) a different nodes (include itself
Node) commit status message after, it is believed that the processing of the new block the whole network (i.e. all nodes of alliance's block chain)
Reach an agreement, into committed state (i.e. the 4th state), alliance's block chain be written into the metadata information of the new block,
And the full content of the new block is stored in the local relevant database such as local, in sqlite database.
Further, in execution and reply stage, present node such as node B is to the whole network (i.e. all sections of alliance's block chain
Point) broadcast the message that new block has generated;Each node in alliance's block chain after receiving the generated message of new block,
Whether verification is local had generated the block, and the message is ignored if generating;If not generating, new block is locally being carried out
Generation processing, i.e., alliance's block chain is written into the metadata information of new block, and the full content of new block is stored in this
Such as local relevant database in ground, in sqlite database.
As it can be seen that in concrete application scene, all nodes for judging alliance's block chain in this step are to confirmation message
No generation of reaching common understanding is in the commit stage;And being generated in this step according to the new block of pre-generatmg is initiated new block generation and is asked
The new block for the node asked then has processing in commit stage and execution and reply stage.
As it can be seen that through this embodiment, for alliance's block chain, no longer needing to elect a host node from the whole network node
(Leader) Lai Shengcheng new block, the whole network is broadcasted after any node can construct block.To guarantee in no host node
Block normally generate, used number verification scheme, receive new block generate request after, i.e., to block to be generated
The number of (the i.e. described new block) is verified, and to determine the sequence of block to be generated according to number, avoids block chain bifurcated;
In turn, after pre-generatmg new block, the number of block to be generated is verified again, to guarantee the block in processing stage
It is still newest block to be generated.As a result, in the case where no host node, alliance block chain is it is also ensured that new block
Genesis sequence and uniqueness, during also efficiently solving existing alliance's block chain generation new block, when generation host node
When failure or generation host node election, new block can not be generated, and then not can guarantee and reach data inside alliance's block chain
The problem of consistency.
The block generation method of the present embodiment can be executed by any suitable electronic equipment with data-handling capacity,
Including but not limited to: server, mobile terminal (such as tablet computer, mobile phone) and PC machine etc..
Embodiment three
The embodiment of the invention also provides a kind of computer-readable medium, the computer storage medium is stored with readable journey
Sequence, the readable program are applied to alliance's block chain, and alliance's block chain does not have host node, and the readable program includes:
New block for receiving the initiation of the node in alliance's block chain generates the instruction of request, wherein the new block generates
The number of requested new block and the information of corresponding block content are carried in request;For the number to the new block
Verified, the information for the corresponding block content of number for verifying the successfully new block verified, and verification at
The instruction of pre-generatmg new block after function;It is verified for the number again to the new block, and to institute after verifying successfully
State the instruction that all nodes in alliance's block chain send confirmation message;For judging all nodes to the confirmation message
Whether reach common understanding, generates the node requested if so, generating according to the new block of pre-generatmg and initiating the new block
The instruction of new block.
Optionally, the instruction for being verified to the number of the new block, comprising: for being based on the new district
The corresponding hash value of block traverses all vote informations of new block, if traversing result indicates that the new block has been voted,
The instruction of number verification failure;If being less than or equal to the number of current block for the number of the new block, numbers verification and lose
The instruction lost;If being greater than the number of the current block for the number of the new block, verification successfully instruction is numbered.
Optionally, the readable program further include: in the instruction for being verified to the number of the new block
Before, for examine the new block generate request whether be repetitive requests instruction;For if so, not to the new block
Generate the instruction that request is handled;For if it is not, then executing the instruction that the number to the new block verified.
Optionally, it is verified for the number to the new block, to the number pair for verifying the successfully new block
The information for the block content answered is verified, and after verifying successfully pre-generatmg new block instruction, comprising: for described new
Verification is numbered in the number of block, if number verification failure, no longer generates the finger that request is handled to the new block
It enables;If the information for successfully verifying the block content of the new block is verified for numbering, and pre-generatmg new block, if pre- life
Newly fail at block, then the instruction that request is handled no longer is generated to the new block;If for the success of pre-generatmg block,
The new block is added to the instruction for preparing queue.
Optionally, described for being verified again to the number of the new block, and to described after verifying successfully
All nodes in alliance's block chain send the instruction of confirmation message, comprising: compile for the number again to the new block
Number verification, if number verification failure, no longer generates the instruction that is handled of request to the new block;If being verified for numbering
Success, then all nodes into alliance's block chain send the instruction of confirmation message.
Optionally, the confirmation message is to submit status message;It is described to be used to judge all nodes to the confirmation
The instruction whether message reaches common understanding, comprising: for judging whether to receive mentioning for all nodes in alliance's block chain
Hand over the instruction of status message;For if so, the instruction that determining all nodes are reached common understanding;For otherwise, it is determined that not
The instruction reached common understanding.
Optionally, described for generating the node initiated the new block and generate request according to the new block of pre-generatmg
New block instruction, comprising: for verifying the local instruction for whether having generated the new block;For if so, no longer
The instruction of generation;For if it is not, metadata information and content-data are then obtained from the new block of pre-generatmg, by the member
Alliance's block chain is written in data information, and in the instruction for locally saving the content-data.
Optionally, the instruction packet that request is generated for receiving the new block that the node in alliance's block chain is initiated
Include: the second stage for generating processing in block receives the new district that the node in alliance's block chain is initiated in the first stage
Block generates request and generates the instruction for the first state message that request generates according to the new block;Wherein, the first state
Message is used to indicate the new block and is in first state, and the first state is used to indicate the new block and is in pending pre-
Generate the state of processing;
It is described to be used to verify the number of the new block, it is corresponding to the number for verifying the successfully new block
The information of block content is verified, and the instruction of pre-generatmg new block includes: in the second-order after verifying successfully
Section verifies the number of the new block, the information to the corresponding block content of number for verifying the successfully new block
The instruction verified is set as for the pre-generatmg new block after verifying successfully, and by the Block status of the new block
Two-state, all nodes in Xiang Suoshu alliance block chain send the instruction of corresponding second status message, second state
It is used to indicate the state that the new block is in pending confirmation processing;
It is described to be used to again verify the number of the new block, and to alliance's block chain after verifying successfully
In all nodes send confirmation message instruction include: for the block generate handle phase III again to described
The number of new block is verified, and after verifying successfully, sets the Block status of the new block on the finger of the third state
It enables, for regarding corresponding third state message as confirmation message, the finger of all nodes transmission in Xiang Suoshu alliance block chain
It enables, wherein the third state is used to indicate the new block and is in the pending state for submitting processing;
It is described to be used to judge whether all nodes reach common understanding to the confirmation message, if so, according to pre-generatmg
The new block to generate the instruction for the new block for initiating the node that the new block generates request include: in the block
Generate processing fourth stage judge the instruction whether all nodes reach common understanding to the confirmation message, be used for if so,
The 4th state then is set by the Block status of the new block, and according to the new district of the 4th state and pre-generatmg
Block, the new block that the new block generates the node of request is initiated in generation, and sends the described new of generation to all nodes
The instruction of the information of block, wherein the 4th state is used to indicate the new block and is in the shape for having been carried out and submitting processing
State;For generating the 5th stage of processing in the block, the information of the new block is received, and according to the letter of the new block
Breath is verified to locally the new block whether had been generated, and is carried out the new block according to check results and is generated request
The instruction of processing.
Optionally, the first stage is the request stage, and the first state message is that pre-prepare state disappears
Breath;The second stage is the pre-prepare stage, and second status message is prepare status message;The third rank
Section is the prepare stage, and the third state message is commit status message;The fourth stage is commit stage, institute
Stating the 4th status message is committed status message;5th stage is execution and reply stage.
Computer-readable medium through this embodiment uses host node, no longer in alliance's block chain to guarantee in nothing
Block in the case of host node normally generates, and scheme provided in an embodiment of the present invention has used number verification scheme, is receiving
After new block generates request, i.e., the number of block (the i.e. described new block) to be generated is verified, to be determined according to number
The sequence of block to be generated avoids block chain bifurcated;In turn, after pre-generatmg new block, again to block to be generated
Number is verified, to guarantee that the block in processing stage is still newest block to be generated.As a result, in not host node
In the case of, alliance's block chain it is also ensured that new block genesis sequence and uniqueness, also efficiently solve existing area, alliance
During block chain generates new block, when host node failure occurs or host node election occurs, new block can not be generated, into
And the problem of reaching data consistency inside alliance's block chain is not can guarantee.
It may be noted that all parts/step described in the embodiment of the present invention can be split as more according to the needs of implementation
The part operation of two or more components/steps or components/steps can also be combined into new component/step by multi-part/step
Suddenly, to realize the purpose of the embodiment of the present invention.
It is above-mentioned to be realized in hardware, firmware according to the method for the embodiment of the present invention, or be implemented as being storable in note
Software or computer code in recording medium (such as CD ROM, RAM, floppy disk, hard disk or magneto-optic disk), or it is implemented through net
The original storage of network downloading in long-range recording medium or nonvolatile machine readable media and will be stored in local recording medium
In computer code, so that method described herein can be stored in using general purpose computer, application specific processor or can compile
Such software processing in journey or the recording medium of specialized hardware (such as ASIC or FPGA).It is appreciated that computer, processing
Device, microprocessor controller or programmable hardware include can store or receive software or computer code storage assembly (for example,
RAM, ROM, flash memory etc.), when the software or computer code are by computer, processor or hardware access and execute, realize
Block generation method described herein.In addition, when general purpose computer accesses for realizing the block generation method being shown here
When code, general purpose computer is converted to the dedicated computing for being used for executing the block generation method being shown here by the execution of code
Machine.
Those of ordinary skill in the art may be aware that list described in conjunction with the examples disclosed in the embodiments of the present disclosure
Member and method and step can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually
It is implemented in hardware or software, the specific application and design constraint depending on technical solution.Professional technician
Each specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceed
The range of the embodiment of the present invention.
Embodiment that the above embodiments are only used to illustrate the present invention, and the limitation not to the embodiment of the present invention, related skill
The those of ordinary skill in art field can also make various in the case where not departing from the spirit and scope of the embodiment of the present invention
Variation and modification, therefore all equivalent technical solutions also belong to the scope of the embodiment of the present invention, the patent of the embodiment of the present invention
Protection scope should be defined by the claims.