CN112732831B - Transaction source-destination address separation processing method and system - Google Patents

Transaction source-destination address separation processing method and system Download PDF

Info

Publication number
CN112732831B
CN112732831B CN202011638966.XA CN202011638966A CN112732831B CN 112732831 B CN112732831 B CN 112732831B CN 202011638966 A CN202011638966 A CN 202011638966A CN 112732831 B CN112732831 B CN 112732831B
Authority
CN
China
Prior art keywords
transaction
transactions
destination address
account
address
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.)
Active
Application number
CN202011638966.XA
Other languages
Chinese (zh)
Other versions
CN112732831A (en
Inventor
丁有振
王顺利
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Jiansu Network Technology Co ltd
Original Assignee
Shanghai Jiansu Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Jiansu Network Technology Co ltd filed Critical Shanghai Jiansu Network Technology Co ltd
Priority to CN202011638966.XA priority Critical patent/CN112732831B/en
Publication of CN112732831A publication Critical patent/CN112732831A/en
Application granted granted Critical
Publication of CN112732831B publication Critical patent/CN112732831B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2308Concurrency control
    • G06F16/2336Pessimistic concurrency control approaches, e.g. locking or multiple versions without time stamps
    • G06F16/2343Locking methods, e.g. distributed locking or locking implementation details
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Abstract

The invention discloses a transaction source and destination address separation processing method and a system, comprising the following steps: s1: the block sequentially receives and screens a plurality of transactions; s2: parallel processing is carried out on transactions in a transaction pool through a plurality of threads: if the destination addresses of the transactions processed in parallel are the same, each transaction is sequentially executed by locking the destination address; if the source addresses of the transactions processed in parallel are the same, executing each transaction in sequence according to the priority of the account transaction serial number of the source address; if the account transaction serial number of the source address in the current parallel processing transaction has a broken number, the transaction is put into a buffer area for later execution. The invention solves the data coverage problem in the transaction parallel processing, solves the problem of the data processing sequence, solves the problem that the address is used as a source address and a destination address, realizes the real blockchain transaction parallel processing, and greatly improves the execution efficiency of the transaction processing.

Description

Transaction source-destination address separation processing method and system
Technical Field
The invention belongs to the technical field of blockchain, and particularly relates to a transaction source and destination address separation processing method and system.
Background
The blockchain technology realizes various functions in real life based on the characteristics of incapability of forging, whole-course trace, traceability, openness, transparency, collective maintenance and the like, not only is ensured safely and reliably, but also is greatly convenient for the aspects of real life.
Meanwhile, due to unique characteristics of the blockchain, simple transaction processing in the reality is quite complex in the blockchain, and specifically, the following defects exist in the blockchain transaction processing technology in the prior art:
1) In a block, if duplicate addresses are simply rejected, a problem arises in that an account can only transfer or receive a transaction in a block, which is not only too restrictive for the user, but also results in inefficiency in transaction processing;
2) In a block, if a transaction is a source address, the destination address cannot be made any more, that is, in a block, multiple transactions can be directed to the same destination address, or multiple transactions with different destination addresses can be sent by one source address, but one address cannot be a source address in some transactions, and destination addresses are made in other addresses, so that the simultaneous processing process of multiple transactions becomes very complex, the transaction processing efficiency is low, and meanwhile, the problem of data coverage exists between the transactions;
3) In one block, if parallel processing is to be performed, if the destination address or the source address of two transactions are the same, a data coverage problem exists between the transactions;
the above problems are specifically described by way of an example:
for example, in the blockchain, assume that there are 50 accounts A, 60 accounts B, 70 accounts C, and now two transactions, A to B transfer 20, B to C transfer 40. If the normal sequence is executed, after two transactions are executed, A has 30 blocks, B has 40 blocks, and C has 110. But if the two transactions are performed in parallel, the B account results are different at different nodes. Assuming that the second transaction is executed first, the change of the first transaction to the B account covers the change of the second transaction to the B account, then after the two transactions are executed, the B account has 80 blocks, otherwise, if the second transaction covers the first transaction, the B account has 20 blocks, if the second transaction is executed normally in parallelization, the B has 40 blocks, so that the two simple transactions may generate different results due to different execution sequences, and the problem of data coverage can occur.
And meanwhile, the problem of sequence is also needed to be solved, when one address is simultaneously displayed on a source address and a destination address of different transactions, the transaction sequence also influences the transaction result, for example, if the transfer of B to C in the example is changed to 70 blocks, after the synchronous lock is added, if the second stroke is executed first, the second stroke is failed, and if the first stroke is executed first, both strokes are successful.
Therefore, in order to implement parallel processing, the existing blockchain transaction processing technology needs to solve not only the problem of data coverage, but also the problem of data processing sequence, and also the problem that addresses are used as both source addresses and destination addresses.
Disclosure of Invention
The invention provides a transaction source and destination address separation processing method and a system for solving the technical problems, wherein the technical scheme is as follows:
a transaction source-destination address separation processing method comprises the following steps:
s1: the block sequentially receives and screens a plurality of transactions, each time receives a transaction, if the source address of the transaction is the same as the destination address of the transaction in the transaction pool, or if the destination address of the transaction is the same as the source address of the transaction in the transaction pool, the transaction is discarded, otherwise, the transaction is put into the transaction pool;
s2: parallel processing is carried out on transactions in a transaction pool through a plurality of threads:
if the destination addresses of the transactions processed in parallel are the same, each transaction is sequentially executed by locking the destination address;
if the source addresses of the transactions processed in parallel are the same, executing each transaction in sequence according to the priority of the account transaction serial number of the source address, wherein the account transaction serial number is the serial number marked by each account for the transaction initiated by the user;
If the account transaction serial number of the source address in the current parallel processing transaction has a broken number, the transaction is put into a buffer area for later execution, and the broken number is that the transaction which is not executed by the transaction pool has a higher priority than the account transaction serial number of the current transaction.
In one embodiment, a first buffer area for storing a source address and a second buffer area for storing a destination address are pre-established, and step S1 further includes:
the block sequentially receives and screens a plurality of transactions, and each time a transaction is received, the source address and the destination address of the transaction are acquired, the destination address is queried in a first buffer zone, and the source address is queried in a second buffer zone:
if the transaction is not present, the source address of the transaction is stored in the first buffer area, the destination address of the transaction is stored in the second buffer area, the transaction is inserted into the transaction pool, and otherwise, the transaction is discarded.
In one embodiment, sequentially executing each transaction by locking the destination address further comprises:
and processing threads of all transactions with the same destination address in parallel, locking the destination address through a synchronous lock corresponding to the destination address in sequence, and executing the transactions, wherein the thread of the later execution acquires the synchronous lock after the execution of the former transaction.
In one embodiment, sequentially executing each transaction according to the priority of the account transaction serial number of the source address further comprises:
and processing threads of all transactions with the same source address in parallel, and sequentially executing all transactions according to the priority of the account transaction serial numbers of the source address, wherein before each thread executes the transactions, if the account transaction serial numbers of the transactions have broken numbers, the thread puts the transactions into a cache area, and when all transactions with higher priority than the account transaction serial numbers of the threads are executed, the thread takes out the transactions for execution.
In one embodiment, the placing the transaction in the buffer is performed with a delay further comprising:
after the transaction is put into the buffer, the thread takes out the transaction to execute after all the transactions with higher priority than the account transaction serial numbers are executed by monitoring the change condition of the account transaction serial numbers of the source address of the transaction in real time.
In one embodiment, step S2 further includes:
and (3) finishing executing all the transactions in the transaction pool, emptying the transaction pool, and emptying the first buffer zone and the second buffer zone.
A transaction source-destination address separation processing system, comprising:
The receiving and screening module is used for sequentially receiving and screening a plurality of transactions, each time a transaction is received, if the source address of the transaction is the same as the destination address of the transaction in the transaction pool, or if the destination address of the transaction is the same as the source address of the transaction in the transaction pool, the transaction is discarded, otherwise, the transaction is put into the transaction pool;
the parallel processing module is used for carrying out parallel processing on the transactions in the transaction pool through a plurality of threads:
if the destination addresses of the transactions processed in parallel are the same, each transaction is sequentially executed by locking the destination address;
if the source addresses of the transactions processed in parallel are the same, executing each transaction in sequence according to the priority of the account transaction serial number of the source address, wherein the account transaction serial number is the serial number marked by each account for the transaction initiated by the user;
if the account transaction serial number of the source address in the current parallel processing transaction has a broken number, the transaction is put into a buffer area for later execution, and the broken number is that the transaction which is not executed by the transaction pool has a higher priority than the account transaction serial number of the current transaction.
In one embodiment, the method further comprises an initialization module, which is used for ending all transaction execution in the transaction pool, emptying the transaction pool and emptying the first buffer zone and the second buffer zone.
A computer device comprising a memory and a processor, the memory having stored therein computer readable instructions which, when executed by the processor, cause the processor to perform the transaction source destination address separation processing method described above.
A storage medium storing computer readable instructions that, when executed by one or more processors, cause the one or more processors to perform the transaction source-destination address separation processing method described above.
Compared with the prior art, the invention has the following advantages and positive effects:
1) The invention ensures that the transaction in the block transaction pool can not occur the situation that an account address is used as a source address and a destination address by screening a plurality of transactions sequentially received by the block, wherein the technical characteristics of source-destination address separation are adopted, the source address and the destination address are separated by setting two buffer areas respectively used for storing the source address and the destination address, and whether the current transaction can occur with the transaction in the transaction pool can be known only by inquiring the two buffer areas when each transaction is received, so that the technical problem that the account address is used as the source address and the destination address is solved, the transaction complexity in the transaction pool is greatly simplified, thereby enabling the parallel transaction processing to be easier and further improving the transaction processing efficiency;
2) When the situation that the destination addresses among the transactions in the parallel processing process are the same occurs, each transaction is sequentially executed by locking the destination address, so that data after each transaction in the situation cannot be covered, similarly, when the situation that the source addresses among the transactions in the parallel processing are the same occurs, each transaction can be sequentially executed according to the priority of the account transaction serial numbers of the source addresses, and the data after each transaction cannot be covered, and similarly, when the situation that the account transaction serial numbers of the source addresses in the transactions in the parallel processing are broken, the data after each transaction is placed into a buffer area for later execution, each transaction can be sequentially executed, and the data after each transaction cannot be covered. The problem of data coverage under various conditions is solved, the problem of data processing sequence under various conditions is also solved, and the ordering and safety of parallel processing of a plurality of transactions are ensured;
3) In the parallel processing process of multiple transactions, the invention not only can orderly and safely execute each transaction when the above situation occurs in the parallel processing process, but also can rapidly and parallelly process the multiple transactions when the above situation does not occur, solves the processing abnormality of the former, avoids the processing error in the parallel processing process, ensures the orderly and safe whole parallel processing, and greatly improves the whole execution efficiency.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention.
FIG. 1 is a flow chart showing a transaction source-destination address separation processing method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for separating transaction source and destination addresses according to an embodiment of the present invention;
FIG. 3 is a block diagram illustrating a transaction source-destination address separation processing system according to an embodiment of the present invention.
Reference numerals illustrate:
1-a receiving and screening module; 2-parallel processing module.
Detailed Description
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following description will explain the specific embodiments of the present invention with reference to the accompanying drawings. It is evident that the drawings in the following description are only examples of the invention, from which other drawings and other embodiments can be obtained by a person skilled in the art without inventive effort.
For the sake of simplicity of the drawing, the parts relevant to the present invention are shown only schematically in the figures, which do not represent the actual structure thereof as a product. Additionally, in order to simplify the drawing for ease of understanding, components having the same structure or function in some of the drawings are shown schematically with only one of them, or only one of them is labeled. Herein, "a" means not only "only this one" but also "more than one" case.
The blockchain is simply referred to as a decentralized distributed ledger database, and the blockchain technology is essentially a database technology, each block looks like a hard disk, all information is stored, and the stored information cannot be tampered by encrypting through the cryptography technology. The blockchain has the characteristics of decentralization, openness, independence, safety and anonymity, and can be applied to various aspects of life, wherein in various applications, transactions, payments and the like are one of important applications of the blockchain, and due to the characteristic of decentralization of the blockchain, point-to-point transactions can be helped, so that the payments and the transactions become more efficient and more convenient.
Although blockchains have numerous advantages, for parallel processing of transactions on blockchain platforms, it is desirable to address not only the problem of data coverage, but also the problem of data processing order, and also the problem of addresses as both source and destination addresses.
First embodiment
In order to solve the above-mentioned problems, referring to fig. 1, the present embodiment proposes a transaction source-destination address separation processing method, which includes the following steps:
s1: the block sequentially receives and screens a plurality of transactions, each time receives a transaction, if the source address of the transaction is the same as the destination address of the transaction in the transaction pool, or if the destination address of the transaction is the same as the source address of the transaction in the transaction pool, the transaction is discarded, otherwise, the transaction is put into the transaction pool;
S2: parallel processing is carried out on transactions in a transaction pool through a plurality of threads:
if the destination addresses of the transactions processed in parallel are the same, each transaction is sequentially executed by locking the destination address;
if the source addresses of the transactions processed in parallel are the same, executing each transaction in sequence according to the priority of the account transaction serial number of the source address, wherein the account transaction serial number is the serial number marked by each account for the transaction initiated by the user;
if the account transaction serial number of the source address in the current parallel processing transaction has a broken number, the transaction is put into a buffer area for later execution, and the broken number is that the transaction which is not executed by the transaction pool has a higher priority than the account transaction serial number of the current transaction.
The present embodiment will now be described in detail, but is not limited thereto.
The method is suitable for parallel processing of multiple transactions, particularly for parallel processing of multiple transactions under complex conditions, wherein the complex conditions include, but are not limited to, the condition that addresses are used as source addresses and destination addresses, the condition that the destination addresses among the parallel processing transactions are the same, the condition that the source addresses among the parallel processing transactions are the same, the condition that account transaction serial numbers of the source addresses exist in the parallel processing transactions are broken, under the complex conditions, the method can not only orderly and safely execute each transaction when the conditions appear in the parallel processing process, but also more importantly, the multiple transactions can be rapidly and parallelly processed when the conditions do not appear, the processing abnormality of the latter is solved, the processing error in the parallel processing process is avoided, the integral ordering and safety of the parallel processing are ensured, and the integral execution efficiency is greatly improved.
In this embodiment, two buffers for storing transaction addresses are pre-set, one for storing source addresses in the transaction and one for storing destination addresses in the transaction, so as to separate the source address from the destination address, thereby implementing the transaction source address and destination address separation processing in this embodiment.
1) Detailed description step S1
The block of this embodiment sequentially receives and screens a plurality of transactions, each time receives a transaction, if the source address of the transaction is the same as the destination address of the transaction in the transaction pool, or if the destination address of the transaction is the same as the source address of the transaction in the transaction pool, the transaction is discarded, otherwise the transaction is put into the transaction pool. The source address is the account from which the transaction is initiated, the destination address is the account from which the transaction is received, and the transaction pool of the block is used for block verification and caching of the transaction.
Preferably, the block receives a plurality of transactions by verifying the private key signature of the user account, and confirming the identity of the user account to confirm whether the transaction to be received is legal, wherein the validity of the private key signature is verified by the public key of the user account on the blockchain, and the screening of the transaction is executed after the verification is passed.
Specifically, referring to fig. 2, step S1 of the present embodiment further includes: the block sequentially receives and screens a plurality of transactions, and each time a transaction is received, the source address and the destination address of the transaction are acquired, the destination address is queried in a first buffer zone, and the source address is queried in a second buffer zone: if the transaction is not present, the source address of the transaction is stored in the first buffer area, the destination address of the transaction is stored in the second buffer area, the transaction is inserted into the transaction pool, and otherwise, the transaction is discarded.
The method specifically includes separating source address from destination address and screening transactions by a first buffer area for storing source address and a second buffer area for storing destination address, and is notable in that the query is to search opposite buffer areas, i.e. the source address is to search the second buffer area for storing destination address, but the destination address is to search the first buffer area for storing source address, but the buffer area is normally inserted into the buffer area, i.e. the source address is inserted into the first buffer area for storing source address, and the destination address is inserted into the second buffer area for storing destination address, so as to screen out transactions which collide with the existing transaction pool, i.e. the destination address of the current transaction is already used as the source address in the existing transaction pool, and the source address of the current transaction is already used as the destination address in the existing transaction pool, which need to be screened out before entering the transaction pool, so as to avoid affecting orderly, safe and accurate execution of parallel processing of multiple transactions.
The following specifically describes the above step S1 by way of example, but is not limited thereto:
assuming that there are four accounts a, B, C, D, there will be the following 6 transactions involving these accounts.
1A(1)-10->B
2B(1)-20->C
3A(2)-15->C
4D(1)-25->B
5A(3)-10->D
6D(2)-20->C
The forefront number is the number of the transaction, the number in the bracket of the account is a nonce value, the nonce value is the number marked on the transaction initiated by each account, the accounts do not collide, the account is called as the account transaction number in the embodiment, and the number in the middle of the arrow is the transfer amount.
For the 6 transactions, the 1 st transaction request is sent to the chain, the block obtains the source address A of the request to store the second buffer area searching of the destination address, and finds no address A, and then obtains the destination address B of the transaction to store the first buffer area searching of the source address, and finds no address B. Therefore, A is inserted into the first buffer, B is inserted into the second buffer, and the 1 st transaction is inserted into the transaction pool. Note that the lookup is to a counter buffer lookup, the source address to destination address buffer lookup, and the destination address to source address buffer lookup, but the insertion is to a normal insertion buffer.
Then the blockchain receives the 2 nd transaction request, the block obtains the source address B to find the second buffer area for storing the destination address, and finds that B exists in the second buffer area, and the separation lock mechanism of the embodiment is not met, namely the 2 nd transaction collides with the 1 st transaction, and the address B is used as the destination address of the 1 st transaction and the source address of the 2 nd transaction, so that the 2 nd transaction is directly discarded.
Then, the 3 rd transaction is checked that the source address A is not in the second buffer area and the destination address C is not in the first buffer area, so that C is inserted into the destination address buffer area and the 3 rd transaction is inserted into the transaction pool. Because a is already in the first buffer, insertion of a into the first buffer will not perform any operations.
The 4 th transaction is similar to the 1 st and 3 rd transactions, the address D is inserted into the first buffer and the transaction is inserted into the transaction pool.
The 5 th transaction checks that the destination address D is present in the first buffer, and the transaction is discarded.
The 6 th transaction is also without problems and will be inserted into the transaction pool.
Thus, after all 6 transactions were submitted, the result of the screening was that the 2 nd and 5 th transactions were discarded, with the following 4 transactions entering the pool, as follows:
1A(1)-10->B
3A(2)-15->C
4D(1)-25->B
6D(2)-20->C
therefore, the embodiment ensures that the situation that an account address is used as a source address and a destination address is not generated in the transaction in the block transaction pool by screening a plurality of transactions sequentially received by the block, wherein the technical characteristics of source-destination address separation are adopted, the source address and the destination address are separated by setting two buffer areas respectively used for storing the source address and the destination address, and whether the current transaction can be generated with the transaction in the transaction pool or not can be known only by inquiring the two buffer areas when one transaction is received, so that the technical problem that the account address is used as the source address and the destination address is solved, the transaction complexity in the transaction pool is greatly simplified, and the parallel transaction processing becomes easier, and the transaction processing efficiency is further improved.
2) Detailed description step S2
In this embodiment, transactions in the transaction pool are processed in parallel through a plurality of threads: if the destination addresses of the transactions processed in parallel are the same, each transaction is sequentially executed by locking the destination address; if the source addresses of the transactions processed in parallel are the same, executing each transaction in sequence according to the priority of the account transaction serial number of the source address; if the account transaction serial number of the source address in the current parallel processing transaction has a broken number, the transaction is put into a cache area for later execution; if the current parallel processing transaction does not have the conditions, each transaction is currently executed in parallel. The account transaction serial numbers are serial numbers marked by the accounts for transactions initiated by the accounts, and can be used for identifying the processing sequence of the transactions, wherein the broken account transaction serial numbers are transactions which are not executed by the transaction pool and have higher priority than the account transaction serial numbers of the current transactions, namely the transactions executed by the current thread are not in the highest priority among the transactions which are not executed.
a. Specifically, when the destination addresses of the transactions processed in parallel are the same, each transaction is sequentially executed by locking the destination address, where threads of each transaction with the same destination address are processed in parallel, locking the destination address and executing the transaction sequentially through a synchronization lock corresponding to the destination address, where a thread of the next execution obtains the synchronization lock after the previous transaction is executed, and the synchronization lock is a mechanism for thread synchronization, and may include thread synchronization mechanisms such as a mutual exclusion lock, a semaphore, a critical section, and the like, and in this embodiment, data synchronization between multiple transactions with the same destination address is realized specifically through the synchronization lock.
The transaction processing procedure in this case will be described with respect to four transactions after the above-described example screening, but is not limited thereto.
In these 4 transactions, account a and account D initiate two transactions, respectively, and account B and account C are turned twice, respectively. Assuming that two threads are executing transactions in parallel, account B has 50 money and account C has 40 money, if two transactions initiated by account a are located in one thread, two transactions initiated by account D are located in the other thread, as follows:
thread 1:1A (1) -10- > B,3A (2) -15- > C;
thread 2:4D (1) -25- > B,6D (2) -20- > C.
In this case, thread 1 and thread 2 are executed in no order, and because for the destination account, no matter which thread is executed first, the final result is not affected, so the execution of this process can be performed sequentially according to the actual situation of thread 1 and thread 2:
if thread 1 first performs transaction 1, namely, a transaction for 10 blocks of B transfer, then the synchronous lock in the B account locks the B account, and the B account is unlocked after the A transfer to the B account, and 60 blocks of B account exist. After thread 2 waits for thread 1 to finish execution, a synchronous lock is obtained, transaction 4 is executed, namely, D transfers 25 blocks to B, and finally, 85 blocks of B are obtained.
If thread 2 first performs transaction 4, namely, D to 25 blocks of B transfer, then the synchronization lock in B account will lock B account, D to unlock after B transfer, and B account has 75 blocks. After thread 1 waits for thread 2 to finish executing, a synchronous lock is obtained, transaction 1 is executed, namely, transfer A to B is 10 blocks, and finally B has 85 blocks.
Transaction 3 is similar to transaction 6 and is not illustrated herein. In this regard, for the source account, because both external transfers of A are in one thread and are ordered by account transaction number within the thread, the execution result is not affected by the account transaction number break, as is the case for D. It should be noted that, although the above only exemplifies the process of processing 4 transactions in parallel by two threads, it is obvious that the present embodiment is not limited thereto, and it is easy to think that if there are three transactions whose destination addresses are the same and require parallel processing, each transaction can be sequentially executed by locking the destination addresses through a similar processing procedure as described above.
b. Specifically, when the source addresses of the transactions processed in parallel are the same, each transaction is sequentially executed according to the priority of the account transaction serial number of the source address, wherein the threads of each transaction with the same source address are processed in parallel, each transaction is sequentially executed according to the priority of the account transaction serial number of the source address, before each thread executes the transaction, if the account transaction serial number of the transaction has a broken number, the thread puts the transaction into a cache area, and when all the transactions with higher priority than the account transaction serial number are executed, the thread takes out the transaction for execution.
For the transaction processing procedure of this case, another case is assumed to be illustrated, but not limited to this: the two transactions initiated by a are not in one thread, nor are the two transactions initiated by D are in one thread, as follows:
thread 1:1A (1) -10- > B,6D (2) -20- > C;
thread 2:3A (2) -15- > C,4D (1) -25- > B.
In this case, if thread 2 first executed transaction 3, a- > C, finds that the nonce value of a has a break, then the transaction is put into the cache, executed later, and then transaction 4, D- > B, is executed. At the same time, thread 1 begins executing transaction 1, i.e., A- > B. Therefore, in the first period, the two threads respectively execute the transaction 1:A- > B and the transaction 4:D- > B, and the 2 transactions are all transfer B, and in the case that the destination addresses are the same in the previous embodiment, each transaction can be sequentially executed by locking the destination address.
After thread 1 completes transaction 1:A- > B, thread 2 also completes transaction 4:D- > B, at this time, thread 2 will fetch the previously cached transaction 3:A- > C for re-execution, because thread 1 has already completed transaction 1:A- > B and the nonce value of the A account has already been increased by 1, no break number problem exists, so thread 2 can normally execute transaction 3:A- > C. Similarly, thread 1 may continue to execute transaction 6:D- > C.
The embodiment realizes the process of parallel processing 4 transactions by two threads through the steps, wherein the parallel processing process has the same condition of destination address and source address, and the whole parallel processing process only realizes partial parallel processing, but can improve the overall transaction processing efficiency compared with the prior art.
c. Specifically, when the account transaction serial number of the source address in the parallel processing transaction has a broken number, the transaction is put into a buffer area for later execution, wherein after the transaction is put into the buffer area, the thread takes out the transaction for execution by monitoring the change condition of the account transaction serial number of the source address of the transaction in real time, and when the execution of all the transactions with higher priority than the account transaction serial number is finished.
For the transaction processing procedure of this case, another case is assumed for illustration, but not limited thereto, as follows:
thread 1:1A (1) -10- > B,4D (1) -25- > B;
thread 2:3A (2) -15- > C,6D (2) -20- > C.
In this case, since there is a break in the nonce value for both source accounts within thread 2, i.e., neither of the two transactions that thread 2 is responsible for processing is at the highest priority in the unexecuted transactions, it will have to wait for the nonce value to change before executing. Preferably, loops may be set in thread 2 to monitor changes in the nonce value in real time, indicating that the transaction prior to the account has been performed when the nonce value is a transaction executable value. Then the four transactions will be executed first in the two threads 1:A- > B, then thread 1 and thread 2 execute transactions 4:D- > B and transactions 3:a- > C, respectively, in parallel, and finally thread 2 executes transactions 6:D- > C again.
The embodiment realizes the process of processing 4 transactions in parallel by two threads through the steps, wherein the account transaction serial numbers of the source addresses in the transactions appear in the threads to have broken numbers, and the execution efficiency can be improved in the multi-core CPU computer although the whole system only realizes partial parallelism.
In summary, many cases can be enumerated in addition to the above three cases, but all of them do not depart from the variants of the above three cases, and since the above three cases already cover all conflict cases occurring when transactions are executed in parallel, they are not described in detail herein. Through the analysis of the above three cases, it can be demonstrated that the transactions inserted into the transaction pool can be executed in parallel correctly, safely and orderly through the step S2 of the present embodiment.
In this embodiment, when the destination addresses between the transactions in the parallel processing process are the same, each transaction is sequentially executed by locking the destination address, so that the data after each transaction in this case will not be covered, similarly, when the source addresses between the transactions in the parallel processing process are the same, each transaction can be sequentially executed in this case by sequentially executing each transaction according to the priority of the account transaction serial number of the source address, and the data after each transaction will not be covered, and similarly, when the broken number exists in the account transaction serial number of the source address in the transaction in the parallel processing process, by placing the transaction into the buffer area, the execution is delayed, so that each transaction can be sequentially executed in this case, and the data after each transaction will not be covered. The method solves the problem of data coverage under various conditions, also solves the problem of data processing sequence under various conditions, and ensures the ordering and safety of parallel processing of a plurality of transactions.
Preferably, step S2 of the present embodiment further includes: and after all the transactions in the transaction pool are executed, emptying the transaction pool, and emptying the first buffer zone and the second buffer zone so as to facilitate parallel processing of a plurality of transactions in the next block.
After the pool is emptied, the discarded transactions in step S1 may be considered in the next block parallel processing of the plurality of transactions, and since the transactions that conflict with the discarded transactions, such as the transactions that conflict with the source address and/or the destination address of the discarded transactions, i.e. the account address is performed as both the source address and the destination address in the plurality of transactions, may not have transactions that conflict with the source address or the destination address during the present processing, and may be performed. Of course, these discarded transactions still need to be processed according to the procedure described in the foregoing embodiments at this time, for example, according to the source address and the destination address of the transaction, the destination address is queried in the first buffer, and the source address is queried in the second buffer: if the transaction does not exist, the source address of the transaction is stored in the first buffer area, the destination address of the transaction is stored in the second buffer area, the transaction is inserted into the transaction pool, otherwise, the transaction is discarded, and the parallel processing of the next block is continued to be waited. The rest of the processing is substantially the same as described in the previous embodiments, and is not repeated here and is incorporated herein by reference.
Second embodiment
Referring to fig. 3, the present invention proposes a transaction source-destination address separation processing system, which includes:
the receiving and screening module 1 is used for sequentially receiving and screening a plurality of transactions, and receiving one transaction each time, if the source address of the transaction is the same as the destination address of the transaction in the transaction pool, or if the destination address of the transaction is the same as the source address of the transaction in the transaction pool, discarding the transaction, otherwise, placing the transaction in the transaction pool;
the parallel processing module 2 is configured to process transactions in the transaction pool in parallel through several threads:
if the destination addresses of the transactions processed in parallel are the same, each transaction is sequentially executed by locking the destination address;
if the source addresses of the transactions processed in parallel are the same, executing each transaction in sequence according to the priority of the account transaction serial number of the source address, wherein the account transaction serial number is the serial number marked by each account for the transaction initiated by the user;
if the account transaction serial number of the source address in the current parallel processing transaction has a broken number, the transaction is put into a buffer area for later execution, and the broken number is that the transaction which is not executed by the transaction pool has a higher priority than the account transaction serial number of the current transaction.
The present embodiment will now be described in detail, but is not limited thereto.
The method is suitable for parallel processing of multiple transactions, particularly for parallel processing of multiple transactions under complex conditions, wherein the complex conditions include, but are not limited to, the condition that addresses are used as source addresses and destination addresses, the condition that the destination addresses among the parallel processing transactions are the same, the condition that the source addresses among the parallel processing transactions are the same, the condition that account transaction serial numbers of the source addresses exist in the parallel processing transactions are broken, under the complex conditions, the method can not only orderly and safely execute each transaction when the conditions appear in the parallel processing process, but also more importantly, the multiple transactions can be rapidly and parallelly processed when the conditions do not appear, the processing abnormality of the latter is solved, the processing error in the parallel processing process is avoided, the integral ordering and safety of the parallel processing are ensured, and the integral execution efficiency is greatly improved.
In this embodiment, two buffers for storing transaction addresses are pre-set, one for storing source addresses in the transaction and one for storing destination addresses in the transaction, so as to separate the source address from the destination address, thereby implementing the transaction source address and destination address separation processing in this embodiment.
1) Detailed description receiving and screening module
The receiving and screening module of this embodiment is configured to sequentially receive and screen a plurality of transactions, and each time a transaction is received, if the source address of the transaction is the same as the destination address of the transaction in the transaction pool, or if the destination address of the transaction is the same as the source address of the transaction in the transaction pool, discard the transaction, otherwise put the transaction into the transaction pool. The source address is the account from which the transaction is initiated, the destination address is the account from which the transaction is received, and the transaction pool of the block is used for block verification and caching of the transaction.
Preferably, the block receives a plurality of transactions by verifying the private key signature of the user account, and confirming the identity of the user account to confirm whether the transaction to be received is legal, wherein the validity of the private key signature is verified by the public key of the user account on the blockchain, and the screening of the transaction is executed after the verification is passed.
Specifically, the receiving filtering module of this embodiment is further configured to perform: the block sequentially receives and screens a plurality of transactions, and each time a transaction is received, the source address and the destination address of the transaction are acquired, the destination address is queried in a first buffer zone, and the source address is queried in a second buffer zone: if the transaction is not present, the source address of the transaction is stored in the first buffer area, the destination address of the transaction is stored in the second buffer area, the transaction is inserted into the transaction pool, and otherwise, the transaction is discarded.
The method specifically includes separating source address from destination address and screening transactions by a first buffer area for storing source address and a second buffer area for storing destination address, and is notable in that the query is to search opposite buffer areas, i.e. the source address is to search the second buffer area for storing destination address, but the destination address is to search the first buffer area for storing source address, but the buffer area is normally inserted into the buffer area, i.e. the source address is inserted into the first buffer area for storing source address, and the destination address is inserted into the second buffer area for storing destination address, so as to screen out transactions which collide with the existing transaction pool, i.e. the destination address of the current transaction is already used as the source address in the existing transaction pool, and the source address of the current transaction is already used as the destination address in the existing transaction pool, which need to be screened out before entering the transaction pool, so as to avoid affecting orderly, safe and accurate execution of parallel processing of multiple transactions.
The following describes the above-mentioned receiving and screening module by way of example, but not limited thereto:
assuming that there are four accounts a, B, C, D, there will be the following 6 transactions involving these accounts.
1A(1)-10->B
2B(1)-20->C
3A(2)-15->C
4D(1)-25->B
5A(3)-10->D
6D(2)-20->C
The forefront number is the number of the transaction, the number in the bracket of the account is a nonce value, the nonce value is the number marked on the transaction initiated by each account, the accounts do not collide, the account is called as the account transaction number in the embodiment, and the number in the middle of the arrow is the transfer amount.
For the 6 transactions, the 1 st transaction request is sent to the chain, the block obtains the source address A of the request to store the second buffer area searching of the destination address, and finds no address A, and then obtains the destination address B of the transaction to store the first buffer area searching of the source address, and finds no address B. Therefore, A is inserted into the first buffer, B is inserted into the second buffer, and the 1 st transaction is inserted into the transaction pool. Note that the lookup is to a counter buffer lookup, the source address to destination address buffer lookup, and the destination address to source address buffer lookup, but the insertion is to a normal insertion buffer.
Then the blockchain receives the 2 nd transaction request, the block obtains the source address B to find the second buffer area for storing the destination address, and finds that B exists in the second buffer area, and the separation lock mechanism of the embodiment is not met, namely the 2 nd transaction collides with the 1 st transaction, and the address B is used as the destination address of the 1 st transaction and the source address of the 2 nd transaction, so that the 2 nd transaction is directly discarded.
Then, the 3 rd transaction is checked that the source address A is not in the second buffer area and the destination address C is not in the first buffer area, so that C is inserted into the destination address buffer area and the 3 rd transaction is inserted into the transaction pool. Because a is already in the first buffer, insertion of a into the first buffer will not perform any operations.
The 4 th transaction is similar to the 1 st and 3 rd transactions, the address D is inserted into the first buffer and the transaction is inserted into the transaction pool.
The 5 th transaction checks that the destination address D is present in the first buffer, and the transaction is discarded.
The 6 th transaction is also without problems and will be inserted into the transaction pool.
Thus, after all 6 transactions were submitted, the result of the screening was that the 2 nd and 5 th transactions were discarded, with the following 4 transactions entering the pool, as follows:
1A(1)-10->B
3A(2)-15->C
4D(1)-25->B
6D(2)-20->C
therefore, the embodiment ensures that the situation that an account address is used as a source address and a destination address is not generated in the transaction in the block transaction pool by screening a plurality of transactions sequentially received by the block, wherein the technical characteristics of source-destination address separation are adopted, the source address and the destination address are separated by setting two buffer areas respectively used for storing the source address and the destination address, and whether the current transaction can be generated with the transaction in the transaction pool or not can be known only by inquiring the two buffer areas when one transaction is received, so that the technical problem that the account address is used as the source address and the destination address is solved, the transaction complexity in the transaction pool is greatly simplified, and the parallel transaction processing becomes easier, and the transaction processing efficiency is further improved.
2) Detailed description parallel processing module
The parallel processing module of the embodiment processes the transactions in the transaction pool in parallel through a plurality of threads: if the destination addresses of the transactions processed in parallel are the same, each transaction is sequentially executed by locking the destination address; if the source addresses of the transactions processed in parallel are the same, executing each transaction in sequence according to the priority of the account transaction serial number of the source address; if the account transaction serial number of the source address in the current parallel processing transaction has a broken number, the transaction is put into a cache area for later execution; if the current parallel processing transaction does not have the conditions, each transaction is currently executed in parallel. The account transaction serial numbers are serial numbers marked by the accounts for transactions initiated by the accounts, and can be used for identifying the processing sequence of the transactions, wherein the broken account transaction serial numbers are transactions which are not executed by the transaction pool and have higher priority than the account transaction serial numbers of the current transactions, namely the transactions executed by the current thread are not in the highest priority among the transactions which are not executed.
a. Specifically, when the destination addresses of the transactions processed in parallel are the same, each transaction is sequentially executed by locking the destination address, where threads of each transaction with the same destination address are processed in parallel, locking the destination address and executing the transaction sequentially through a synchronization lock corresponding to the destination address, where a thread of the next execution obtains the synchronization lock after the previous transaction is executed, and the synchronization lock is a mechanism for thread synchronization, and may include thread synchronization mechanisms such as a mutual exclusion lock, a semaphore, a critical section, and the like, and in this embodiment, data synchronization between multiple transactions with the same destination address is realized specifically through the synchronization lock.
The transaction processing procedure in this case will be described with respect to four transactions after the above-described example screening, but is not limited thereto.
In these 4 transactions, account a and account D initiate two transactions, respectively, and account B and account C are turned twice, respectively. Assuming that two threads are executing transactions in parallel, account B has 50 money and account C has 40 money, if two transactions initiated by account a are located in one thread, two transactions initiated by account D are located in the other thread, as follows:
thread 1:1A (1) -10- > B,3A (2) -15- > C;
thread 2:4D (1) -25- > B,6D (2) -20- > C.
In this case, thread 1 and thread 2 are executed in no order, and because for the destination account, no matter which thread is executed first, the final result is not affected, so the execution of this process can be performed sequentially according to the actual situation of thread 1 and thread 2:
if thread 1 first performs transaction 1, namely, a transaction for 10 blocks of B transfer, then the synchronous lock in the B account locks the B account, and the B account is unlocked after the A transfer to the B account, and 60 blocks of B account exist. After thread 2 waits for thread 1 to finish execution, a synchronous lock is obtained, transaction 4 is executed, namely, D transfers 25 blocks to B, and finally, 85 blocks of B are obtained.
If thread 2 first performs transaction 4, namely, D to 25 blocks of B transfer, then the synchronization lock in B account will lock B account, D to unlock after B transfer, and B account has 75 blocks. After thread 1 waits for thread 2 to finish executing, a synchronous lock is obtained, transaction 1 is executed, namely, transfer A to B is 10 blocks, and finally B has 85 blocks.
Transaction 3 is similar to transaction 6 and is not illustrated herein. In this regard, for the source account, because both external transfers of A are in one thread and are ordered by account transaction number within the thread, the execution result is not affected by the account transaction number break, as is the case for D. It should be noted that, although the above only exemplifies the process of processing 4 transactions in parallel by two threads, it is obvious that the present embodiment is not limited thereto, and it is easy to think that if there are three transactions whose destination addresses are the same and require parallel processing, each transaction can be sequentially executed by locking the destination addresses through a similar processing procedure as described above.
b. Specifically, when the source addresses of the transactions processed in parallel are the same, each transaction is sequentially executed according to the priority of the account transaction serial number of the source address, wherein the threads of each transaction with the same source address are processed in parallel, each transaction is sequentially executed according to the priority of the account transaction serial number of the source address, before each thread executes the transaction, if the account transaction serial number of the transaction has a broken number, the thread puts the transaction into a cache area, and when all the transactions with higher priority than the account transaction serial number are executed, the thread takes out the transaction for execution.
For the transaction processing procedure of this case, another case is assumed to be illustrated, but not limited to this: the two transactions initiated by a are not in one thread, nor are the two transactions initiated by D are in one thread, as follows:
thread 1:1A (1) -10- > B,6D (2) -20- > C;
thread 2:3A (2) -15- > C,4D (1) -25- > B.
In this case, if thread 2 first executed transaction 3, a- > C, finds that the nonce value of a has a break, then the transaction is put into the cache, executed later, and then transaction 4, D- > B, is executed. At the same time, thread 1 begins executing transaction 1, i.e., A- > B. Therefore, in the first period, the two threads respectively execute the transaction 1:A- > B and the transaction 4:D- > B, and the 2 transactions are all transfer B, and in the case that the destination addresses are the same in the previous embodiment, each transaction can be sequentially executed by locking the destination address.
After thread 1 completes transaction 1:A- > B, thread 2 also completes transaction 4:D- > B, at this time, thread 2 will fetch the previously cached transaction 3:A- > C for re-execution, because thread 1 has already completed transaction 1:A- > B and the nonce value of the A account has already been increased by 1, no break number problem exists, so thread 2 can normally execute transaction 3:A- > C. Similarly, thread 1 may continue to execute transaction 6:D- > C.
The embodiment realizes the process of parallel processing 4 transactions by two threads through the modules, wherein the parallel processing process has the same condition of destination address and source address, and the whole parallel processing process only realizes partial parallel processing, but can improve the overall transaction processing efficiency compared with the prior art.
c. Specifically, when the account transaction serial number of the source address in the parallel processing transaction has a broken number, the transaction is put into a buffer area for later execution, wherein after the transaction is put into the buffer area, the thread takes out the transaction for execution by monitoring the change condition of the account transaction serial number of the source address of the transaction in real time, and when the execution of all the transactions with higher priority than the account transaction serial number is finished.
For the transaction processing procedure of this case, another case is assumed for illustration, but not limited thereto, as follows:
thread 1:1A (1) -10- > B,4D (1) -25- > B;
thread 2:3A (2) -15- > C,6D (2) -20- > C.
In this case, since there is a break in the nonce value for both source accounts within thread 2, i.e., neither of the two transactions that thread 2 is responsible for processing is at the highest priority in the unexecuted transactions, it will have to wait for the nonce value to change before executing. Preferably, loops may be set in thread 2 to monitor changes in the nonce value in real time, indicating that the transaction prior to the account has been performed when the nonce value is a transaction executable value. Then the four transactions will be executed first in the two threads 1:A- > B, then thread 1 and thread 2 execute transactions 4:D- > B and transactions 3:a- > C, respectively, in parallel, and finally thread 2 executes transactions 6:D- > C again.
According to the embodiment, the process of parallel processing of 4 transactions by two threads is realized through the modules, wherein account transaction serial numbers of source addresses in transactions appear in the threads, and the execution efficiency can be improved in a multi-core CPU computer although the whole process only realizes partial parallelism.
In summary, many cases can be enumerated in addition to the above three cases, but all of them do not depart from the variants of the above three cases, and since the above three cases already cover all conflict cases occurring when transactions are executed in parallel, they are not described in detail herein. Through the analysis of the above three cases, it can be demonstrated that the transactions inserted into the transaction pool can be executed in parallel correctly, safely and orderly through the step S2 of the present embodiment.
In this embodiment, when the destination addresses between the transactions in the parallel processing process are the same, each transaction is sequentially executed by locking the destination address, so that the data after each transaction in this case will not be covered, similarly, when the source addresses between the transactions in the parallel processing process are the same, each transaction can be sequentially executed in this case by sequentially executing each transaction according to the priority of the account transaction serial number of the source address, and the data after each transaction will not be covered, and similarly, when the broken number exists in the account transaction serial number of the source address in the transaction in the parallel processing process, by placing the transaction into the buffer area, the execution is delayed, so that each transaction can be sequentially executed in this case, and the data after each transaction will not be covered. The method solves the problem of data coverage under various conditions, also solves the problem of data processing sequence under various conditions, and ensures the ordering and safety of parallel processing of a plurality of transactions.
Preferably, the embodiment further includes an initialization module, configured to end execution of all transactions in the transaction pool, empty the transaction pool, and empty the first buffer area and the second buffer area, so as to process multiple transactions in parallel in a next block.
After the pool is emptied, the discarded transactions in step S1 may be considered in the next block parallel processing of the plurality of transactions, and since the transactions that conflict with the discarded transactions, such as the transactions that conflict with the source address and/or the destination address of the discarded transactions, i.e. the account address is performed as both the source address and the destination address in the plurality of transactions, may not have transactions that conflict with the source address or the destination address during the present processing, and may be performed. Of course, these discarded transactions still need to be processed according to the procedure described in the foregoing embodiments at this time, for example, according to the source address and the destination address of the transaction, the destination address is queried in the first buffer, and the source address is queried in the second buffer: if the transaction does not exist, the source address of the transaction is stored in the first buffer area, the destination address of the transaction is stored in the second buffer area, the transaction is inserted into the transaction pool, otherwise, the transaction is discarded, and the parallel processing of the next block is continued to be waited. The rest of the processing is substantially the same as described in the previous embodiments, and is not repeated here and is incorporated herein by reference.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
Third embodiment
The present invention also proposes a computer device comprising a memory and a processor, the memory having stored therein computer readable instructions which, when executed by the processor, cause the processor to perform a transaction source destination address separation processing method as mentioned in the first embodiment above.
Fourth embodiment
The present invention proposes a storage medium storing computer readable instructions that, when executed by one or more processors, cause the one or more processors to perform a transaction source-destination address separation processing method as mentioned in the first embodiment above.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer 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, read only compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage, quantum memory, graphene-based storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by the computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
The technical features of the above-described embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above-described embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above-described embodiments represent only some exemplary embodiments of the invention, which are described in more detail and are not to be construed as limiting the scope of the invention. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the invention, which are all within the scope of the invention. Accordingly, the scope of protection of the present invention is to be determined by the appended claims.

Claims (8)

1. The transaction source-destination address separation processing method is characterized by comprising the following steps:
s1: the method comprises the steps that a block sequentially receives and screens a plurality of transactions, each time a transaction is received, if the source address of the transaction is the same as the destination address of the transaction in a transaction pool, or if the destination address of the transaction is the same as the source address of the transaction in the transaction pool, the transaction is discarded, otherwise, the transaction is put into the transaction pool, a first buffer area for storing the source address and a second buffer area for storing the destination address are pre-established, the block sequentially receives and screens a plurality of transactions, each time a transaction is received, the source address and the destination address of the transaction are obtained, the destination address is searched in the first buffer area, and the source address is searched in the second buffer area:
If the transaction is not present, the source address of the transaction is stored in the first buffer area, the destination address of the transaction is stored in the second buffer area, the transaction is inserted into the transaction pool, and otherwise, the transaction is discarded;
s2: parallel processing is carried out on transactions in the transaction pool through a plurality of threads:
if the destination addresses of the transactions processed in parallel are the same, each transaction is sequentially executed by locking the destination address;
if the source addresses of the transactions processed in parallel are the same, executing each transaction in sequence according to the priority of the account transaction serial number of the source address, wherein the account transaction serial number is the serial number marked on the transaction initiated by each account;
if the account transaction serial number of the source address in the current parallel processing transaction has a broken number, the transaction is put into a buffer area for later execution, and the broken number is a transaction with higher priority than the account transaction serial number of the current transaction in the non-executed transaction of the transaction pool;
after the transaction is put into the buffer, the thread takes out the transaction to be executed after all the transactions with higher priority than the account transaction serial numbers are finished by monitoring the change condition of the account transaction serial numbers of the source address of the transaction in real time.
2. The method of claim 1, wherein sequentially executing each transaction by locking the destination address further comprises:
and processing threads of all transactions with the same destination address in parallel, locking the destination address through a synchronous lock corresponding to the destination address in sequence, and executing the transactions, wherein the thread of the later execution acquires the synchronous lock after the execution of the former transaction.
3. The method for processing and separating a transaction source and destination address according to claim 1, wherein sequentially executing each transaction according to the priority of the account transaction serial number of the source address further comprises:
and processing threads of all transactions with the same source address in parallel, and sequentially executing all transactions according to the priority of the account transaction serial numbers of the source address, wherein before each thread executes the transactions, if the account transaction serial numbers of the transactions have the broken numbers, the thread puts the transactions into a cache area, and when all transactions with higher priority than the account transaction serial numbers are executed, the thread takes out the transactions for execution.
4. The method according to claim 1, wherein the step S2 further comprises:
And ending all transaction execution in the transaction pool, emptying the transaction pool, and emptying the first buffer zone and the second buffer zone.
5. A transaction source-destination address separation processing system, comprising:
the receiving and screening module is used for sequentially receiving and screening a plurality of transactions by the block, receiving one transaction each time, if the source address of the transaction is the same as the destination address of the transaction in the transaction pool, or if the destination address of the transaction is the same as the source address of the transaction in the transaction pool, discarding the transaction, otherwise, placing the transaction into the transaction pool, pre-setting a first buffer area for storing the source address and a second buffer area for storing the destination address, sequentially receiving and screening a plurality of transactions by the block, acquiring the source address and the destination address of the transaction each time when receiving one transaction, inquiring the destination address in the first buffer area, and inquiring the source address in the second buffer area:
if the transaction is not present, the source address of the transaction is stored in the first buffer area, the destination address of the transaction is stored in the second buffer area, the transaction is inserted into the transaction pool, and otherwise, the transaction is discarded;
The parallel processing module is used for carrying out parallel processing on the transactions in the transaction pool through a plurality of threads:
if the destination addresses of the transactions processed in parallel are the same, each transaction is sequentially executed by locking the destination address;
if the source addresses of the transactions processed in parallel are the same, executing each transaction in sequence according to the priority of the account transaction serial number of the source address, wherein the account transaction serial number is the serial number marked on the transaction initiated by each account;
if the account transaction serial number of the source address in the current parallel processing transaction has a broken number, the transaction is put into a buffer area for later execution, and the broken number is a transaction with higher priority than the account transaction serial number of the current transaction in the non-executed transaction of the transaction pool;
after the transaction is put into the buffer, the thread takes out the transaction to be executed after all the transactions with higher priority than the account transaction serial numbers are finished by monitoring the change condition of the account transaction serial numbers of the source address of the transaction in real time.
6. The transaction source address separation processing system of claim 5, further comprising an initialization module for ending execution of all transactions in the transaction pool, flushing the transaction pool, and flushing the first buffer and the second buffer.
7. A computer device comprising a memory and a processor, the memory having stored therein computer readable instructions that, when executed by the processor, cause the processor to perform the transaction source destination address separation processing method of any of claims 1 to 4.
8. A storage medium storing computer readable instructions which, when executed by one or more processors, cause the one or more processors to perform the transaction source destination address separation processing method of any of claims 1 to 4.
CN202011638966.XA 2020-12-31 2020-12-31 Transaction source-destination address separation processing method and system Active CN112732831B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011638966.XA CN112732831B (en) 2020-12-31 2020-12-31 Transaction source-destination address separation processing method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011638966.XA CN112732831B (en) 2020-12-31 2020-12-31 Transaction source-destination address separation processing method and system

Publications (2)

Publication Number Publication Date
CN112732831A CN112732831A (en) 2021-04-30
CN112732831B true CN112732831B (en) 2023-12-15

Family

ID=75608874

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011638966.XA Active CN112732831B (en) 2020-12-31 2020-12-31 Transaction source-destination address separation processing method and system

Country Status (1)

Country Link
CN (1) CN112732831B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108027867A (en) * 2015-07-14 2018-05-11 Fmr有限责任公司 Calculate efficient transfer accounts processing, audit and searcher, method and system
CN110264207A (en) * 2019-08-15 2019-09-20 广州蚁比特区块链科技有限公司 Block chain separation processing method and system
CN111736963A (en) * 2020-06-08 2020-10-02 中国科学院计算技术研究所 Transaction processing system and method for backbone-free multi-partition blockchain

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108027867A (en) * 2015-07-14 2018-05-11 Fmr有限责任公司 Calculate efficient transfer accounts processing, audit and searcher, method and system
CN110264207A (en) * 2019-08-15 2019-09-20 广州蚁比特区块链科技有限公司 Block chain separation processing method and system
CN111736963A (en) * 2020-06-08 2020-10-02 中国科学院计算技术研究所 Transaction processing system and method for backbone-free multi-partition blockchain

Also Published As

Publication number Publication date
CN112732831A (en) 2021-04-30

Similar Documents

Publication Publication Date Title
CN108648078B (en) Transaction preprocessing method and device and electronic equipment
CN107040585B (en) Service checking method and device
AU2016244128B2 (en) Processing database transactions in a distributed computing system
CN111882435B (en) Method and device for executing transaction in block chain
CN110675255B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN108572876B (en) Method and device for realizing read-write lock
US9460143B2 (en) Methods, systems, and computer readable media for a multi-view data construct for lock-free operations and direct access
CN110706101B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN110188110B (en) Method and device for constructing distributed lock
CN110648124B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN113568981B (en) Transaction data processing method, device, equipment and medium
CN112053149A (en) Method and device for preventing repeated payment, electronic equipment and readable storage medium
CN112748994B (en) Block chain transaction parallel processing method and system
CN112732831B (en) Transaction source-destination address separation processing method and system
CN110706108B (en) Method and apparatus for concurrently executing transactions in a blockchain
TWI732501B (en) Method and device for parallel execution of transactions in block chain, computer readable storage medium and computing equipment
US10101999B2 (en) Memory address collision detection of ordered parallel threads with bloom filters
JP4712863B2 (en) Address exclusion control system and address exclusion control method
WO2021057165A1 (en) Method for concurrently executing transactions in blockchain, and device
CN113256419B (en) Block chain transaction retrieval method and system
WO2022120313A1 (en) Methods for distributed key-value store
CN114281892A (en) Data synchronization method, device, equipment and storage medium
CN117648159A (en) Method and device for parallelizing execution of block chain transaction and electronic equipment
CN112866211A (en) Information processing method for big data security authentication and block chain trust server
CN111242781A (en) Transaction management method and device based on block chain

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
GR01 Patent grant
GR01 Patent grant