CN116091216A - Transaction data processing method, device, equipment and storage medium based on blockchain - Google Patents
Transaction data processing method, device, equipment and storage medium based on blockchain Download PDFInfo
- Publication number
- CN116091216A CN116091216A CN202211473359.1A CN202211473359A CN116091216A CN 116091216 A CN116091216 A CN 116091216A CN 202211473359 A CN202211473359 A CN 202211473359A CN 116091216 A CN116091216 A CN 116091216A
- Authority
- CN
- China
- Prior art keywords
- executed
- transaction
- target
- transactions
- transaction data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 44
- 238000003860 storage Methods 0.000 title claims abstract description 39
- 238000000034 method Methods 0.000 claims description 36
- 238000012545 processing Methods 0.000 claims description 30
- 230000008569 process Effects 0.000 claims description 20
- 238000013507 mapping Methods 0.000 claims description 16
- 238000004590 computer program Methods 0.000 description 13
- 230000006870 function Effects 0.000 description 10
- 238000010586 diagram Methods 0.000 description 8
- 230000009286 beneficial effect Effects 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 238000003491 array Methods 0.000 description 2
- 238000009826 distribution Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 230000009466 transformation Effects 0.000 description 2
- 241000699670 Mus sp. Species 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- Marketing (AREA)
- Signal Processing (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Computer Networks & Wireless Communication (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
The application discloses a transaction data processing method, device, equipment and storage medium based on a blockchain, wherein the transaction data processing method based on the blockchain comprises the following steps: acquiring a block to be executed; grouping all the transactions to be executed according to the target contract addresses corresponding to all the transactions to be executed in the blocks to be executed; executing all groups of transactions to be executed in parallel, generating transaction data, and storing the transaction data in a preset first cache; if the fact that the target transaction to be executed which is successful in the transaction to be executed exists in the transactions to be executed is determined, transaction data corresponding to the target transaction to be executed are stored in a preset second cache; and when all the transactions to be executed in the blocks to be executed are determined to be executed, writing the transaction data stored in the preset second buffer into an account book database. The technical problem that the transaction execution efficiency of the prior art blockchain is low is solved.
Description
Technical Field
The present disclosure relates to the field of blockchain technologies, and in particular, to a blockchain-based transaction data processing method, device, equipment, and storage medium.
Background
With the rapid development of computer technology, the security of transaction data is increasingly emphasized, and the blockchain is widely applied to the fields of finance, intelligent manufacturing, supply chain, logistics and the like due to the characteristics of decentralization, openness, autonomy, non-falsification of information and the like, and drives a new round of technology transformation and application transformation. However, when the block link points execute the transactions in the block after the consensus is completed, the transactions are usually required to be executed serially according to a specific order due to higher complexity of executing operations of the transactions, and the efficiency of executing the transactions serially is low, so that the processing performance of the block chain in actual application is low, and it is difficult to meet the requirements of the alliance chain on the processing performance in service scenes such as finance and supply chains.
Disclosure of Invention
The main purpose of the present application is to provide a transaction data processing method, device, equipment and storage medium based on blockchain, which aims to solve the technical problem of low transaction execution efficiency of blockchain in the prior art.
In order to achieve the above object, the present application provides a blockchain-based transaction data processing method, which includes:
Acquiring a block to be executed;
grouping all the transactions to be executed according to the target contract addresses corresponding to all the transactions to be executed in the blocks to be executed;
executing all groups of transactions to be executed in parallel, generating transaction data, and storing the transaction data in a preset first cache;
if the fact that the target transaction to be executed which is successful in the transaction to be executed exists in the transactions to be executed is determined, transaction data corresponding to the target transaction to be executed are stored in a preset second cache;
and when all the transactions to be executed in the blocks to be executed are determined to be executed, writing the transaction data stored in the preset second buffer into an account book database.
The application also provides a transaction data processing device based on the blockchain, which comprises:
the acquisition module is used for acquiring the block to be executed;
the grouping module is used for grouping all the transactions to be executed according to the target contract addresses corresponding to all the transactions to be executed in the block to be executed;
the first storage module is used for executing all groups of transactions to be executed in parallel, generating transaction data and storing the transaction data in a preset first cache;
The second storage module is used for storing transaction data corresponding to target transactions to be executed in a preset second cache if the target transactions to be executed with successful transactions exist in the transactions to be executed;
and the data writing module is used for writing the transaction data stored in the preset second cache into an account book database when all the transactions to be executed in the blocks to be executed are determined to be executed.
The application also provides an electronic device, which is an entity device, and includes: the system comprises a memory, a processor and a program of the block chain based transaction data processing method stored in the memory and capable of running on the processor, wherein the program of the block chain based transaction data processing method can realize the steps of the block chain based transaction data processing method when being executed by the processor.
The present application also provides a storage medium, which is a computer readable storage medium, where a program for implementing a blockchain-based transaction data processing method is stored on the computer readable storage medium, where the program for implementing the blockchain-based transaction data processing method implements the steps of the blockchain-based transaction data processing method as described above when executed by a processor.
The present application also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of a blockchain-based transaction data processing method as described above.
The application provides a transaction data processing method, device, equipment and storage medium based on a blockchain, wherein the grouping of the transactions to be executed in the blocks to be executed is realized by acquiring the blocks to be executed according to target contract addresses corresponding to the transactions to be executed in the blocks to be executed, then the transaction data are generated by parallel execution of the transactions to be executed, the transaction data are stored in a preset first cache, the parallel execution of the transactions to be executed is realized, the generated transaction data are stored in the preset first cache, further, the transaction data corresponding to the target transactions to be executed are stored in a preset second cache if the successful target transactions to be executed exist in the transactions to be executed, the transaction data of the successful target transactions to be executed are stored in the preset second cache, and then the transaction data stored in the second cache are written into an account book database when the completion of the execution of all the transactions to be executed in the blocks to be executed is determined, and the transaction database corresponding to the successful transaction to be executed is written after the successful transaction is executed in the preset second cache. Compared with serial execution, the method has the advantages that the execution data are directly written into the account book database, if the transaction fails and then the rollback is carried out, on one hand, the method can fully utilize the computing resources and doubly improve the transaction execution efficiency by parallel execution of each group of transactions to be executed after grouping through the target contract address, on the other hand, the method can only store the transaction data of the transactions to be executed which are successfully executed into the preset second cache, namely only the transaction data of the transactions to be executed which are successfully executed are written into the account book database, so that the transaction data of the transactions to be executed which are successfully executed are not written into the account book database, rollback operation is not needed, the transaction execution efficiency can be effectively improved, and the technical problem of lower transaction execution efficiency of block chains in the prior art is overcome.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a flow chart of an embodiment of a blockchain-based transaction data processing method of the present application;
FIG. 2 is a flow diagram of one embodiment of a blockchain-based transaction data processing method of the present application;
FIG. 3 is a flow chart of another embodiment of a blockchain-based transaction data processing method of the present application;
FIG. 4 is a schematic diagram of a block chain based transaction data processing device according to an embodiment of the present application;
fig. 5 is a schematic device structure diagram of a hardware operating environment related to a transaction data processing method based on blockchain in an embodiment of the present application.
The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings in conjunction with the embodiments.
Detailed Description
In order to make the above objects, features and advantages of the present invention more comprehensible, the following description of the embodiments accompanied with the accompanying drawings will be given in detail. It will be apparent that the described embodiments are only some, but not all, embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In a first embodiment of the blockchain-based transaction data processing method of the present application, referring to fig. 1, the blockchain-based transaction data processing method includes:
step S10, obtaining a block to be executed;
in this embodiment, it should be noted that, the present embodiment is applied to an executing node, where the executing node refers to a blockchain node that executes a transaction to be executed in the block to be executed after the consensus is completed. The method comprises the steps that a blockchain processes a data request in a transaction mode, a user submits a transaction to a blockchain network, such as a transfer or call chain, an intelligent contract on the chain and the like, the transaction to be executed submitted by the user is stored in a transaction pool of the blockchain network before being executed, a consensus algorithm takes out the transaction to be executed from the transaction pool and packages the transaction to be executed into a block to be subjected to consensus, after the consensus is completed, a blockchain node for executing the transaction to be executed in the block to be executed can be determined, the blockchain node executes the transaction to be executed in the block to be executed, and a transaction result is stored in an account book database of the blockchain, so that the uplink is realized.
In one embodiment, referring to fig. 2, fig. 2 is a flow chart illustrating an embodiment of a blockchain-based transaction data processing method of the present application, a set of transactions stored in each transaction executor call the same smart contract, for example, transaction 1-1, transaction 1-2, … …, transaction 1-m1 all call smart contract 1, transaction 2-2, … …, transaction 2-m2 all call smart contract 2, transaction n-1, transaction n-2, … …, transaction n-mn all call smart contract n, and the transactions may be executed in parallel due to the different smart contracts called by each transaction executor. The account mutex module refers to a module for synchronizing a plurality of transactions accessing the same account by locking the account, specifically, when a transaction is executed, if an intelligent contract account is accessed, the locking of the intelligent contract account is firstly queried and requested, if the account is currently in a locking state, this suggests that other transactions are accessing the account, the locking is requested and accessed after the transaction access which is accessing the account is completely unlocked, and if the account is not currently locked by other transactions, the locking is requested and accessed. The storage module refers to a module for storing account data in a blockchain, wherein the account comprises a common external account and an intelligent contract account, and the storage module comprises a double-layer cache for storing the account data, namely a first cache serving as a temporary cache layer and a second cache serving as a to-be-submitted cache layer. When the transaction is executed, the updated account data and the corresponding memory data are firstly stored in a first cache, and when the transaction is executed successfully, the account data stored in the first cache are copied into a second cache; when the transaction fails to be executed, account data related to the transaction is not copied from the first cache to the second cache. And when the transaction to be executed in the block to be executed is executed, writing all account data stored in the second buffer into a block chain account book database to complete the uplink operation.
Specifically, after the block chain consensus is completed, determining an execution node for executing the block to be executed from all the block chain nodes of the block chain, wherein the execution node acquires the block to be executed.
Step S20, grouping all the transactions to be executed according to the target contract addresses corresponding to all the transactions to be executed in the blocks to be executed;
in this embodiment, it should be noted that, the transaction to be executed refers to a transaction in a blockchain network, where the consensus engine takes out from a transaction pool and packages the transaction into a block. These transactions access smart contracts on blockchain, and more specifically call function interfaces in the smart contracts to conduct specific business processes such as deposit, transfer, etc. Wherein the smart contracts are a computer protocol intended to propagate, verify or execute contracts in an informative manner, under an account model, each smart contract is modeled and stored as a smart contract account, which includes attributes such as balance, contract code and status data, each smart contract having a unique contract address. The execution of a transaction may require the invocation of more than one smart contract, the target contract address being the contract address of the first smart contract invoked when the transaction to be executed is executed.
Specifically, the to-be-executed transaction is obtained from the to-be-executed block, the to-be-executed transaction is grouped according to the target contract address carried by the to-be-executed transaction, the to-be-executed transaction with the same target contract address is divided into the same group, the sequence of the to-be-executed transaction in the same group is consistent with the sequence of the to-be-executed transaction in the to-be-executed block, for example, the to-be-executed block is provided with a transaction 1, a transaction 2 and a transaction 3 which are arranged in time sequence from early to late, the transaction 1 and the transaction 3 are divided into a group 1, the transaction 1 and the transaction 3 are arranged in time sequence from early to late, and the transaction 1 is still prior to the transaction 3 in time sequence.
The method for grouping the transactions to be executed includes determining a plurality of groups in advance, determining a corresponding relation between each group and a contract address, and dividing each transaction to be executed into groups corresponding to a target contract address in time sequence; the grouping manner of each transaction to be executed may be that all transactions to be executed in the block to be executed are acquired, and all transactions to be executed are grouped according to the contract address carried by each transaction to be executed.
Optionally, the step of grouping each transaction to be executed according to the target contract address corresponding to each transaction to be executed in the block to be executed includes:
step S21, acquiring transactions to be executed from the blocks to be executed in sequence;
in this embodiment, the priority ranking is specifically performed according to the transaction submitting time sequence of the transactions to be executed, the earlier the transaction submitting time is, the higher the priority is, the transaction to be executed with the highest current priority of the transaction executor is obtained from the block to be executed, and the obtained transaction to be executed with the highest current priority is cleared from the block to be executed, or is marked as obtained.
Step S22, distributing the transaction to be executed to a corresponding target transaction executor according to the target contract address corresponding to the transaction to be executed;
in this embodiment, specifically, a target contract address carried by the transaction to be executed is determined, the transaction to be executed is allocated to a target transaction executor corresponding to the target contract address, where the transaction executor refers to a data structure for executing a transaction accessing an intelligent contract, a group of transactions accessing the same intelligent contract are stored in the transaction executor, and a function interface corresponding to the intelligent contract may be provided at the same time to execute the group of transactions.
Optionally, the step of distributing the to-be-executed transaction to the corresponding target transaction executor according to the target contract address corresponding to the to-be-executed transaction includes:
step S221, determining a target contract address corresponding to the transaction to be executed;
step S222, if a target transaction executor corresponding to the target contract address is queried according to a mapping relation table between the preset contract address and the transaction executor, the transaction to be executed is distributed to the target transaction executor.
In this embodiment, specifically, a target contract address carried by the transaction to be executed is determined, a mapping relation table between a preset contract address and a transaction executor is queried according to the target contract address, and if a target transaction executor corresponding to the target contract address is queried according to the mapping relation table between the preset contract address and the transaction executor, the transaction to be executed is distributed to the target transaction executor. In one implementation manner, the mapping relationship table between the preset contract address and the transaction executor may be a hash table, the target contract address is a key, and the queried value is identification information of the transaction executor, for example, a name, an identification number, or a number.
Optionally, after the step of determining the target contract address corresponding to the transaction to be executed, the method further includes:
step S223, if the target transaction executor corresponding to the target contract address is not queried according to the preset mapping relation table between the contract address and the transaction executor, creating a mapping relation between the target transaction executor and the target contract address, and distributing the transaction to be executed to the target transaction executor.
In this embodiment, specifically, according to the target contract address, a mapping relationship table between a preset contract address and a transaction executor is queried, if a target transaction executor corresponding to the target contract address is not queried according to the mapping relationship table between the preset contract address and the transaction executor, it is indicated that no transaction carries the same target contract address before, so that the transaction executor is newly built, the newly built transaction executor is determined to be the target transaction executor corresponding to the target contract address, the transaction to be executed is allocated to the target transaction executor, and meanwhile, the mapping relationship between the target transaction executor and the target contract address is added to the mapping relationship table between the preset contract address and the transaction executor, so that when the transaction to be executed carrying the target contract address is subsequently allocated, the transaction executor can be allocated without newly building the transaction executor.
Step S23, returning to execute the step of acquiring the transaction to be executed from the block to be executed according to the sequence.
In this embodiment, specifically, after each time the to-be-executed transaction is allocated to the corresponding target transaction executor, the step of sequentially obtaining the to-be-executed transaction from the to-be-executed block is returned to be executed until all to-be-executed transactions in the to-be-executed block complete allocation of the transaction executor.
Step S30, executing all groups of transactions to be executed in parallel, generating transaction data, and storing the transaction data in a preset first cache;
in this embodiment, specifically, different threads are allocated to each group of transactions to be executed for processing, so as to implement parallel execution of different groups of transactions to be executed. For the transactions to be executed in each group, since each thread corresponds to a group of transactions to be executed, each group of transactions to be executed corresponds to a target contract address, and each target contract address can determine a unique target intelligent contract, that is, each transaction to be executed in each group corresponds to the target function interface of the same target intelligent contract, the corresponding target function interface can be called through each group of threads corresponding to the transactions to be executed, the transactions to be executed in the groups are sequentially executed, account data corresponding to the target intelligent contract are processed, transaction data are generated according to the data processing result when each call of the target intelligent contract to execute the transactions to be executed is completed, and the transaction data are stored in a preset first cache, wherein the transaction data refer to data generated when the intelligent contract is called to execute the transactions to process account data.
Illustratively, the target contract addresses corresponding to the transactions 1-1, 1-2 and 1-3 are A1, divided into a first group, the target contract addresses corresponding to the transactions 2-1, 2-2 and 2-3 are A2, divided into a second group, the first group of transactions to be executed are executed by the distribution thread 1, the second group of transactions to be executed are executed by the distribution thread 2, the function interface 1 corresponding to the A1 is called by the thread 1 to execute the transactions 1-1 in sequence, the transaction data 1-1 is generated, the transaction data 1-1 is stored in a preset first cache, the transaction 1-2 is executed, the transaction data 1-2 is generated, the transaction data 1-2 is stored in a preset first cache, the transaction 1-3 is executed, the transaction data 1-3 is generated, and the transaction data 1-3 is stored in the preset first cache; the thread 2 and the thread 1 synchronously perform, the thread 2 calls the function interface 2 corresponding to the A2 to sequentially execute the transaction 2-1 to generate transaction data 2-1, the transaction data 2-1 is stored in a preset first buffer memory, the transaction 2-2 is further executed to generate the transaction data 2-2, the transaction data 2-2 is stored in the preset first buffer memory, the transaction 2-3 is further executed to generate the transaction data 2-3, and the transaction data 2-3 is stored in the preset first buffer memory.
Optionally, the step of executing the transaction to be executed in each target transaction executor in parallel, generating transaction data, and storing the transaction data in a preset first cache includes:
Step S31, determining the current transaction to be executed and the target account data corresponding to the current transaction to be executed from all groups of transactions to be executed through different threads in sequence;
in this embodiment, specifically, different threads are allocated to each group of transactions to be executed, the transaction to be executed with the earliest time of submitting the transaction is taken out from each group of transactions to be executed as the current transaction to be executed according to the sequence from early to late of time of submitting the transaction by the different threads, and the target account number data corresponding to the current transaction to be executed is determined.
Step S32, executing each transaction to be executed currently respectively, so as to process the corresponding target account data, generate transaction data, and store the transaction data in a preset first cache.
In this embodiment, specifically, through threads allocated to each group of transactions, a target account number corresponding to each current transaction to be executed is accessed respectively, a corresponding current transaction to be executed is executed with the target account number, so as to process target account number data corresponding to each current transaction to be executed, when the processing of the target account number data is completed, transaction data is generated according to a processing result of the target account number data, and the transaction data is stored in a preset first cache.
Step S40, if it is determined that a target transaction to be executed exists in each transaction to be executed, storing transaction data corresponding to the target transaction to be executed in a preset second cache;
in this embodiment, it should be noted that, the executing process of the transaction to be executed includes at least one step, if the transaction to be executed includes multiple steps, when the target smart contract execution transaction is called, the transaction to be executed is not yet executed, and further other smart contracts need to be called to continue to execute the transaction until all steps in the transaction to be executed are executed, in the executing process of the transaction to be executed, each time the smart contract execution transaction is called to be executed successfully, the transaction to be executed can be judged to be successful, and if in the executing process of the transaction to be executed, any one time the smart contract execution transaction is called to fail, the transaction to be executed is judged to fail.
Specifically, in the process of executing the transaction through each thread, whether each transaction to be executed is continuously detected, whether the transaction to be executed is completed or not is successful, if the target transaction to be executed, which is executed and is successful, is detected, all transaction data corresponding to the target transaction to be executed are determined from the preset first cache, and all transaction data corresponding to the target transaction to be executed are sent or copied to the preset second cache. In an implementation manner, all transaction data corresponding to the target to-be-executed transaction stored in the preset first cache may be deleted, and the storage space may be cleaned in time.
Step S50, when it is determined that all the transactions to be executed in the block to be executed are executed, writing the transaction data stored in the preset second buffer into an account database.
In this embodiment, specifically, when it is determined that all transactions to be executed in the block to be executed are executed, the transaction data stored in the preset second buffer is written into an account book database. In one implementation manner, all transaction data stored in the preset first buffer and the preset second buffer can be deleted, and the storage space can be cleaned in time.
The transaction data generated by each step of intelligent contract execution transaction in the execution process of the transaction to be executed are stored in a preset first cache, namely, the preset first cache is equivalent to a temporary cache area and is used for storing transaction data generated by each time of intelligent contract execution transaction, only transaction data corresponding to the transaction to be executed, which is successful, are further stored in a preset second cache, and further the purpose of writing only the transaction data corresponding to the transaction to be executed, which is successful, into an account database can be achieved by writing the transaction data corresponding to the transaction to be executed, which is not written into the account database, so that complex operations of correcting error data such as rollback after the transaction is failed are not needed.
In this embodiment, grouping the transactions to be executed in the blocks to be executed is achieved by obtaining the blocks to be executed according to the target contract addresses corresponding to the transactions to be executed in each block to be executed, further, transaction data are generated by executing each group of transactions to be executed in parallel, the transaction data are stored in a preset first cache, parallel execution of each transaction to be executed is achieved, the generated transaction data are stored in the preset first cache, further, if the target transaction to be executed for successful transaction exists in each transaction to be executed, the transaction data corresponding to the target transaction to be executed are stored in a preset second cache, the transaction data of the target transaction to be executed for successful transaction are stored in the preset second cache, and further, after all transactions to be executed in the blocks to be executed are confirmed to be executed are completed, the transaction data stored in the preset second cache are written into the account database, and the transaction data corresponding to the transaction to be successful account database are written into the account database after all transactions to be executed in the blocks to be executed are confirmed. Compared with serial execution, the method has the advantages that the execution data are directly written into the account book database, if the transaction fails and then the rollback is carried out, on one hand, the method can fully utilize the computing resources and doubly improve the transaction execution efficiency by parallel execution of each group of transactions to be executed after grouping through the target contract address, on the other hand, the method can only store the transaction data of the transactions to be executed which are successfully executed into the preset second cache, namely only the transaction data of the transactions to be executed which are successfully executed are written into the account book database, so that the transaction data of the transactions to be executed which are successfully executed are not written into the account book database, rollback operation is not needed, the transaction execution efficiency can be effectively improved, and the technical problem of lower transaction execution efficiency of block chains in the prior art is overcome.
Further, referring to fig. 3, in another embodiment of the present application, the same or similar content as the above embodiment may be referred to the above description, and will not be repeated. On this basis, the step of respectively executing each current transaction to be executed to process the corresponding target account data to generate transaction data, and storing the transaction data in a preset first cache includes:
step S321, detecting whether the target account data is currently in a locking state;
step S322, if it is detected that the target account data is not currently in the locked state, setting the target account data to be in the locked state, and executing the transaction to be executed currently to process the target account data, generating transaction data, and storing the transaction data in a preset first cache;
step S323, releasing the locked state of the target account data.
In this embodiment, specifically, when executing a current transaction to be executed by any thread, it is first detected whether target account data corresponding to the current transaction to be executed is currently in a locked state, if it is detected that the target account data is not currently in the locked state, the target account data is set in the locked state, and the current transaction to be executed is executed, so as to process the target account data corresponding to the current transaction to be executed, and when the processing of the target account data is completed, transaction data is generated according to a processing result of the target account data, and the transaction data is stored in a preset first cache, so that the locked state of the target account data is released.
Optionally, after the step of detecting whether the target account number data is currently in the locked state, the method further includes:
step A10, if the target account data is detected to be in the locking state currently, returning to the step of executing the step of detecting whether the target account data is in the locking state currently;
step A20, until the fact that the target account data is not in a locking state currently is detected, setting the target account data to be in a locking state, executing the transaction to be executed currently, processing the target account data, generating transaction data, and storing the transaction data in a preset first cache;
and step A30, unlocking the locking state of the target account data.
In this embodiment, specifically, if it is detected that the target account data is currently in a locked state, it is indicated that other threads currently access the target account to process the target account data, and in order to ensure the accuracy and security of the transaction, it is required to wait for the thread accessing the target account to end, and return to execute the step of detecting whether the target account data is currently in a locked state, so as to continuously detect whether the thread accessing the target account ends. And setting the target account data into a locking state until the target account data is detected not to be in the locking state currently, executing the transaction to be executed currently, processing the target account data corresponding to the transaction to be executed currently, generating transaction data according to the processing result of the target account data when the processing of the target account data is completed, storing the transaction data into a preset first cache, and releasing the locking state of the target account data.
In the embodiment, the situation that a plurality of threads access the same account at the same time can be effectively avoided by locking the account data being accessed, so that the consistency of global data is ensured, and the accuracy and the safety of transaction are improved.
Further, the embodiment of the application also provides a transaction data processing device based on a blockchain, which is applied to a transaction data processing device based on the blockchain, and the transaction data processing device based on the blockchain comprises:
the acquisition module is used for acquiring the block to be executed;
the grouping module is used for grouping all the transactions to be executed according to the target contract addresses corresponding to all the transactions to be executed in the block to be executed;
the first storage module is used for executing all groups of transactions to be executed in parallel, generating transaction data and storing the transaction data in a preset first cache;
the second storage module is used for storing transaction data corresponding to target transactions to be executed in a preset second cache if the target transactions to be executed with successful transactions exist in the transactions to be executed;
and the data writing module is used for writing the transaction data stored in the preset second cache into an account book database when all the transactions to be executed in the blocks to be executed are determined to be executed.
Optionally, the grouping module is further configured to:
sequentially acquiring transactions to be executed from the blocks to be executed;
distributing the transaction to be executed to a corresponding target transaction executor according to the target contract address corresponding to the transaction to be executed;
and returning to execute the step of acquiring the transaction to be executed from the block to be executed in sequence.
Optionally, the grouping module is further configured to:
determining a target contract address corresponding to the transaction to be executed;
and if the target transaction executor corresponding to the target contract address is queried according to a mapping relation table between the preset contract address and the transaction executor, distributing the transaction to be executed to the target transaction executor.
Optionally, the grouping module is further configured to:
if the target transaction executor corresponding to the target contract address is not queried according to a preset mapping relation table between the contract address and the transaction executor, a mapping relation between the target transaction executor and the target contract address is newly established, and the transaction to be executed is distributed to the target transaction executor.
Optionally, the first storage module is further configured to:
Determining the current transaction to be executed and target account data corresponding to the current transaction to be executed from all groups of transactions to be executed in sequence through different threads;
and respectively executing each current transaction to be executed so as to process the corresponding target account data, generating transaction data, and storing the transaction data in a preset first cache.
Optionally, the first storage module is further configured to:
detecting whether the target account data is currently in a locking state or not;
if the target account data is detected not to be in the locking state currently, setting the target account data to be in the locking state, executing the transaction to be executed currently, processing the target account data to generate transaction data, and storing the transaction data in a preset first cache;
and releasing the locking state of the target account data.
Optionally, the first storage module is further configured to:
if the target account data is detected to be in the locking state currently, returning to the step of executing the step of detecting whether the target account data is in the locking state currently;
setting the target account data to be in a locking state until the target account data is detected not to be in the locking state currently, executing the transaction to be executed currently, processing the target account data to generate transaction data, and storing the transaction data in a preset first cache;
And releasing the locking state of the target account data.
The transaction data processing device based on the blockchain provided by the invention adopts the transaction data processing method based on the blockchain in the embodiment, so that the technical problem of lower transaction execution efficiency of the blockchain in the prior art is solved. Compared with the prior art, the beneficial effects of the transaction data processing device based on the blockchain provided by the embodiment of the invention are the same as those of the transaction data processing method based on the blockchain provided by the embodiment, and other technical features in the transaction data processing device based on the blockchain are the same as those disclosed by the method of the embodiment, so that the description is omitted.
Further, an embodiment of the present invention provides an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the blockchain-based transaction data processing method of the above embodiments.
Referring now to fig. 5, a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure is shown. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 5 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 5, the electronic device may include a processing means (e.g., a central processing unit, a graphic processor, etc.) that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) or a program loaded from a storage means into a Random Access Memory (RAM). In the RAM, various programs and arrays required for the operation of the electronic device are also stored. The processing device, ROM and RAM are connected to each other via a bus. An input/output (I/O) interface is also connected to the bus.
In general, the following systems may be connected to the I/O interface: input devices including, for example, touch screens, touch pads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices including, for example, liquid Crystal Displays (LCDs), speakers, vibrators, etc.; storage devices including, for example, magnetic tape, hard disk, etc.; a communication device. The communication means may allow the electronic device to communicate with other devices wirelessly or by wire to exchange arrays. While electronic devices having various systems are shown in the figures, it should be understood that not all of the illustrated systems are required to be implemented or provided. More or fewer systems may alternatively be implemented or provided.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from ROM. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by a processing device.
The electronic equipment provided by the invention adopts the transaction data processing method based on the blockchain in the embodiment, and solves the technical problem of lower transaction execution efficiency of the blockchain in the prior art. Compared with the prior art, the electronic device provided by the embodiment of the invention has the same beneficial effects as the transaction data processing method based on the blockchain provided by the embodiment, and other technical features in the electronic device are the same as the features disclosed by the method of the embodiment, and are not repeated herein.
It should be understood that portions of the present disclosure may be implemented in hardware, software, firmware, or a combination thereof. In the description of the above embodiments, particular features, structures, materials, or characteristics may be combined in any suitable manner in any one or more embodiments or examples.
The foregoing is merely illustrative of the present invention, and the present invention is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Further, the present embodiment provides a computer-readable storage medium having computer-readable program instructions stored thereon for performing the blockchain-based transaction data processing method of the above embodiments.
The computer readable storage medium according to the embodiments of the present invention may be, for example, a usb disk, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this embodiment, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, or device. Program code embodied on a computer readable storage medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The above-described computer-readable storage medium may be contained in an electronic device; or may exist alone without being assembled into an electronic device.
The computer-readable storage medium carries one or more programs that, when executed by an electronic device, cause the electronic device to: acquiring a block to be executed; grouping all the transactions to be executed according to the target contract addresses corresponding to all the transactions to be executed in the blocks to be executed; executing all groups of transactions to be executed in parallel, generating transaction data, and storing the transaction data in a preset first cache; if the fact that the target transaction to be executed which is successful in the transaction to be executed exists in the transactions to be executed is determined, transaction data corresponding to the target transaction to be executed are stored in a preset second cache; and when all the transactions to be executed in the blocks to be executed are determined to be executed, writing the transaction data stored in the preset second buffer into an account book database.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented in software or hardware. Wherein the name of the module does not constitute a limitation of the unit itself in some cases.
The computer readable storage medium provided by the invention stores the computer readable program instructions for executing the transaction data processing method based on the blockchain, and solves the technical problem of lower transaction execution efficiency of the blockchain in the prior art. Compared with the prior art, the beneficial effects of the computer readable storage medium provided by the embodiment of the invention are the same as those of the transaction data processing method based on the blockchain provided by the embodiment, and are not described in detail herein.
Further, the present application also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of a blockchain-based transaction data processing method as described above.
The present application provides a computer program product that solves the technical problem of lower transaction execution efficiency of prior art blockchains. Compared with the prior art, the beneficial effects of the computer program product provided by the embodiment of the invention are the same as those of the transaction data processing method based on the blockchain provided by the embodiment, and are not described in detail herein.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the scope of the claims, and all equivalent structures or equivalent processes using the descriptions and drawings of the present application, or direct or indirect application in other related technical fields are included in the scope of the claims.
Claims (10)
1. A blockchain-based transaction data processing method, characterized in that the blockchain-based transaction data processing method comprises the following steps:
acquiring a block to be executed;
grouping all the transactions to be executed according to the target contract addresses corresponding to all the transactions to be executed in the blocks to be executed;
executing all groups of transactions to be executed in parallel, generating transaction data, and storing the transaction data in a preset first cache;
if the fact that the target transaction to be executed which is successful in the transaction to be executed exists in the transactions to be executed is determined, transaction data corresponding to the target transaction to be executed are stored in a preset second cache;
and when all the transactions to be executed in the blocks to be executed are determined to be executed, writing the transaction data stored in the preset second buffer into an account book database.
2. The blockchain-based transaction data processing method of claim 1, wherein the step of grouping each of the transactions to be executed according to a target contract address corresponding to each of the transactions to be executed in the block to be executed comprises:
sequentially acquiring transactions to be executed from the blocks to be executed;
Distributing the transaction to be executed to a corresponding target transaction executor according to the target contract address corresponding to the transaction to be executed;
and returning to execute the step of acquiring the transaction to be executed from the block to be executed in sequence.
3. The blockchain-based transaction data processing method of claim 2, wherein the step of assigning the to-be-executed transaction to the corresponding target transaction executor according to the target contract address corresponding to the to-be-executed transaction comprises:
determining a target contract address corresponding to the transaction to be executed;
and if the target transaction executor corresponding to the target contract address is queried according to a mapping relation table between the preset contract address and the transaction executor, distributing the transaction to be executed to the target transaction executor.
4. The blockchain-based transaction data processing method of claim 3, further comprising, after the step of determining the target contract address to which the transaction is to be performed:
if the target transaction executor corresponding to the target contract address is not queried according to a preset mapping relation table between the contract address and the transaction executor, a mapping relation between the target transaction executor and the target contract address is newly established, and the transaction to be executed is distributed to the target transaction executor.
5. The blockchain-based transaction data processing method of claim 1, wherein the step of executing each set of transactions to be executed in parallel, generating transaction data, and storing the transaction data in a preset first cache includes:
determining the current transaction to be executed and target account data corresponding to the current transaction to be executed from all groups of transactions to be executed in sequence through different threads;
and respectively executing each current transaction to be executed so as to process the corresponding target account data, generating transaction data, and storing the transaction data in a preset first cache.
6. The blockchain-based transaction data processing method of claim 5, wherein the step of respectively executing each of the current transactions to be executed to process corresponding target account data to generate transaction data, and storing the transaction data in a preset first cache includes:
detecting whether the target account data is currently in a locking state or not;
if the target account data is detected not to be in the locking state currently, setting the target account data to be in the locking state, executing the transaction to be executed currently, processing the target account data to generate transaction data, and storing the transaction data in a preset first cache;
And releasing the locking state of the target account data.
7. The blockchain-based transaction data processing method of claim 6, further comprising, after the step of detecting whether the target account data is currently in a locked state:
if the target account data is detected to be in the locking state currently, returning to the step of executing the step of detecting whether the target account data is in the locking state currently;
setting the target account data to be in a locking state until the target account data is detected not to be in the locking state currently, executing the transaction to be executed currently, processing the target account data to generate transaction data, and storing the transaction data in a preset first cache;
and releasing the locking state of the target account data.
8. A blockchain-based transaction data processing device, the blockchain-based transaction data processing device comprising:
the acquisition module is used for acquiring the block to be executed;
the grouping module is used for grouping all the transactions to be executed according to the target contract addresses corresponding to all the transactions to be executed in the block to be executed;
The first storage module is used for executing all groups of transactions to be executed in parallel, generating transaction data and storing the transaction data in a preset first cache;
the second storage module is used for storing transaction data corresponding to target transactions to be executed in a preset second cache if the target transactions to be executed with successful transactions exist in the transactions to be executed;
and the data writing module is used for writing the transaction data stored in the preset second cache into an account book database when all the transactions to be executed in the blocks to be executed are determined to be executed.
9. An electronic device, the electronic device comprising:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the steps of the blockchain-based transaction data processing method of any of claims 1 to 7.
10. A storage medium, characterized in that the storage medium is a computer-readable storage medium having stored thereon a program implementing a blockchain-based transaction data processing method, the program implementing the blockchain-based transaction data processing method being executed by a processor to implement the steps of the blockchain-based transaction data processing method according to any of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211473359.1A CN116091216A (en) | 2022-11-21 | 2022-11-21 | Transaction data processing method, device, equipment and storage medium based on blockchain |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211473359.1A CN116091216A (en) | 2022-11-21 | 2022-11-21 | Transaction data processing method, device, equipment and storage medium based on blockchain |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116091216A true CN116091216A (en) | 2023-05-09 |
Family
ID=86199918
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211473359.1A Pending CN116091216A (en) | 2022-11-21 | 2022-11-21 | Transaction data processing method, device, equipment and storage medium based on blockchain |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116091216A (en) |
-
2022
- 2022-11-21 CN CN202211473359.1A patent/CN116091216A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110297689B (en) | Intelligent contract execution method, device, equipment and medium | |
CN107577427B (en) | data migration method, device and storage medium for blockchain system | |
US8880488B1 (en) | Efficient extent-based B-tree insertion | |
CN107766039B (en) | Method, server and storage medium for accessing attribute value from Java object | |
CN107016016B (en) | Data processing method and device | |
CN109951553B (en) | Data processing method, system, electronic device and computer readable storage medium | |
KR20230004394A (en) | Hared memory access control method, device, electronic device and autonomous vehicle | |
CN110633046A (en) | Storage method and device of distributed system, storage equipment and storage medium | |
US20240314021A1 (en) | Method, apparatus, electronic device and storage medium for resource operation | |
CN111338834B (en) | Data storage method and device | |
CN112631751A (en) | Task scheduling method and device, computer equipment and storage medium | |
CN115686881A (en) | Data processing method and device and computer equipment | |
US10127270B1 (en) | Transaction processing using a key-value store | |
CN111414356A (en) | Data storage method and device, non-relational database system and storage medium | |
CN105279029A (en) | Local storage dynamic distribution method base on work calculating resources | |
CN117056123A (en) | Data recovery method, device, medium and electronic equipment | |
CN114840562B (en) | Distributed caching method and device for business data, electronic equipment and storage medium | |
US11989171B2 (en) | Data storage method and system | |
CN116091216A (en) | Transaction data processing method, device, equipment and storage medium based on blockchain | |
CN115860950A (en) | Contract transaction execution method and device, electronic equipment and readable storage medium | |
CN115099398A (en) | Hardware accelerator operation optimization method and device, electronic equipment and storage medium | |
CN114415981A (en) | IO processing method and system of multi-control storage system and related components | |
CN114756293A (en) | Service processing method, device, computer equipment and storage medium | |
US20060010026A1 (en) | Transaction polymorphism | |
CN112434013A (en) | Data table migration method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |