Specific embodiment
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched
The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to
Convenient for description, part relevant to invention is illustrated only in attached drawing.
It should be noted that in the absence of conflict, the features in the embodiments and the embodiments of the present application can phase
Mutually combination.The application is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 is a kind of flow chart for parallel chain block generation method that one embodiment of the invention provides.As shown in Figure 1, In
In the present embodiment, the present invention provides a kind of parallel chain block generation method suitable for parallel chain node, and the above method includes, and
Row executes following two step:
S12: receiving the first block data of the first main chain block that main chain node is sent, and is updated according to the first block data
Interim parallel chain block queue is simultaneously stored in local data base;Wherein, the first block data includes the firstth area of the first main chain block
Build information, the first block head information include first father's Hash of the first main chain block;
S13: the interim parallel chain block of interim parallel chain block queue is read to generate parallel sequence from local data base
Block simultaneously executes.
(the applied every parallel chain patent text of applicant is specifically referred in the parallel chain mechanism that applicant is proposed
This) in, parallel chain receives the area of a main chain block (assuming that the parallel chain that the main chain block includes current parallel chain is traded)
For block number after, the parallel chain transaction for screening current parallel chain generates parallel chain block, after executing parallel chain block generated, then
Receive next main chain block.
The reasons why originally applicant designs in this way is that the execution that parallel chain node must be serial receives block data and execution
Parallel chain block (assuming that there are the transaction of the parallel chain of the affiliated parallel chain of parallel chain node in each main chain block), that is, parallel
The block data for the main chain block (block (100)) that chain node must be first 100 according to block height generates parallel chain block simultaneously
It executes, generate parallel chain block further according to block height for the block data of 101 main chain block (block (101)) and executes;
If parallel chain node first reads block (101), parallel sequence is generated according to the block data of block (101)
Block simultaneously executes, and the parallel chain that will lead to parallel chain node generation in this way is different from the parallel chain that other parallel chain nodes generate;
Parallel chain to guarantee different parallel chain nodes generations is identical, even if the parallel chain node first reads block (101), also only
Can in completion " first generate parallel chain block according to the block data of block (100) and execute " after step, then execute " according to
The block data of block (101) generates parallel chain block and executes " step;In this case, it is designed to execute parallel not only
Cpu resource utilization will not be improved, also will cause the problem of wasting space goes to storage (101) block;
In view of the scene of parallel chain node processing main chain bifurcated rollback, current main chain-parallel chain mechanism, parallel chain link
Point needs the rollback scene of reproduction main chain node completely, that is, main chain node generates block (100), generates block (101), returns
It rolls block (101), generates block (101) ';Parallel chain node also will generate parallel chain block according to block (100), according to
Block (101) generates parallel chain block, the corresponding parallel chain block generated of rollback block (101), according to block (101) '
Generate parallel chain block;
Applicant it is considered that if parallel chain node execute according to block (100) generate parallel chain block when, master link
Point has executed " generating block (101), rollback block (101), generate block (101) ' " step, at this point, parallel chain link
Rollback scene of the point without reproduction main chain node completely, directly generates parallel chain block, such mechanism according to block (101) '
More flexible and expansible, therefore, applicant provide the parallel chain block generation methods of the application executed parallel.
Specifically, thread one and thread two execute parallel;
Step S12 is executed in thread one, parallel chain node receives the first of the first main chain block that main chain node is sent
Block data updates interim parallel chain block queue according to the first block data and is stored in local data base;Wherein, the first block
Data include the first block head information of the first main chain block, and the first block head information includes that the first father of the first main chain block breathes out
It is uncommon;
Step S13 is executed in thread two, parallel chain node reads interim parallel chain block queue from local data base
Interim parallel chain block is to generate parallel chain block and execute.
In more embodiments, interim parallel chain block queue can also be stored in memory, improve parallel chain node
From the reading efficiency of the interim parallel chain block read in memory in interim parallel chain block queue, still, interim parallel sequence
Block queue still needs deposit local data base to lose internal storage data to prevent delay machine.
Above-described embodiment strengthens flexibility, robustness and the scalability of block catenary system.
Fig. 2 is the flow chart of step S12 in a kind of preferred embodiment of method shown in Fig. 1.As shown in Fig. 2, excellent one
It selects in embodiment, step S12 includes:
S120: the first block data of the first main chain block that main chain node is sent is received, is judged in the first block data
Whether the parallel chain comprising current parallel chain is traded:
It is to then follow the steps S121: the first interim parallel chain block is generated according to the first block data, it is interim according to first
Parallel chain block and the interim parallel chain block queue of the first block head information update are simultaneously stored in local data base;
It is no, it thens follow the steps S122: according to the interim parallel chain block queue of the first block head information update and being stored in local
Database.
First block data of above-described embodiment includes the All Activity of the first main chain block, therefore parallel chain node is connecing
When receiving the first block data of the first main chain block that main chain node is sent, need by judging whether wrap in the first block data
Parallel chain transaction containing current parallel chain is traded to filter out the parallel chain of current parallel chain;
In more embodiments, the parallel chain transaction of current parallel chain can also be filtered out at the very start by main chain node
Come and is sent to current parallel chain node (that is, the first block data includes the parallel chain of current parallel chain in the first main chain block
Transaction, and if do not have in the first main chain block current parallel chain parallel chain trade, the first block data be sky), at this point, in parallel
Chain node need to only judge whether the first block data is empty: it is no, then the first interim parallel sequence is generated according to the first block data
Block according to the first interim parallel chain block and the interim parallel chain block queue of the first block head information update and is stored in local data
Library;It is then according to the interim parallel chain block queue of the first block head information update and to be stored in local data base;It can be achieved identical
Technical effect.
Fig. 3 is a kind of flow chart of preferred embodiment of method shown in Fig. 1.As shown in figure 3, in a preferred embodiment
In, the above method further include:
S14: the first parallel chain block height of current parallel chain is obtained;
S15: whether the remainder for judging the first threshold of the first parallel chain block height and pre-configuration is 0:
Be to then follow the steps S16: the difference for calculating the first threshold of the first parallel chain block height and pre-configuration obtains second
Parallel chain block height;And
S17: the interim parallel chain block in interim parallel chain block queue before the second parallel chain block height is deleted.
Specifically, it is assumed that first threshold 1000, the first parallel chain block height of current parallel chain are 3000;
In step S14, parallel chain node obtains the first parallel chain block height of current parallel chain;
In step S15, parallel chain node judges the remainder of the first threshold of the first parallel chain block height and pre-configuration
Whether it is 0:
Since the first parallel chain block height is 3000, the remainder that the first threshold of pre-configuration is 1000,3000 and 1000
Be 0, then follow the steps S16: the difference that parallel chain node calculates the first threshold of the first parallel chain block height and pre-configuration obtains
Second parallel chain block height, that is, the second parallel chain block height is 2000;And
In step S17, facing before block height is 2000 in the interim parallel chain block queue of parallel chain knot removal
When parallel chain block.
In more embodiments, other numerical value can also be configured by first threshold according to actual needs, for example, being configured to
500, it can be achieved that identical technical effect.
In more embodiments, other numerical value can also be configured by remainder according to actual needs, for example, it is configured to 1,
That is, it is judged that whether the remainder of the first parallel chain block height and the first threshold of pre-configuration is 1, it can be achieved that identical technology is imitated
Fruit.
In more embodiments, it can also configure according to actual needs and delete older interim parallel chain in local data base
The method of block is, it can be achieved that identical technical effect.Such as it is configured that the first parallel chain block for obtaining current parallel chain is high
Degree;The second parallel chain block height is calculated according to the first parallel chain block height and the first threshold of pre-configuration;It deletes interim flat
All interim parallel chain blocks in row chain block queue before the second parallel chain block height.
The memory space of local data base can be saved by deleting older interim parallel chain block in local data base, but
Parallel chain node switches connected main chain node, the area of the newest parallel chain block of parallel chain node by load-balanced server
The difference of the block height of newest interim parallel chain block is super in the interim parallel chain block queue of block height and new main chain node
It crosses under the scene of first threshold;Or, parallel chain node can not in the case where main chain rollback is more than the scene of first threshold quantity block
Interim parallel chain block is read from interim parallel chain block queue to generate parallel chain block.At this point, parallel chain node is forward
Main chain block is traversed, until finding third main chain block;Wherein, the third father Hash of third main chain block and interim parallel chain
The block Hash of the corresponding main chain block of the interim parallel chain block of third in block queue is identical, and parallel chain knot removal is interim
All interim parallel chain blocks in parallel chain block queue after the interim parallel chain block of third;And according to third main chain area
The block data of block updates interim parallel chain block queue, and is stored in local data base.
Above-described embodiment deletes the interim parallel chain block in part in local data base, improves the inquiry effect of local data base
Rate.
Fig. 4 is the flow chart of step S12 in another preferred embodiment of method shown in Fig. 1.As shown in figure 4, another
In one preferred embodiment, step S12 includes:
S123: the first block data of the first main chain block that main chain node is sent is received;
S124: the block for verifying the corresponding main chain block of newest interim parallel chain block in interim parallel chain block queue is breathed out
It is uncommon whether identical as first father's Hash:
It is: thens follow the steps S125: interim parallel chain block is generated to update interim parallel chain according to the first block data
Block queue is simultaneously stored in local data base;
It is no, it thens follow the steps S126: traversing main chain block forward, until finding the second main chain block;Wherein, second is main
Second father's Hash of chain block main chain block corresponding with the second interim parallel chain block in interim parallel chain block queue
Block Hash is identical;And
S127: all interim parallel sequences in interim parallel chain block queue after the second interim parallel chain block are deleted
Block;And
S128: interim parallel chain block queue is updated according to the block data of the second main chain block, and is stored in local data
Library.
Assuming that there is the first application scenarios, the first application scenarios are as follows:
When the main chain node A delay machine that parallel chain node a is connected, a is connected to new master by load-balanced server
Chain node B, at this point, the corresponding main chain block of newest interim parallel chain block in the interim parallel chain block queue of parallel chain node
Block Hash blockhash (100) may be with first father's Hash parenthash of the first main chain block of new main chain node
(101) ' different;If a directly updates interim parallel chain block team according to the first block data of the first main chain block of B at this time
Column, then the parallel chain block queue error updated;
The problem that for the first application scenarios, can be solved by step S123 to step S128;
Assuming that blockhash (100) is identical as parenthash (101) ':
In step S123, a receives the first block data of the first main chain block that B is sent;
In step S124, a verifies the corresponding main chain area of newest interim parallel chain block in interim parallel chain block queue
Whether the block Hash blockhash (100) of block and first father's Hash parenthash (101) ' are identical:
Since blockhash (100) is identical as parenthash (101) ', S125 is thened follow the steps, a is according to the first block
Data generate interim parallel chain block to update interim parallel chain block queue and be stored in local data base;
Assuming that blockhash (100) is different from parenthash (101) ':
In step S123, a receives the first block data of the first main chain block that B is sent;
In step S124, a verifies the corresponding main chain area of newest interim parallel chain block in interim parallel chain block queue
Whether the block Hash blockhash (100) of block and first father's Hash parenthash (101) ' are identical:
Since blockhash (100) is different from parenthash (101) ', S126 is thened follow the steps, a traverses forward main chain
Block, until finding the second main chain block;Wherein, second father's Hash of the second main chain block and interim parallel chain block queue
In the corresponding main chain block of the second interim parallel chain block block Hash it is identical;And
In step S127, a deletes all interim after the second interim parallel chain block in interim parallel chain block queue
Parallel chain block;And
In step S128, a updates interim parallel chain block queue according to the block data of the second main chain block, and is stored in
Local data base.
Fig. 5 is the flow chart of step S13 in a kind of preferred embodiment of method shown in Fig. 1.As shown in figure 5, excellent one
It selects in embodiment, step S13 includes:
S132: the third father Hash for verifying the interim parallel chain block of read third is newest parallel with current parallel chain
Whether the block Hash of chain block is identical:
It is to then follow the steps S133: parallel chain block is generated according to the interim parallel chain block of third and is executed;
It is no, it thens follow the steps S134: traversing the interim parallel chain block in interim parallel chain block queue forward, until looking for
To the 4th interim parallel chain block;Wherein, father's Hash of the 4th interim parallel chain block is parallel with first in current parallel chain
The block Hash of chain block is identical;And
S135: it deletes according to all parallel chain blocks after the first parallel chain block;And
S136: parallel chain block is generated according to the 4th interim parallel chain block and is executed.
Assuming that there is the second application scenarios, the second application scenarios are as follows:
Parallel chain node a reads the interim parallel chain block of interim parallel chain block queue from local data base, when a is read
Third father's Hash parenthash (21_ put down _ faces) of the interim parallel chain block of the third taken is newest parallel with current parallel chain
When the block Hash blockhash (20_ is flat) of chain block is not identical, if directly being generated according to the interim parallel chain block of third parallel
Chain block, then the parallel chain block error generated;
The problem that for the second application scenarios, can be solved by step S132 to step S136;
Assuming that parenthash (21_ put down _ faces) is identical as blockhash (20_ is flat);
In step S132, a verifies third father's Hash parenthash of the interim parallel chain block of read third
Whether (21_ put down _ faces) be identical as the block Hash blockhash (20_ is flat) of the newest parallel chain block of current parallel chain:
Since parenthash (21_ put down _ faces) and blockhash (20_ is flat) is identical, S133 is thened follow the steps: according to the
Three interim parallel chain blocks generate parallel chain block and execute;
Assuming that parenthash (21_ put down _ faces) is different from blockhash (20_ is flat);
In step S132, a verifies third father's Hash parenthash of the interim parallel chain block of read third
Whether (21_ put down _ faces) be identical as the block Hash blockhash (20_ is flat) of the newest parallel chain block of current parallel chain:
Since parenthash (21_ put down _ faces) and blockhash (20_ is flat) is different, S134:a is thened follow the steps forward time
The interim parallel chain block in interim parallel chain block queue is gone through, until finding the 4th interim parallel chain block;Wherein, the 4th faces
When parallel chain block father's Hash it is identical as the block Hash of the first parallel chain block in current parallel chain;And
In step S135, a is deleted according to all parallel chain blocks after the first parallel chain block;
And
In step S136, a generates parallel chain block according to the 4th interim parallel chain block and executes.
Fig. 6 is a kind of structural schematic diagram for equipment that one embodiment of the invention provides.
As shown in fig. 6, present invention also provides a kind of equipment 600, including one or more centres as on the other hand
Unit (CPU) 601 is managed, can be added according to the program being stored in read-only memory (ROM) 602 or from storage section 608
The program that is downloaded in random access storage device (RAM) 603 and execute various movements appropriate and processing.In RAM603, also deposit
It contains equipment 600 and operates required various programs and data.CPU601, ROM602 and RAM603 pass through the phase each other of bus 604
Even.Input/output (I/O) interface 605 is also connected to bus 604.
I/O interface 605 is connected to lower component: the importation 606 including keyboard, mouse etc.;It is penetrated including such as cathode
The output par, c 607 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 608 including hard disk etc.;
And the communications portion 609 of the network interface card including LAN card, modem etc..Communications portion 609 via such as because
The network of spy's net executes communication process.Driver 610 is also connected to I/O interface 605 as needed.Detachable media 611, such as
Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 610, in order to read from thereon
Computer program be mounted into storage section 608 as needed.
Particularly, in accordance with an embodiment of the present disclosure, the parallel chain block generation method of any of the above-described embodiment description can be with
It is implemented as computer software programs.For example, embodiment of the disclosure includes a kind of computer program product comprising visibly
Comprising computer program on a machine-readable medium, the computer program includes for executing parallel chain block generation method
Program code.In such embodiments, which can be downloaded and be pacified from network by communications portion 609
Dress, and/or be mounted from detachable media 611.
As another aspect, present invention also provides a kind of computer readable storage medium, the computer-readable storage mediums
Matter can be computer readable storage medium included in the device of above-described embodiment;It is also possible to individualism, it is unassembled
Enter the computer readable storage medium in equipment.Computer-readable recording medium storage has one or more than one program, should
Program is used to execute the parallel chain block generation method for being described in the application by one or more than one processor.
Flow chart and block diagram in attached drawing are illustrated according to the system of various embodiments of the invention, method and computer journey
The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation
A part of one module, program segment or code of table, a part of the module, program segment or code include one or more use
The executable instruction of the logic function as defined in realizing.It should also be noted that in some implementations as replacements, being marked in box
The function of note can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are actually
It can be basically executed in parallel, they can also be executed in the opposite order sometimes, this is depending on related function.Also it wants
It is noted that the combination of each box in block diagram and or flow chart and the box in block diagram and or flow chart, Ke Yitong
The dedicated hardware based system of functions or operations as defined in executing is crossed to realize, or by specialized hardware and can be calculated
The combination of machine instruction is realized.
Being described in the embodiment of the present application involved unit or module can be realized by way of software, can also be with
It is realized by way of hardware.Described unit or module also can be set in the processor, for example, each unit can
To be the software program being arranged in computer or intelligent movable equipment, it is also possible to the hardware device being separately configured.Wherein, this
The title of a little units or module does not constitute the restriction to the unit or module itself under certain conditions.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.Those skilled in the art
Member is it should be appreciated that invention scope involved in the application, however it is not limited to technology made of the specific combination of above-mentioned technical characteristic
Scheme, while should also cover in the case where not departing from the application design, appointed by above-mentioned technical characteristic or its equivalent feature
Other technical solutions of meaning combination and formation.Such as features described above and (but being not limited to) disclosed herein have similar functions
Technical characteristic replaced mutually and the technical solution that is formed.