Summary of the invention
The purpose of the present invention is to provide a kind of device, method and storage mediums across chain transaction, it is intended to realize that safety hasAcross the chain transaction of effect.
To achieve the above object, the present invention provides a kind of device across chain transaction, and the device across chain transaction includes depositingReservoir and the processor connecting with the memory are stored with the processing system that can be run on the processor in the memorySystem, the processing system realize following steps when being executed by the processor:
When carrying out across chain transaction between each node of multichain, receives client and send the Transaction Information of this transaction and be somebody's turn to doClient, to the locking request of corresponding associated data, is based on the locking request for this friendship on this node based on the Transaction InformationEasy corresponding associated data is locked;
Intelligent contract is executed based on the Transaction Information and associated data, and by the complete of this transaction after completing this transactionClient is pushed at message;
When client be respectively received the completion message of each node of the multichain and respectively send unlocking request it is more to thisAfter each node of chain, the unlocking request is received, is based on the unlocking request for this corresponding associated data of trading on this nodeIt is unlocked.
Preferably, it is described based on the locking request by this corresponding associated data of trading on this node into line-locked stepSuddenly, it specifically includes: this corresponding pass of trading on this node is written on the intelligent contract of scheduled locking based on the locking requestJoin data, executes the locking intelligence contract to lock this corresponding associated data of trading on this node;
The described unlocking request that is based on is by the step of this corresponding associated data of trading is unlocked on this node, specificallyIt include: that this corresponding associated data of trading on this node is written on the intelligent contract of scheduled unlock based on the unlocking request,The unlock intelligence contract is executed so that this corresponding associated data of trading on this node to be unlocked.
Preferably, it is described based on the locking request by this corresponding associated data of trading on this node into line-locked stepSuddenly, comprising: this corresponding incidence number of trading on this node is written on the intelligent contract of scheduled locking based on the locking requestAccording to and the first identity information, execute the locking intelligence contract to lock this corresponding associated data of trading on this nodeIt is fixed;
The described unlocking request that is based on is by the step of this corresponding associated data of trading is unlocked on this node, into oneStep includes: that this corresponding associated data of trading on this node is written on the intelligent contract of scheduled unlock based on the unlocking requestAnd second identity information, the unlock intelligence contract is executed, when second identity information is identical as first identity information,This corresponding associated data of trading on this node is unlocked.
Preferably, it is described based on the locking request by this corresponding associated data of trading on this node into line-locked stepSuddenly, comprising: this corresponding incidence number of trading on this node is written on the intelligent contract of scheduled locking based on the locking requestAccording to and locking duration, execute the locking intelligence contract to lock this corresponding associated data of trading on this node;
When the processing system is executed by the processor, following steps are also realized: when the completion message that this is tradedIt is pushed to after client when not receiving unlocking request, if time difference at the time of current time and locking associated data is greater than etc.When the locking duration, this corresponding associated data of trading on this node is unlocked.
To achieve the above object, the present invention also provides a kind of method across chain transaction, the method across chain transaction includes:
S1 when carrying out across chain transaction between each node of multichain, receives the Transaction Information that client sends this transactionAnd the client based on the Transaction Information to the locking request of corresponding associated data, based on the locking request by this node thisSecondary corresponding associated data of trading is locked;
S2 executes intelligent contract based on the Transaction Information and associated data, and this is traded after completing this transactionCompletion message be pushed to client;
S3, when client is respectively received the completion message of each node of the multichain and sends unlocking request respectively to thisAfter each node of multichain, the unlocking request is received, is based on the unlocking request for this corresponding incidence number of trading on this nodeAccording to being unlocked.
Preferably, it is described based on the locking request by this corresponding associated data of trading on this node into line-locked stepSuddenly, it specifically includes: this corresponding pass of trading on this node is written on the intelligent contract of scheduled locking based on the locking requestJoin data, executes the locking intelligence contract to lock this corresponding associated data of trading on this node;
The described unlocking request that is based on is by the step of this corresponding associated data of trading is unlocked on this node, specificallyIt include: that this corresponding associated data of trading on this node is written on the intelligent contract of scheduled unlock based on the unlocking request,The unlock intelligence contract is executed so that this corresponding associated data of trading on this node to be unlocked.
Preferably, it is described based on the locking request by this corresponding associated data of trading on this node into line-locked stepSuddenly, comprising: this corresponding incidence number of trading on this node is written on the intelligent contract of scheduled locking based on the locking requestAccording to and the first identity information, execute the locking intelligence contract to lock this corresponding associated data of trading on this nodeIt is fixed;
The described unlocking request that is based on is by the step of this corresponding associated data of trading is unlocked on this node, into oneStep includes: that this corresponding associated data of trading on this node is written on the intelligent contract of scheduled unlock based on the unlocking requestAnd second identity information, the unlock intelligence contract is executed, when second identity information is identical as first identity information,This corresponding associated data of trading on this node is unlocked.
Preferably, it is described based on the locking request by this corresponding associated data of trading on this node into line-locked stepSuddenly, comprising: this corresponding incidence number of trading on this node is written on the intelligent contract of scheduled locking based on the locking requestAccording to and locking duration, execute the locking intelligence contract to lock this corresponding associated data of trading on this node;
The method across chain transaction, further includes: do not received after the completion message that this is traded is pushed to clientWhen unlocking request, if time difference at the time of current time and locking associated data is more than or equal to the locking duration, by this sectionThis corresponding associated data of trading is unlocked on point.
Preferably, it is described based on the locking request by this corresponding associated data of trading on this node into line-locked stepSuddenly, comprising: this corresponding incidence number of trading on this node is written on the intelligent contract of scheduled locking based on the locking requestAccording to and number of blocks, execute the locking intelligence contract to lock this corresponding associated data of trading on this node;
The method across chain transaction, further includes: do not received after the completion message that this is traded is pushed to clientWhen unlocking request, if current block number and the difference of the block number at the time of locking associated data are more than or equal to the number of blocksWhen, this corresponding associated data of trading on this node is unlocked.
The present invention also provides a kind of computer readable storage medium, processing is stored on the computer readable storage mediumThe step of system, the processing system realizes the above-mentioned method across chain transaction when being executed by processor.
The beneficial effects of the present invention are: node is receiving when the present invention carries out across chain transaction between each node of multichainThis corresponding associated data of trading on this node is locked to when transaction, by this transaction after completing this transactionIt completes message and is pushed to client, after client is respectively received the completion message of each node of the multichain, to each nodeUnlocking request is sent, this corresponding associated data of trading on node is unlocked, the present invention is when carrying out across chain transactionLocking data simultaneously unlocks data after completion of transactions, can be realized safely and effectively across chain transaction.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, rightThe present invention is further elaborated.It should be appreciated that described herein, specific examples are only used to explain the present invention, notFor limiting the present invention.Based on the embodiments of the present invention, those of ordinary skill in the art are not before making creative workEvery other embodiment obtained is put, shall fall within the protection scope of the present invention.
It should be noted that the description for being related to " first ", " second " etc. in the present invention is used for description purposes only, and cannotIt is interpreted as its relative importance of indication or suggestion or implicitly indicates the quantity of indicated technical characteristic.Define as a result, " theOne ", the feature of " second " can explicitly or implicitly include at least one of the features.In addition, the skill between each embodimentArt scheme can be combined with each other, but must be based on can be realized by those of ordinary skill in the art, when technical solutionWill be understood that the combination of this technical solution is not present in conjunction with there is conflicting or cannot achieve when, also not the present invention claimsProtection scope within.
As shown in fig.1, being the application environment schematic diagram of presently preferred embodiments of the present invention.In this embodiment, multichain packetBlock chain 1, block chain 2 and block chain 3 are included, client sends the transaction to multiple block chains, between each node of multichainCarry out across chain transaction.Device across chain transaction is the equipment executed where the node of transaction in block chain.
Device across chain transaction is that one kind can be automatic to carry out numerical value calculating according to the instruction for being previously set or storingAnd/or the equipment of information processing.The device across chain transaction can be computer, be also possible to single network server, moreThe server group that a network server forms or the cloud being made of a large amount of hosts or network server based on cloud computing,Middle cloud computing is one kind of distributed computing, a super virtual computer consisting of a loosely coupled set of computers.
Referring to shown in Fig. 2, the schematic diagram of the hardware structure of one embodiment of device for the present invention across chain transaction, in this implementationIn example, the device 1 across chain transaction may include, but be not limited only to, and memory 11, the place of connection can be in communication with each other by system busDevice 12, network interface 13 are managed, memory 11 is stored with the processing system 10 that can be run on the processor 12.It should be pointed out thatFig. 2 illustrates only the device 1 across chain transaction with component 11-13, it should be understood that being not required for implementing all showComponent, the implementation that can be substituted is more or less component.
Wherein, memory 11 includes the readable storage medium storing program for executing of memory and at least one type.Inside save as the dress across chain transactionThe operation for setting 1 provides caching;Readable storage medium storing program for executing can be for if flash memory, hard disk, multimedia card, card-type memory are (for example, SD or DXMemory etc.), random access storage device (RAM), static random-access memory (SRAM), read-only memory (ROM), electrically erasableIt is non-except programmable read only memory (EEPROM), programmable read only memory (PROM), magnetic storage, disk, CD etc.Volatile storage medium.In some embodiments, readable storage medium storing program for executing can be the storage inside list of the device 1 across chain transactionMember, such as it is somebody's turn to do the hard disk for the device 1 that traded across chain;In further embodiments, the non-volatile memory medium be also possible to acrossThe External memory equipment of the device 1 of chain transaction, such as the plug-in type hard disk being equipped on the device 1 across chain transaction, intelligent memory card(Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card) etc..ThisIn embodiment, the readable storage medium storing program for executing of memory 11 commonly used in storage be installed on the device 1 across chain transaction operating system andThe program code etc. of processing system 10 in types of applications software, such as storage one embodiment of the invention.In addition, memory 11 is alsoIt can be used for temporarily storing the Various types of data that has exported or will export.
The processor 12 can be in some embodiments central processing unit (Central Processing Unit,CPU), controller, microcontroller, microprocessor or other data processing chips store in the memory 11 for runningProgram code or processing data, such as operation processing system 10 etc..
The network interface 13 may include the radio network interface of standard, wired network interface, and the network interface 13 is usualFor establishing communication connection between the device 1 and other electronic equipments across chain transaction.
The processing system 10 is stored in memory 11, can including at least one computer being stored in memory 11Reading instruction, at least one computer-readable instruction can be executed by processor device 12, the method to realize each embodiment of the application;And the function that at least one computer-readable instruction is realized according to its each section is different, can be divided into different logicsModule.
In one embodiment, following steps are realized when above-mentioned processing system 10 is executed by the processor 12:
When carrying out across chain transaction between each node of multichain, receives client and send the Transaction Information of this transaction and be somebody's turn to doClient, to the locking request of corresponding associated data, is based on the locking request for this friendship on this node based on the Transaction InformationEasy corresponding associated data is locked;
Intelligent contract is executed based on the Transaction Information and associated data, and by the complete of this transaction after completing this transactionClient is pushed at message;
When client be respectively received the completion message of each node of the multichain and respectively send unlocking request it is more to thisAfter each node of chain, the unlocking request is received, is based on the unlocking request for this corresponding associated data of trading on this nodeIt is unlocked.
Concrete principle please refers to Program modual graph and Fig. 4 process about this method of following Fig. 3 about processing system 10The introduction of figure.
It is the Program modual graph of processing system 10 in Fig. 2 referring to shown in Fig. 3.The processing system 10 is divided into multipleModule, multiple module are stored in memory 12, and are executed by processor 13, to complete the present invention.The present invention is so-calledModule is the series of computation machine program instruction section for referring to complete specific function.
The processing system 10 can be divided into: locking module 101, pushing module 102 and unlocked state 103.
The locking module 101 when for carrying out across chain transaction between each node of multichain, receiving client and sending thisThe Transaction Information of secondary transaction and the client, to the locking request of corresponding associated data, are based on the locking based on the Transaction InformationRequest locks this corresponding associated data of trading on this node;
Wherein, associated data is the data that must be used in transaction, and the associated data of different transaction is different.For example, AMechanism belongs to different block chains from B mechanism, and the Transaction Information across chain transaction is for example are as follows: 1,000,000 are transferred accounts to B mechanism from A mechanism,Then corresponding associated data is A mechanism in the account information of account information, B mechanism on block chain on block chain.If eachData interlock success on a chain, then can execute transaction.The purpose of the locking of associated data is to prevent other users modification shouldData, so that Fail Transaction.
The pushing module 102 for executing intelligent contract based on the Transaction Information and associated data, and completes thisThis completion message traded is pushed to client after transaction;
Wherein, after completion of transactions, by the completion message active push of this transaction to client, so that the client on upper layerEnd can timely learning transaction results, do not need constantly to node polls transaction results.
The unlocked state 103, for being respectively received the completion message of each node of the multichain when client and dividingNot Fa Song unlocking request to each node of the multichain after, receive the unlocking request, based on the unlocking request by this node thisSecondary corresponding associated data of trading is unlocked.
After client receives the completion message of each node of the multichain, analyses whether to receive and all execute transactionNode completion message, with determine this transaction whether succeed, if it is, can send transmission unlocking request give the multichainEach node, this corresponding associated data of trading on this node is unlocked.In other embodiments, node is being handed overAfter being readily accomplished, voluntarily associated data can be unlocked.
As shown in figure 4, Fig. 4 is the flow diagram of method one embodiment of the present invention across chain transaction, the dress across chain transactionThe following steps of this method are realized when setting the processing system 10 stored in the 1 execution memory 12 of processor 13:
Step S1 when carrying out across chain transaction between each node of multichain, receives the transaction that client sends this transactionInformation and the client based on the Transaction Information to the locking request of corresponding associated data, based on the locking request by this nodeThis upper corresponding associated data of transaction is locked;
Wherein, each node that this Transaction Information traded is sent to multichain is subjected to across chain transaction by client, togetherWhen client send each node of the Transaction Information to the locking request of corresponding associated data to multichain.Associated data is to hand overThe associated data of the data that must be used in easily, different transaction is different, for example, A mechanism belongs to different blocks from B mechanismChain, the Transaction Information across chain transaction is for example are as follows: transfers accounts 1,000,000 to B mechanism from A mechanism, then corresponding associated data is that A mechanism existsThe account information of account information, B mechanism on block chain on block chain.
Wherein, if there is the associated data in block chain does not lock success, then this across chain Fail Transaction, needs againInitiate transaction.If the data interlock success on each chain, can execute transaction.The purpose of the locking of associated data is to preventOther users modify the data, so that Fail Transaction.
Step S2 executes intelligent contract based on the Transaction Information and associated data, and by this after completing this transactionThe completion message of transaction is pushed to client;
Wherein, each node of multichain is based on the Transaction Information and associated data executes intelligent contract, after completion of transactionsIt executes to submit and trades and Transaction Information is written on block chain account book, meanwhile, after completion of transactions, this completion traded is disappearedActive push is ceased to client, enables the client timely learning transaction results on upper layer, is not needed constantly to node pollsTransaction results.
Further, client can obtain transaction by way of long poll and complete message, i.e. client is sending thisAfter the Transaction Information of secondary transaction is to node, connection is idle and waits, when node generates completion message after completion of transactions, at onceIt returns and completes message to client.The operation allows for: when the case where unstable appearance transaction of message is lost is completed in push,Transaction has just fallen into unknowable state, and therefore, can be used simultaneously message ensures to be sent to mechanism, i.e. client while node pushesEnd carries out long poll.
Step S3, when client is respectively received the completion message of each node of the multichain and sends unlocking request respectivelyAfter each node of the multichain, the unlocking request is received, is based on the unlocking request for this corresponding pass of trading on this nodeConnection data are unlocked.
After client receives the completion message of each node of the multichain, analyses whether to receive and all execute transactionNode completion message, with determine this transaction whether succeed, if it is, can send transmission unlocking request give the multichainEach node, this corresponding associated data of trading on this node is unlocked.In other embodiments, node is being handed overAfter being readily accomplished, voluntarily associated data can be unlocked.
In one embodiment, on the basis of the above embodiments, the described locking request that is based on is by this friendship on this nodeThe step of easy corresponding associated data is locked, specifically includes: based on the locking request on the intelligent contract of scheduled lockingThis corresponding associated data of trading on this node is written, executes the locking intelligence contract to correspond to this transaction on this nodeAssociated data locked;
The described unlocking request that is based on is by the step of this corresponding associated data of trading is unlocked on this node, specificallyIt include: that this corresponding associated data of trading on this node is written on the intelligent contract of scheduled unlock based on the unlocking request,The unlock intelligence contract is executed so that this corresponding associated data of trading on this node to be unlocked.
Wherein, associated data locking can be realized with intelligent contract is locked, for example, transaction are as follows: user needs to modify numberAccording to A, then locking associated data can be LOCK-A, when LOCK-A success is written on block chain with the intelligent contract of locking,Indicate that data A is locked successfully.
Wherein, associated data unlock can be realized with intelligent contract is unlocked, for example, when needing to unlock data A, thenUnlocking associated data can be LOCK-A, when LOCK-A success is written on block chain with the intelligent contract of unlock, indicate data AIt unlocks successfully.
In one embodiment, on the basis of the above embodiments, the described locking request that is based on is by this friendship on this nodeThe step of easy corresponding associated data is locked, comprising: be written on the intelligent contract of scheduled locking based on the locking requestThis trade corresponding associated data and first identity information on this node, execute the locking intelligence contract on this nodeSecondary corresponding associated data of trading is locked;
The described unlocking request that is based on is by the step of this corresponding associated data of trading is unlocked on this node, into oneStep includes: that this corresponding associated data of trading on this node is written on the intelligent contract of scheduled unlock based on the unlocking requestAnd second identity information, the unlock intelligence contract is executed, when second identity information is identical as first identity information,This corresponding associated data of trading on this node is unlocked.
Wherein, the second identity information and the first identity information can be the digital certificate of user (mechanism), in locking intelligenceThe number card of associated data and mechanism is written in the digital certificate that associated data and mechanism are written on contract on unlocking intelligent contractBook, in unlock, unanimously then proof of identity passes through only two digital certificates, can execute unlock operation.It is closed in locking intelligenceAbout and in the intelligent contract of unlock it is respectively written into identity information, in order to prevent other users malice unlock data (i.e.In the case where being had user's locking data, unlock uses the data by force) and transaction is interrupted, it further increases across chain transactionSafety.
In one embodiment, on the basis of the above embodiments, the described locking request that is based on is by this friendship on this nodeThe step of easy corresponding associated data is locked, comprising: be written on the intelligent contract of scheduled locking based on the locking requestThis trade corresponding associated data and locking duration on this node, execute the locking intelligence contract with by this node this hand overEasy corresponding associated data is locked;
The method across chain transaction, further includes: do not received after the completion message that this is traded is pushed to clientWhen unlocking request, if time difference at the time of current time and locking associated data is more than or equal to the locking duration, by this sectionThis corresponding associated data of trading is unlocked on point.
Wherein, number is not unlocked for a long time after some user's long-time locking data or across the chain transaction of completion in order to preventAccording to (for example, abnormal delay machine occurs in client-side program can not continue to execute normal logic be unlocked), prevent locking data fromIt is used by other users, associated data can be written in the present embodiment on locking intelligent contract and locking duration is being handed over certainlyIn the case where being readily accomplished, the big of analysis current time and time difference and the locking duration at the time of locking associated data is just executedData are unlocked by small relationship when the time difference being more than or equal to the locking duration.
In one embodiment, on the basis of the above embodiments, the described locking request that is based on is by this friendship on this nodeThe step of easy corresponding associated data is locked, comprising: be written on the intelligent contract of scheduled locking based on the locking requestThis trade corresponding associated data and number of blocks on this node, execute the locking intelligence contract with by this node this hand overEasy corresponding associated data is locked;
The method across chain transaction, further includes: do not received after the completion message that this is traded is pushed to clientWhen unlocking request, if current block number and the difference of the block number at the time of locking associated data are more than or equal to the number of blocksWhen, this corresponding associated data of trading on this node is unlocked.
The present embodiment can not often unify that consistent (each node operates in individually in view of the node time on block chainOn server, the time of each server be not it is completely the same, may have the difference of several seconds, a few minutes), therefore can be usedNumber of blocks replaces above-mentioned locking duration, for example, number of blocks is 10, then the effective time of locking data is 10 areasBlock, it is assumed that current block number is 100, then other users can not unlock the data before block number reaches 110, unless withThe dynamic release of householder, block number proceed to after 110, automatic unlocking.
Compared with prior art, when the present invention carries out across chain transaction between each node of multichain, node is receiving friendshipThis corresponding associated data of trading on this node is locked when easily, the completion that this is traded after completing this transactionMessage is pushed to client, after client is respectively received the completion message of each node of the multichain, sends to each nodeThis corresponding associated data of trading on node is unlocked by unlocking request, and the present invention is locked when carrying out across chain transactionData simultaneously unlock data after completion of transactions, can be realized safely and effectively across chain transaction.
In addition, the embodiment of the present invention also proposes a kind of computer readable storage medium, the computer readable storage mediumIt can be hard disk, multimedia card, SD card, flash card, SMC, read-only memory (ROM), Erasable Programmable Read Only Memory EPROM(EPROM), any one in portable compact disc read-only memory (CD-ROM), USB storage etc. or several timessMeaning combination.It include processing system, the function which realizes when being executed by processor in the computer readable storage mediumCan, the above-mentioned introduction about Fig. 3 and Fig. 4 is please referred to, details are not described herein.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-rowHis property includes, so that the process, device, article or the method that include a series of elements not only include those elements, andAnd further include other elements that are not explicitly listed, or further include for this process, device, article or method institute it is intrinsicElement.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment sideMethod can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many casesThe former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior artThe part contributed out can be embodied in the form of software products, which is stored in a storage mediumIn (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal device (can be mobile phone, computer, clothesBusiness device, air conditioner or the network equipment etc.) execute method described in each embodiment of the present invention.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hairEquivalent structure or equivalent flow shift made by bright specification and accompanying drawing content is applied directly or indirectly in other relevant skillsArt field, is included within the scope of the present invention.