A kind of cochain based on block chain and condition processing method, device and interacted system
Technical field
This specification embodiment is related to network technique field more particularly to a kind of cochain and state processing based on block chain
Method, apparatus and interacted system.
Background technology
Block chain technology is also referred to as distributed account book technology, is substantially a kind of distributed interconnection data of decentralization
Library.Block chain network can be considered using the network of block chain Technical Architecture, include multiple block chain nodes in the block chain network,
Either block chain node can correspond at least one block chain, and either block chain may include at least one block.
There are transaction and state in block chain, there is the set of numerous transaction in each block.Each pen in block chain
New Transaction after processing, in the presence of numerous nodes, will produce one group of data containing determining our times state, i.e.,
State root, and indicate that the state root of the world state can be stored in block again.
In current block chain algorithm process, each transaction after processing, can be broadcast to other on block chain
Participate in node, need other nodes on block chain to participate in algorithm of knowing together together, and be ranked up by timestamp, come determine by
This transaction of which node verification.After the completion of transaction is known together and sorted, need that node is waited for all to locate these transaction
It has been managed that, calculate last state root, then this state root is write back in block.The common recognition of trading processing calculates each time in this way
It is all carried out in time according to sequencing with the calculating of state root, when especially handling more transactions simultaneously, calculation processing is very
It takes.
It is a synchronizing process above, if block uplink calculations and state computation are separated into independent flow, to each other
By message communicating, then computational efficiency may be increased substantially.As a result, there is an urgent need for find a kind of new cochain based on block chain with
Condition processing method, to overcome the above problem.
Invention content
This specification embodiment provides a kind of cochain based on block chain and condition processing method, device and interacted system,
To solve the problems, such as network congestion present in the common recognition scheme of the prior art and storage burden.
In order to solve the above-mentioned technical problem, this specification embodiment uses following technical proposals:
In a first aspect, a kind of cochain and condition processing method based on block chain are provided, including:Chain process and actuator
Process;The chain process includes transaction distribution flow and block cochain flow, the actuator process include contract flow and shape
State root calculation process, the chain process and actuator process are respectively independently carried out and are in communication with each other, and the chain process is executing friendship
During easy distribution flow, actuator process is sent transaction information to, the transaction is handled by the state root calculation process
Information and obtain state root, and the state root is returned into the chain process, stored within a block to complete the block cochain
Flow.
Second aspect provides a kind of cochain based on block chain and state processing device, including:Chain module and actuator
Module;The chain module is for handling transaction distribution flow and block cochain flow, and the actuator is for handling contract flow
With state root calculation process, the chain module and executor module are respectively independently carried out and are in communication with each other, and the chain module is being held
During row transaction distribution flow, executor module is sent transaction information to, described in state root calculation process processing
Transaction Information and obtain state root, and the state root is returned into the chain module, stored within a block to complete the block
Cochain flow.
The third aspect provides a kind of interacted system, includes positioned at supervisory application layer and positioned at the podium level of subordinate, institute
It includes chain module and executor module to state podium level;The chain module is used to handle transaction distribution flow and block cochain flow,
For handling contract flow and state root calculation process, the chain module and executor module respectively independently carry out the actuator
And be in communication with each other, the chain module sends transaction information to executor module, by institute during executing transaction distribution flow
It states state root calculation process to handle the Transaction Information and obtain state root, and the state root is returned into the chain module, deposit
Storage is in middle block to complete the block cochain flow;The podium level provides interface, and the application layer is opened using the interface
Hair uses the application program of intelligent contract.
Above-mentioned at least one technical solution that this specification embodiment uses can reach following advantageous effect:
Through the above technical solutions, the cochain of block chain and state processing are divided into separate chain process and actuator
Process;Chain process sends transaction information to actuator process by distribution flow of merchandising, and the chain process executes block cochain
Flow handles the Transaction Information by the state root calculation process and obtains state root, and will be described in state root return
Block cochain and state root are calculated separating treatment by chain process, storage in this way to complete the block cochain flow within a block,
The efficiency of trading processing and block cochain in block chain can be effectively improved, computing resource is saved.
Description of the drawings
In order to illustrate more clearly of this specification embodiment or technical solution in the prior art, below will to embodiment or
Attached drawing needed to be used in the description of the prior art is briefly described, it should be apparent that, the accompanying drawings in the following description is only
Some embodiments described in this specification embodiment are not paying creative labor for those of ordinary skill in the art
Under the premise of dynamic property, other drawings may also be obtained based on these drawings.
Fig. 1 is the schematic diagram for the cochain and condition processing method based on block chain that this specification embodiment provides;
Fig. 2 is the cochain and state processing apparatus structure schematic diagram based on block chain that this specification embodiment provides;
The structural schematic diagram for the interacted system that Fig. 3 this specification embodiments provide.
Specific implementation mode
To keep the purpose, technical scheme and advantage of this specification embodiment clearer, have below in conjunction with this specification
The technical solution of this specification embodiment is clearly and completely described in body embodiment and corresponding attached drawing.Obviously, described
Embodiment be only this specification a part of the embodiment, instead of all the embodiments.The embodiment of base in this manual, this
The every other embodiment that field those of ordinary skill is obtained without making creative work, belongs to this explanation
The range of book embodiment protection.
Below in conjunction with attached drawing, the technical solution that each embodiment of this specification provides is described in detail.
It should be noted that in this specification embodiment, the cochain of block chain and state processing are divided into respective independence
Chain process and actuator process;Chain process sends transaction information to actuator process, the chain by distribution flow of merchandising
Process executes block cochain flow, handles the Transaction Information by the state root calculation process and obtains state root, and by institute
It states state root and returns to the chain process, store within a block to complete the block cochain flow in this way by block cochain and state
Root calculates separating treatment, can effectively improve the efficiency of trading processing and block cochain in block chain, saves computing resource.
Embodiment one
Shown in referring to Fig.1, a kind of cochain and condition processing method based on block chain that are provided for this specification embodiment
Schematic diagram, cochain of the present embodiment based on block chain include with condition processing method:
Chain process 101 and actuator process 102;The chain process 101 includes transaction distribution flow 104 and block cochain stream
Journey 103, the actuator process 102 include contract flow 105 and state root calculation process 106.
The chain process 101 and 102 process of actuator are respectively independently carried out and are in communication with each other.
According to cochain and condition processing method of the present embodiment based on block chain, when generating new transaction on block chain,
The chain process 101 executes transaction distribution flow 104, during executing transaction distribution flow 104, sends transaction information to
Actuator process 102 handles the Transaction Information by the state root calculation process 106 and obtains state root (state_
Root the chain process 101), and by the state root is returned, is stored within a block to complete the block cochain flow.
In the present embodiment, while the chain process 101 executes transaction distribution flow 104, the block cochain flow
103 synchronize progress.Specifically, the block cochain flow 103 submits out block request including node, and each node is calculated by knowing together
Method generates new block, handles transaction data and generates block cryptographic Hash, and the block cryptographic Hash and new block are added to area
On block chain, the flow of new block cochain is just completed in this way.
In the present embodiment, while executing block cochain flow 103, the chain process 101 executes transaction distribution flow
Journey 104 sends transaction information to actuator process 102.
In the existing block catenary system being made of multiple nodes, a large amount of node is completed by proof of work mechanism
The common recognition mechanism of New Transaction cochain, needs to expend a large amount of computing resources, and by the most fast completion block cochain of wherein calculating speed,
As it can be seen that a large amount of computing resource is wasted.
In addition, after the completion of common recognition mechanism, it is also necessary to expend a large amount of calculation amounts and handle the Transaction Information and obtain representing institute
The state root (state_root) for having Transaction Information, could complete block cochain.
And according to method provided in this embodiment, since the block cochain flow 103 and state root calculation process 106 are each
It is executed from separation, each node on meshed network can handle block cochain flow 103 in batches or respectively and state root calculates
Flow 106, for example, part of nodes special disposal block cochain flow 103, the common recognition for carrying out proof of work calculates alternatively, its
His node then carries out to transaction data handle and then completion status root calculates, and finally most fast node, which obtains, carries out cochain behaviour
The right of work, while from the implementing result of other nodes calling state root calculation process 106, completing block cochain.Therefore, individually
Node, which is not necessarily to consume respectively in block cochain flow 103 and state root calculation process 106, calculates power, using side provided in this embodiment
Calculating speed can be greatly improved for entire block chain in method.
It should be noted that in the present embodiment, the actuator process 102 further includes contract flow 105, the conjunction
About flow 105 is to carry out intelligent contract to the transaction data that chain process 101 provides to execute, i.e., multiple nodes are carried out at the same time digital label
Name proving program, to ensure the validity of the transaction.
Specifically, in the present embodiment, it due to contract flow 105 and 103 lock out operation of block cochain flow, that is, counts
Word signature verification program and block cochain lock out operation, further improve the efficiency of information processing.For example, node net can be made
Part of nodes in network carries out block cochain flow 103, and another part special disposal contract flow 105 can equally reach completion
Verify the function of contract validity.
Therefore, according to method provided in this embodiment, block cochain flow 103 and state root calculation process 106 are detached
Processing, while executing block cochain flow 103, multiple nodes carry out intelligent contract verification, and participate in carry out state root meter
It calculates.
It should be noted that when user carries out the electronic money tradings such as bit coin, often there is number in entire block chain
Above transaction carries out in same section in terms of ten thousand.Traditional block cochain mode, multiple nodes often receive thousand or more
Transaction Information after, these transaction data are carried out with intelligent contract and block cochain together.Each node is in a large amount of friendship of processing
Simultaneously, the common recognition that also complete proof of work calculates easy data, and uses method provided in this embodiment, a large amount of for these
Transaction, meshed network can in batches, classification processing, the great deal of nodes in meshed network is corresponded to different calculating stream respectively
Journey, and then improve computational efficiency.
Therefore, when being carried out at the same time more transactions on block chain, trading processing and block in block chain can be effectively improved
The efficiency of cochain saves computing resource, shortens the time used in block cochain.Optionally, in the present embodiment, the chain process
101 is corresponding with chain database 108,108 memory block data of the chain database and transaction data, the actuator process
102 corresponding states databases 109,109 storage state root information of the slip condition database and account information.
101 call chain database 108 of the chain process or to 108 output data of chain database, the actuator process 102
Call slip condition database 109 or to 109 output data of slip condition database.
Optionally, the chain process 101 and actuator process 102 can be in communication with each other or the chain process 101 and hold
Row device process 102 can also be with other process communications, when with other process communications, the chain process 101 and actuator process 102
The information of subscription includes that common recognition calculates information, Network Synchronization block information and motion pre-execution information.
It should be noted that in the present embodiment, in other embodiments, the common recognition calculates information and right can specially set
The common recognition module set, which calculates, to be completed.That is, the chain process 101 can only include transaction distribution flow 104 and block
Basic operation in cochain flow 103, and transfer to common recognition module to calculate computationally intensive proof of work, further increase meter
Calculate efficiency.
Optionally, the chain process 101 and actuator process 102 can by far call process 107 (RPC,
Remote Procedure Call) inquiry so that the chain process 101 and actuator process 102 can be by remote user's tune
With.
Embodiment two
Fig. 2 is the cochain and state processing apparatus structure schematic diagram based on block chain that this specification embodiment provides, under
The block cochain and state processing device of this specification embodiment are discussed in detail with reference to Fig. 2 for face.It should be noted that in this implementation
In example, cochain based on block chain that block cochain and state processing device are provided using first embodiment of the invention at state
Reason method carries out block and connects uplink operation, but the present invention is without limitation.
The present embodiment provides a kind of cochains based on block chain and state processing device, including:Chain module 201 and execution
Device module 202.The chain module 201 is used for handling transaction distribution flow and block cochain flow, the executor module 202
It respectively independently carries out and is in communication with each other in processing contract flow and state root calculation process, the chain module and executor module,
The chain module 201 sends transaction information to executor module 202, by the shape during executing transaction distribution flow
State root calculation process handles the Transaction Information and obtains state root, and the state root is returned to the chain module 201, storage
Within a block to complete the block cochain flow.
In the present embodiment, the block cochain flow includes that node submits out block request, and each node is calculated by knowing together
Method generates new block, handles transaction data and generates block cryptographic Hash, and the block cryptographic Hash and new block are added to area
On block chain.
Therefore, according to device provided in this embodiment, block cochain flow and state root calculation process 106 are existed respectively
It is handled in chain module 201 and executor module 202, while executing block cochain flow, multiple nodes carry out intelligent contract
It verifies, and participate in carry out state root calculating to effectively improve and hand in block chain when being carried out at the same time more transactions on block chain
Disposable and block cochain efficiency, saves computing resource, shortens the time used in block cochain.
Optionally, in the present embodiment, the chain module 201 includes chain database 108, and the chain database 108 stores
The information such as block data, receipt and transaction data, the executor module 202 include slip condition database 109, the status number
According to 109 library storage state root informations and account information.The chain database 108 and slip condition database 109 can be by respective independent
It is independent to call, further improve computation rate.
After the executor module 202 executes block cochain flow, the Transaction Information and receipt that will be obtained after execution
It is stored into the chain database 108;The executor module 202 is carried as intelligent contract enforcement engine for contract process flow operation
For performing environment, and the account information after contract flow and the storage of state root will be executed to the slip condition database 108.
Optionally, in the present embodiment, the cochain based on block chain and state processing device further include common recognition module
With Network Synchronization module 205, the common recognition module and Network Synchronization module 205 undertake common recognition calculating and Network Synchronization function, and
It is communicated with the chain module 201 or executor module 202, but the present invention is without limitation, the common recognition calculates and network
Synchronizing function can also be encapsulated in the chain module 201 or executor module 202 and complete.
It should be noted that in the present embodiment, the cochain based on block chain can be electricity with state processing device
Sub- equipment, in hardware view, which includes processor, further includes optionally internal bus, network interface, memory.
Wherein, memory may include memory, such as high-speed random access memory (Random-Access Memory, RAM), also may be used
Can further include nonvolatile memory (Non-Volatile Memory), for example, at least 1 magnetic disk storage etc..Certainly, should
Electronic equipment is also possible that the required hardware of other business.
Processor, network interface and memory can be connected with each other by internal bus, which can be industry
Standard architecture (Industry Standard Architecture, ISA) bus, Peripheral Component Interconnect standard
(Peripheral Component Interconnect, PCI) bus or expanding the industrial standard structure (Extended
Industry Standard Architecture, EISA) bus etc..The bus can be divided into address bus, data/address bus,
Controlling bus etc..For ease of indicating, only indicated with a four-headed arrow in Fig. 2, it is not intended that an only bus or one kind
The bus of type.
Memory, for storing program.Specifically, program may include program code, and said program code includes calculating
Machine operational order.Memory may include memory and nonvolatile memory, and provide instruction and data to processor.
Processor is from then operation in corresponding computer program to memory is read in nonvolatile memory, in logical layer
Content recommendation device is formed on face.Processor executes the program that memory is stored, and specifically for executing service described previously
Performed method operation when device is as executive agent.
Method disclosed in above-mentioned-Fig. 2 such as this specification embodiment Fig. 1 can be applied in processor, or by processor
It realizes.Processor may be a kind of IC chip, the processing capacity with signal.During realization, the above method
Each step can be completed by the integrated logic circuit of the hardware in processor or the instruction of software form.Above-mentioned processor
Can be general processor, including central processing unit (Central Processing Unit, CPU), network processing unit
(Network Processor, NP) etc.;Can also be digital signal processor (Digital Signal Processor,
DSP), application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate
Array (Field-Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or crystalline substance
Body pipe logical device, discrete hardware components.It may be implemented or execute disclosed each method, the step in this specification embodiment
And logic diagram.General processor can be microprocessor or the processor can also be any conventional processor etc..Knot
The step of closing the method disclosed in this specification embodiment can be embodied directly in hardware decoding processor and execute completion, Huo Zheyong
Hardware and software module combination in decoding processor execute completion.Software module can be located at random access memory, flash memory, read-only
The storage medium of this fields such as memory, programmable read only memory or electrically erasable programmable memory, register maturation
In.The storage medium is located at memory, and processor reads the information in memory, and the step of the above method is completed in conjunction with its hardware
Suddenly.
Certainly, other than software realization mode, other realization sides are not precluded in the electronic equipment of this specification embodiment
Formula, for example, logical device or software and hardware combining mode etc., that is to say, that the executive agent of following process flow is simultaneously unlimited
Can also be hardware or logical device due to each logic unit.
Embodiment three
The structural schematic diagram for the interacted system that Fig. 3 this specification embodiments provide, this explanation is discussed in detail with reference to Fig. 3
The interacted system of book embodiment.
The interacted system that this specification embodiment provides includes being located at supervisory application layer 301 and the podium level positioned at subordinate
302.The podium level 301 includes chain module 201 and executor module 202;The chain module 201 is for handling transaction distribution flow
Journey and block cochain flow, the executor module 202 is for handling contract flow and state root calculation process, the chain module
201 and executor module 202 respectively independently carry out and be in communication with each other, the chain module 201 execute merchandise distribution flow process
In, executor module 202 is sent transaction information to, the Transaction Information is handled by the state root calculation process and obtains shape
State root, and the state root is returned into the chain module 201, middle block is stored in complete block cochain flow.
The podium level 302 provides interface, and the application layer 201 is using the interface exploitation using the application of intelligent contract
Program.Optionally, user can develop in application layer 301 using application programs such as the electronic money of intelligent contract, and use platform
The interface that layer 302 provides calls inquiry data.
According to interacted system provided in this embodiment, in podium level 302, block cochain flow and state root are calculated into stream
Journey 106 is handled in chain module 201 and executor module 202 respectively, while executing block cochain flow, multiple nodes into
Row intelligence contract verification, and participate in carry out state root calculating and can be effectively improved when being carried out at the same time more transactions on block chain
The efficiency of trading processing and block cochain in block chain saves computing resource, shortens the time used in block cochain.It is same in this way
It is obviously improved so that being located at the application programs speeds of service such as the intelligent contract of application layer 301, electronic money.
In short, the foregoing is merely the preferred embodiment of this specification embodiment, it is not intended to limit this specification
The protection domain of embodiment.It is all this specification embodiment spirit and principle within, made by any modification, equivalent replacement,
Improve etc., it should be included within the protection domain of this specification embodiment.
System, device, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.It is a kind of typically to realize that equipment is computer.Specifically, computer for example may be used
Think personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
It is any in device, navigation equipment, electronic mail equipment, game console, tablet computer, wearable device or these equipment
The combination of equipment.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology realizes information storage.Information can be computer-readable instruction, data structure, the module of program or other data.
The example of the storage medium of computer include, but are not limited to phase transition internal memory (PRAM), static RAM (SRAM),
Dynamic random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electrically erasable
Except programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only disc read only memory (CD-ROM) (CD-
ROM), digital versatile disc (DVD) or other optical storages, magnetic tape cassette, tape magnetic disk storage or other magnetism are deposited
Equipment or any other non-transmission medium are stored up, can be used for storage and can be accessed by a computing device information.According to boundary herein
Fixed, computer-readable medium does not include temporary computer readable media (transitory media), such as the data-signal of modulation and
Carrier wave.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
Including so that process, method, commodity or equipment including a series of elements include not only those elements, but also wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence " including one ... ", it is not excluded that including described
There is also other identical elements in the process of element, method, commodity or equipment.
Each embodiment in this specification embodiment is described in a progressive manner, identical phase between each embodiment
As part just to refer each other, each embodiment focuses on the differences from other embodiments.Especially for
For system embodiment, since it is substantially similar to the method embodiment, so description is fairly simple, related place is referring to method
The part of embodiment illustrates.