CN112950380A - Block chain-based transaction consistency processing method and device - Google Patents

Block chain-based transaction consistency processing method and device Download PDF

Info

Publication number
CN112950380A
CN112950380A CN202110336821.2A CN202110336821A CN112950380A CN 112950380 A CN112950380 A CN 112950380A CN 202110336821 A CN202110336821 A CN 202110336821A CN 112950380 A CN112950380 A CN 112950380A
Authority
CN
China
Prior art keywords
transaction
request
transaction request
asynchronous processing
amount
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110336821.2A
Other languages
Chinese (zh)
Other versions
CN112950380B (en
Inventor
赵钊
安兴朝
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Construction Bank Corp
Original Assignee
CCB Finetech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CCB Finetech Co Ltd filed Critical CCB Finetech Co Ltd
Priority to CN202110336821.2A priority Critical patent/CN112950380B/en
Publication of CN112950380A publication Critical patent/CN112950380A/en
Application granted granted Critical
Publication of CN112950380B publication Critical patent/CN112950380B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Finance (AREA)
  • General Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • Strategic Management (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Technology Law (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a processing method and device for transaction consistency based on a block chain, and relates to the technical field of block chains. One embodiment of the method comprises: receiving a first transaction request, the first transaction request indicating a transaction amount; sending the first transaction request to a transaction system, so that the transaction system carries out transaction according to the transaction amount; responding to transaction exception of the transaction system, and executing asynchronous processing corresponding to the first transaction request by adopting a first asynchronous processing thread; in response to a successful transaction of the transaction system, sending a second transaction request to the blockchain according to an execution result of the first transaction request, the second transaction request indicating a transaction amount; in response to a transaction exception for the blockchain, asynchronous processing corresponding to the second transaction request is performed using the first asynchronous processing thread. The implementation mode strengthens the consistency guarantee of the transaction between the transaction system and the block chain, so that the generation of wrong accounts is avoided or reduced in a special abnormal scene.

Description

Block chain-based transaction consistency processing method and device
Technical Field
The invention relates to the technical field of blockchain, in particular to a processing method and device for transaction consistency based on blockchain.
Background
The block chain is integrated into the transfer process of the traditional bank, and the following two scenes exist: 1) the bank account is deducted, and then chain entry is carried out on the block chain, namely deposit is carried out; 2) and (4) deducting account of the block chain down link, and then entering account of the bank account, namely withdrawing.
In the above-mentioned transfer process, because the party of keeping accounts is different, and one party is the bank system, and one party is the block chain, can't use traditional bank record mode or traditional third party mechanism mode to keep accounts, consequently, detain between bank system and the block chain and account for and the transaction uniformity of posting is difficult to guarantee.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for processing transaction consistency based on a block chain, which can enhance the consistency guarantee of transactions between a transaction system and the block chain, and further avoid or reduce the occurrence of miscount in a special abnormal scene.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a processing method for transaction consistency based on a blockchain, including:
receiving a first transaction request, the first transaction request indicating a transaction amount;
sending the first transaction request to a transaction system, so that the transaction system carries out transaction according to the transaction amount;
responding to transaction exception of the transaction system, and executing asynchronous processing corresponding to the first transaction request by adopting a first asynchronous processing thread;
in response to a transaction success of the transaction system, sending a second transaction request to the blockchain according to an execution result of the first transaction request, the second transaction request indicating the transaction amount;
and responding to the transaction exception of the blockchain, and executing asynchronous processing corresponding to the second transaction request by adopting a first asynchronous processing thread.
Optionally, the transaction is interrupted in response to a transaction failure of the transaction system for the first transaction request.
Optionally, in response to the transaction system not returning a result for the first transaction request, sending an inquiry request to the transaction system, and recording a first current number of times the inquiry request is sent;
and when the first current times is greater than a preset first threshold value, determining that the transaction of the transaction system is abnormal.
Optionally, when the first current number is not greater than a preset first threshold, in response to feedback from the transaction system for the inquiry request, determining that the transaction system succeeded or failed in the transaction for the first transaction request.
Optionally, determining whether the transaction for the second transaction request was successful in response to feedback of the blockchain for the second transaction request;
when the transaction for the second transaction request is successful, it is determined that the transactions performed according to the transaction amount are all successful.
Optionally, when the transaction for the second transaction request fails, a reverse transaction corresponding to the second transaction request is executed.
Optionally, in response to the blockchain not returning feedback for the second transaction request, sending a query request to the blockchain, and recording a second current number of times of sending the query request;
and when the second current times is greater than a preset second threshold value, determining that the block chain transaction is abnormal.
Optionally, the first transaction request is a withholding request for the transaction system, and the second transaction request is an posting request for the blockchain.
Optionally, in response to a message of successful account deduction returned by the transaction system, generating first transaction information according to default transaction information and the transaction amount;
sending the posting request to the blockchain according to the first transaction information;
and responding to the message of the failure of posting returned by the blockchain, and processing the first transaction information to restore the default transaction information.
Optionally, the first transaction information is obtained according to a sum of the default value indicated by the default transaction information and the transaction amount.
Optionally, in response to success of the reverse transaction corresponding to the second transaction request, the reverse transaction corresponding to the first transaction request is executed.
Optionally, in response to failure of the reverse transaction corresponding to the second transaction request, continuing to execute the reverse transaction corresponding to the second transaction request, and recording a first execution number;
and executing asynchronous processing corresponding to the second transaction request by adopting a first asynchronous processing thread under the condition that the first execution times is greater than a preset third threshold value or the reverse transaction is abnormal.
Optionally, in response to a success of executing the inverse transaction corresponding to the first transaction request, determining that the transaction corresponding to the transaction amount failed;
in response to an exception to execute the inverse transaction corresponding to the first transaction request, executing asynchronous processing corresponding to the first transaction request with a first asynchronous processing thread.
Optionally, executing asynchronous processing corresponding to the first transaction request and/or the second transaction request by using a first asynchronous processing thread includes:
acquiring abnormal transaction data;
and determining whether all the transactions aiming at the transaction amount are successfully executed according to the abnormal transaction data, if so, determining whether all the inverse transactions aiming at the transaction amount are successfully executed, and when all the inverse transactions are failed, determining that all the transactions aiming at the transaction amount are successfully executed.
Optionally, the abnormal transaction data indicates an abnormal situation in which the server is down and/or the transaction execution result cannot be obtained.
According to another aspect of the embodiments of the present invention, there is provided a processing apparatus for transaction consistency based on blockchain, including: the device comprises a receiving module, a first sending module, a second sending module and an asynchronous processing module; wherein the content of the first and second substances,
a receiving module to receive a first transaction request, the first transaction request indicating a transaction amount;
the first sending module is used for sending the first transaction request to a transaction system so that the transaction system can carry out transaction according to the transaction amount;
the second sending module is used for responding to the transaction success of the transaction system and sending a second transaction request to the block chain according to the execution result of the first transaction request, wherein the second transaction request indicates the transaction amount;
the asynchronous processing module is used for responding to the transaction exception of the transaction system and executing asynchronous processing corresponding to the first transaction request by adopting a first asynchronous processing thread; and responding to the transaction exception of the blockchain, and executing asynchronous processing corresponding to the second transaction request by adopting a first asynchronous processing thread.
According to another aspect of an embodiment of the present invention, there is provided an electronic apparatus including:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the processing method for transaction consistency based on the blockchain provided by the invention.
According to a further aspect of the embodiments of the present invention, there is provided a computer readable medium, on which a computer program is stored, which when executed by a processor, implements the processing method for block chain based transaction consistency provided by the present invention.
One embodiment of the above invention has the following advantages or benefits: by adopting the first asynchronous processing thread to carry out asynchronous processing on the transaction abnormity of the transaction system and the block chain, the consistency of the transaction system and the block chain is ensured under the condition that the server is down and/or the transaction execution result cannot be obtained, the guarantee of the transaction consistency is enhanced, and the generation of wrong accounts can be reduced or avoided.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of a main flow of a processing method for transaction consistency based on a blockchain according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a main flow of another block chain based transaction consistency processing method according to an embodiment of the invention;
FIG. 3 is a schematic diagram of a main flow of another block chain-based transaction consistency processing method according to an embodiment of the invention;
FIG. 4 is a schematic diagram of a main flow of another block chain-based transaction consistency processing method according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of the main modules of a processing device for blockchain based transaction consistency, according to an embodiment of the invention;
FIG. 6 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 7 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The block chain is essentially a shared database, and data or information stored in the block chain has the characteristics of 'non-counterfeiting' and 'trace in the whole process', so that the block chain can be integrated into the transfer process of a traditional bank system, for example, in the cross-border payment scene, the block chain can be used as a 'middleman' for third party accounting. However, in the transfer process involving the block chain, one party of the bookkeeping party is a bank system, and the other party is the block chain, so that the consistency of withholding and posting cannot be ensured by using a traditional bank record mode (storing withholding and posting data in the same database and relying on the database underlying transaction technology to keep consistency) or a mode of a third party organization (such as global banking inter-finance Telecommunications association, Society for world across Financial inter-bank Financial Telecommunications communications, SWIFT). Therefore, it is necessary to provide a processing method and apparatus for transaction consistency based on blockchain to ensure the consistency of transactions.
Fig. 1 to 4 are schematic diagrams illustrating a main flow of a processing method for transaction consistency based on blockchain according to an embodiment of the present invention, as shown in fig. 1, the method includes:
step S101: a first transaction request is received, the first transaction request indicating a transaction amount.
In an embodiment of the present invention, the first transaction request may be a transfer request, and the transaction amount may be a transfer amount. The first transaction request also indicates a payment account number, a collection account number, and a transaction identification. For example, the first transaction request may be a transfer request for transferring money from a bank account to a blockchain, or may be a transfer request for transferring money from a blockchain to a bank account, the transfer request indicating the transfer amount. Each transaction has a unique transaction identification, and the transaction data corresponding to the transaction can be inquired according to the transaction identification. For example, the transaction identification may be a transaction serial number.
In the embodiment of the invention, in the process of each transaction (or transfer), the steps of deducting account and posting account are included, wherein the deducting account can be a multi-party deducting account, for example, when N (N is a natural number greater than 2) bank accounts transfer to the block chain, the deducting account of the N bank accounts can be sequentially performed according to the sequence, after the deducting account of all the N bank accounts is completed, the posting account of the block chain is performed, and the posting account amount is the sum of the amounts of the deducted account of the N bank accounts. The posting can also be multi-party posting, such as block link posting, and then posting on N bank accounts respectively.
In the embodiment of the invention, when the first transaction request is received, the transaction state corresponding to the transaction identifier and the first transaction request is recorded. The transaction identification is the only identification of the transaction, such as a transaction serial number, and the transaction data corresponding to the transaction can be inquired according to the transaction identification; the transaction status (or trace record) corresponding to the first transaction request records the status of the transaction, for example, when the first transaction request is received, the transaction status corresponding to the first transaction request may be recorded as "expected", which indicates that the first transaction request is about to be executed. By recording the transaction state, the following transaction is possible or certain to occur under the condition that the transaction state record exists, and if the transaction state is not recorded, the transaction is not occurred. If the 'prediction' of the transaction state is not recorded, account deduction processing is directly carried out, and in the process of the account deduction operation, abnormal server downtime occurs, so that the source cannot be traced when the service is restarted.
Step S102: and sending the first transaction request to a transaction system, so that the transaction system carries out transaction according to the transaction amount.
In the embodiment of the present invention, the transaction system may be, for example, a bank host system, that is, the transaction may be a transaction between the bank host system and the blockchain. And the transaction system receives the first transaction request and carries out transaction according to the transaction amount. When the transaction system executes the transaction, the residual amount of the account of the payer is reduced, and the transaction flow is recorded. Wherein the residual amount of the payer account is the amount before executing the account deduction operation. For example, when a transfer request is initiated by a bank account a, the transaction system receives the transfer request, and executes a charge operation according to the transfer amount, so as to reduce the remaining amount in the account a, wherein the reduced amount is the transaction amount.
Step S103, responding to the transaction exception of the transaction system, and executing asynchronous processing corresponding to the first transaction request by adopting a first asynchronous processing thread.
In the embodiment of the present invention, before step S103, the method further includes:
step 201: in response to the transaction system not returning a result for the first transaction request, sending an inquiry request to the transaction system, and recording a first current number of times the inquiry request is sent; and when the first current times is greater than a preset first threshold value, determining that the transaction of the transaction system is abnormal.
In the embodiment of the invention, after the transaction system receives the first transaction request and executes the transaction according to the transaction amount, the transaction execution result is returned in a communication mode.
In the embodiment of the present invention, when the transaction system does not return the result of the request for the first transaction due to the downtime of the server or the network anomaly, that is, the result of the first transaction request returned by the transaction system is not received within the preset time, it is necessary to send the query request to the transaction system, query the result of the first transaction request, and record the first current number of times of sending the query request (i.e., the number of times of querying).
In the embodiment of the invention, when the first current number is not greater than the preset first threshold, the transaction system is determined to be successful or unsuccessful in transaction for the first transaction request in response to the feedback of the transaction system for the query request. That is, within the number of queries with the preset first threshold, when sending the query request to the transaction system, the transaction system feeds back the transaction result according to the query request, and if the query is successful, the transaction state corresponding to the first transaction request may be updated to "successful", and step S104 is executed; if the query is a failure, the transaction is failed, the transaction status corresponding to the first transaction request may be updated to "failure", and step S202 is executed.
In an embodiment of the present invention, the query request may be sent to the transaction system according to a transaction identifier (e.g., a transaction serial number).
In the embodiment of the invention, when the first current times is greater than a preset first threshold, the transaction system is determined to be abnormal in transaction.
In the embodiment of the invention, when the transaction system is determined to have abnormal transaction, the transaction is interrupted, the transaction state is updated to be abnormal, and the transaction failure-to-be-funded rollback can also be returned.
In the embodiment of the invention, when the transaction system has abnormal transaction, the first asynchronous processing thread is adopted to execute the asynchronous processing corresponding to the first transaction request.
In an embodiment of the present invention, the method further includes:
step S202: interrupting the transaction in response to a transaction failure of the transaction system for the first transaction request.
In the embodiment of the invention, after the information of the transaction failure of the first transaction request returned by the transaction system is received, the transaction is ended. The transaction failure may be caused by insufficient remaining amount of the account, account fund blocking or locking, and the like.
Step S104: in response to a transaction success of the transaction system, sending a second transaction request to the blockchain in accordance with an execution result of the first transaction request, the second transaction request indicating the transaction amount.
In an embodiment of the present invention, the first transaction request is a withholding request for a transaction system, and the second transaction request is an posting request for a blockchain.
In the embodiment of the invention, when the transaction system returns the transaction success result, the transaction state corresponding to the first transaction request is updated to be 'transaction success', namely the account deduction is successful; and then sending a second transaction request to the blockchain, wherein the second transaction request indicates the transaction amount, and meanwhile, recording a transaction state corresponding to the second transaction request, for example, recording that the transaction state corresponding to the second transaction request is "expected", which indicates that an accounting operation corresponding to the second transaction request is to be executed.
In an embodiment of the present invention, the method further includes:
responding to a message of successful account deduction returned by the transaction system, and generating first transaction information according to default transaction information and transaction amount;
sending an account posting request to the blockchain according to the first transaction information;
and processing the first transaction information to restore the default transaction information in response to the message of the account posting failure returned by the blockchain.
In an embodiment of the present invention, the first transaction information is obtained according to a sum of a default value indicated by the default transaction information and the transaction amount.
Before receiving an account deduction request, default transaction information is set in a transaction consistency processing device based on a block chain, the default transaction information indicates a default value, when a transaction system returns an account deduction success message, transaction amount is increased on the basis of the default value to obtain first transaction information, an account posting request is sent to the block chain according to the first transaction information, when the block chain returns an account posting failure message, the block chain is proved to be failed to enter account, then the first transaction information is processed, and the first transaction information is restored to the default transaction information. For example, the default value indicated in the default transaction information is 0, the remaining amount in the account a of the banking system is 100 yuan, when 10 yuan is transferred to the blockchain from the account a of the banking system, if the banking system returns that the account a deducts 10 yuan successfully, the first transaction information is obtained, and the first transaction information is obtained by the sum of the default value and the transaction amount, namely 0+ 10; entering the posting of the block chain, if the posting failure is returned by the block chain, processing the first transaction information, and restoring the first transaction information to a default value of 0, namely restoring the default transaction information.
In the embodiment of the invention, the block link receives the transaction second transaction request, performs transaction according to the transaction amount and feeds back the transaction result. For example, the blockchain receives an account posting request, the account posting request indicates a transaction amount, the blockchain performs an account posting operation according to the transaction amount, and increases the remaining amount of the blockchain account, where the increased amount is the transaction amount.
In an embodiment of the present invention, the method further includes:
step S301: and in response to the blockchain not returning feedback for the second transaction request, sending a query request to the blockchain, and recording a second current number of times the query request is sent.
In the embodiment of the present invention, when the server is down or the network is abnormal, and the transaction result for the second transaction request returned by the blockchain is not received, the query request is sent to the blockchain, the query request may be sent to the blockchain according to the transaction identifier to query the transaction result for the second transaction request, and the second current number of times (i.e., the number of times of query) for sending the query request is recorded.
When the second current number of times is not greater than the preset second threshold, if the transaction result is successfully inquired, updating the transaction state corresponding to the second transaction request to be 'transaction successful', and executing step 204, determining that all transactions performed according to the transaction amount are successful, namely the transactions aiming at the second transaction request are successful, namely the posting is successful, and ending the transaction; if the query transaction result is failure, updating the transaction state corresponding to the second transaction request to be "transaction failure", and executing step 205, executing the inverse transaction corresponding to the second transaction request; and if the transaction result is not inquired, continuously sending an inquiry request to the blockchain.
When the second current number of times is greater than the preset second threshold, no query request is sent to the blockchain any more, the blockchain transaction is determined to be abnormal, the transaction state corresponding to the second transaction request is updated to be abnormal, the transaction is interrupted, and step S105 is executed, and the transaction abnormal-to-be-asynchronously-processed identifier can be recorded.
In an embodiment of the present invention, the method further includes:
step S302: determining whether the transaction for the second transaction request was successful in response to feedback of the blockchain for the second transaction request.
In the embodiment of the invention, after the block chain executes the transaction of the posting request, the posting result is fed back, and meanwhile, the transaction state aiming at the posting request is updated so as to judge whether the transaction aiming at the posting request is successful.
Step S303: when the transaction for the second transaction request is successful, it is determined that the transactions performed according to the transaction amount are all successful.
And when the transaction aiming at the second transaction request is successful, updating the transaction state corresponding to the second transaction request to be 'transaction successful', and at the moment, if the transaction system deducts account successfully and the block chain enters account successfully, indicating that the transfer from the transaction system to the block chain is successful, the transaction is completed and the transaction is ended.
Step S304: and when the transaction aiming at the second transaction request fails, executing the reverse transaction corresponding to the second transaction request.
And when the transaction aiming at the second transaction request fails, updating the transaction state corresponding to the second transaction request to be transaction failure, and executing the reverse transaction corresponding to the second transaction request, namely when the block chain returns to the posting failure, updating the transaction state to be posting failure, and executing the forward (rollback) transaction of the posting.
Step S305: in response to success of the reverse transaction corresponding to the second transaction request, the reverse transaction corresponding to the first transaction request is executed.
In the embodiment of the present invention, when the reverse transaction corresponding to the second transaction request is executed, if the corresponding transaction status is updated to be "reverse transaction successful" with respect to the reverse transaction corresponding to the second transaction request, the reverse transaction corresponding to the first transaction request is executed, that is, the posting is successful, and then the posting is executed.
Step S306: responding to the failure of the reverse transaction corresponding to the second transaction request, continuing to execute the reverse transaction corresponding to the first transaction request, and recording the first execution times; and if the first execution times is greater than a preset third threshold value or the reverse transaction is abnormal, executing asynchronous processing corresponding to the second transaction request by adopting the first asynchronous processing thread.
In the embodiment of the present invention, when executing the posting and checking transaction, if the posting and checking transaction is returned and fails, the corresponding transaction state is updated to be "checking failure", and the posting and checking orthogonal transaction is continuously executed, and at the same time, the first execution time is recorded, that is, the time for executing the posting and checking transaction is recorded, if the first execution time is greater than the preset third threshold, step S105 is executed, the transaction is interrupted, the transaction state is updated to be "checking orthogonal transaction abnormal", and the transaction identifier can also be recorded as "transaction abnormal-to-be-funded rollback".
When the reverse transaction corresponding to the second transaction request is executed, if a transaction result of the reverse transaction corresponding to the second transaction request is not received, sending an inquiry request to the blockchain according to the transaction identifier to inquire the transaction result of the reverse transaction, and recording the second execution times, if the inquiry result is that the reverse transaction is successful, executing step S305, if the inquiry result is that the reverse transaction is failed, executing step S305, and if the inquiry result is that the second execution times exceeds a preset fourth threshold value, the inquiry result is not obtained, and executing step S105.
Step S307: in response to a success of executing the inverse transaction corresponding to the first transaction request, a transaction failure corresponding to the transaction amount is determined.
When the reverse transaction corresponding to the first transaction request is executed successfully, namely the deduction and positive reversal are successful, the transaction state of the reverse transaction corresponding to the first transaction request is updated to be 'reverse transaction successful', and the transfer from the transaction system to the block chain is failed, so that the transaction is failed.
Step S308: and in response to the failure of executing the reverse transaction corresponding to the first transaction request, continuing to execute the reverse transaction corresponding to the first transaction request, recording a third execution time, and executing the step S103 when the fourth execution time is greater than a preset fifth threshold.
When the execution of the account deduction and positive reversal fails, updating the transaction state of the reverse transaction corresponding to the first transaction request to be 'reverse transaction failure', continuing initiating the account deduction and positive reversal easy, and executing the step S103, wherein the account deduction and positive reversal easy is not initiated until the number of the account deduction and positive reversal times reaches a preset fifth threshold value.
Step S309: in response to an exception to execute the inverse transaction corresponding to the first transaction request, executing asynchronous processing corresponding to the first transaction request with a first asynchronous processing thread.
When the transaction result of the inverse transaction corresponding to the first transaction request is not received, sending an inquiry request to the transaction system, and recording the frequency of the inquiry request, namely the fourth execution frequency, if the inquiry transaction result is that the inverse transaction is successful, executing step S307; if the query transaction result fails to additionally reverse the transaction, executing S308; if the fourth execution time is greater than the preset sixth threshold value and the transaction result is not obtained yet, it is determined that the reverse transaction is abnormal, the transaction state of the reverse transaction corresponding to the first transaction request is updated to be "reverse transaction abnormal", and step S103 is executed.
Step S105: and responding to the transaction exception of the blockchain, and executing asynchronous processing corresponding to the second transaction request by adopting a first asynchronous processing thread.
In an embodiment of the present invention, executing asynchronous processing corresponding to the first transaction request and/or the second transaction request by using a first asynchronous processing thread includes:
acquiring abnormal transaction data;
and determining whether all the transactions aiming at the transaction amount are successfully executed according to the abnormal transaction data, if so, determining whether all the inverse transactions aiming at the transaction amount are successfully executed, and when all the inverse transactions are failed, determining that all the transactions aiming at the transaction amount are successfully executed.
Wherein the abnormal transaction data indicates an abnormal condition that the server is down and/or the transaction execution result cannot be obtained.
In the embodiment of the invention, when a first transaction request (a deduction request) and/or a second transaction request (an account posting request) are/is asynchronously processed, abnormal transaction data about abnormal request conditions that a server is down and/or a transaction execution result cannot be obtained are obtained, wherein the abnormal transaction data comprises transaction abnormal identification; and according to the abnormal transaction data, judging whether all transactions of the transaction amount are successfully executed in a reverse order, namely whether all transactions of account deduction and account posting are successfully executed, if all transactions are successfully executed, namely, the transactions of account deduction and the transactions of account posting are successfully executed, judging whether all transactions of account deduction and account posting are successful, and if all transactions of account deduction and account posting are failed, indicating that all transactions are successfully executed, namely, the transactions transferred from the transaction system to the block chain are successful.
According to the abnormal transaction data, reverse order judgment is carried out, if all transactions aiming at the transaction amount are successfully executed, namely, the account deduction is successful and the account entry is successful, reverse transactions aiming at the transaction amount are not successfully executed, if the account entry is not successful, inquiry is carried out according to the transaction identification so as to judge whether to initiate the account entry, and if the inquiry result is that the account entry is successful, the inquiry is skipped; if the inquiry result is that the posting fails, skipping; if the result is not inquired, continuously initiating inquiry to judge whether to initiate reversal, if the inquiry times reach a preset threshold value and no result exists, skimming the transaction and waiting for next asynchronous processing.
In the embodiment of the invention, when the number of asynchronous processing reaches the preset eighth threshold value, the transaction result cannot be obtained, the alarm information is initiated, and the manual intervention is used for adjusting the account.
The processing method for transaction consistency based on the block chain provided by the embodiment of the invention carries out asynchronous processing on transaction abnormity appearing in the first transaction request and the second transaction request by carrying out high-reliability expansion on the basis of final transaction consistency, and simultaneously carries out transaction state updating on the transactions and inverse transactions of the first transaction request and the second transaction request, thereby realizing the record of expected running and updated transaction state running, and realizing high-reliability expansion design by adopting synchronous data rollback and asynchronous data rollback, strengthening the guarantee of final transaction consistency of transfer between a transaction system and the block chain, and being more suitable for the accounting mechanism and system of the existing bank.
Fig. 5 shows a processing apparatus 500 for transaction consistency based on blockchain according to an embodiment of the present invention, including: a receiving module 501, a first sending module 502, a second sending module 503 and an asynchronous processing module 504; wherein the content of the first and second substances,
a receiving module 501, configured to receive a first transaction request, where the first transaction request indicates a transaction amount;
a first sending module 502, configured to send the first transaction request to a transaction system, so that the transaction system performs a transaction according to the transaction amount;
a second sending module 503, configured to send, in response to a successful transaction of the transaction system, a second transaction request to the blockchain according to an execution result of the first transaction request, where the second transaction request indicates the transaction amount;
an asynchronous processing module 504, configured to, in response to a transaction exception of the transaction system, execute asynchronous processing corresponding to the first transaction request by using a first asynchronous processing thread; and responding to the transaction exception of the blockchain, and executing asynchronous processing corresponding to the second transaction request by adopting a first asynchronous processing thread.
Asynchronous processing module 504, further configured to: acquiring abnormal transaction data; and determining whether all the transactions aiming at the transaction amount are successfully executed according to the abnormal transaction data, if so, determining whether all the inverse transactions aiming at the transaction amount are successfully executed, and when all the inverse transactions are failed, determining that all the transactions aiming at the transaction amount are successfully executed.
An embodiment of the present invention further provides an electronic device, including:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the processing method for block chain based transaction consistency provided by the embodiment of the invention.
Fig. 6 illustrates an exemplary system architecture 600 of a blockchain based transaction consistency processing method and apparatus to which embodiments of the present invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 serves to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. Network 604 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 601, 602, 603 to interact with the server 605 via the network 604 to receive or send messages or the like. Various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like, may be installed on the terminal devices 601, 602, and 603.
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 605 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 601, 602, 603. The background management server can analyze and process the received data such as the product information inquiry request and feed back the processing result to the terminal equipment.
It should be noted that the processing method for transaction consistency based on the blockchain provided by the embodiment of the present invention is generally executed by the server 605, and accordingly, the processing device for transaction consistency based on the blockchain is generally disposed in the server 605.
It should be understood that the number of terminal devices, networks, and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a receiving module, a first transmitting module, a second transmitting module, and an asynchronous processing module. Where the names of these modules do not in some cases constitute a limitation of the module itself, for example, a receiving module may also be described as a "module receiving a first transaction request".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: receiving a first transaction request, the first transaction request indicating a transaction amount; sending the first transaction request to a transaction system, so that the transaction system carries out transaction according to the transaction amount; responding to transaction exception of the transaction system, and executing asynchronous processing corresponding to the first transaction request by adopting a first asynchronous processing thread; in response to a transaction success of the transaction system, sending a second transaction request to the blockchain according to an execution result of the first transaction request, the second transaction request indicating the transaction amount; and responding to the transaction exception of the blockchain, and executing asynchronous processing corresponding to the second transaction request by adopting a first asynchronous processing thread.
According to the technical scheme of the embodiment of the invention, high-reliability expansion is carried out on the basis of final transaction consistency, asynchronous processing is carried out on transaction abnormity appearing in the first transaction request and the second transaction request, meanwhile, the transaction state of the transaction and the reverse transaction of the first transaction request and the second transaction request are updated, the running records of the expected running and updated transaction state are realized, high-reliability expansion design is realized by adopting synchronous data rollback and asynchronous data rollback, the guarantee of final transaction consistency of transfer between a transaction system and a block chain is enhanced, and the method is more suitable for the accounting mechanism and system of the existing bank.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (18)

1. A transaction consistency processing method based on a blockchain is characterized by comprising the following steps:
receiving a first transaction request, the first transaction request indicating a transaction amount;
sending the first transaction request to a transaction system, so that the transaction system carries out transaction according to the transaction amount;
responding to transaction exception of the transaction system, and executing asynchronous processing corresponding to the first transaction request by adopting a first asynchronous processing thread;
in response to a transaction success of the transaction system, sending a second transaction request to the blockchain according to an execution result of the first transaction request, the second transaction request indicating the transaction amount;
and responding to the transaction exception of the blockchain, and executing asynchronous processing corresponding to the second transaction request by adopting a first asynchronous processing thread.
2. The method of claim 1, further comprising:
interrupting the transaction in response to a transaction failure of the transaction system for the first transaction request.
3. The method of claim 1,
in response to the transaction system not returning a result for the first transaction request, sending an inquiry request to the transaction system, and recording a first current number of times the inquiry request is sent;
and when the first current times is greater than a preset first threshold value, determining that the transaction of the transaction system is abnormal.
4. The method of claim 3,
when the first current number is not greater than a preset first threshold, responding to feedback of the transaction system for the query request, and determining that the transaction of the transaction system for the first transaction request is successful or failed.
5. The method of claim 1,
determining whether the transaction for the second transaction request was successful in response to feedback of the blockchain for the second transaction request;
when the transaction for the second transaction request is successful, it is determined that the transactions performed according to the transaction amount are all successful.
6. The method of claim 5,
and when the transaction aiming at the second transaction request fails, executing the reverse transaction corresponding to the second transaction request.
7. The method of claim 5,
responding to the block chain not returning feedback aiming at the second transaction request, sending a query request to the block chain, and recording a second current time for sending the query request;
and when the second current times is greater than a preset second threshold value, determining that the block chain transaction is abnormal.
8. The method of claim 6,
the first transaction request is a withholding request aiming at the transaction system, and the second transaction request is an entry request aiming at the block chain.
9. The method of claim 8,
responding to a message of successful account deduction returned by the transaction system, and generating first transaction information according to default transaction information and the transaction amount;
sending the posting request to the blockchain according to the first transaction information;
and responding to the message of the failure of posting returned by the blockchain, and processing the first transaction information to restore the default transaction information.
10. The method of claim 9,
the first transaction information is obtained according to the sum of the default value indicated by the default transaction information and the transaction amount.
11. The method of claim 6,
and in response to the success of the reverse transaction corresponding to the second transaction request, executing the reverse transaction corresponding to the first transaction request.
12. The method of claim 6,
responding to the failure of the reverse transaction corresponding to the second transaction request, continuing to execute the reverse transaction corresponding to the second transaction request, and recording the first execution times;
and executing asynchronous processing corresponding to the second transaction request by adopting a first asynchronous processing thread under the condition that the first execution times is greater than a preset third threshold value or the reverse transaction is abnormal.
13. The method of claim 11,
in response to a success of executing the inverse transaction corresponding to the first transaction request, determining that a transaction corresponding to the transaction amount failed;
in response to an exception to execute the inverse transaction corresponding to the first transaction request, executing asynchronous processing corresponding to the first transaction request with a first asynchronous processing thread.
14. The method of claim 1, wherein performing asynchronous processing corresponding to the first transaction request and/or the second transaction request using a first asynchronous processing thread comprises:
acquiring abnormal transaction data;
and determining whether all the transactions aiming at the transaction amount are successfully executed according to the abnormal transaction data, if so, determining whether all the inverse transactions aiming at the transaction amount are successfully executed, and when all the inverse transactions are failed, determining that all the transactions aiming at the transaction amount are successfully executed.
15. The method of claim 14,
the abnormal transaction data indicates an abnormal condition regarding a server downtime and/or a failure to obtain a transaction execution result.
16. A blockchain-based transaction consistency processing apparatus, comprising: the device comprises a receiving module, a first sending module, a second sending module and an asynchronous processing module; wherein the content of the first and second substances,
a receiving module to receive a first transaction request, the first transaction request indicating a transaction amount;
the first sending module is used for sending the first transaction request to a transaction system so that the transaction system can carry out transaction according to the transaction amount;
the second sending module is used for responding to the transaction success of the transaction system and sending a second transaction request to the block chain according to the execution result of the first transaction request, wherein the second transaction request indicates the transaction amount;
the asynchronous processing module is used for responding to the transaction exception of the transaction system and executing asynchronous processing corresponding to the first transaction request by adopting a first asynchronous processing thread; and responding to the transaction exception of the blockchain, and executing asynchronous processing corresponding to the second transaction request by adopting a first asynchronous processing thread.
17. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-15.
18. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-15.
CN202110336821.2A 2021-03-29 2021-03-29 Block chain-based transaction consistency processing method and device Active CN112950380B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110336821.2A CN112950380B (en) 2021-03-29 2021-03-29 Block chain-based transaction consistency processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110336821.2A CN112950380B (en) 2021-03-29 2021-03-29 Block chain-based transaction consistency processing method and device

Publications (2)

Publication Number Publication Date
CN112950380A true CN112950380A (en) 2021-06-11
CN112950380B CN112950380B (en) 2022-10-21

Family

ID=76227341

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110336821.2A Active CN112950380B (en) 2021-03-29 2021-03-29 Block chain-based transaction consistency processing method and device

Country Status (1)

Country Link
CN (1) CN112950380B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005078453A (en) * 2003-09-01 2005-03-24 Hitachi Ltd Method for controlling storage system, storage system, and storage device
CN107862600A (en) * 2017-10-24 2018-03-30 深圳四方精创资讯股份有限公司 Bank transfer method and its system based on block chain
CN108733768A (en) * 2018-04-19 2018-11-02 深圳市网心科技有限公司 transaction data consistency processing method, electronic device and storage medium
CN109670954A (en) * 2018-12-18 2019-04-23 陕西医链区块链集团有限公司 Transaction processing method based on block chain
CN109951474A (en) * 2019-03-15 2019-06-28 杭州云象网络技术有限公司 A method of realizing that block chain is known together out block
CN110619576A (en) * 2018-06-19 2019-12-27 成都高新信息技术研究院 Decentralized supply chain B2B transaction method and system
CN110782252A (en) * 2019-10-24 2020-02-11 福建福链科技有限公司 Monitoring video data transaction method and system based on block chain
CN112101923A (en) * 2020-09-17 2020-12-18 中国建设银行股份有限公司 Transaction information processing method and device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005078453A (en) * 2003-09-01 2005-03-24 Hitachi Ltd Method for controlling storage system, storage system, and storage device
CN107862600A (en) * 2017-10-24 2018-03-30 深圳四方精创资讯股份有限公司 Bank transfer method and its system based on block chain
CN108733768A (en) * 2018-04-19 2018-11-02 深圳市网心科技有限公司 transaction data consistency processing method, electronic device and storage medium
CN110619576A (en) * 2018-06-19 2019-12-27 成都高新信息技术研究院 Decentralized supply chain B2B transaction method and system
CN109670954A (en) * 2018-12-18 2019-04-23 陕西医链区块链集团有限公司 Transaction processing method based on block chain
CN109951474A (en) * 2019-03-15 2019-06-28 杭州云象网络技术有限公司 A method of realizing that block chain is known together out block
CN110782252A (en) * 2019-10-24 2020-02-11 福建福链科技有限公司 Monitoring video data transaction method and system based on block chain
CN112101923A (en) * 2020-09-17 2020-12-18 中国建设银行股份有限公司 Transaction information processing method and device

Also Published As

Publication number Publication date
CN112950380B (en) 2022-10-21

Similar Documents

Publication Publication Date Title
CN111277639B (en) Method and device for maintaining data consistency
CN111857888B (en) Transaction processing method and device
CN106101179B (en) Resource processing method, device and system
CN111127181A (en) Voucher bookkeeping method and device
CN112288577B (en) Transaction processing method, device, electronic equipment and medium for distributed service
CN112184240A (en) Refund request processing method and device
CN112068973A (en) Asynchronous information processing method and device of policy mode, server and storage medium
US20210049561A1 (en) Transaction processing method and device, electronic device and computer-readable storage medium
CN109583873B (en) Transaction communication method, server, POS machine and electronic equipment
CN112819638A (en) Transaction weight judging method, device, equipment and computer readable medium
CN110705981A (en) Real-time settlement method and device
CN112101923A (en) Transaction information processing method and device
CN112950380B (en) Block chain-based transaction consistency processing method and device
CN111724245A (en) Credit card financing method and system
CN111259032A (en) Service processing method and device
CN114612204A (en) Account checking method and device
CN116263925A (en) Accounting method and device based on blockchain
CN109087097B (en) Method and device for updating same identifier of chain code
CN111861746A (en) Method and device for processing transaction data
CN113778631A (en) Distributed transaction compensation method and device, electronic equipment and readable storage medium
CN111210349A (en) Virtual asset transfer hosting method and device, electronic equipment and storage medium
CN111415245A (en) Account opening method and device
CN113778959B (en) Method, apparatus, device and computer readable medium for data processing
CN117437076B (en) Account checking method, device, equipment and medium based on account checking code
CN115981828B (en) Service message processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20220922

Address after: 25 Financial Street, Xicheng District, Beijing 100033

Applicant after: CHINA CONSTRUCTION BANK Corp.

Address before: 12 / F, 15 / F, No. 99, Yincheng Road, Shanghai pilot Free Trade Zone, 200120

Applicant before: Jianxin Financial Science and Technology Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant