WO2021135131A1 - 区块链的交易方法、装置、计算机设备及存储介质 - Google Patents

区块链的交易方法、装置、计算机设备及存储介质 Download PDF

Info

Publication number
WO2021135131A1
WO2021135131A1 PCT/CN2020/099537 CN2020099537W WO2021135131A1 WO 2021135131 A1 WO2021135131 A1 WO 2021135131A1 CN 2020099537 W CN2020099537 W CN 2020099537W WO 2021135131 A1 WO2021135131 A1 WO 2021135131A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
node
stage
status
successful
Prior art date
Application number
PCT/CN2020/099537
Other languages
English (en)
French (fr)
Inventor
李文强
褚镇飞
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021135131A1 publication Critical patent/WO2021135131A1/zh

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

Definitions

  • This application relates to the field of blockchain technology, and in particular to a blockchain transaction method, device, computer equipment and storage medium.
  • the blockchain network is a decentralized distributed network. Different blockchain networks are isolated from each other; different channels of the same blockchain network are isolated from each other. When multiple blockchain networks coexist and some data needs to be shared between blockchain networks; or when data needs to be shared between different channels in the same blockchain network, cross-channel transactions are required.
  • Each transaction in a cross-chain and cross-channel transaction uses a two-stage submission method.
  • the inventor realized that due to the complexity of the network and the system, problems may occur at all stages of the transaction.
  • the caller of a cross-chain transaction has a downtime during the execution of the transaction, and the caller cannot perceive the execution status of the transaction on each chain or each channel after restarting, and submitting the transaction again or abandoning the transaction is not a reasonable processing method. If the transaction is partial chain or partial channel success, other chains or channels fail, abandoning the transaction at this time will result in inconsistent data between the chains, and repeated submissions will cause the successful chain or channel to fail.
  • This application provides a blockchain transaction method, device, computer equipment and storage medium, which ensures the consistency of distributed transaction data and reduces block data in the distributed network caused by abnormalities such as network abnormalities or machine downtime.
  • the problem of inconsistency is to maintain the normality of blockchain cross-chain or cross-channel transactions.
  • the embodiment of the present application provides a blockchain transaction method, and the method includes:
  • the two transaction success record tables respectively record the nodes that succeeded in the first stage transaction
  • the two The transaction status table respectively records the transaction status of the corresponding node in the first transaction stage
  • the embodiment of the application provides a block chain transaction device, the device includes:
  • the obtaining module is used to obtain the transaction success record table and the transaction status table respectively corresponding to the first node and the second node in the first phase transaction; the two transaction success record tables respectively record the nodes whose first phase transactions are successful , The two transaction status tables respectively record the transaction status of the corresponding node in the first transaction stage;
  • the determining module is used to determine whether in the transaction success record table corresponding to the first node and the second node respectively, whether one transaction success record table stores a node for a successful transaction, and the other transaction success record table does not store a transaction success Node
  • the rollback module is configured to store a successful transaction node in one transaction success record table in the transaction success record table corresponding to the first node and the second node, and no transaction success is stored in the other transaction success record table Node, roll back the node that succeeded in the transaction to the state before the first-stage transaction, delete the node that succeeded in the transaction from the transaction success record table, and modify the transaction status table accordingly The transaction status of the first phase of the transaction.
  • a computer device includes a memory and a processor, the processor and the memory are connected to each other, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the memory
  • the two transaction success record tables respectively record the nodes that succeeded in the first stage transaction
  • the two The transaction status table respectively records the transaction status of the corresponding node in the first transaction stage
  • a computer-readable storage medium wherein the computer-readable storage medium stores a computer program, the computer program includes program instructions, and when the program instructions are executed by a processor, they are used to implement the following steps:
  • the two transaction success record tables respectively record the nodes that succeeded in the first stage transaction
  • the two The transaction status table respectively records the transaction status of the corresponding node in the first transaction stage
  • the device, computer equipment and storage medium first obtain the transaction success record table and the transaction status table respectively corresponding to the first node and the second node in the first phase transaction; the two transaction success records The nodes whose transactions in the first stage are successful are recorded in the tables, and the transaction states of the corresponding nodes in the first transaction stage are respectively recorded in the two transaction status tables; then it is determined that the nodes in the first node and the second node Corresponding to the transaction success record table respectively, whether one transaction success record table stores a successful transaction node, and another transaction success record table does not store a successful transaction node; if so, roll back the successful transaction node to the The state before the first-stage transaction, and the node that succeeded in the transaction is deleted from the transaction success record table, and the transaction state of the first-stage transaction in the transaction status table is correspondingly modified.
  • this application can accurately know the transaction status of the node through the recorded transaction success record table and transaction status table, and there is one table in the transaction success record table that stores the nodes that are successful in the transaction, and the other table does not store the nodes that are successful in the transaction.
  • the node with successful transaction is rolled back to the state before the first stage transaction, so that this application guarantees the consistency of distributed transaction data, and reduces the distributed network caused by abnormal network or machine downtime.
  • the problem of inconsistent block data is to maintain the normality of blockchain cross-chain or cross-channel transactions.
  • Fig. 1 is a flowchart of a blockchain transaction method in an embodiment of the present application
  • Fig. 2 is a flowchart of the second-stage transaction confirmation method in an embodiment of the present application
  • Fig. 3 is a flowchart of a method for confirming whether the second-stage transaction is successful in an embodiment of the present application
  • FIG. 4 is a schematic block diagram of the second-stage transaction confirmation device in an embodiment of the present application.
  • Fig. 5 is a schematic diagram of a computer device in an embodiment of the present application.
  • a blockchain transaction method includes the following steps:
  • S101 Obtain a transaction success record table and a transaction status table respectively corresponding to the first node and the second node in the first-stage transaction.
  • the first node and the second node are nodes that need to perform transactions, and each node corresponds to a transaction success record table and a transaction status table, and the two transaction success record tables respectively record the nodes that succeeded in the first phase of the transaction ,
  • the two transaction status tables respectively record the transaction status of the corresponding node in the first transaction stage.
  • the transaction success record table stores node identification information for successful transactions
  • the transaction status table stores node identification information and corresponding transaction status.
  • the transaction status can specifically be the first stage transaction success, the first node transaction failure, and the second stage transaction.
  • Information such as success and second-stage transaction failure are not specifically limited in the embodiment of this application.
  • the first node and the second node in the first stage transaction failure (simulation execution failure) and the first stage transaction not received (the request is lost in the network or the caller does not send the transaction) are considered to be the same transaction, not recorded, that is, if If the record is not found in the transaction status table, it means that the first phase of the transaction failed. If the record cannot be found in the transaction success record form, it means that the transaction has been rolled back, or has been submitted, or the first stage has failed.
  • the first-stage transaction in the embodiment of this application is the pre-submission stage: the caller sends the transaction to the node that needs the transaction, for example, the transaction of transferring 10 yuan from account A to account B is sent to P1 and P2.
  • Nodes, P1 and P2 nodes first simulate the operation of account A-10 yuan and account B+10 yuan.
  • the simulation execution refers to the verification of business presets such as identity verification, security verification, account verification, etc.
  • the results of account A-10 yuan and account B+10 yuan will not actually fall into the library, but Simulate the real transfer transaction to see if it can be successful.
  • the accounts A and B will be temporarily locked, that is, accounts A and B cannot do other transfer transactions. Record the transaction status of the two nodes P1 and P2 respectively.
  • the corresponding transaction success record table and transaction status table if the simulation fails, you do not need to lock the two accounts A and B, and you need to record the successful transaction node in the transaction success record table, and in the two P1 and P2
  • the transaction status of the first stage is recorded in the transaction status table corresponding to each node.
  • the method before obtaining the transaction success record table and the transaction status table respectively corresponding to the first node and the second node in the first phase transaction, the method further includes: obtaining The transaction status of the first node and the second node in the stage transaction; write the successful transaction node into the transaction success record table corresponding to the node, and correspondingly modify the transaction status of the first stage transaction in the transaction status table .
  • the transaction status of the first stage transaction includes transaction success and transaction failure. For example, there are nodes P1 and P2. In the first transaction stage, the P1 node transaction is successful, and the P2 node transaction fails.
  • the node ID of P1 is written into the corresponding transaction success record table, and the corresponding transaction status table is added
  • the first stage transaction of the P1 node is successful; for the P2 node, only the first stage transaction of P2 is recorded as a failure in its corresponding transaction status table, and there is no need to record any information in its corresponding transaction success record table.
  • S102 Determine whether one transaction success record table stores a successful transaction node in the transaction success record table respectively corresponding to the first node and the second node, and the other transaction success record table does not store a successful transaction node.
  • the transaction A1 succeeds and the transaction A2 fails. That is, the transaction success record table corresponding to A1 stores the A1 node, and the transaction success record table corresponding to A2 does not store it. A2 node, at this time, it can be confirmed that in the transaction success record table corresponding to nodes A1 and A2, one table stores the nodes that have successful transactions, and the other table does not store nodes that have successful transactions.
  • the node that succeeds in the transaction is written into the transaction success record table corresponding to the node, and the transaction status of the first-stage transaction in the transaction status table is correspondingly modified only as pre-commit
  • the transaction that has not completed the second stage transaction submission indicates that the transaction has passed the verification and can be placed in the blockchain network, but it is not really a block, but the resource is locked , Ready to drop blocks.
  • the transaction success record table corresponding to the first node and the second node one table stores the nodes with successful transactions, and the other table does not store the nodes with successful transactions Next, it means that the first-stage transaction is not completely successful. Therefore, the node that succeeded in the transaction needs to be rolled back to the state before the first-stage transaction. The first-stage transaction does not execute the real block, and the transaction needs to be The successful node is deleted from the transaction success record table, and the transaction status of the first-stage transaction in the transaction status table is correspondingly modified.
  • the embodiment of the application provides a block chain transaction method. Firstly, the transaction success record table and the transaction status table corresponding to the first node and the second node in the first phase transaction are obtained; the two transaction success record tables Nodes where the first-stage transaction was successful are recorded in the two transaction status tables, and the transaction status of the corresponding node in the first transaction stage is recorded in the two transaction status tables; then it is determined that the first node and the second node respectively In the corresponding transaction success record table, whether one transaction success record table stores a successful transaction node, and another transaction success record table does not store a successful transaction node; if so, roll back the successful transaction node to the first The state before the first-stage transaction, and the node that succeeded in the transaction is deleted from the transaction success record table, and the transaction state of the first-stage transaction in the transaction status table is correspondingly modified.
  • this application can accurately know the transaction status of the node through the recorded transaction success record table and transaction status table, and there is one table in the transaction success record table that stores the nodes that are successful in the transaction, and the other table does not store the nodes that are successful in the transaction.
  • the node with successful transaction is rolled back to the state before the first stage transaction, so that this application guarantees the consistency of distributed transaction data, and reduces the distributed network caused by abnormal network or machine downtime.
  • the problem of inconsistent block data is to maintain the normality of blockchain cross-chain or cross-channel transactions.
  • a second-stage transaction confirmation method is provided, and the method includes the following steps:
  • the second phase of the transaction is the submission phase: according to the results of each node's pre-commit, the submission or rollback is performed. For example, if there are two nodes P1 and P2, node P1 succeeds in the first phase of the transaction, and node P2 fails in the second phase of the transaction, then the first phase of the node P1 transaction is rolled back, that is, the node P1 is removed from the transaction success record table In the transaction status table where the node P1 is located, the transaction status of the first-stage transaction in the transaction status table where the node P1 is located is modified accordingly; if both the node P1 and the node P2 succeed in the first-stage transaction, the second-stage transaction is entered.
  • S20 Determine whether the second-stage transaction is successful according to the transaction submission time of the second-stage transaction.
  • the transaction submission time of the second-stage transaction is the actual submission time of the second-stage transaction for the transaction.
  • it can be based on the time of entering the second-stage transaction and the transaction submission time of the second-stage transaction To determine whether the second stage transaction is successful.
  • step S20 determines whether the second-phase transaction is successful according to the transaction submission time of the second-phase transaction, including:
  • S201 Detect whether the second-stage transaction is submitted within a preset time.
  • the preset time can be set according to actual needs. Specifically, it can be determined according to the statistics of the normal submission time in the second phase. If the normal submission time of the second phase transaction is within 3 seconds, the preset time can be preset The time is set to 3 seconds, and the embodiment of the present application does not specifically limit the setting of the preset time.
  • the subsequent execution steps are determined according to the result of detecting whether the second-stage transaction is submitted within the preset time. If the second-stage transaction is submitted within the preset time, step S202A is entered to determine the first The second-stage transaction is successful; if the second-stage transaction is not submitted within the preset time, step S202B is entered to determine that the second-stage transaction has failed.
  • the submission of the second-stage transaction can be controlled by the coordinator's internal code logic according to the business needs to allow the coordinator to roll back or submit this type of transaction. That is, automatic processing. If the coordinator chooses to submit, then go to step S203A to continue execution; if the coordinator chooses to roll back, go to step S203B to continue execution.
  • S203A Delete the transaction successful node stored in the transaction success record table respectively corresponding to the first node and the second node in the first phase transaction; and correspondingly update the transaction status table corresponding to the first node and the second node respectively The transaction status of the second stage transaction is successful.
  • the two transaction status tables also respectively record the transaction status of the corresponding node in the second transaction stage.
  • step S202B is a parallel step of step S202A. If the second-stage transaction is not submitted within the preset time, it is determined that the second-stage transaction has failed.
  • S203B Roll back the first node and the second node to the state before the first-phase transaction respectively.
  • S204B Delete the transaction success node stored in the transaction success record table respectively corresponding to the first node and the second node in the first phase transaction; and correspondingly update the transaction status table corresponding to the first node and the second node respectively
  • the transaction status of the second stage transaction is the first stage transaction rollback.
  • transaction A is queried in node P1 and transaction A is not queried in node P2, it means that transaction A is in the first stage of success in P1 and the second stage has not started, then transaction A is in the first stage in P2 Failed, or submitted or rolled back; in order to determine the status of A in P2, query the status of transaction A in the transaction status table in P2. If the record is not found in Table 2, it means that the transaction is in P2 If it fails in the first stage, the overall status is "A succeeded in the first stage at P1, and failed in the first stage at P2". The transaction is an abnormal transaction and should be rolled back at the P1 node; if you query in the transaction status table When transaction A is submitted (or rolled back), the overall status is
  • transaction A is not queried in node P1, and transaction A is not queried in node P2, the transaction fails in the first phase or has been submitted or rolled back in the second phase, and the status is consistent and no management is required. If transaction A is queried in node P1, and transaction A is also queried in node P2, then the transaction is consistent across all nodes, and it only needs to be submitted or rolled back at the same time.
  • a block chain transaction device is provided, and the block chain transaction device corresponds to the block chain transaction method in the foregoing embodiment one-to-one.
  • the blockchain transaction device includes an acquisition module 10, a determination module 20, and a rollback module 30.
  • the detailed description of each functional module is as follows:
  • the obtaining module 10 is used to obtain the transaction success record table and the transaction status table respectively corresponding to the first node and the second node in the first stage transaction; the two transaction success record tables respectively record the first stage transaction success Nodes, each of the two transaction status tables records the transaction status of the corresponding node in the first transaction stage;
  • the determining module 20 is used to determine whether in the transaction success record tables corresponding to the first node and the second node respectively, whether one transaction success record table stores a successful transaction node, and the other transaction success record table does not store a transaction Successful node
  • the rollback module 30 is configured to store a successful transaction node in one transaction success record table in the transaction success record table corresponding to the first node and the second node, and no transaction is stored in the other transaction success record table For a successful node, roll back the node with a successful transaction to the state before the first-stage transaction, delete the node with a successful transaction from the transaction success record table, and modify the transaction status accordingly The transaction status of the first stage transaction in the table.
  • the device further includes:
  • the determining module 20 is further configured to determine whether the second-phase transaction is successful according to the transaction submission time of the second-phase transaction.
  • the determining module 20 includes:
  • the determining unit 21 is configured to determine that the second-phase transaction is successful if the second-phase transaction is submitted within a preset time
  • the editing unit 22 is configured to delete the transaction success node stored in the transaction success record table respectively corresponding to the first node and the second node in the first phase transaction; and correspondingly update the corresponding nodes of the first node and the second node respectively
  • the transaction status of the second-stage transaction in the transaction status table is success; the two transaction status tables also respectively record the transaction status of the corresponding node in the second transaction stage.
  • the determination module 20 shown further includes:
  • the determining unit 21 is further configured to determine that the second-stage transaction fails if the second-stage transaction is not submitted within a preset time;
  • the rollback unit 23 is further configured to roll back the first node and the second node to the state before the first-phase transaction respectively;
  • the editing unit 22 is further configured to delete the successful transaction nodes stored in the transaction success record table respectively corresponding to the first node and the second node in the first stage transaction; and correspondingly update the first node and the second node.
  • the transaction status of the second-stage transaction in the transaction status table corresponding to each node is the first-stage transaction rollback.
  • the device further includes:
  • the acquiring module 10 is also used to acquire the transaction status of the first node and the second node in the first-phase transaction;
  • the editing module 50 is used to write a successful transaction node into the transaction success record table corresponding to the node, and correspondingly modify the transaction status of the first-stage transaction in the transaction status table, and the transaction of the first-stage transaction
  • the status includes transaction success and transaction failure.
  • Each module in the above-mentioned blockchain transaction device can be implemented in whole or in part by software, hardware, and a combination thereof.
  • the above-mentioned modules may be embedded in the form of hardware or independent of the processor in the computer equipment, or may be stored in the memory of the computer equipment in the form of software, so that the processor can call and execute the operations corresponding to the above-mentioned modules.
  • a computer device is provided.
  • the computer device may be a server, and its internal structure diagram may be as shown in FIG. 5.
  • the computer equipment includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, a computer program, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium.
  • the database of the computer equipment is used to store the transaction success record table and the transaction status table respectively corresponding to each node.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer program is executed by the processor to realize a blockchain transaction method.
  • a computer device including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the processor implements the following steps when the processor executes the computer program:
  • the two transaction success record tables respectively record the nodes that succeeded in the first stage transaction
  • the two The transaction status table respectively records the transaction status of the corresponding node in the first transaction stage
  • a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
  • the two transaction success record tables respectively record the nodes that succeeded in the first stage transaction
  • the two The transaction status table respectively records the transaction status of the corresponding node in the first transaction stage
  • the computer-readable storage medium may be non-volatile or volatile.
  • a person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing relevant hardware through a computer program.
  • the computer program can be stored in a non-volatile computer readable storage.
  • the medium when the computer program is executed, it may include the processes of the above-mentioned method embodiments.
  • any reference to memory, storage, database, or other media used in the embodiments provided in this application may include non-volatile and/or volatile memory.
  • Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

Landscapes

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

Abstract

一种区块链的交易方法、装置、计算机设备及存储介质,涉及区块链技术领域,主要用于保证分布式事务数据的一致性。所述方法包括:获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表(S101);确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点(S102);若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态(S103)。

Description

区块链的交易方法、装置、计算机设备及存储介质
本申请要求于2020年01月03日提交中国专利局、申请号为2020100055527,发明名称为“区块链的交易方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及区块链技术领域,尤其涉及一种区块链的交易方法、装置、计算机设备及存储介质。
背景技术
区块链网络是一个去中心化的分布式网络,不同区块链网络之间相互隔离;相同区块链网络的不同通道之间相互隔离。当多个区块链网络并存,且区块链网络之间需要共享某些数据时;或在同一个区块链网络中的不同通道之间需要共享数据时,就需要做跨通道的交易。
跨链跨通道交易中每笔交易都是采用二阶段提交的方式,发明人意识到,由于网络的复杂性及系统等原因,在交易的各个阶段都可能发生问题。例如,跨链交易的调用者在执行交易时发生宕机,再次启动后调用者无法感知该交易在各个链或者各个通道上的执行状态,再次提交交易或者放弃交易都不是合理的处理方式。如果该笔交易是部分链或者部分通道成功,其他链或通道失败,此时放弃交易就会导致链之间的数据不一致,如果重复提交会导致成功的链或通道失败。
发明内容
本申请提供一种区块链的交易方法、装置、计算机设备及存储介质,保证了分布式事务数据的一致性,减少了因为网络异常或者机器宕机等异常导致的分布式网络中区块数据不一致的问题,维护区块链跨链或者跨通道交易的正常。
本申请实施例提供一种区块链的交易方法,所述方法包括:
获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;
确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;
若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
本申请实施例提供一种区块链的交易装置,所述装置包括:
获取模块,用于获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;
确定模块,用于确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;
回滚模块,用于若在所述第一节点和所述第二节点分别对应的交易成功记录表中一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
一种计算机设备,包括存储器和处理器,所述处理器和所述存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器用于执行所述存储器的所述程序指令,其中:
获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;
确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;
若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令被处理器执行时,用于实现以下步骤:
获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;
确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;
若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
上述区块链的交易方法、装置、计算机设备及存储介质,首先获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;然后确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。由于本申请可以通过记录的交易成功记录表和交易状态表准确 的获知节点的交易状态,并在交易成功记录表中存在一个表中存储交易成功的节点,另一个表中未存储交易成功的节点的情况下,将交易成功的节点回滚到第一阶段交易之前的状态,从而本申请保证了分布式事务数据的一致性,减少了因为网络异常或者机器宕机等异常导致的分布式网络中区块数据不一致的问题,维护区块链跨链或者跨通道交易的正常。
附图说明
图1是本申请一实施例中区块链的交易方法的一流程图;
图2是本申请一实施例中第二阶段交易确认方法的一流程图;
图3是本申请一实施例中确认第二阶段交易是否成功方法的一流程图;
图4是本申请一实施例中第二阶段交易确认装置的一原理框图;
图5是本申请一实施例中计算机设备的一示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
在一实施例中,如图1所示,提供一种区块链的交易方法,所述方法包括如下步骤:
S101,获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表。
其中,第一节点和第二节点为需要进行交易的节点,每个节点均对应一个交易成功记录表和交易状态表,所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态。具体的,交易成功记录表存储交易成功的节点标识信息,交易状态表中存储节点标识信息及对应的交易状态,交易状态具体可以为第一阶段交易成功、第一节点交易失败、第二阶段交易成功、第二阶段交易失败等信息,本申请实施例不做具体限定。
第一节点和第二节点在第一阶段交易失败(模拟执行失败)和第一阶段交易未收到(请求在网络中丢失或者调用者未发送交易)认为是同一种交易,不记录,即如果在交易状态表中查不到该记录则说明该笔交易第一阶段交易失败。如果在交易成功记录表中查不到该记录则说明该笔交易已回滚、或已提交、或第一阶段失败。
需要说明的是,本申请实施例中的第一阶段交易为预提交阶段:调用者发送交易到需要进行交易的节点,例如从A账户转账10元到B账户的交易发送到P1、P2两个节点,P1、P2节点先模拟执行账户A-10元、账户B+10元的操作。其中,模拟执行指的是做业务预设的校验如身份校验、安全校验、账户校验等,账户A-10元、账户B+10元的结果并不会真正落库,而是模拟真正转账的交易看是否可以成功,如模拟成功,会将A、B两个账户暂时上锁,即A、B账户无法做其他转账交易,将P1、P2两个节点交易的状态分别记录到其对应的交易成功记录表和交易状态表;如模拟失败,则不需要对A、B两个账户上锁,需 要将交易成功的节点记录到交易成功记录表中,并在P1、P2两个节点分别对应的交易状态表中记录第一阶段的交易状态。
在本申请提供的一个实施例中,在获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表之前,所述方法还包括:获取在所述第一阶段交易中的第一节点和第二节点的交易状态;将交易成功的节点写入到与该节点对应的交易成功记录表中,并对应修改所述交易状态表中第一阶段交易的交易状态。其中,所述第一阶段交易的交易状态包括交易成功和交易失败。例如,存在节点P1和P2,在第一交易阶段中P1节点交易成功,P2节点交易失败,则在P1的节点标识写到对应的交易成功记录表中,并在其对应的交易状态表中添加P1节点第一阶段交易成功;而对于P2节点,仅在其对应的交易状态表中记录P2的第一阶段交易为失败,不需要在其对应的交易成功记录表中记录任何信息。
S102,确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点。
例如,存在两个交易节点A1和A2,在第一阶段交易中,A1交易成功,A2交易失败,即A1对应的交易成功记录表中存储了A1节点,A2对应的交易成功记录表中未存储A2节点,此时便可确认节点A1和A2分别对应的交易成功记录表中一个表中存储交易成功的节点,另一个表中未存储交易成功的节点。
S103,若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
需要说明的是,在第一阶段交易中,将交易成功的节点写入到与该节点对应的交易成功记录表中,并对应修改所述交易状态表中第一阶段交易的交易状态只是预提交阶段,只完成第一阶段交易预提交,没完成第二阶段交易提交的交易说明该笔交易已经通过了验证可以在区块链网络中落块,但并不真正落块,只是将资源上锁,准备落块。而在本申请实施例中,对于在所述第一节点和所述第二节点分别对应的交易成功记录表中一个表中存储交易成功的节点,另一个表中未存储交易成功的节点的情况下,说明第一阶段交易并没有完全成功,因此需要将所述交易成功的节点回滚到所述第一阶段交易之前的状态,第一阶段交易不执行真正的落块,需要将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
本申请实施例提供了一种区块链的交易方法,首先获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;然后确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段 交易的交易状态。由于本申请可以通过记录的交易成功记录表和交易状态表准确的获知节点的交易状态,并在交易成功记录表中存在一个表中存储交易成功的节点,另一个表中未存储交易成功的节点的情况下,将交易成功的节点回滚到第一阶段交易之前的状态,从而本申请保证了分布式事务数据的一致性,减少了因为网络异常或者机器宕机等异常导致的分布式网络中区块数据不一致的问题,维护区块链跨链或者跨通道交易的正常。
在一实施例中,如图2所示,提供一种第二阶段交易确认方法,所述方法包括如下步骤:
S10,若确定所述第一节点和所述第二节点分别对应的交易成功记录表中均存储所述交易成功的节点;则进入所述第二阶段交易。
其中,第二阶段交易为提交阶段:根据各个节点预提交的结果,执行提交或者回滚。例如,存在两个节点P1和P2,节点P1在第一阶段交易成功,节点P2在第二阶段交易失败,则将节点P1的第一阶段交易回滚,即将节点P1从所述交易成功记录表中删除,并对应修改节点P1所在交易状态表中第一阶段交易的交易状态;如节点P1和节点P2在第一阶段交易都成功,则进入第二阶段交易。
S20,根据在所述第二阶段交易的交易提交时间,确定所述第二阶段交易是否交易成功。
具体的,第二阶段交易的交易提交时间为在第二阶段交易对该次交易的实际提交时间,对于本申请实施例可以根据进入第二阶段交易的时间,以及第二阶段交易的交易提交时间,确定第二阶段是否交易成功。
进一步地,请参见图3,图3是本申请一实施例中确认第二阶段交易是否成功方法的一流程图。在本申请提供的一个实施例中,步骤S20根据在所述第二阶段交易的交易提交时间,确定所述第二阶段交易是否交易成功,包括:
S201,检测所述第二阶段交易是否在预置时间内提交交易。
其中,预置时间可以根据实际需求进行设置,具体的,可以根据统计在第二阶段正常的提交时间进行确定,如正常的第二阶段交易的提交时间为在3秒内,则可将预置时间设置为3秒,本申请实施例对预置时间的设定不做具体限定。
在本申请实施例,根据检测第二阶段交易是否在预置时间内提交交易的结果,确定后续的执行步骤,若第二阶段交易在预置时间内提交交易,则进入步骤S202A确定所述第二阶段交易成功;若第二阶段交易未在预置时间内提交交易,则进入步骤S202B确定所述第二阶段交易失败。
第二阶段交易的提交,这种多选择的情况下,可以根据业务需求,来让协调者对此类交易进行回滚还是提交操作,由协调者内部代码逻辑控制。即自动处理,如果协调者选择提交则进入步骤S203A继续进行执行;如果协调者选择回滚则进入步骤S203B继续进行执行。
S202A,若所述第二阶段交易在预置时间内提交交易,则确定所述第二阶段交易成功。
S203A,将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第 二阶段交易的交易状态为成功。
其中,所述两个交易状态表中还分别记录有对应节点在第二交易阶段中的交易状态。
S202B,若所述第二阶段交易未在预置时间内提交交易,则确定所述第二阶段交易失败。
其中,步骤S202B为步骤S202A的并列步骤,若第二阶段交易未在预置时间内提交交易,则确定所述第二阶段交易失败。
S203B,将所述第一节点和第二节点分别回滚到所述第一阶段交易之前的状态。
S204B,将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第二阶段交易的交易状态为第一阶段交易回滚。
例如:节点P1中查询到交易A,节点P2中未查询到交易A,则说明A交易在P1中处于第一阶段成功,第二阶段未开始的状态,则A交易在P2中处于第一阶段失败,或者已提交或已回滚;为确定A在P2中的状态,再在P2中的交易状态表中查询交易A的状态,如果表2没有查询到该记录,则说明该交易在P2中处于第一阶段失败,则整体状态为“A在P1是第一阶段成功,在P2是第一阶段失败”,该笔交易为异常交易,应在P1节点回滚;如果在交易状态表中查询到交易A为已提交(或已回滚),则整体状态为
“A在P1是第一阶段成功,在P2是第二阶段已提交(或已回滚)”,该笔交易为异常交易,应在P1节点回滚(或提交)。
节点P1中未查询到交易A,节点P2中也未查询到交易A,则该笔交易处于第一阶段失败或者第二阶段已提交或已回滚,状态一致无需管理。节点P1中查询到交易A,节点P2中也查询到交易A,则该笔交易在各个节点一致,只需同时提交或同时回滚即可。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
在一实施例中,提供一种区块链的交易装置,该区块链的交易装置与上述实施例中区块链的交易方法一一对应。如图4所示,该区块链的交易装置包括获取模块10、确定模块20、回滚模块30。各功能模块详细说明如下:
获取模块10,用于获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;
确定模块20,用于确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;
回滚模块30,用于若在所述第一节点和所述第二节点分别对应的交易成功记录表中一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易 状态。
进一步的,所述装置还包括:
进入模块40,若确定所述第一节点和所述第二节点分别对应的交易成功记录表中均存储所述交易成功的节点;则进入所述第二阶段交易;
所述确定模块20,还用于根据所述第二阶段交易的交易提交时间,确定所述第二阶段交易是否交易成功。
在本申请提供的一个实施例中,所述确定模块20包括:
确定单元21,用于若所述第二阶段交易在预置时间内提交交易,则确定所述第二阶段交易成功;
编辑单元22,用于将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第二阶段交易的交易状态为成功;所述两个交易状态表中还分别记录有对应节点在所述第二交易阶段中的交易状态。
在本申请提供的一个实施例中,所示确定模块20还包括:
所述确定单元21,还用于若所述第二阶段交易未在预置时间内提交交易,则确定所述第二阶段交易失败;
回滚单元23,还用于将所述第一节点和第二节点分别回滚到所述第一阶段交易之前的状态;
所述编辑单元22,还用于将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第二阶段交易的交易状态为第一阶段交易回滚。
进一步的,所述装置还包括:
所述获取模块10,还用于获取在所述第一阶段交易中的第一节点和第二节点的交易状态;
编辑模块50,用于将交易成功的节点写入到与该节点对应的交易成功记录表中,并对应修改所述交易状态表中第一阶段交易的交易状态,所述第一阶段交易的交易状态包括交易成功和交易失败。
关于区块链的交易装置的具体限定可以参见上文中对于区块链的交易法的限定,在此不再赘述。上述区块链的交易装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
在一个实施例中,提供了一种计算机设备,该计算机设备可以是服务器,其内部结构图可以如图5所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该 计算机设备的数据库用于存储各节点分别对应的交易成功记录表和交易状态表。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种区块链的交易法。
在一个实施例中,提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行计算机程序时实现以下步骤:
获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;
确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;
若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
在一个实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现以下步骤:
获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;
确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;
若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
其中,所述计算机可读存储介质可以是非易失性,也可以是易失性。本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟 悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (20)

  1. 一种区块链的交易方法,其中,所述方法包括:
    获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;
    确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;
    若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
  2. 根据权利要求1所述的区块链的交易方法,其中,所述方法还包括:
    若所述第一节点和所述第二节点分别对应的交易成功记录表中均存储所述交易成功的节点;则进入所述第二阶段交易;
    根据所述第二阶段交易的交易提交时间,确定所述第二阶段交易是否交易成功。
  3. 根据权利要求2所述的区块链的交易方法,其中,所述根据所述第二阶段交易的交易提交时间,确定所述第二阶段交易是否交易成功,包括:
    若所述第二阶段交易在预置时间内提交交易,则确定所述第二阶段交易成功;
    将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第二阶段交易的交易状态为成功;所述两个交易状态表中还分别记录有对应节点在第二交易阶段中的交易状态。
  4. 根据权利要求3所述的区块链的交易方法,其中,所述根据所述第二阶段交易的交易提交时间,确定所述第二阶段交易是否交易成功,包括:
    若所述第二阶段交易未在预置时间内提交交易,则确定所述第二阶段交易失败;
    将所述第一节点和第二节点分别回滚到所述第一阶段交易之前的状态;
    将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第二阶段交易的交易状态为第一阶段交易回滚。
  5. 根据权利要求1所述的区块链的交易方法,其中,在获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表之前,所述方法还包括:
    获取在所述第一阶段交易中的第一节点和第二节点的交易状态;
    将交易成功的节点写入到与该节点对应的交易成功记录表中,并对应修改所述交易状态表中第一阶段交易的交易状态,所述第一阶段交易的交易状态包括交易成功和交易失败。
  6. 一种区块链的交易装置,其中,所述装置包括:
    获取模块,用于获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录 表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;
    确定模块,用于确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;
    回滚模块,用于若在所述第一节点和所述第二节点分别对应的交易成功记录表中一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
  7. 根据权利要求6所述的区块链的交易装置,其中,所述装置还包括:
    进入模块,若所述第一节点和所述第二节点分别对应的交易成功记录表中均存储所述交易成功的节点;则进入所述第二阶段交易;
    所述确定模块,还用于根据所述第二阶段交易的交易提交时间,确定所述第二阶段交易是否交易成功。
  8. 根据权利要求7所述的区块链的交易装置,其中,所述确定模块包括:
    确定单元,用于若所述第二阶段交易在预置时间内提交交易,则确定所述第二阶段交易成功;
    编辑模块,用于将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第二阶段交易的交易状态为成功;所述两个交易状态表中还分别记录有对应节点在所述第二交易阶段中的交易状态。
  9. 根据权利要求8所述的区块链的交易装置,其中,所述确定模块还包括:
    所述确定单元,还用于若所述第二阶段交易未在预置时间内提交交易,则确定所述第二阶段交易失败;
    回滚单元,用于将所述第一节点和第二节点分别回滚到所述第一阶段交易之前的状态;
    所述编辑单元,还用于将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第二阶段交易的交易状态为第一阶段交易回滚。
  10. 根据权利要求6所述的区块链的交易装置,其中,所述装置还包括:
    所述获取模块,还用于获取在所述第一阶段交易中的第一节点和第二节点的交易状态;
    编辑模块,用于将交易成功的节点写入到与该节点对应的交易成功记录表中,并对应修改所述交易状态表中第一阶段交易的交易状态,所述第一阶段交易的交易状态包括交易成功和交易失败。
  11. 一种计算机设备,包括存储器和处理器,所述处理器和所述存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器用于执行所述存储器的所述程序指令,其中:
    获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;
    确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;
    若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
  12. 根据权利要求11所述的计算机设备,其中,所述处理器用于:
    若所述第一节点和所述第二节点分别对应的交易成功记录表中均存储所述交易成功的节点;则进入所述第二阶段交易;
    根据所述第二阶段交易的交易提交时间,确定所述第二阶段交易是否交易成功。
  13. 根据权利要求12所述的计算机设备,其中,所述处理器用于:
    若所述第二阶段交易在预置时间内提交交易,则确定所述第二阶段交易成功;
    将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第二阶段交易的交易状态为成功;所述两个交易状态表中还分别记录有对应节点在第二交易阶段中的交易状态。
  14. 根据权利要求13所述的计算机设备,其中,所述处理器用于:
    若所述第二阶段交易未在预置时间内提交交易,则确定所述第二阶段交易失败;
    将所述第一节点和第二节点分别回滚到所述第一阶段交易之前的状态;
    将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第二阶段交易的交易状态为第一阶段交易回滚。
  15. 根据权利要求11所述的计算机设备,其中,所述处理器用于:
    获取在所述第一阶段交易中的第一节点和第二节点的交易状态;
    将交易成功的节点写入到与该节点对应的交易成功记录表中,并对应修改所述交易状态表中第一阶段交易的交易状态,所述第一阶段交易的交易状态包括交易成功和交易失败。
  16. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令被处理器执行时,用于实现以下步骤:
    获取第一阶段交易中的第一节点和第二节点分别对应的交易成功记录表和交易状态表;所述两个交易成功记录表中分别记录有第一阶段交易成功的节点,所述两个交易状态表中分别记录有对应节点在第一交易阶段中的交易状态;
    确定在所述第一节点和所述第二节点分别对应的交易成功记录表中是否一个交易成功记录表中存储交易成功的节点,另一个交易成功记录表中未存储交易成功的节点;
    若是,则将所述交易成功的节点回滚到所述第一阶段交易之前的状态,并将所述交易 成功的节点从所述交易成功记录表中删除,以及对应修改所述交易状态表中第一阶段交易的交易状态。
  17. 根据权利要求16所述的计算机可读存储介质,其中,所述程序指令被处理器执行时,还用于实现以下步骤:
    若所述第一节点和所述第二节点分别对应的交易成功记录表中均存储所述交易成功的节点;则进入所述第二阶段交易;
    根据所述第二阶段交易的交易提交时间,确定所述第二阶段交易是否交易成功。
  18. 根据权利要求17所述的计算机可读存储介质,其中,所述程序指令被处理器执行时,还用于实现以下步骤:
    若所述第二阶段交易在预置时间内提交交易,则确定所述第二阶段交易成功;
    将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第二阶段交易的交易状态为成功;所述两个交易状态表中还分别记录有对应节点在第二交易阶段中的交易状态。
  19. 根据权利要求18所述的计算机可读存储介质,其中,所述程序指令被处理器执行时,还用于实现以下步骤:
    若所述第二阶段交易未在预置时间内提交交易,则确定所述第二阶段交易失败;
    将所述第一节点和第二节点分别回滚到所述第一阶段交易之前的状态;
    将在所述第一阶段交易中第一节点和第二节点分别对应的交易成功记录表中存储的交易成功的节点删除;并对应更新第一节点和第二节点分别对应的交易状态表中第二阶段交易的交易状态为第一阶段交易回滚。
  20. 根据权利要求16所述的计算机可读存储介质,其中,所述程序指令被处理器执行时,还用于实现以下步骤:
    获取在所述第一阶段交易中的第一节点和第二节点的交易状态;
    将交易成功的节点写入到与该节点对应的交易成功记录表中,并对应修改所述交易状态表中第一阶段交易的交易状态,所述第一阶段交易的交易状态包括交易成功和交易失败。
PCT/CN2020/099537 2020-01-03 2020-06-30 区块链的交易方法、装置、计算机设备及存储介质 WO2021135131A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010005552.7A CN111210350A (zh) 2020-01-03 2020-01-03 区块链的交易方法、装置、计算机设备及存储介质
CN202010005552.7 2020-01-03

Publications (1)

Publication Number Publication Date
WO2021135131A1 true WO2021135131A1 (zh) 2021-07-08

Family

ID=70787210

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/099537 WO2021135131A1 (zh) 2020-01-03 2020-06-30 区块链的交易方法、装置、计算机设备及存储介质

Country Status (2)

Country Link
CN (1) CN111210350A (zh)
WO (1) WO2021135131A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111210350A (zh) * 2020-01-03 2020-05-29 平安科技(深圳)有限公司 区块链的交易方法、装置、计算机设备及存储介质
CN112927073A (zh) * 2021-02-23 2021-06-08 网易(杭州)网络有限公司 跨链数据互换方法、系统、装置、电子设备
CN115601160A (zh) * 2021-06-28 2023-01-13 华为云计算技术有限公司(Cn) 数据处理的方法以及装置
CN113918654B (zh) * 2021-12-07 2022-04-01 深圳前海微众银行股份有限公司 一种区块数据提交的方法及装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108269190A (zh) * 2018-01-17 2018-07-10 深圳四方精创资讯股份有限公司 基于跨链中继平台的跨链方法及其系统
WO2018213880A1 (en) * 2017-05-22 2018-11-29 Haventec Pty Ltd System for blockchain based domain name and ip number register
CN109544171A (zh) * 2018-11-30 2019-03-29 众安信息技术服务有限公司 用于实现跨区块链交易的一致性的方法及设备
CN111210350A (zh) * 2020-01-03 2020-05-29 平安科技(深圳)有限公司 区块链的交易方法、装置、计算机设备及存储介质

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073540B (zh) * 2010-12-15 2013-05-08 北京新媒传信科技有限公司 分布式事务提交方法和装置
CN103885854A (zh) * 2012-12-19 2014-06-25 华为技术有限公司 一种数据备份方法、装置及系统
CN109325762B (zh) * 2018-08-30 2020-07-10 杭州复杂美科技有限公司 平行链跨链交易方法、设备和存储介质
CN110473100B (zh) * 2019-08-15 2023-07-11 深圳前海微众银行股份有限公司 一种基于区块链系统的交易处理方法及装置
CN110502319B (zh) * 2019-08-23 2021-10-12 腾讯科技(深圳)有限公司 分布式事务的处理方法、装置、电子设备及存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018213880A1 (en) * 2017-05-22 2018-11-29 Haventec Pty Ltd System for blockchain based domain name and ip number register
CN108269190A (zh) * 2018-01-17 2018-07-10 深圳四方精创资讯股份有限公司 基于跨链中继平台的跨链方法及其系统
CN109544171A (zh) * 2018-11-30 2019-03-29 众安信息技术服务有限公司 用于实现跨区块链交易的一致性的方法及设备
CN111210350A (zh) * 2020-01-03 2020-05-29 平安科技(深圳)有限公司 区块链的交易方法、装置、计算机设备及存储介质

Also Published As

Publication number Publication date
CN111210350A (zh) 2020-05-29

Similar Documents

Publication Publication Date Title
WO2021135131A1 (zh) 区块链的交易方法、装置、计算机设备及存储介质
CN108769212B (zh) 数据同步方法、装置、计算机设备和存储介质
CN110457157B (zh) 分布式事务异常处理方法、装置、计算机设备及存储介质
US20200272620A1 (en) Transaction processing at non-relational databases
CN112363941A (zh) 接口测试方法、装置、计算机设备及存储介质
WO2020253122A1 (zh) 数据核对方法、装置、计算机设备和存储介质
CN110209652A (zh) 数据表迁移方法、装置、计算机设备和存储介质
CN110764998B (zh) 基于Django框架的数据比对方法、装置、设备及存储介质
CN110286998B (zh) 虚拟机图形用户界面生效、执行过程记录方法和装置
CN108965383B (zh) 文件同步方法、装置、计算机设备和存储介质
CN111026767B (zh) 区块链的数据存储方法、装置及硬件设备
CN110795171B (zh) 业务数据处理方法、装置、计算机设备及存储介质
CN110727698A (zh) 数据库访问方法、装置、计算机设备和存储介质
CN113612814B (zh) 一种会话信息的筛选方法、装置、终端及存储介质
CN110674145A (zh) 数据一致性的检测方法、装置、计算机设备和存储介质
WO2024078015A1 (zh) 基于镜像对的故障注入方法、装置、设备和存储介质
CN113609230A (zh) 数据同步异常告警方法、装置、计算机设备和存储介质
WO2021012562A1 (zh) 区块链数据清理方法、装置、计算机设备和存储介质
CA3191210A1 (en) Data syncronization method and device, computer equipment and storage medium
WO2022121548A1 (zh) 一种bios错误定位方法、装置、设备及非易失性存储介质
CN112765126A (zh) 数据库事务的管理方法、装置、计算机设备和存储介质
CN111338848B (zh) 故障应用副本处理方法、装置、计算机设备和存储介质
CN112631821A (zh) 内存故障检测定位方法、装置、计算机设备及存储介质
CN111209187B (zh) 业务请求处理方法、装置、计算机设备和存储介质
CN110673987A (zh) 数据库的恢复方法、装置、设备和存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20908530

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20908530

Country of ref document: EP

Kind code of ref document: A1