Summary of the invention
The main object of the present invention is to provide a kind of node device, real-time account checking method and computer based on block chain canRead storage medium, it is intended to realize the real-time reconciliation of transaction.
To achieve the above object, the present invention proposes a kind of node device, and the node device includes memory and processor,The real-time reconciliation program based on block chain is stored on the memory, the real-time reconciliation program based on block chain is describedProcessor realizes following steps when executing:
Receiving step: receiving and request into chain, it is described enter chain request carry the K transaction detail of a transaction, the friendshipEasy detail includes stateful transaction, and K is positive integer;
First judgment step: judge the K transaction detail whether be the transaction the first stroke transaction details;
Storing step: when the K transaction detail is the first stroke transaction details of the transaction, by described KTransaction details are stored into block chain;
Reconciliation step: when the K transaction detail is not the first stroke transaction details of the transaction, according to default ruleThen, the first reconciliation of the K transaction detail is determined as a result, and the K transaction detail and the K transaction is brightThe first thin reconciliation result is stored into the block chain.
Preferably, the reconciliation step includes:
First query steps: inquiring the K-1 transaction detail of the transaction in the block chain, when inquiring,It is transferred to the second judgment step, when not inquiring, second is transferred to and determines step;
Second judgment step: whether the stateful transaction for judging the K-1 transaction detail of the transaction is final state, if so,It is then transferred to third judgment step, if it is not, being transferred to second determines that step, the final state refer to that stateful transaction is to trade successfully or tradeThe state of failure;
Third judgment step: whether the stateful transaction for judging the K transaction detail is final state, if so, being transferred toOne determines step, if it is not, being then transferred to second determines step;
First determines step: judging the stateful transaction of the K transaction detail and the friendship of the K-1 transaction detailWhether easy state is identical, if so, the first reconciliation result of the label K transaction detail is normal, and by described KFirst reconciliation result of transaction details and the K transaction detail is stored into the block chain, if it is not, then marking describedFirst reconciliation result of K transaction detail is abnormal, and by the of the K transaction detail and the K transaction detailOne reconciliation result is stored into the block chain;
Second determines step: the first reconciliation result of the label K transaction detail is unknown, and by described KFirst reconciliation result of transaction details and the K transaction detail is stored into the block chain.
Preferably, the processor executes the real-time reconciliation program based on block chain, after the reconciliation step,Also perform the steps of
First obtaining step: the transaction execution time that real-time or timing acquisition is respectively traded, and transaction execution time is greater thanThe transaction of preset duration is as transaction to be processed;
Third determines step: the type of transaction of each transaction to be processed is determined, according to the friendship of each transaction to be processedMapping relations between easy type and predetermined type of transaction and preset quantity determine that each transaction to be processed is correspondingPreset quantity;
Selection step: judge whether the transaction details quantity of each transaction to be processed is less than the transaction pair to be processed one by oneThe preset quantity answered, whenever the transaction details quantity for determining a transaction to be processed is less than the corresponding preset quantity to be processed of tradingWhen, using the All Activity detail of the transaction to be processed as the first transaction details to be processed;
First markers step: after finding out all first transaction details to be processed, by all first friendships to be processedSecond reconciliation result queue of easy detail is abnormal, and the second reconciliation result of all first transaction details to be processed is depositedStorage is into the block chain.
Preferably, the first reconciliation result includes normal, abnormal and unknown, and the processor executes described based on blockThe real-time reconciliation program of chain also performs the steps of after first obtaining step
Second obtaining step: it is that unknown transaction is bright that all first reconciliation results are obtained from all transaction to be processedSpy is the second transaction details to be processed;
Second query steps: select the second transaction to be processed bright one by one from all second transaction details to be processedCarefully, when the second selected transaction details to be processed are the i-th transaction detail of affiliated transaction, institute is inquired in the block chainThe the (i-1)-th transaction detail traded belonging to second transaction details to be processed of choosing is transferred to third and determines step when inquiring,When not inquiring, it is transferred to the second markers step, wherein i is the positive integer greater than 1;
Third determines step: whether the stateful transaction for judging the (i-1)-th transaction detail is final state, if so, being transferred to4th determines step, if it is not, it is then transferred to the second markers step,;
4th determines step: whether the stateful transaction for judging the i-th transaction detail is final state, if so, being transferred to theFive determine step, if it is not, it is then transferred to the second markers step,;
5th determines step: judging the stateful transaction of the i-th transaction detail and the friendship of the (i-1)-th transaction detailWhether easy state is identical, if so, it is transferred to third markers step, if it is not, being then transferred to the second markers step;
Second markers step: being abnormal by the second reconciliation result queue of the i-th transaction detail, and by described i-thSecond reconciliation result of transaction detail is stored into block chain;
Third markers step: being normal by the second reconciliation result queue of the i-th transaction detail, and by described i-thSecond reconciliation result of transaction detail is stored into block chain;
Detecting step: judge in all second transaction details to be processed with the presence or absence of unselected mistake second wait locateTransaction details are managed, when it is present, returns and executes second query steps.
Preferably, the processor executes the real-time reconciliation program based on block chain, also performs the steps of
In real time or all first reconciliation results of timing acquisition or the second reconciliation result are abnormal transaction details, when gettingWhen, account-checking report is generated according to the All Activity detail of acquisition, and send the account-checking report to monitoring device, for the monitoringEquipment creates abnormality processing item according to the account-checking report;
Alternatively, real-time or all first reconciliation results of timing acquisition or the second reconciliation result are abnormal transaction details, whenWhen getting, account-checking report is generated according to the All Activity detail of acquisition, and the account-checking report is stored to the block chainIn, the account-checking report is obtained from the block chain for the monitoring device, and according to the account-checking report, create exceptionDirector.
In addition, to achieve the above object, the present invention also proposes a kind of real-time account checking method based on block chain, this method is suitableFor the node device in block catenary system, the method comprising the steps of:
Receiving step: receiving and request into chain, it is described enter chain request carry the K transaction detail of a transaction, the friendshipEasy detail includes stateful transaction, and K is positive integer;
First judgment step: judge the K transaction detail whether be the transaction the first stroke transaction details;
Storing step: when the K transaction detail is the first stroke transaction details of the transaction, by described KTransaction details are stored into block chain;
Reconciliation step: when the K transaction detail is not the first stroke transaction details of the transaction, according to default ruleThen, the first reconciliation of the K transaction detail is determined as a result, and the K transaction detail and the K transaction is brightThe first thin reconciliation result is stored into the block chain.
Preferably, the reconciliation step includes:
First query steps: inquiring the K-1 transaction detail of the transaction in the block chain, when inquiring,It is transferred to the second judgment step, when not inquiring, second is transferred to and determines step;
Second judgment step: whether the stateful transaction for judging the K-1 transaction detail of the transaction is final state, if so,It is then transferred to third judgment step, if it is not, being transferred to second determines that step, the final state refer to that stateful transaction is to trade successfully or tradeThe state of failure;
Third judgment step: whether the stateful transaction for judging the K transaction detail is final state, if so, being transferred toOne determines step, if it is not, being then transferred to second determines step;
First determines step: judging the stateful transaction of the K transaction detail and the friendship of the K-1 transaction detailWhether easy state is identical, if so, the first reconciliation result of the label K transaction detail is normal, and by described KFirst reconciliation result of transaction details and the K transaction detail is stored into the block chain, if it is not, then marking describedFirst reconciliation result of K transaction detail is abnormal, and by the of the K transaction detail and the K transaction detailOne reconciliation result is stored into the block chain;
Second determines step: the first reconciliation result of the label K transaction detail is unknown, and by described KFirst reconciliation result of transaction details and the K transaction detail is stored into the block chain.
Preferably, after the reconciliation step, this method further include:
First obtaining step: the transaction execution time that real-time or timing acquisition is respectively traded, and transaction execution time is greater thanThe transaction of preset duration is as transaction to be processed;
Third determines step: the type of transaction of each transaction to be processed is determined, according to the friendship of each transaction to be processedMapping relations between easy type and predetermined type of transaction and preset quantity determine that each transaction to be processed is correspondingPreset quantity;
Selection step: judge whether the transaction details quantity of each transaction to be processed is less than the transaction pair to be processed one by oneThe preset quantity answered, whenever the transaction details quantity for determining a transaction to be processed is less than the corresponding preset quantity to be processed of tradingWhen, using the All Activity detail of the transaction to be processed as the first transaction details to be processed;
First markers step: after finding out all first transaction details to be processed, by all first friendships to be processedSecond reconciliation result queue of easy detail is abnormal, and the second reconciliation result of all first transaction details to be processed is depositedStorage is into the block chain.
Preferably, the first reconciliation result includes normal, abnormal and unknown, should after first obtaining stepMethod further include:
Second obtaining step: it is that unknown transaction is bright that all first reconciliation results are obtained from all transaction to be processedSpy is the second transaction details to be processed;
Second query steps: select the second transaction to be processed bright one by one from all second transaction details to be processedCarefully, it when the second selected transaction details to be processed are the i-th transaction detail of affiliated transaction, is inquired in the block chainThe the (i-1)-th transaction detail traded belonging to the transaction details to be processed of selected second is transferred to third and determines step when inquiringSuddenly, when not inquiring, it is transferred to the second markers step, wherein i is the positive integer greater than 1;
Third determines step: whether the stateful transaction for judging the (i-1)-th transaction detail is final state, if so, being transferred to4th determines step, if it is not, it is then transferred to the second markers step,;
4th determines step: whether the stateful transaction for judging the i-th transaction detail is final state, if so, being transferred to theFive determine step, if it is not, it is then transferred to the second markers step,;
5th determines step: judging the stateful transaction of the i-th transaction detail and the friendship of the (i-1)-th transaction detailWhether easy state is identical, if so, it is transferred to third markers step, if it is not, being then transferred to the second markers step;
Second markers step: being abnormal by the second reconciliation result queue of the i-th transaction detail, and by described i-thSecond reconciliation result of transaction detail is stored into block chain;
Third markers step: being normal by the second reconciliation result queue of the i-th transaction detail, and by described i-thSecond reconciliation result of transaction detail is stored into block chain;
Detecting step: judge in all second transaction details to be processed with the presence or absence of unselected mistake second wait locateTransaction details are managed, when it is present, returns and executes second query steps.
In addition, to achieve the above object, the present invention also proposes a kind of computer readable storage medium, described computer-readableStorage medium is stored with the real-time reconciliation program based on block chain, and the real-time reconciliation program based on block chain can be by least oneA processor executes, so that at least one described processor executes the real-time reconciliation as described in any one of the above embodiments based on block chainThe step of method.
The present invention is received to be requested into chain, it is described enter chain request carry a transaction transaction ID information and the transaction theK transaction detail;Judge the K transaction detail whether be the transaction the first stroke transaction details, if so, will be describedK transaction detail is stored into block chain, if it is not, then determining first pair of the K transaction detail according to preset rulesAccount is as a result, and store the K transaction detail and its first reconciliation result into the block chain.Compared to existing skillArt, each transaction participant of the present invention are stored the transaction details of each transaction to block chain, node device by node deviceDuring storing transaction details to block chain, the first reconciliation of every transaction detail is determined as a result, to realize to friendshipEasy real-time reconciliation shortens fund in way time and fund clearing period, improves safety of the fund during transaction.ThisOutside, due to advantages such as the anti-tamper of block chain, high transparency and decentralizations, it is ensured that the authenticity and safety of transaction details.
Specific embodiment
The principle and features of the present invention will be described below with reference to the accompanying drawings, and the given examples are served only to explain the present invention, andIt is non-to be used to limit the scope of the invention.
As shown in fig.1, being the optional application environment schematic diagram of each embodiment one of the invention.
In the present embodiment, present invention can apply to include but are not limited to, node device 1, block chain network 2 and prisonIn the application environment for controlling equipment 3.Wherein, block chain network 2 and multiple node devices 1 collectively form a block catenary system,Multiple node device 1 is communicated to connect by block chain network 2.In addition, monitoring device 3 is respectively in block catenary system at least oneA node device communication connection.
In the following, above-mentioned application environment and relevant device will be based on, each embodiment of the invention is proposed.
The present invention proposes a kind of real-time reconciliation program based on block chain.
Referring to Fig. 2, being 10 first, second, third, fourth embodiment of real-time reconciliation program the present invention is based on block chainRunning environment schematic diagram.
In the present embodiment, the real-time reconciliation program 10 based on block chain is installed and is run in node device 1, for example,Real-time reconciliation program 10 based on block chain, which can be, to be installed and runs on the intelligent contract in node device 1.Node device 1 canTo be that mine machine, desktop PC, notebook, palm PC and server etc. calculate equipment.The node device 1 may include, butIt is not limited only to, the memory 11 and processor 12 being in communication with each other by program bus.Fig. 2 is illustrated only with component 11,12Node device 1, it should be understood that be not required for implementing all components shown, the implementation that can be substituted is more or moreFew component.
Memory 11 can be the internal storage unit of node device 1 in some embodiments, such as the node device 1Hard disk or memory.Memory 11 is also possible to the External memory equipment of node device 1 in further embodiments, such as node is setThe plug-in type hard disk being equipped on standby 1, intelligent memory card (Smart Media Card, SMC), secure digital (SecureDigital, SD) card, flash card (Flash Card) etc..Further, memory 11 can also be both interior including node device 1Portion's storage unit also includes External memory equipment.Memory 11 is for storing the application software for being installed on node device 1 and all kinds ofData, such as the program code etc. of the real-time reconciliation program 10 based on block chain.Memory 11 can be also used for temporarily storingThe data that has exported or will export.
Processor 12 can be in some embodiments a central processing unit (Central Processing Unit,CPU), microprocessor or other data processing chips, program code or processing data for being stored in run memory 11, exampleSuch as execute the real-time reconciliation program 10 based on block chain.
Referring to Fig. 3, being the Program modual graph of real-time 10 first embodiment of reconciliation program the present invention is based on block chain.?In the present embodiment, the real-time reconciliation program 10 based on block chain can be divided into one or more modules, one or moreModule is stored in memory 11, and performed by one or more processors (the present embodiment is processor 12), to completeThe present invention.For example, in Fig. 3, the real-time reconciliation program 10 based on block chain can be divided into receiving module 101, first sentenceDisconnected module 102, memory module 103 and reconciliation module 104.The so-called module of the present invention is the system for referring to complete specific functionColumn count machine program instruction section, than program more suitable for describing the real-time reconciliation program 10 based on block chain in node device 1Implementation procedure, in which:
Receiving module 101 is requested for receiving into chain, it is described enter chain request carry the K transaction detail of a transaction,The transaction details include stateful transaction, and K is positive integer, and represent the transaction detail enters chain request sequence.
In the following, by the following two kinds application scenarios illustrate it is above-mentioned enter chain request triggering mode:
The first, the application scenarios of bank electronic account charging: the fund side of applying to purchase receives the carrying recharge amount that user sendsAnd the electronic account recharge instruction of bank card number, operation is supplemented with money to electronic account execution according to the recharge amount, according to supplementing with moneyOperating result generates transaction details, and requests to the chain that enters that the fund side of applying to purchase node device initiates to carry transaction details, shouldTransaction details are recorded into block chain.Then, fund applies to purchase the recharging payment request that direction bank initiates electronic account, the bankRecharging payment request is executed, and transaction details are generated according to the implementing result of recharging payment request, and to bank node equipmentThe chain that enters for initiating to carry the transaction details of the production is requested, which is recorded into block chain.Finally, bank is to baseThe gold side of applying to purchase returns to the implementing result of recharging payment request, and fund applies to purchase root and updates platform according to the implementing result that recharging payment is requestedAccount, and updated according to account as a result, transaction details are generated, to entering for the fund side of the applying to purchase node device initiation carrying transaction detailsChain request.
The second, the application scenarios applied to purchase of fund: the fund side of applying to purchase receives the fund Shen that quantity is applied to purchase in the carrying that user sendsPurchase instruction, fund apply to purchase root and generate transaction details according to the fund instruction of applying to purchase, initiate to carry to the fund side of applying to purchase node deviceThe transaction details enter chain request.Then, fund applies to purchase the initiation fund request of applying to purchase of direction fund mechanism, and fund authorities shouldAfter applying to purchase request, request of withholing is returned to the fund side of applying to purchase.After the fund side of applying to purchase receives the request of withholing, electronic account is executedIt withholds operation, and transaction details is generated according to operating result of withholing, initiate to carry transaction details to the fund side of applying to purchase node deviceEnter chain request.Then, fund applies to purchase the transaction request of withholing that direction bank initiates electronic account, which receives the friendship of withholingEasily after request, the transaction request of withholing is executed, and transaction details are generated according to the implementing result for transaction request of withholing, saved to bankThe chain that enters that point device initiates to carry the transaction details is requested.Then, bank returns to holding for transaction request of withholing to the fund side of applying to purchaseRow is as a result, the implementing result of the transaction request of withholing is fed back to fund mechanism by the fund side of applying to purchase, and fund mechanism is according to the executionAs a result the fund request of applying to purchase is executed, and transaction details are generated according to result of applying to purchase, initiates to carry the transaction to fund node deviceDetail enters chain request.In addition, the result of applying to purchase also is back to the fund side of applying to purchase by fund mechanism.Finally, fund applies to purchase rootAccount is updated according to result of applying to purchase, and result is updated according to account and generates transaction details, is taken to the initiation of the fund side of applying to purchase node deviceEnter chain request with the transaction details.
It should be noted that above-mentioned application scenarios are only used for illustrating, the triggering mode for specifically entering chain request can be according to toolThe application scenarios of body determine.
First judgment module 102, for judge the K transaction detail whether be the transaction the first transaction it is brightCarefully, if so, calling memory module 103, if it is not, calling reconciliation module 104.
Above-mentioned first judgment module 102 judge the K transaction detail whether be the transaction the first transaction it is brightThin step includes:
Judge whether K is equal to 1, if so, determine that the K transaction detail is the first stroke transaction details of the transaction, ifIt is no, then determine that the K transaction detail is not the first stroke transaction details of the transaction.
Alternatively, it is described enter chain request in carry the transaction ID information of the transaction, believed according to the transaction ID of the transactionThe corresponding transaction details of the transaction whether are stored in breath inquiry block chain, if so, determining that the K transaction detail is not thisThe first stroke transaction details of transaction, if it is not, then determining that the K transaction detail is the first stroke transaction details of the transaction.
Memory module 103, for storing the K transaction detail into block chain.
For the first stroke transaction details of a transaction, without carrying out reconciliation to it, memory module 103 is directly by this KFirst reconciliation result of transaction details and the K transaction detail is stored into block chain.
Reconciliation module 104, for according to preset rules, determining the first reconciliation of the K transaction detail as a result, and willThe K transaction detail is stored into the block chain.
Referring to Fig. 4, above-mentioned reconciliation module 104 includes query unit 1041, the first judging unit 1042, second judgment unit1043, third judging unit 1044, the first marking unit 1045, the second marking unit 1046 and third marking unit 1047,In:
Query unit 1041, the K-1 transaction detail for inquiring the transaction in the block chain whether there is,If so, the first judging unit 1042 is called, if it is not, calling third marking unit 1047.
First judging unit 1042, for judging whether the stateful transaction of K-1 transaction detail of the transaction is eventuallyState, if so, second judgment unit 1043 is called, if it is not, calling third marking unit 1047.
The stateful transaction of transaction details has two classes: the first kind is final state, and the final state refers to that stateful transaction is to trade successfullyOr the state of Fail Transaction;Second class is non-final state, the stateful transaction including present.
Second judgment unit 1043, for judging whether the stateful transaction of the K transaction detail is final state, if so,Third judging unit 1044 is called, if it is not, calling third marking unit 1047.
Third judging unit 1044, for judge the K transaction detail stateful transaction and the K-1 transactionWhether the stateful transaction of detail is identical, if so, the first marking unit 1045 is called, if it is not, calling the second marking unit 1046.
First marking unit 1045 is normal for marking the first reconciliation result of the K transaction detail, and by instituteThe the first reconciliation result for stating K transaction detail and the K transaction detail is stored into the block chain.
Second marking unit 1046 will be described for marking the first reconciliation result of the K transaction detail to be abnormalK transaction detail is stored into the block chain.
Third marking unit 1047 is unknown for marking the first reconciliation result of the K transaction detail, and by instituteThe the first reconciliation result for stating K transaction detail and the K transaction detail is stored into the block chain.
It is unknown that refer to temporarily can not be by the stateful transaction of K-1 transaction detail and the transaction shape of K transaction detailState carries out reconciliation to K transaction detail, to determine the first reconciliation result of K transaction detail.
For example, there are following any case, can not temporarily reconciliation be carried out to K transaction detail:
There is no (lacking) for K-1 transaction detail, alternatively, K-1 transaction detail is that non-final state (is being handledIn stateful transaction), alternatively, K transaction detail be non-final state (i.e. the stateful transaction of present).
The present invention is received to be requested into chain, it is described enter chain request carry a transaction transaction ID information and the transaction theK transaction detail;Judge the K transaction detail whether be the transaction the first stroke transaction details, if so, will be describedK transaction detail is stored into block chain, if it is not, then determining first pair of the K transaction detail according to preset rulesAccount is as a result, and store the K transaction detail and its first reconciliation result into the block chain.Compared to existing skillArt, each transaction participant of the present invention are stored the transaction details of each transaction to block chain, node device by node deviceDuring storing transaction details to block chain, the first reconciliation of every transaction detail is determined as a result, to realize to friendshipEasy real-time reconciliation shortens fund in way time and fund clearing period, improves safety of the fund during transaction.ThisOutside, due to advantages such as the anti-tamper of block chain, high transparency and decentralizations, it is ensured that the authenticity and safety of transaction details.
As shown in figure 5, Fig. 5 is that the present invention is based on the program modules of real-time 10 second embodiment of reconciliation program of block chainFigure.
The present embodiment on the basis of first embodiment, the program further include the first acquisition module 105, determining module 106,First choice module 107, the first mark module 108, in which:
First obtains module 105, when executing for the transaction that (for example, every 5 minutes) obtain each transaction in real time or periodicallyBetween, and transaction execution time is greater than the transaction of preset duration (for example, 10 minutes) as transaction to be processed.
Determining module 106, for determining the type of transaction of each transaction to be processed, according to each transaction to be processedMapping relations between type of transaction and predetermined type of transaction and preset quantity determine that each transaction to be processed corresponds toPreset quantity.
Presetting every transaction need to complete in preset duration (for example, in 10 minutes), and for a type of transactionTransaction should record its corresponding preset quantity (for example, the transaction of a type of transaction is corresponding after completely being executed in block chainPreset quantity be 8) transaction details.
Since the corresponding preset quantity of the transaction of each type of transaction is different, by each type of transaction and its correspondingMapping relations (for example, mapping table) is established between preset quantity, and the mapping relations are stored to the local of each node device and are depositedIt stores up in space, or stores into block chain.
First choice module 107, for judging whether the transaction details quantity of each transaction to be processed is less than this one by oneCorresponding preset quantity to be processed of trading, whenever the transaction details quantity for determining a transaction to be processed is less than the transaction pair to be processedWhen the preset quantity answered, using the All Activity detail of the transaction to be processed as the first transaction details to be processed.
First mark module 108, it is to be processed by all described first after finding out all first transaction details to be processedSecond reconciliation result queue of transaction details is abnormal, and by the second reconciliation result of all first transaction details to be processedIt stores into the block chain.
When transaction details quantity is less than the corresponding preset quantity of transaction to be processed, it is believed that the transaction to be processed executes superWhen, or because part transaction step fails, cause subsequent transaction step that can not continue to execute, therefore, which is corresponded toThe second reconciliation result of All Activity detail mark and be.
The present embodiment filters out the transaction for executing time-out, and by the corresponding All Activity detail of transaction of execution time-outSecond reconciliation result, which marks, is.Be conducive to the transaction that monitoring personnel timely handles the time-out, further shorten fundIn way time and fund clearing period.
As shown in fig. 6, Fig. 6 is that the present invention is based on the program modules of real-time 10 3rd embodiment of reconciliation program of block chainFigure.
For the present embodiment on the basis of second embodiment, which further includes the second acquisition module 109, the second selecting module110, enquiry module 111, the second judgment module 112, third judgment module 113, the 4th judgment module 114, the second mark module115, third mark module 116, detection module 117 and output module 118, in which:
Second obtains module 109, is unknown for obtaining all first reconciliation results from all transaction to be processedTransaction details as the second transaction details to be processed.
Second selecting module 110, it is second to be processed for being selected one by one from all second transaction details to be processedTransaction details.
Enquiry module 111, for (i to be greater than 1 when i-th that the second selected transaction details to be processed are affiliated transactionPositive integer) transaction detail, (i-1)-th of transaction belonging to the second selected transaction details to be processed is inquired in the block chainTransaction detail calls the second judgment module 112 when inquiring, and when not inquiring, calls the second mark module 115.
Second judgment module 112, for judging whether the stateful transaction of the (i-1)-th transaction detail is final state, if so,Third judgment module 113 is called, if it is not, calling the second mark module 115.
Third judgment module 113, for judging whether the stateful transaction of the i-th transaction detail is final state, if so, adjustingWith the 4th judgment module 114, if it is not, calling the second mark module 115.
4th judgment module 114, for judge the i-th transaction detail stateful transaction and (i-1)-th transactionWhether the stateful transaction of detail is identical, if so, third mark module 116 is called, if it is not, calling the second mark module 115.
Second mark module 115, for being abnormal by the second reconciliation result queue of the i-th transaction detail, and willSecond reconciliation result of the i-th transaction detail is stored into block chain.
Third mark module 116, for being normal by the second reconciliation result queue of the i-th transaction detail, and willSecond reconciliation result of the i-th transaction detail is stored into block chain.
Detection module 117, for judging in all second transaction details to be processed with the presence or absence of unselected mistakeSecond transaction details to be processed, if so, the second selecting module 110 is called, if it is not, calling output module 118.
Output module 118 is abnormal transaction details for exporting all second reconciliation results.
In the present embodiment, it need to be completed in preset duration (for example, in 10 minutes) due to presetting every transaction, ifFirst reconciliation result of one transaction details be it is unknown, then need again to the transaction details carry out reconciliation.If knowing during reconciliationBeing clipped to the corresponding stateful transaction of any transaction details in the previous transaction detail of the transaction details or the transaction details is not eventuallyState, then it is assumed that stateful transaction is not that the corresponding transaction step of transaction details of final state executes time-out, by the of the transaction detailTwo reconciliation result queues are abnormal.
The present embodiment is that unknown transaction details carry out reconciliation again to the first reconciliation result, to further determine that the transactionWhether the second reconciliation result of detail is abnormal.By timely finding out abnormal transaction details, be conducive to monitoring personnel andWhen processing extremely trade, further shorten fund in way time and fund clearing period.
As shown in fig. 7, Fig. 7 is that the present invention is based on the program modules of real-time 10 fourth embodiment of reconciliation program of block chain to showIt is intended to.
For the present embodiment on the basis of the first, second, third embodiment, which further includes monitoring modular 119.
Monitoring modular 119 is abnormal for all first reconciliation results of real-time or timing acquisition or the second reconciliation resultTransaction details generate account-checking report according to the All Activity detail of acquisition when getting, and send the account-checking report to prisonEquipment is controlled, for the monitoring device according to the account-checking report, creates abnormality processing item.
Further, in the present embodiment, monitoring modular 119 is also used to:
In real time or all first reconciliation results of timing acquisition or the second reconciliation result are abnormal transaction details, when gettingWhen, account-checking report is generated according to the All Activity detail of acquisition, and the account-checking report is stored into the block chain, for instituteIt states monitoring device and obtains the account-checking report from the block chain, and according to the account-checking report, create abnormality processing item.
The present embodiment node device generates account-checking report according to abnormal transaction details, and monitoring device is obtaining the reconciliation reportAfter announcement, abnormality processing item is created according to the account-checking report, monitoring personnel, which can be intervened timely, handles the abnormality processing item, fromAnd it can further shorten fund in way time and fund clearing period.
Further it is proposed that a kind of real-time account checking method based on block chain.Suitable for node device.
As shown in figure 8, Fig. 8 is that the present invention is based on the flow diagrams of the real-time account checking method first embodiment of block chain.
In the present embodiment, this method comprises:
Step S10 is received and is requested into chain, it is described enter chain request carry the K transaction detail of a transaction, the transactionDetail includes stateful transaction, and K is positive integer, and represent the transaction detail enters chain request sequence.
In the following, by the following two kinds application scenarios illustrate it is above-mentioned enter chain request triggering mode:
The first, the application scenarios of bank electronic account charging: the fund side of applying to purchase receives the carrying recharge amount that user sendsAnd the electronic account recharge instruction of bank card number, operation is supplemented with money to electronic account execution according to the recharge amount, according to supplementing with moneyOperating result generates transaction details, and requests to the chain that enters that the fund side of applying to purchase node device initiates to carry transaction details, shouldTransaction details are recorded into block chain.Then, fund applies to purchase the recharging payment request that direction bank initiates electronic account, the bankRecharging payment request is executed, and transaction details are generated according to the implementing result of recharging payment request, and to bank node equipmentThe chain that enters for initiating to carry the transaction details of the production is requested, which is recorded into block chain.Finally, bank is to baseThe gold side of applying to purchase returns to the implementing result of recharging payment request, and fund applies to purchase root and updates platform according to the implementing result that recharging payment is requestedAccount, and updated according to account as a result, transaction details are generated, to entering for the fund side of the applying to purchase node device initiation carrying transaction detailsChain request.
The second, the application scenarios applied to purchase of fund: the fund side of applying to purchase receives the fund Shen that quantity is applied to purchase in the carrying that user sendsPurchase instruction, fund apply to purchase root and generate transaction details according to the fund instruction of applying to purchase, initiate to carry to the fund side of applying to purchase node deviceThe transaction details enter chain request.Then, fund applies to purchase the initiation fund request of applying to purchase of direction fund mechanism, and fund authorities shouldAfter applying to purchase request, request of withholing is returned to the fund side of applying to purchase.After the fund side of applying to purchase receives the request of withholing, electronic account is executedIt withholds operation, and transaction details is generated according to operating result of withholing, initiate to carry transaction details to the fund side of applying to purchase node deviceEnter chain request.Then, fund applies to purchase the transaction request of withholing that direction bank initiates electronic account, which receives the friendship of withholingEasily after request, the transaction request of withholing is executed, and transaction details are generated according to the implementing result for transaction request of withholing, saved to bankThe chain that enters that point device initiates to carry the transaction details is requested.Then, bank returns to holding for transaction request of withholing to the fund side of applying to purchaseRow is as a result, the implementing result of the transaction request of withholing is fed back to fund mechanism by the fund side of applying to purchase, and fund mechanism is according to the executionAs a result the fund request of applying to purchase is executed, and transaction details are generated according to result of applying to purchase, initiates to carry the transaction to fund node deviceDetail enters chain request.In addition, the result of applying to purchase also is back to the fund side of applying to purchase by fund mechanism.Finally, fund applies to purchase rootAccount is updated according to result of applying to purchase, and result is updated according to account and generates transaction details, is taken to the initiation of the fund side of applying to purchase node deviceEnter chain request with the transaction details.
It should be noted that above-mentioned application scenarios are only used for illustrating, the triggering mode for specifically entering chain request can be according to toolThe application scenarios of body determine.
Step S20, judges whether the K transaction detail is the first stroke transaction details of the transaction, if so, being transferred toStep S30, if it is not, being transferred to step S40.
It is above-mentioned to judge that the step of whether the K transaction detail is the first stroke transaction details of the transaction includes:
Judge whether K is equal to 1, if so, determine that the K transaction detail is the first stroke transaction details of the transaction, ifIt is no, then determine that the K transaction detail is not the first stroke transaction details of the transaction.
Alternatively, it is described enter chain request in carry the transaction ID information of the transaction, believed according to the transaction ID of the transactionThe corresponding transaction details of the transaction whether are stored in breath inquiry block chain, if so, determining that the K transaction detail is not thisThe first stroke transaction details of transaction, if it is not, then determining that the K transaction detail is the first stroke transaction details of the transaction.
Step S30 stores the K transaction detail into block chain.
For the first stroke transaction details of a transaction, without carrying out reconciliation to it, directly the K transaction detail is storedInto block chain.
Step S40 determines the first reconciliation of the K transaction detail as a result, and by the K according to preset rulesFirst reconciliation result of transaction detail and the K transaction detail is stored into the block chain.
Include: referring to Fig. 9, above-mentioned steps S40
Step S41, the K-1 transaction detail that the transaction is inquired in the block chain whether there is, if so, being transferred toStep S42, if it is not, being transferred to step S47.
Step S42 judges whether the stateful transaction of the K-1 transaction detail of the transaction is final state, if so, being transferred toStep S43, if it is not, being transferred to step S47.
The stateful transaction of transaction details has two classes: the first kind is final state, and the final state refers to that stateful transaction is to trade successfullyOr the state of Fail Transaction;Second class is non-final state, the stateful transaction including present.
Step S43 judges whether the stateful transaction of the K transaction detail is final state, if so, it is transferred to step S44,If it is not, being then transferred to step S47.
Step S44 judges the stateful transaction of the K transaction detail and the transaction shape of the K-1 transaction detailWhether state is identical, if so, step S45 is transferred to, if it is not, being then transferred to step S46.
Step S45 stores the K transaction detail into the block chain, and marks the K transaction detailThe first reconciliation result be normal, and the first reconciliation result of the K transaction detail and the K transaction detail is depositedStorage is into the block chain.
Step S46 stores the K transaction detail into the block chain, and marks the K transaction detailThe first reconciliation result be abnormal, and the first reconciliation result of the K transaction detail and the K transaction detail is depositedStorage is into the block chain.
Step S47 stores the K transaction detail into the block chain, and marks the K transaction detailThe first reconciliation result be it is unknown, and the first reconciliation result of the K transaction detail and the K transaction detail is depositedStorage is into the block chain.
It is unknown that refer to temporarily can not be by the stateful transaction of K-1 transaction detail and the transaction shape of K transaction detailState carries out reconciliation to K transaction detail, to determine the first reconciliation result of K transaction detail.
For example, there are following any case, can not temporarily reconciliation be carried out to K transaction detail:
There is no (lacking) for K-1 transaction detail, alternatively, K-1 transaction detail is that non-final state (is being handledIn stateful transaction), alternatively, K transaction detail be non-final state (i.e. the stateful transaction of present).
The present invention is received to be requested into chain, it is described enter chain request carry a transaction transaction ID information and the transaction theK transaction detail;Judge the K transaction detail whether be the transaction the first stroke transaction details, if so, will be describedK transaction detail is stored into block chain, if it is not, then determining first pair of the K transaction detail according to preset rulesAccount is as a result, and store the K transaction detail and its first reconciliation result into the block chain.Compared to existing skillArt, each transaction participant of the present invention are stored the transaction details of each transaction to block chain, node device by node deviceDuring storing transaction details to block chain, the first reconciliation of every transaction detail is determined as a result, to realize to friendshipEasy real-time reconciliation shortens fund in way time and fund clearing period, improves safety of the fund during transaction.ThisOutside, due to advantages such as the anti-tamper of block chain, high transparency and decentralizations, it is ensured that the authenticity and safety of transaction details.
As shown in Figure 10, Figure 10 is that the present invention is based on the signals of the process of the real-time account checking method second embodiment of block chainFigure.
The present embodiment is on the basis of first embodiment, after step S40, this method further include:
Step S50, in real time or timing (for example, every 5 minutes) obtains the transaction execution time of each transaction, and transaction is heldThe row time is greater than the transaction of preset duration (for example, 10 minutes) as transaction to be processed.
Step S60 determines the type of transaction of each transaction to be processed, according to the type of transaction of each transaction to be processedAnd the mapping relations between predetermined type of transaction and preset quantity, determine each corresponding present count to be processed of tradingAmount.
Presetting every transaction need to complete in preset duration (for example, in 10 minutes), and for a type of transactionTransaction should record its corresponding preset quantity (for example, the transaction of a type of transaction is corresponding after completely being executed in block chainPreset quantity be 8) transaction details.
Since the corresponding preset quantity of the transaction of each type of transaction is different, by each type of transaction and its correspondingMapping relations (for example, mapping table) is established between preset quantity, and the mapping relations are stored to the local of each node device and are depositedIt stores up in space, or stores into block chain.
Step S70, judges whether the transaction details quantity of each transaction to be processed is less than the transaction pair to be processed one by oneThe preset quantity answered, whenever the transaction details quantity for determining a transaction to be processed is less than the corresponding preset quantity to be processed of tradingWhen, using the All Activity detail of the transaction to be processed as the first transaction details to be processed.
Step S80, after finding out all first transaction details to be processed, by all first transaction details to be processedThe second reconciliation result queue be abnormal, and the second reconciliation result of all first transaction details to be processed is stored to instituteIt states in block chain.
When transaction details quantity is less than the corresponding preset quantity of transaction to be processed, it is believed that the transaction to be processed executes superWhen, or because part transaction step fails, cause subsequent transaction step that can not continue to execute, therefore, which is corresponded toThe second reconciliation result of All Activity detail mark and be.
The present embodiment node device filters out the transaction for executing time-out, and by the corresponding all friendships of the transaction of execution time-outSecond reconciliation result of easy detail, which marks, is.Be conducive to the transaction that monitoring personnel timely handles the time-out, furtherShortening fund is in way time and fund clearing period.
As shown in figure 11, Figure 11 is that the present invention is based on the signals of the process of the real-time account checking method 3rd embodiment of block chainFigure.
The present embodiment is on the basis of second embodiment, after step S50, this method further include:
Step S90, it is that unknown transaction details are made that all first reconciliation results are obtained from all transaction to be processedFor the second transaction details to be processed.
Step S100 selects the second transaction details to be processed from all second transaction details to be processed one by one.StepRapid S110, when i-th (i is greater than 1 positive integer) transaction that the second selected transaction details to be processed are affiliated transaction is brightWhen thin, the (i-1)-th transaction detail of transaction belonging to the second selected transaction details to be processed is inquired in the block chain, when looking intoIt askes then, is transferred to step S120, when not inquiring, is transferred to step S160.
Step S120 judges whether the stateful transaction of the (i-1)-th transaction detail is final state, if so, being transferred to stepS130, if it is not, being then transferred to step S160.
Step S130 judges whether the stateful transaction of the i-th transaction detail is final state, if so, being transferred to stepS140, if it is not, being then transferred to step S160.
Step S140 judges the stateful transaction of the i-th transaction detail and the transaction shape of the (i-1)-th transaction detailWhether state is identical, if so, S150 is transferred to, if it is not, being then transferred to step S160.
Second reconciliation result queue of the i-th transaction detail is normal by step S150, and described i-th is handed overSecond reconciliation result of easy detail is stored into block chain.
Second reconciliation result queue of the i-th transaction detail is abnormal, and described i-th is handed over by step S160Second reconciliation result of easy detail is stored into block chain.
Step S170 judges in all second transaction details to be processed with the presence or absence of unselected mistake second wait locateTransaction details are managed, if so, S100 is returned to step, if it is not, being then transferred to step S180.
Step S180, exporting all second reconciliation results is abnormal transaction details.
In the present embodiment, it need to be completed in preset duration (for example, in 10 minutes) due to presetting every transaction, ifFirst reconciliation result of one transaction details be it is unknown, then need to again through step S100-S180 to the transaction details carry out reconciliation.If it is corresponding to recognize any transaction details in the previous transaction detail of the transaction details or the transaction details during reconciliationStateful transaction be not final state, then it is assumed that stateful transaction is not that the corresponding transaction step of transaction details of final state executes time-out, willSecond reconciliation result queue of the transaction detail is abnormal.
The present embodiment node device is that unknown transaction details carry out reconciliation again to the first reconciliation result, with further trueWhether the second reconciliation result of the fixed transaction details is abnormal.By timely finding out abnormal transaction details, be conducive to superviseControl personnel timely handle abnormal transaction, further shorten fund in way time and fund clearing period.
Further, a in the present embodiment, this method further include:
In real time or all first reconciliation results of timing acquisition or the second reconciliation result are abnormal transaction details, when gettingWhen, account-checking report is generated according to the All Activity detail of acquisition, and send the account-checking report to monitoring device, for the monitoringEquipment creates abnormality processing item according to the account-checking report.
Alternatively, real-time or all first reconciliation results of timing acquisition or the second reconciliation result are abnormal transaction details, whenWhen getting, account-checking report is generated according to the All Activity detail of acquisition, and the account-checking report is stored to the block chainIn, the account-checking report is obtained from the block chain for the monitoring device, and according to the account-checking report, create exceptionDirector.
The present embodiment node device generates account-checking report according to abnormal transaction details, and monitoring device is obtaining the reconciliation reportAfter announcement, abnormality processing item is created according to the account-checking report, monitoring personnel, which can be intervened timely, handles the abnormality processing item, fromAnd it can further shorten fund in way time and fund clearing period.
Further, the present invention also proposes that a kind of computer readable storage medium, the computer readable storage medium are depositedThe real-time reconciliation program based on block chain is contained, the real-time reconciliation program based on block chain can be held by least one processorRow, so that at least one described processor executes the real-time account checking method based on block chain in any of the above-described embodiment.
The above description is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all at thisUnder the inventive concept of invention, using equivalent structure transformation made by description of the invention and accompanying drawing content, or directly/use indirectlyIt is included in other related technical areas in scope of patent protection of the invention.