Blockchain data storage, update, reading method and device, electronic device

By storing business orders in a database outside the blockchain and performing concurrent control, the storage consumption and performance problems during idempotent protection processing on the blockchain are solved, and efficient idempotent protection processing is achieved.

CN115115429BActive Publication Date: 2025-05-06ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210764531.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-29
Publication Date
2025-05-06
Estimated Expiration
2042-06-29

AI Technical Summary

Technical Problem

When idempotent protection processing of business orders on blockchain, the relationship between business orders and their associated business requests needs to be stored, resulting in an increase in blockchain storage consumption and affecting processing performance.

Method used

By storing business orders in the database mounted by the business system outside the blockchain, and reusing the concurrency control logic of the database, concurrently controlling the business orders is completed, thus completing idempotent protection processing outside the blockchain.

Benefits of technology

It reduces the on-chain storage resource consumption when idempotent protection of business orders, improves processing performance, and makes up for the shortcomings of insufficient concurrency capabilities on the blockchain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115115429B_ABST
    Figure CN115115429B_ABST
Patent Text Reader

Abstract

A business processing method is applied to a business system connected to a blockchain, wherein the business system is equipped with a database for storing business orders. The method comprises: in response to a user's business operation on a target business order, executing a concurrent control logic corresponding to the database, performing concurrent control on the target business order stored in the database, so as to trigger a target business request for the target business order that contains a unique business identifier and uniquely corresponds to the target business order; creating a blockchain transaction uniquely corresponding to the target business request; and submitting the created blockchain transaction to a node device in the blockchain so that the node device in the blockchain executes the blockchain transaction, thereby completing business processing on the target business order on the blockchain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of this specification relate to the field of blockchain technology, and in particular, to a blockchain data storage, update, and reading method and device, and electronic device. Background Art

[0002] Order idempotency protection: refers to the fact that in actual business scenarios, for a business order, there can be multiple corresponding business requests, but for the business system, it is necessary to ensure that only one of these multiple business requests can be successfully executed. If the business request fails to execute due to various reasons, the business request can be re-initiated until the business request is successfully executed. In actual business systems, idempotency protection of generated orders is a very critical processing link. If the generated orders are not processed with idempotency protection, or idempotency protection processing fails, serious problems may occur. Summary of the invention

[0003] This specification proposes a business processing method, which is applied to a business system connected to a blockchain, wherein the business system is equipped with a database for storing business orders, and the method includes:

[0004] Step A, in response to a user's business operation on a target business order, executing a concurrency control logic corresponding to the database, performing concurrency control on the target business order stored in the database, so as to trigger a target business request for the target business order that contains a unique business identifier and uniquely corresponds to the target business order;

[0005] Step B, creating a blockchain transaction uniquely corresponding to the target business request;

[0006] Step C, submitting the created blockchain transaction to the node device in the blockchain, so that the node device in the blockchain executes the blockchain transaction and completes the business processing for the target business order on the blockchain.

[0007] This specification also proposes a business processing device, which is applied to a business system connected to a blockchain, wherein the business system is equipped with a database for storing business orders, and the device includes:

[0008] a concurrency control module, in response to a user's business operation on a target business order, executing a concurrency control logic corresponding to the database, and performing concurrency control on the target business order stored in the database, so as to trigger, for the target business order, a target business request containing a unique business identifier and uniquely corresponding to the target business order;

[0009] A transaction creation module, which creates a blockchain transaction uniquely corresponding to the target business request;

[0010] The transaction submission module submits the created blockchain transaction to the node device in the blockchain, so that the node device in the blockchain executes the blockchain transaction and completes the business processing for the target business order on the blockchain.

[0011] This specification also proposes an electronic device, comprising:

[0012] processor;

[0013] a memory for storing processor-executable instructions;

[0014] The processor executes the executable instructions to implement the following steps:

[0015] In response to a business operation of a user on a target business order, executing a concurrency control logic corresponding to the database, and performing concurrency control on the target business order stored in the database, so as to trigger a target business request for the target business order that contains a unique business identifier and uniquely corresponds to the target business order;

[0016] Creating a blockchain transaction uniquely corresponding to the target business request;

[0017] Submit the created blockchain transaction to the node device in the blockchain so that the node device in the blockchain executes the blockchain transaction and completes the business processing for the target business order on the blockchain.

[0018] This specification also proposes a computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the following steps are implemented:

[0019] In response to a business operation of a user on a target business order, executing a concurrency control logic corresponding to the database, and performing concurrency control on the target business order stored in the database, so as to trigger a target business request for the target business order that contains a unique business identifier and uniquely corresponds to the target business order;

[0020] Creating a blockchain transaction uniquely corresponding to the target business request;

[0021] Submit the created blockchain transaction to the node device in the blockchain so that the node device in the blockchain executes the blockchain transaction and completes the business processing for the target business order on the blockchain.

[0022] The above technical solution has the following technical effects:

[0023] For business orders that need to be processed on the blockchain, there is no need to perform idempotent protection on the blockchain. Instead, the business orders can be stored in a database installed in a business system outside the blockchain, and the database's own concurrency control logic can be reused to perform concurrency control on the business orders. Idempotent protection for the business orders can be completed outside the blockchain, thereby reducing the on-chain storage resources consumed when performing idempotent protection on the business orders and improving the processing performance when performing idempotent protection on the business orders. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 This is a tree structure diagram of an MPT tree provided by an exemplary embodiment.

[0025] Figure 2 is a schematic structural diagram of an electronic device provided by an exemplary embodiment;

[0026] Figure 3 It is a block diagram of a service processing device provided by an exemplary embodiment. DETAILED DESCRIPTION

[0027] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0028] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.

[0029] In actual business systems, idempotent protection of generated orders is a very critical processing link. If idempotent protection is not performed on the generated orders, or idempotent protection fails, serious problems may occur.

[0030] For example, taking the above-mentioned business as a payment business, if the payment of the order is not processed with idempotent protection, or the idempotent protection processing fails, it may cause multiple payment requests corresponding to the same order to be successfully executed, causing financial losses to the user.

[0031] With the development of blockchain technology, more and more businesses are being deployed on blockchain in a decentralized manner; for example, the business can be deployed on blockchain in the form of smart contracts. The business orders generated by the business usually also need to be processed on the blockchain. Therefore, it is very important to perform idempotent protection on the business orders related to the business deployed on the blockchain.

[0032] In practical applications, in order to perform idempotent protection processing on business orders on the blockchain, it is usually necessary to store the business order and the association relationship of the business request triggered by the business order in the blockchain, and then complete the idempotent protection processing for the business order on the blockchain based on the association relationship.

[0033] For example, taking the above-mentioned business deployed on the blockchain in the form of a smart contract as an example, all business orders and the association relationship of the business requests triggered for the business order can be stored in the state data maintained by the smart contract, and idempotent protection processing logic for the business order can be developed in the smart contract. Then, in the process of calling the smart contract to perform business processing on the business order, the idempotent protection processing logic can be executed to perform idempotent protection processing on the business order based on the above-mentioned association relationship.

[0034] However, since idempotent protection is required for business orders that need to be processed on the blockchain, all business orders and the associated relationships of business requests triggered for the business orders need to be stored on the blockchain. Therefore, as the number of orders continues to increase, the storage consumption on the blockchain will increase exponentially, which will eventually affect the performance of idempotent protection processing of business orders.

[0035] In view of this, this specification proposes a technical solution for idempotent protection of business orders that need to be processed on the blockchain by reusing the storage and concurrency control capabilities of the database outside the chain.

[0036] During implementation, the business system connected to the blockchain can be equipped with a database for storing business orders.

[0037] When a user initiates a business operation for a target business order in the business system, the business system can execute the concurrency control logic corresponding to the above-mentioned database in response to the user's business operation for the target business order, and perform concurrency control on the target business order stored in the database to ensure that a target business request containing a unique business identifier and uniquely corresponding to the target business order is triggered for the target business order.

[0038] Then, a blockchain transaction uniquely corresponding to the target business request can be further created, and the created blockchain transaction can be submitted to the node device in the blockchain so that the node device in the blockchain executes the blockchain transaction and completes the business processing for the target business order on the blockchain.

[0039] In the above technical solution, for business orders that need to be processed on the blockchain, it is not necessary to perform idempotent protection on the blockchain. Instead, the business orders can be stored in a database installed in a business system outside the blockchain, and the database's own concurrency control logic can be reused to perform concurrency control on the business orders. Idempotent protection for the business orders can be completed outside the blockchain, thereby reducing the on-chain storage resources consumed when performing idempotent protection on the business orders and improving the processing performance when performing idempotent protection on the business orders.

[0040] Moreover, since the database of the business system has mature concurrency control capabilities, different business orders stored in the database can still be processed concurrently, thus making up for the lack of concurrency when processing business orders on the blockchain, thereby significantly improving the efficiency of business processing of business orders.

[0041] See also Figure 1 , Figure 1 This is a flowchart of a business processing method provided by an exemplary embodiment. The method is applied to a business system connected to a blockchain, and the business system is equipped with a database for storing business orders; the method includes the following steps:

[0042] Step 102, in response to a user's business operation on a target business order, executing a concurrency control logic corresponding to the database, performing concurrency control on the target business order stored in the database, so as to trigger a target business request for the target business order that contains a unique business identifier and uniquely corresponds to the target business order;

[0043] The above-mentioned business may specifically include any type of order-based business that can be deployed on the blockchain. The so-called order-based business refers to a business type that creates orders based on specific business needs and processes the created orders. The above-mentioned business operations may specifically be any type of operations for the above-mentioned target business orders, and are not particularly limited in this specification; for example, in one example, the above-mentioned business operations may specifically be payment operations. Correspondingly, the above-mentioned unique business identifier may specifically be a unique payment order identifier. Of course, in addition to payment operations, other forms of operations such as locking and unlocking the above-mentioned target business orders may also be specifically performed, which will not be listed one by one in this specification.

[0044] The target business request may specifically be a business request that matches the type of the business operation triggered after the business operation is performed on the target business order; for example, taking the business operation as a payment operation, the target business request may specifically be a target payment request corresponding to the payment operation. The business process may specifically be a payment process flow.

[0045] Among them, when the above-mentioned business operation is a payment operation, the specific payment scenario involved is not particularly limited in this specification. For example, in one example, the above-mentioned business may specifically be a ticket purchase business, and in this case, the above-mentioned target business order may be a ticket purchase order. The above-mentioned target business order may be a ticket purchase order. And the above-mentioned business operation may be a ticket purchase payment operation for the above-mentioned ticket purchase order. Correspondingly, the above-mentioned target business request may specifically be a ticket purchase payment request for the ticket purchase order. And the above-mentioned business processing may be a payment processing flow for the ticket purchase order. In addition, the above-mentioned business processing may also include a processing flow for issuing an electronic voucher corresponding to the purchased ticket to the user after the above-mentioned payment process is completed.

[0046] In this specification, a user can perform a business operation on a target business order stored in the above-mentioned database in the above-mentioned business system to trigger business processing of the target business order. After the user initiates a business operation on the above-mentioned target business order in the business system, the business system can respond to the user's business operation on the target business order, use the concurrency control capability of the above-mentioned database itself, execute the concurrency control logic corresponding to the above-mentioned database, and perform concurrency control on the target business order stored in the database to complete the idempotent protection processing for the above-mentioned target business order.

[0047] It should be explained that, in order to perform idempotent protection on the target business order, it is usually necessary to ensure that a target business request containing a unique business identifier and uniquely corresponding to the target business order is triggered for the target business order. That is, for a business order that needs to perform a business operation, it is necessary to ensure that only one target business request containing a unique business identifier and uniquely corresponding to the business order is generated at the same time.

[0048] The concurrency control scheme used when performing concurrency control on the target business orders stored in the database is not specifically limited in this specification. In practical applications, different types of databases usually support different concurrency control schemes. Therefore, when those skilled in the art implement the technical solution of this specification, they can flexibly select a concurrency control scheme based on the specific type of the above database.

[0049] In one embodiment shown, the above database may specifically adopt a relational database; for example, a MySQL database may be adopted. For a relational database, when performing concurrency control on data stored in the database, it can usually be implemented based on various lock mechanisms supported by the database. Therefore, in this specification, concurrency control on business orders stored in the database may be implemented based on pessimistic locks supported by the database.

[0050] In this case, the concurrency control logic may be based on the business logic of concurrent protection of pessimistic lock supported by the database, wherein the business logic may be used to trigger a target business request for the target business order that contains a unique business identifier and uniquely corresponds to the target business order.

[0051] It should be explained that pessimistic locking is a locking technology with strong exclusive and exclusive characteristics. When using pessimistic locking to protect a section of execution logic concurrently, it can usually be achieved by adding a pessimistic lock to this section of execution logic. Once a pessimistic lock is added to this section of execution logic, when different threads try to execute this section of execution logic at the same time, only one thread will be able to execute this section of execution logic, and the other threads will wait until the pessimistic lock added to this section of execution logic is released.

[0052] In this specification, the above business logic is protected concurrently through pessimistic locking, which can specifically ensure that only one thread can execute the above business logic at the same time, thereby ensuring that only one target business request containing a unique business identifier and uniquely corresponding to the business order can be triggered for a business order at the same time.

[0053] Of course, in practical applications, the above database may also be a non-relational database. When performing concurrency control on the data stored in the database, other types of lock technologies other than pessimistic locks may also be used, which are not particularly limited in this specification. For example, in one example, the above database may be a non-relational database such as Redis. In this case, a distributed lock solution may be used to perform concurrency control on the business orders stored in the database.

[0054] As mentioned above, the above business logic can be specifically used to trigger a target business request for the above target business order that contains a unique business identifier and uniquely corresponds to the above target business order, and the specific execution process corresponding to the above business logic is not specifically limited in this specification. In practical applications, when implementing the technical solution of this specification, those skilled in the art can use triggering a target business request for the above target business order that contains a unique business identifier and uniquely corresponds to the above target business order as a specific implementation target to flexibly determine the above execution process.

[0055] In this embodiment, the database can be used to store business orders and business requests associated with the business orders. The business orders and business requests associated with the business orders stored in the database can be used to perform idempotent protection on the business orders stored in the database to ensure that a target business request containing a unique business identifier and uniquely corresponding to the target business order is triggered for the target business order.

[0056] It should be noted that triggering a target business request containing a unique business identifier and uniquely corresponding to the target business order for the target business order specifically means that a business order in the database can only trigger a corresponding business request, and the business request also needs to contain a unique business identifier that can uniquely identify the business request.

[0057] In actual applications, when performing idempotent protection processing on the target business order stored in the database, it is usually necessary to create a unique corresponding target business request for the target business order, and store the target business request in association with the target business order in the database. Therefore, if the business logic is divided according to whether the target business request associated with the target business order is stored in the database, the business logic may specifically include the following two execution logic branches:

[0058] 1) The database does not store the logical branch of the target business request associated with the above target business order

[0059] Under this logic branch, the above business logic may specifically include the execution logic shown below:

[0060] Determining whether a target business request associated with the target business order is stored in the database;

[0061] If the target service request associated with the target service order is not stored in the database, generating a target service request including a unique service identifier and uniquely corresponding to the target service order for the target service order stored in the database;

[0062] The generated target business request is stored in association with the target business order in the database, and after the target business request is stored in association with the target business order in the database, the process jumps to step 104 to continue execution.

[0063] In an embodiment shown, under this logic branch, in addition to the execution process described above, the business logic may further include the following execution logic:

[0064] Before determining whether the target service request associated with the target service order is stored in the database, it may also be determined whether the target service order is stored in the database;

[0065] If the target service order is not stored in the database, the target service order is created in the database, and it is further determined whether a target service request associated with the target service order is stored in the database.

[0066] If the target service order is stored in the database, it is further determined whether a target service request associated with the target service order is stored in the database.

[0067] 2) The database stores the logical branches of the target business request associated with the above target business order

[0068] The business system may also maintain an order status corresponding to the target business order stored in the database. The order status may specifically include a first status indicating that the blockchain transaction corresponding to the target business request has been submitted to the node device in the blockchain; a second status indicating that the blockchain transaction corresponding to the target business request has failed to execute; and a third status indicating that the blockchain transaction corresponding to the target business request has been successfully executed.

[0069] When the target business request associated with the target business order is stored in the database, the next step of processing for the target business order can be determined based on the order status of the target business order.

[0070] Under this logic branch, the above business logic may specifically include the execution logic shown below:

[0071] If the target business request associated with the target business order is stored in the database, the order status corresponding to the target business order may be further determined.

[0072] Case 1: If the order status corresponding to the target business order is the first status, the process may jump to step 104 to continue the execution.

[0073] In this case, since the first state indicates that the blockchain transaction corresponding to the target business request has been submitted to the node device in the blockchain, it may be that the blockchain transaction submitted to the blockchain has not been executed yet, and the business system has not yet obtained the execution result of the blockchain transaction. Therefore, by executing the execution process described in the above situation 1, you can continue to follow the target business request stored in the database associated with the target business order to recreate the blockchain transaction uniquely corresponding to the target business request, and submit the created blockchain transaction to the node device in the blockchain.

[0074] In this way, when it is confirmed that the blockchain transaction corresponding to the above-mentioned target business request has been submitted to the node device in the blockchain, but the transaction has not been executed for some reason and the business system has not obtained the execution result of the blockchain transaction, the blockchain transaction can be resubmitted to the node device in the blockchain according to the target business request stored in the database associated with the above-mentioned target business order until the submitted blockchain transaction is successfully executed.

[0075] Case 2: If the order status corresponding to the target service order is the second status, the unique service identifier contained in the target service request stored in association with the target service order in the database is modified to a new unique service identifier, and the process jumps to step 104 to continue execution;

[0076] In this case, since the second status indicates that the blockchain transaction corresponding to the target business request has failed to execute, the unique business identifier contained in the target business request stored in the database associated with the target business order can be modified to a new unique business identifier. After the modification is completed, the blockchain transaction uniquely corresponding to the target business request can be re-created according to the target business request stored in the database associated with the target business order, and the created blockchain transaction can be submitted to the node device in the blockchain.

[0077] In this way, when it is confirmed that the blockchain transaction corresponding to the above-mentioned target business request has failed to execute, the unique business identifier contained in the target business request stored in the database associated with the above-mentioned target business order can be modified to a new unique business identifier, and then the blockchain transaction can continue to be submitted to the node device in the blockchain according to the modified target business request stored in the database associated with the above-mentioned target business order until the submitted blockchain transaction is successfully executed.

[0078] Case 3: If the order status corresponding to the above target business order is the above third status, the execution result of the above blockchain transaction is returned to the user.

[0079] In this case, since the second state is used to indicate that the blockchain transaction corresponding to the target business request has been successfully executed, the business processing for the target business order has been completed at this time, and the execution result of the blockchain transaction can be directly returned to the user.

[0080] Please continue to see Figure 2 In one embodiment shown, in order to limit the modification authority of the unique business identifier contained in the target business request stored in the database in association with the target business order, under this logic branch, the business logic may further include the execution logic shown below:

[0081] If the order status of the target service order is the first status, the modification authority for the unique service identifier contained in the target service request stored in association with the target service order in the database is disabled.

[0082] In this way, since the order status of the above-mentioned target business order is the above-mentioned first status, the blockchain transaction corresponding to the target business request stored in association with the target business order has been submitted to the node device in the blockchain, and the blockchain transaction may not be completed for some reason; therefore, in this case, if the modification permission for the unique business identifier contained in the above-mentioned target business request is opened at this time, it may cause the blockchain transaction corresponding to the above-mentioned target business request to be submitted to the blockchain but not yet completed, and the unique business identifier contained in the target business request has been modified. If so, it may happen that a business order has two corresponding business requests that have not been processed, resulting in the problem that the business request corresponding to the business order does not have idempotence.

[0083] It can be seen that by disabling the modification permission for the unique business identifier contained in the above-mentioned target business request stored in association with the target business order in the database when the order status of the target business order is the first state, it is fundamentally prevented that the unique business identifier contained in the business request is modified before a business request is processed, thereby ensuring that the business request corresponding to the business order has idempotence.

[0084] In one embodiment shown, when the business system is executing the business logic and performing concurrent control on the target business order, if it receives a modification request from a user for the unique business identifier contained in the target business request stored in the database associated with the target business order, it can determine whether the order status of the target business order is the first status; if so, the modification permission for the target business request has been disabled, and the business system can directly return the first status to the user; or, it can also return a prompt message to the user indicating that the modification of the unique business identifier has failed or a prompt message indicating that the unique business identifier cannot be modified. Step 104: Create a blockchain transaction that uniquely corresponds to the target business request;

[0085] When the business system triggers a target business request containing a unique business identifier and uniquely corresponding to the target business order for the target business order by executing the above-mentioned concurrent control logic, a blockchain transaction uniquely corresponding to the target business request can be further created.

[0086] It should be noted that creating a unique corresponding blockchain transaction for the target business request specifically refers to a target business request, for which only one corresponding blockchain transaction is allowed to be created.

[0087] In actual applications, in order to ensure the idempotence of the triggered business request corresponding to the business order, the business system usually assigns a unique business identifier to the business request, and uses the unique business identifier to ensure the uniqueness of the business request; for example, the unique business identifier can be bizid. That is, the business system outside the chain usually ensures the idempotence of the triggered business request by assigning a unique business identifier to the triggered business request.

[0088] As for blockchain, in order to ensure the idempotence of blockchain transactions submitted to the blockchain, an idempotence field is usually designed in the transaction format of the blockchain transaction, and a dense and increasing random number is filled in the idempotence field to ensure the idempotence of the blockchain transaction.

[0089] For example, most blockchain platforms that currently adopt the account model (such as Ant Chain) usually involve a nonce field in the transaction format of the blockchain transaction. The nonce field is used to fill in a densely incremented nonce value assigned to the blockchain transaction. Each time a user account initiates a new blockchain transaction, the nonce value will be densely incremented in steps of 1, thereby ensuring that each transaction initiated by a user account is unique, so as to ensure the idempotence of blockchain transactions submitted to the blockchain.

[0090] It is not difficult to understand from the above description that in actual applications, there are certain differences between the idempotence mechanism supported by the off-chain business system and the idempotence mechanism supported by the blockchain. Based on this difference, in this specification, when the above-mentioned business system creates a corresponding blockchain transaction for the above-mentioned target business request, in order to ensure the idempotence of the blockchain transaction (that is, to ensure that a business request can only have a unique corresponding blockchain transaction published on the blockchain), it can be specifically converted between the idempotence mechanism supported by the business system and the idempotence mechanism supported by the blockchain to create a unique corresponding blockchain transaction for the triggered target business request.

[0091] For example, in actual applications, the above-mentioned business system can support a reliable on-chain protocol, which refers to a layer of conversion protocol between the idempotence mechanism supported by the business system outside the chain and the idempotence mechanism supported by the blockchain. When the above-mentioned business system creates a unique corresponding blockchain transaction for the triggered target business request, it can convert the above-mentioned target business request generated by triggering the idempotence mechanism supported by the business system into a blockchain transaction generated by triggering the idempotence mechanism supported by the blockchain by running the reliable on-chain protocol. For example, in one example, the business system can package the above-mentioned target business request into a blockchain transaction according to the format of the blockchain transaction, and then add a nonce value assigned to the blockchain transaction according to the idempotence mechanism supported by the blockchain to ensure the idempotence of the blockchain transaction.

[0092] It should be noted that the idempotence mechanism supported by the blockchain, in addition to the mechanism described above of designing an idempotence field in the transaction format of the blockchain transaction and filling the idempotence field with a dense and increasing random number, other forms of idempotence mechanisms may also be adopted in practical applications, which are no longer listed one by one in this specification; for example, in one example, in some blockchain platforms, a timestamp or time window corresponding to the transaction sending time may be added to the blockchain transaction to ensure the idempotence of the blockchain transaction.

[0093] Step 106: Submit the created blockchain transaction to the node device in the blockchain so that the node device in the blockchain executes the blockchain transaction and completes the business processing for the target business order on the blockchain.

[0094] When the business system creates a unique corresponding blockchain transaction for the triggered target business request, the blockchain transaction can be submitted to the node devices in the blockchain, and the node devices in the blockchain will execute the blockchain transaction in a distributed manner to complete the business processing for the target business order on the blockchain.

[0095] In this specification, after the business system submits the above-mentioned blockchain transaction to the node device in the blockchain for execution, the business system can obtain the execution feedback of the blockchain transaction and determine the business processing progress for the above-mentioned target business order based on the execution feedback.

[0096] In one embodiment shown, in addition to maintaining the above three states, the business system can also maintain state machines corresponding to the above three states, and complete the switching of the above three states according to the execution of the above blockchain transactions.

[0097] In one case, when the business system obtains a transaction receipt returned by a node device in the blockchain indicating that the above-mentioned blockchain transaction has been successfully submitted to the node device, the order state corresponding to the above-mentioned target business order can be switched to the first state in response to the obtained transaction receipt. In another case, when the business system obtains an execution result of the above-mentioned blockchain transaction failure returned by a node device in the blockchain, the order state corresponding to the above-mentioned target business order can be switched from the first state to the second state in response to the obtained transaction execution result of the transaction failure. In the third case, when the business system obtains an execution result of the above-mentioned blockchain transaction success returned by a node device in the blockchain, the order state corresponding to the above-mentioned target business order can be switched from the first state to the third state in response to the obtained transaction execution result of the blockchain transaction success.

[0098] In one embodiment shown, in order to ensure the idempotence of the above-mentioned blockchain transaction created, and to ensure that only one corresponding blockchain transaction can be published on the blockchain for a business request, the above-mentioned business system can also perform an idempotence check on the created blockchain transaction before submitting the created blockchain transaction to the node device in the blockchain to determine whether the blockchain transaction is a historical transaction successfully submitted to the node device in the blockchain; if the blockchain transaction is not a historical transaction successfully submitted to the node device in the blockchain, the created blockchain transaction can be further submitted to the node device in the blockchain for execution. On the contrary, if the blockchain transaction is a historical transaction successfully submitted to the node device in the blockchain, the submission of the blockchain transaction to the node device in the blockchain can be terminated at this time. For example, in this case, it may be because the unique business identifier contained in the above-mentioned business request is a submitted historical business identifier. At this time, the business system can re-modify the unique identifier contained in the business request and modify the unique business identifier contained in the business request to a new unique business identifier.

[0099] By introducing an idempotence check on the blockchain transaction before submitting it to a node device in the blockchain for execution, it can be ensured that each blockchain transaction submitted is a new blockchain transaction, and it can be avoided that historical transactions are submitted to a node device in the blockchain for repeated execution.

[0100] In one embodiment shown, the process of completing the business processing for the target business order on the blockchain can be completed by calling the smart contract deployed on the blockchain. In this case, a smart contract for business management for the business order can be deployed on the blockchain. The blockchain transaction created by the business system can be a contract call transaction corresponding to the smart contract.

[0101] In this case, after the above-mentioned business system submits the created contract call transaction to the node device in the blockchain, the node device in the blockchain can respond to the contract call transaction and execute the contract code contained in the smart contract in a distributed manner to complete the business processing for the target business order on the blockchain.

[0102] In the above technical solution, for business orders that need to be processed on the blockchain, it is not necessary to perform idempotent protection on the blockchain. Instead, the business orders can be stored in a database installed in a business system outside the blockchain, and the database's own concurrency control logic can be reused to perform concurrency control on the business orders. Idempotent protection for the business orders can be completed outside the blockchain, thereby reducing the on-chain storage resources consumed when performing idempotent protection on the business orders and improving the processing performance when performing idempotent protection on the business orders.

[0103] For example, compared to blockchain, existing databases usually have cheaper storage and more mature concurrency control capabilities. Therefore, by reusing the storage and concurrency control capabilities of the database outside the chain, compared to the solution of idempotent protection of business orders on the blockchain, it is obvious that in addition to reducing storage costs, it can also improve the processing performance of idempotent protection of business orders.

[0104] Moreover, since the database of the business system has mature concurrency control capabilities, different business orders stored in the database can still be processed concurrently, thus making up for the lack of concurrency when processing business orders on the blockchain, thereby significantly improving the efficiency of business processing of business orders.

[0105] For example, in actual applications, although transactions in the blockchain can be executed concurrently, the blockchain is limited by its own special operating mechanism, and its concurrency capability is usually much lower than that of the database outside the chain. Therefore, using the database outside the chain to perform concurrent control processing on business orders can obviously make up for the lack of concurrency when processing business orders on the blockchain to the greatest extent.

[0106] Corresponding to the above method embodiments, the present application also provides device embodiments.

[0107] The embodiments of the device of this specification can be applied to electronic devices. The device embodiments can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, the processor of the electronic device in which it is located reads the corresponding computer program instructions in the non-volatile memory into the memory and runs them.

[0108] From the hardware level, Figure 2 The figure is a hardware structure diagram of the electronic device where the device of this manual is located, except Figure 2 In addition to the processor, memory, network interface, and non-volatile memory shown, the electronic device in which the device in the embodiment is located may also include other hardware according to the actual function of the electronic device, which will not be described in detail.

[0109] Figure 3 It is a block diagram of a service processing device shown in an exemplary embodiment of this specification.

[0110] Please refer to Figure 3 The service processing device 300 can be applied in the aforementioned Figure 2 In the electronic device shown, the device 30 includes:

[0111] The concurrency control module 301 executes the concurrency control logic corresponding to the database in response to the user's business operation on the target business order, performs concurrency control on the target business order stored in the database, and triggers a target business request containing a unique business identifier and uniquely corresponding to the target business order for the target business order;

[0112] A transaction creation module 302 is used to create a blockchain transaction uniquely corresponding to the target business request;

[0113] The transaction submission module 303 submits the created blockchain transaction to the node device in the blockchain, so that the node device in the blockchain executes the blockchain transaction and completes the business processing for the target business order on the blockchain.

[0114] In this embodiment, the concurrency control logic includes a business logic for concurrency protection based on pessimistic locking supported by the database; wherein the business logic is used to trigger a target business request for the target business order that contains a unique business identifier and uniquely corresponds to the target business order. In this embodiment, the database is used to store business orders and business requests associated with the business orders;

[0115] The business logic includes:

[0116] determining whether a target service request associated with the target service order is stored in the database;

[0117] If the target service request associated with the target service order is not stored in the database, generating a target service request containing a unique service identifier and uniquely corresponding to the target service order for the target service order stored in the database;

[0118] The generated target business request is associated with the target business order and stored in the database. After the target business request is associated with the target business order and stored in the database, the process jumps to the transaction creation module 302 for further execution.

[0119] In this embodiment, the business logic further includes:

[0120] Before determining whether the target business request associated with the target business order is stored in the database, determine whether the target business order is stored in the database; if the target business order is not stored in the database, create the target business order in the database, and further determine whether the target business request associated with the target business order is stored in the database; if the target business order is stored in the database, further determine whether the target business request associated with the target business order is stored in the database.

[0121] In this embodiment, the business system further maintains an order status corresponding to the target business order stored in the database; wherein the order status includes a first status for indicating that the blockchain transaction corresponding to the target business request has been submitted to the node device in the blockchain; a second status for indicating that the blockchain transaction corresponding to the target business request has failed to execute; and a third status for indicating that the blockchain transaction corresponding to the target business request has been successfully executed;

[0122] The business logic also includes:

[0123] If the target service request associated with the target service order is stored in the database, further determining an order status corresponding to the target service order;

[0124] If the order status corresponding to the target business order is the first status, jump to the transaction creation module 302 to continue execution;

[0125] If the order status corresponding to the target business order is the second status, the unique business identifier contained in the target business request stored in association with the target business order in the database is modified to a new unique business identifier, and the process jumps to the transaction creation module 302 for further execution;

[0126] If the order status corresponding to the target business order is the third status, the execution result of the blockchain transaction is returned to the user.

[0127] In this embodiment, the device further includes:

[0128] State maintenance module 304 ( Figure 3 (not shown in the figure), in response to the transaction receipt obtained that the blockchain transaction has been successfully submitted to the node device in the blockchain, the maintained order status corresponding to the target business order is switched to the first state; in response to the transaction execution result obtained that the blockchain transaction fails to execute, the maintained order status corresponding to the target business order is switched from the first state to the second state; in response to the transaction execution result obtained that the blockchain transaction is successfully executed, the maintained order status corresponding to the target business order is switched from the first state to the third state.

[0129] In this embodiment, the business logic further includes:

[0130] If the order status of the target service order is the first status, the modification authority for the unique service identifier contained in the target service request stored in the database in association with the target service order is disabled.

[0131] In this embodiment, the transaction submission module 303 further:

[0132] Before submitting the created blockchain transaction to the node device in the blockchain, an idempotence check is performed on the created blockchain transaction to determine whether the blockchain transaction is a historical transaction successfully submitted to the node device in the blockchain; if not, further executing the step of submitting the created blockchain transaction to the node device in the blockchain.

[0133] In this embodiment, a smart contract for performing business management on the business order is deployed on the blockchain; the blockchain transaction includes a contract call transaction;

[0134] The transaction submission module 303 further:

[0135] The created contract call transaction is submitted to the node device in the blockchain, so that the node device in the blockchain responds to the contract call transaction and executes the contract code contained in the smart contract to complete the business processing for the target business order.

[0136] In this embodiment, the business operation includes a payment operation; the target business request includes a payment request for the target business order; and the business processing includes a payment processing flow.

[0137] In this embodiment, the target business order includes a ticket purchase order; the business operation includes a ticket payment operation for the ticket purchase order; the target business request includes a ticket payment request for the ticket purchase order; the business processing includes a payment processing flow for the ticket purchase order; and, after the payment processing flow is completed, a processing flow for issuing an electronic voucher corresponding to the purchased ticket to the user.

[0138] In this embodiment, the database includes a relational database. The systems, devices, modules or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.

[0139] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0140] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0141] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0142] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0143] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0144] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0145] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0146] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.

Claims

1. A business processing method, applied to a business system connected to a blockchain, wherein the business system is equipped with a database for storing business orders, and the method comprises: Step A, in response to a user's business operation on a target business order, executing a concurrency control logic corresponding to the database, and performing concurrency control on the target business order stored in the database, so as to trigger a target business request for the target business order that contains a unique business identifier and uniquely corresponds to the target business order; wherein the concurrency control logic includes: when the database is a relational database, a business logic for performing concurrency protection based on a pessimistic lock supported by the database, and when the database is a non-relational database, a business logic for performing concurrency protection based on a distributed lock supported by the database; Step B, creating a blockchain transaction uniquely corresponding to the target business request; Step C, submitting the created blockchain transaction to the node device in the blockchain, so that the node device in the blockchain executes the blockchain transaction and completes the business processing for the target business order on the blockchain.

2. The method according to claim 1, wherein the business logic is used to trigger a target business request for the target business order that contains a unique business identifier and uniquely corresponds to the target business order; The database is used to store business orders and business requests associated with the business orders; The business logic includes: Determining whether a target service request associated with the target service order is stored in the database; If the target service request associated with the target service order is not stored in the database, generating a target service request containing a unique service identifier and uniquely corresponding to the target service order for the target service order stored in the database; The generated target business request is stored in association with the target business order in the database, and after the target business request is stored in association with the target business order in the database, the process jumps to step B for further execution.

3. The method according to claim 2, wherein the business logic further comprises: Before determining whether the target business request associated with the target business order is stored in the database, determine whether the target business order is stored in the database; if the target business order is not stored in the database, create the target business order in the database, and further determine whether the target business request associated with the target business order is stored in the database; if the target business order is stored in the database, further determine whether the target business request associated with the target business order is stored in the database.

4. According to the method of claim 2, the business system further maintains an order status corresponding to the target business order stored in the database; wherein, The order status includes a first status for indicating that the blockchain transaction corresponding to the target business request has been submitted to a node device in the blockchain; A second status for indicating that the blockchain transaction corresponding to the target business request has failed to execute; and, a third state for indicating that the blockchain transaction corresponding to the target business request has been successfully executed; The business logic also includes: If the target service request associated with the target service order is stored in the database, further determining an order status corresponding to the target service order; If the order status corresponding to the target business order is the first status, jump to step B to continue execution; If the order status corresponding to the target service order is the second status, the unique service identifier contained in the target service request stored in association with the target service order in the database is modified to a new unique service identifier, and the process jumps to step B for further execution; If the order status corresponding to the target business order is the third status, the execution result of the blockchain transaction is returned to the user.

5. The method according to claim 4, further comprising: In response to the acquired transaction receipt indicating that the blockchain transaction has been successfully submitted to the node device in the blockchain, switching the maintained order state corresponding to the target business order to the first state; In response to the acquired transaction execution result indicating that the blockchain transaction execution failed, switching the maintained order state corresponding to the target business order from the first state to a second state; In response to the acquired transaction execution result indicating successful execution of the blockchain transaction, the maintained order state corresponding to the target business order is switched from the first state to a third state.

6. The method according to claim 4, wherein the business logic further comprises: If the order status of the target service order is the first status, the modification authority for the unique service identifier contained in the target service request stored in the database in association with the target service order is disabled.

7. The method according to claim 1, before submitting the created blockchain transaction to the node device in the blockchain, further comprises: Performing an idempotence check on the created blockchain transaction to determine whether the blockchain transaction is a historical transaction successfully submitted to a node device in the blockchain; If not, further perform the step of submitting the created blockchain transaction to the node device in the blockchain.

8. According to the method of claim 7, a smart contract for business management of the business order is deployed on the blockchain; the blockchain transaction includes a contract call transaction; Submitting the created blockchain transaction to a node device in the blockchain so that the node device in the blockchain executes the blockchain transaction and completes business processing for the target business order on the blockchain, including: The created contract call transaction is submitted to the node device in the blockchain, so that the node device in the blockchain responds to the contract call transaction and executes the contract code contained in the smart contract to complete the business processing for the target business order.

9. According to the method of claim 8, the business operation includes a payment operation; the target business request includes a payment request for the target business order; and the business processing includes a payment processing flow.

10. According to the method of claim 9, the target business order includes a ticket purchase order; the business operation includes a ticket payment operation for the ticket purchase order; the target business request includes a ticket payment request for the ticket purchase order; the business processing includes a payment processing flow for the ticket purchase order; and, after the payment processing flow is completed, a processing flow for issuing an electronic voucher corresponding to the purchased ticket to the user.

11. A business processing device, applied to a business system connected to a blockchain, wherein the business system is equipped with a database for storing business orders, and the device comprises: A concurrency control module, in response to a user's business operation on a target business order, executes a concurrency control logic corresponding to the database, performs concurrency control on the target business order stored in the database, so as to trigger a target business request for the target business order that contains a unique business identifier and uniquely corresponds to the target business order; wherein the concurrency control logic includes: when the database is a relational database, a business logic for performing concurrency protection based on a pessimistic lock supported by the database, and when the database is a non-relational database, a business logic for performing concurrency protection based on a distributed lock supported by the database; A transaction creation module, which creates a blockchain transaction uniquely corresponding to the target business request; The transaction submission module submits the created blockchain transaction to the node device in the blockchain, so that the node device in the blockchain executes the blockchain transaction and completes the business processing for the target business order on the blockchain.

12. An electronic device comprising: processor; a memory for storing processor-executable instructions; The processor implements the steps of the method according to any one of claims 1 to 10 by running the executable instructions.

13. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Invoice generation method and device

    CN110880131A

  • Online-offline collaborative electronic medical record data sharing method based on alliance chain

    CN112559627A