Block chain transaction distribution method and device, equipment and storage medium

By implementing the blockchain transaction allocation method on the blockchain node, and allocating transactions to be matched according to the exchange's matching efficiency, the resource waste caused by repeated matchmaking by multiple exchanges is solved, and transaction efficiency and accuracy are improved.

CN119831591APending Publication Date: 2025-04-15WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411905812.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

In the existing blockchain transaction matching technology, repeated matchmaking of exchanges by multiple exchanges leads to wasting of blockchain system and exchange resources.

Method used

By implementing a blockchain transaction allocation method on the blockchain node, the transactions to be matched are obtained and the target exchange is determined based on the matching efficiency of the registered exchange, and the transactions to be matched are allocated to the target exchange to avoid repeated matching.

Benefits of technology

It effectively saves resources from blockchain systems and exchanges, improves the efficiency and accuracy of matching transactions, and reduces resource waste.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119831591A_ABST
    Figure CN119831591A_ABST
Patent Text Reader

Abstract

The invention provides a block chain transaction distribution method and device, equipment and a storage medium, and relates to the technical field of computers. The method comprises the steps of obtaining a to-be-matched transaction submitted to a block chain system; determining a target exchange according to the matchmaking efficiency of at least one exchange registered to the block chain system, and distributing the to-be-matchled transaction to the target exchange; the matchmaking efficiency of any exchange is obtained by calculating at least one matchmaking transaction pair processed by the exchange; receiving a matchmaking transaction pair for the to-be-matchmaking transaction returned by the target transaction, and completing the matchmaking transaction pair through the block chain; the matchmaking transaction pairs are used for updating matchmaking transaction pairs corresponding to the target transaction. By adoption of the method, waste of block chain system resources and exchange resources caused by repeated competition of at least one exchange in the block chain system for the to-be-matched transaction can be avoided, the block chain system resources and the exchange resources can be saved, and the matching efficiency of the block chain transaction is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a blockchain transaction allocation method, device, equipment and storage medium. Background Art

[0002] In the traditional exchange order trading process, multiple users place orders on the exchange, some users place buy orders, and some users place sell orders. The exchange matches all the orders and executes the orders with matching prices. In the traditional exchange order trading process, buyers and sellers can only place orders on a single exchange. For example, if the order is a Hong Kong stock transaction, then the order can only be traded on the Hong Kong Stock Exchange.

[0003] In blockchain exchanges, due to the openness of blockchain, users are no longer restricted to placing orders on a single exchange. Users can directly send order requests to the blockchain through Web3 wallets. Similarly, some users place buy orders and some users place sell orders. Then the exchanges registered with the blockchain monitor transaction events on the chain, collect order information, and send price-matched order pairs to the chain. Finally, after the smart contract on the chain confirms, delivery is carried out, and relevant fees are charged to the buyer and seller users. At this point, the transaction ends.

[0004] Generally speaking, in order to encourage more exchanges to participate in transaction matching and improve the efficiency of asset circulation, asset issuers usually share profits with successfully matched exchanges. Therefore, in theory, the more successful transactions an exchange matches, the more transaction share fees the exchange will receive, which leads to exchanges wanting to obtain as much pending order information as possible and match them as quickly as possible.

[0005] Existing matching technologies include Figure 1 As shown, Figure 1 There are multiple wallet clients in China, which are denoted as wallet client 1 to wallet client n. Figure 1There are also multiple exchanges, which are recorded as exchange 1 to exchange n. Each exchange includes a transaction listener, a transaction matchmaker, and a transaction on-chain service. Among them, the transaction listener is mainly used to listen to the matching transactions submitted by the wallet client from the blockchain system, the transaction matchmaker is mainly used to match the monitored matching transactions, and the transaction on-chain service is mainly used to send the matching transaction pairs obtained after matching to the blockchain system, and the smart contract on the blockchain system confirms the delivery and other processing. n wallet clients can submit matching transactions to the blockchain system. Each exchange will listen to the matching transactions in the blockchain system and match them independently. Since it takes time to confirm the transaction pairs and synchronize the transaction pairs on the chain, some transactions may be matched repeatedly within this time difference. Although the transaction pairs will eventually be confirmed on the blockchain, the repeated matching transaction pairs will be rejected by the smart contract, but repeated matching will cause a large waste of both the exchange's system resources and the resources of the blockchain system. Summary of the invention

[0006] The present application provides a blockchain transaction allocation method, device, equipment and storage medium for saving resources of blockchain systems and exchanges.

[0007] In a first aspect, the present application provides a blockchain transaction allocation method, which is applied to a blockchain node, comprising:

[0008] Obtain pending transactions submitted to the blockchain system;

[0009] Determine a target exchange according to the matching efficiency of at least one exchange registered with the blockchain system, and assign the to-be-matched transaction to the target exchange; the matching efficiency of any exchange is calculated based on at least one matched transaction pair processed by the exchange;

[0010] Receive the matching transaction pair for the to-be-matched transaction returned by the target exchange, and complete the matching transaction pair through the blockchain system; the matching transaction pair is used to update the matched transaction pair corresponding to the target exchange.

[0011] After obtaining the pending transaction submitted to the blockchain system, the present application does not require at least one exchange registered to the blockchain system to compete for the pending transaction at the same time, but determines the target exchange according to the matching efficiency of at least one exchange and allocates the pending transaction to the target exchange. Therefore, the problem of waste of blockchain system and exchange resources caused by repeated matching of multiple exchanges is avoided, and the resources of the blockchain system and the exchange are saved; and the matching efficiency of at least one exchange is calculated based on the matched transaction pairs of each exchange, and the target exchange will also return the matched transaction pairs after matching the pending transaction to the blockchain system to update the matched transaction pairs of the target exchange. Therefore, each exchange will return the matched transaction pairs to the blockchain system after the transaction matching is successful, which ensures the accuracy of at least one matched transaction pair corresponding to each exchange, and then ensures the accuracy of the matching efficiency calculated based on the matched transaction pairs, and improves the accuracy and rationality of allocating the pending transaction to the target exchange according to the matching efficiency.

[0012] In a possible design, allocating the to-be-matched transaction to the target exchange includes:

[0013] Based on the transaction to be matched and the target exchange, a transaction request is generated, wherein the transaction request includes transaction information of the transaction to be matched and address information of the target exchange;

[0014] The transaction request is propagated in the blockchain system, and any exchange is used to match the to-be-matched transaction when it is determined that the address information of the exchange indicated in the transaction request is the same as its own address information.

[0015] After receiving a transaction request, the exchange will match its own address information with the address information in the transaction request. If its own address information is the same as the address information in the transaction request, the transaction to be matched included in the transaction request should be processed; if its own address information is different from the address information in the transaction request, there is no need to process the transaction request; in this way, repeated matching of the transactions to be matched included in the transaction request by each exchange is avoided.

[0016] In a possible design, the matching efficiency of any exchange is determined by the block height of the buy transaction, the block height of the sell transaction, and the block height of the matched transaction pair in any matched transaction pair matched by the exchange, to determine the matching time of the matched transaction pair; the matching efficiency of the exchange is determined based on the matching time of the most recent N matched transaction pairs; N is a positive integer.

[0017] If the difference between the block height of the buy exchange or the block height of the sell exchange in the matched transaction pair and the block height of the matched transaction pair is larger, it means that the buy transaction or the sell transaction has been waiting for matching for a longer time on the exchange, that is, the longer the matching time of the matched transaction pair is, the slower the matching speed of the exchange is; on the contrary, if the difference between the block height of the buy exchange or the block height of the sell exchange in the matched transaction pair and the block height of the matched transaction pair is smaller, it means that the buy transaction or the sell transaction has been waiting for matching for a shorter time on the exchange, that is, the shorter the matching time of the matched transaction pair is, the faster the matching speed of the exchange is; and the present application takes into account that the matching time of the matched transaction pairs that are relatively far away from the current one may have less reference value. Therefore, the present application determines the matching efficiency of the exchange based on the matching time of the most recent N matched transaction pairs, thereby improving the accuracy of the matching efficiency.

[0018] In a possible design, the matching efficiency of the exchange is determined based on the matching duration of the most recent N matched trading pairs, including:

[0019] Determine the average matching time of the exchange according to the matching time of the most recent N matched trading pairs;

[0020] According to the matching durations of the most recent N matched trading pairs and the average matching duration, the exponentially weighted moving average method EWMA is used to determine the matching efficiency of the exchange.

[0021] EWMA gives exponentially decreasing weights to data collected at different time points, making the impact of recent data on the calculation results more significant. In other words, the matching time of the more recent matched trading pairs among the last N matched trading pairs has a greater impact on the matching efficiency of the exchange.

[0022] In one possible design, the method further includes:

[0023] If no matching transaction pair for the to-be-matched transaction is received within the set time period, it is determined that the matching of the target exchange has timed out;

[0024] If the number of transactions that have timed out on any exchange meets the matching failure conditions, the allocation of pending matching transactions to the exchange will be stopped.

[0025] When the number of transactions that have timed out for matching on an exchange meets the matching failure conditions, it can be considered that the exchange is likely to fail and cannot match transactions. Therefore, the allocation of pending matching transactions to the exchange will be stopped in the future.

[0026] In a possible design, determining a target exchange according to the matching efficiency of at least one exchange registered with the blockchain system includes:

[0027] In each matching efficiency calculation cycle, the matching efficiency of each exchange is determined according to the N matched transaction pairs corresponding to each exchange registered in the blockchain system; a share ring is determined according to the matching efficiency of each exchange, each share on the share ring has its own corresponding exchange, and the number of shares of any exchange is positively correlated with the matching efficiency of the exchange;

[0028] The pointer of the share ring is rotated according to a preset angle, and the exchange corresponding to the share pointed to by the pointer when the pointer stops rotating is determined as the target exchange, wherein the preset angle is the angle corresponding to each share.

[0029] The share ring is composed of the shares corresponding to each exchange, and the shares corresponding to each exchange are positively correlated with the exchange's own matching efficiency. That is to say, the greater the matching efficiency of the exchange, the more shares the exchange occupies in the share ring, and the greater the probability that the pointer points to its corresponding share when it stops moving. Therefore, the exchange with higher matching efficiency is more likely to be identified as the target exchange, shortening the matching time of the transactions to be matched, improving the matching efficiency of the transactions to be matched, and improving the user experience.

[0030] In a possible design, the shares corresponding to each exchange are continuously distributed on the share ring; or, the shares corresponding to each exchange are distributed at intervals on the share ring.

[0031] The shares corresponding to each exchange can be distributed continuously or at intervals on the share ring. Continuous distribution can ensure that exchanges with higher matching efficiency are continuously identified as target exchanges, shortening the matching time of transactions to be matched; intermittent distribution can effectively avoid the problem of matching timeout or matching failure of transactions to be matched due to the identification of an exchange as the target exchange after a failure occurs, thereby improving the reliability of the blockchain system.

[0032] In a possible design, the share ring also includes shares with potential attributes; the potential attributes correspond to exchanges registered with the blockchain system within the matching efficiency calculation cycle, and / or the potential attributes correspond to exchanges that have not completed N matched transaction pairs, and / or the potential attributes correspond to each exchange registered with the blockchain system.

[0033] The share ring with potential attributes can flexibly respond to the situation where exchanges newly register to the blockchain system or exit the blockchain system, thereby improving the flexibility and robustness of the blockchain system.

[0034] In a possible design, if the number of transactions that have timed out on any exchange meets the matching failure condition, the allocation of pending matching transactions to the exchange will be stopped, including:

[0035] If the number of matching timeout transactions of any exchange meets the matching failure condition, the share corresponding to the exchange will be removed from the share ring.

[0036] When the number of matching timeout transactions of an exchange meets the matching failure condition, the shares corresponding to the exchange are promptly removed from the share ring, and the share ring is updated to prevent the pointer of the share ring from turning to the shares corresponding to the exchange.

[0037] In a second aspect, the present application further provides a blockchain transaction allocation device, which is applied to a blockchain node and includes: a processing unit and a transceiver unit;

[0038] The transceiver unit is used to obtain the transaction to be matched submitted to the blockchain system;

[0039] The processing unit is used to determine a target exchange according to the matching efficiency of at least one exchange registered with the blockchain system, and allocate the to-be-matched transaction to the target exchange; the matching efficiency of any exchange is calculated based on at least one matched transaction pair processed by the exchange;

[0040] The transceiver unit is further used to receive the matching transaction pair for the to-be-matched transaction returned by the target exchange, and the processing unit is further used to complete the matching transaction pair through the blockchain system; the matching transaction pair is used to update the matched transaction pair corresponding to the target exchange.

[0041] In a possible design, when the processing unit is used to assign the transaction to be matched to the target exchange, it is specifically used to: generate a transaction request based on the transaction to be matched and the target exchange, wherein the transaction request includes the transaction information indicated by the transaction to be matched and the address information of the target exchange; propagate the transaction request in the blockchain system, and any exchange is used to match the transaction to be matched when it is determined that the address information of the exchange indicated in the transaction request is the same as its own address information.

[0042] In a possible design, the matching efficiency of any exchange is determined by the block height of the buy transaction, the block height of the sell transaction, and the block height of the matched transaction pair in any matched transaction pair matched by the exchange, to determine the matching time of the matched transaction pair; the matching efficiency of the exchange is determined based on the matching time of the most recent N matched transaction pairs; N is a positive integer.

[0043] In one possible design, the processing unit is used to determine the matching efficiency of the exchange based on the matching times of the most recent N matched trading pairs, and is specifically used to: determine the average matching time of the exchange based on the matching times of the most recent N matched trading pairs; and determine the matching efficiency of the exchange using the exponentially weighted moving average method EWMA based on the matching times of the most recent N matched trading pairs and the average matching time.

[0044] In a possible design, if no matching transaction pair for the transaction to be matched is received within a set time period, the processing unit is also used to determine that the matching of the target exchange has timed out; and if the number of transactions with matching timeout in any exchange meets the matching failure condition, the processing unit stops allocating transactions to be matched to the exchange.

[0045] In a possible design, when the processing unit determines the target exchange according to the matching efficiency of at least one exchange registered with the blockchain system, it is specifically used to: determine the matching efficiency of each exchange according to the N matched transaction pairs corresponding to each exchange registered with the blockchain system in each matching efficiency calculation cycle; determine a share ring according to the matching efficiency of each exchange, each share on the share ring has its own corresponding exchange, and the number of shares of any exchange is positively correlated with the matching efficiency of the exchange; rotate the pointer of the share ring according to a preset angle, and determine the exchange corresponding to the share pointed to by the pointer when the pointer stops rotating as the target exchange, and the preset angle is the angle corresponding to each share.

[0046] In a possible design, the shares corresponding to each exchange are continuously distributed on the share ring; or, the shares corresponding to each exchange are distributed at intervals on the share ring.

[0047] In a possible design, the share ring also includes shares with potential attributes; the potential attributes correspond to exchanges registered with the blockchain system within the matching efficiency calculation cycle, and / or the potential attributes correspond to exchanges that have not completed N matched transaction pairs, and / or the potential attributes correspond to each exchange registered with the blockchain system.

[0048] In a possible design, the processing unit is specifically used to: if the number of matching timeout transactions of any exchange meets the matching failure condition, remove the share corresponding to the exchange from the share ring.

[0049] In a third aspect, the present application further provides a blockchain transaction allocation device, the device comprising: a processor, and a memory communicatively connected to the processor;

[0050] The memory stores computer-executable instructions;

[0051] The processor executes the computer-executable instructions stored in the memory to implement the method described in the first aspect above.

[0052] In a fourth aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a program, and when the program is executed on a device, the device executes the method as described in any one of the above-mentioned first aspects.

[0053] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0055] Figure 1 A schematic diagram of an existing blockchain transaction allocation scheme;

[0056] Figure 2 A flowchart of a blockchain transaction allocation method provided in an embodiment of the present application;

[0057] Figure 3 Schematic diagram of the share ring provided in the embodiment of the present application Figure 1 ;

[0058] Figure 4 Schematic diagram of the share ring provided in the embodiment of the present application Figure 2 ;

[0059] Figure 5 A schematic diagram of the share interval distribution of the exchange 1 provided in the embodiment of the present application;

[0060] Figure 6 A schematic diagram of a share ring for removing the share determination of exchange 1 provided in an embodiment of the present application;

[0061] Figure 7 A schematic diagram of the share interval distribution of the exchange 2 provided in the embodiment of the present application;

[0062] Figure 8 A schematic diagram of the share interval distribution of Exchange 1 and Exchange 2 provided in the embodiment of the present application;

[0063] Fig. 9A schematic diagram of the most discrete ring provided in the embodiment of the present application;

[0064] Fig.10 Schematic diagram of the share ring pointer rotation provided in the embodiment of the present application Figure 1 ;

[0065] Fig.11 Schematic diagram of the share ring pointer rotation provided in the embodiment of the present application Figure 2 ;

[0066] Fig.12 Schematic diagram of the blockchain transaction allocation device provided in the embodiment of the present application Figure 1 ;

[0067] Fig.13 Schematic diagram of the blockchain transaction allocation device provided in the embodiment of the present application Figure 2 . DETAILED DESCRIPTION

[0068] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0069] The application scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. It is known to those skilled in the art that with the emergence of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems. In the description of the present application, unless otherwise specified, the meaning of "multiple" is two or more.

[0070] To solve the problem of duplicate matching caused by competition between exchanges, the current main solution is static order division, which can also be called a static order allocation scheme: partition orders according to certain attributes, and each exchange is responsible for a specific partition to avoid duplicate matching between exchanges; for example, taking n exchanges participating in transaction matching as an example, the literal value of the hexadecimal string of the user address can be calculated, and then the literal value can be modulo n, and the modulo result corresponds to a unique exchange, and then the transaction is fixedly assigned to the corresponding exchange; for example, the modulo result equal to 1 is assigned to exchange 1, and the modulo result equal to 2 is assigned to exchange 2...

[0071] However, static order partitioning cannot respond quickly to newly added or exited exchanges and has poor flexibility. For example, if a new exchange is added, it is necessary to coordinate n+1 exchanges to synchronously complete the partition adjustment. In order to avoid inconsistent states during the adjustment process, it is generally necessary to interrupt the service, resulting in service unavailability within a certain period of time. The same is true for exchange exit; moreover, if the exchange responsible for a specific partition fails, this part of the transaction will not be matched, resulting in poor reliability.

[0072] In order to solve the above problems of static order division, this application proposes the following Figure 2 The blockchain transaction allocation method shown in the figure can be executed by a blockchain node or a smart contract deployed on a blockchain node, which is not limited in this application. The following explanation is given by taking a blockchain node as an example. The method includes:

[0073] Step 201: Obtain the transaction to be matched submitted to the blockchain system.

[0074] Exemplarily, all exchanges registered with the blockchain system can submit transactions to be matched to the blockchain system. Transactions to be matched can be buy transactions or sell transactions. For example, registered exchange A submits a transaction to be matched to the blockchain system, hoping to purchase 100 shares of stock with code 10001 at a price not higher than RMB 1.5 per share; registered exchange B submits a transaction to be matched to the blockchain system, hoping to sell 100 shares of stock with code 10001 at a price not lower than RMB 1.2 per share; the above two transactions submitted to the blockchain system can be regarded as transactions to be matched.

[0075] Step 202: Determine a target exchange based on the matching efficiency of at least one exchange registered with the blockchain system, and assign the transactions to be matched to the target exchange; the matching efficiency of any exchange is calculated based on at least one matched transaction pair processed by the exchange.

[0076] Exemplarily, before determining the matching efficiency of an exchange, it is necessary to first determine the matching duration of each matched transaction pair in at least one matched transaction pair processed by the exchange. The blockchain system has block height records for buy transactions or sell transactions submitted by user clients and matched transaction pairs submitted by the exchange. This application determines the matching duration of the matched transaction pairs based on the block height of the buy transaction, the block height of the sell transaction, and the block height of the matched transaction pair in the matched transaction pairs.

[0077] Exemplarily, each matched transaction pair includes the block height of the buy transaction, the block height of the sell transaction, and the block height of the matched transaction pair. In the blockchain, the block height can be regarded as a time unit. The earlier the transaction is submitted to the blockchain, the smaller the block height is. Since the matched transaction pair is obtained by matching the buy transaction and the sell transaction, the block height of the buy transaction and the sell transaction must be smaller than the block height of the matched transaction pair. If the difference between the block height of the matched transaction pair and the block height of the buy transaction or the sell transaction is larger, it means that the buy transaction or the sell transaction waits for matching longer in the exchange, and the matching speed of the exchange is slower; on the contrary, if the difference between the block height of the matched transaction pair and the block height of the buy transaction or the sell transaction is smaller, it means that the buy transaction or the sell transaction waits for matching shorter in the exchange, and the matching speed of the exchange is faster. The matching time of each exchange can be calculated using the following formula:

[0078] Matching time = t-max(t b , t s )

[0079] Among them, t is the block height of the matched transaction pair in the matched transaction pair, t b The block height of the buy order in the matched trading pair, t s The block height of the sell order in the matched transaction. For example, suppose the buy order in a matched transaction pair processed by Exchange A is at block height 10, that is, t b is 10, assuming that the sell order transaction is at block height 5, that is, t s is 5. Assuming that the block height of the matched transaction pair is 20, that is, t is 20, then the matching time of the matched transaction pair = 20-max(10,5) = 10.

[0080] Exemplarily, after determining the matching time of each matched transaction pair processed by the exchange, the matching efficiency of the exchange is determined based on the matching times of the most recent N matched transaction pairs; wherein N is a positive integer; specifically, first determine the average matching time of the exchange based on the matching times of the most recent N matched transaction pairs, sum the matching times of the most recent N matched transaction pairs and divide it by N as the average matching time of the exchange, and then determine the matching efficiency of the exchange based on the matching times of the most recent N matched transaction pairs and the average matching time using the exponentially weighted moving-average (EWMA). EWMA is a time series analysis method that calculates the weighted average of data by giving higher weights to recent observations. The core idea is to give different weights to observations at different time points through exponential decay. When using EWMA for calculation, the weight of earlier observations gradually decreases, while the weight of more recent observations gradually increases. The rate of weight decay is controlled by a parameter called the "decay factor" or "smoothing factor", which can be denoted as α.

[0081] For example, taking an exchange as an example, suppose the time series consisting of the matching time and average matching time of the latest N matched trading pairs of the exchange is recorded as T n , t n ,t n-1 ...arranged in order of time from recent to far, The average matching time is determined by the matching time of the most recent N matched trading pairs. Then, the matching efficiency of the exchange can be calculated using the following formula based on the matching time of the most recent N matched trading pairs and the average matching time:

[0082] S n =α×T n +(1-α)×S n-1

[0083] For example, assuming that α is 0.4, and Exchange A has processed a total of 3 matched trading pairs, then the matching efficiency of Exchange A = S3 = 0.4 × t n +0.6×S2=0.4×t n +0.6×(0.4×t n-1 +0.6×S1), therefore,

[0084] According to the above calculation results, it can be seen that the t closest to the current time nThe weight is the largest. This application uses EWMA to calculate the exchange matching efficiency. It is expected that the matching time of the more recently processed matched transaction pairs among the most recent N matched transaction pairs processed by the exchange will have a more significant impact on the exchange's matching efficiency, so as to improve the real-time nature of the exchange's matching efficiency.

[0085] Further exemplarily, in each matching efficiency calculation cycle, after determining the matching efficiency of each exchange based on the N matched transaction pairs corresponding to each exchange registered with the blockchain system, the share ring can be determined based on the matching efficiency of each exchange, and each share on the share ring has its own corresponding exchange, and the number of shares of any exchange is positively correlated with the matching efficiency of the exchange; that is, the greater the matching efficiency of the exchange, the more shares it has in the share ring, and conversely, the smaller the matching efficiency of the exchange, the fewer shares it has in the share ring.

[0086] One thing that needs to be explained is that if there is an exchange whose number of matching timeout transactions reaches the preset number in the previous matching efficiency calculation cycle, in order to save computing resources, the matching efficiency of this exchange may not be calculated in the current matching efficiency calculation cycle. Accordingly, there will be no share corresponding to this exchange in the share ring, and no matching transactions will be allocated to this exchange.

[0087] The shares corresponding to each exchange can be determined in the following way:

[0088] (1) Determine the minimum exponentially weighted smoothed value of the matching efficiency of each exchange, that is, the maximum matching efficiency, denoted by S min ;

[0089] (2) Divide the exponentially weighted smoothed value of the matching efficiency of each exchange by S min , and round it off to get the ratio p corresponding to each exchange;

[0090] (3) After obtaining the ratio p corresponding to each exchange, this application provides the following two methods to determine the shares corresponding to each exchange:

[0091] ① Reciprocal method: Take the reciprocal of the ratio p corresponding to each exchange Sum up, and determine the total shares corresponding to each exchange and the shares corresponding to each exchange according to the summation result;

[0092] ② Common multiple method: Determine the common multiple based on the ratio p corresponding to each exchange, and determine the shares corresponding to each exchange based on the common multiple.

[0093] For example, suppose there are three exchanges, denoted as Exchange 1 to Exchange 3. Suppose the weighted smoothed value of the matching efficiency index of Exchange 1 is 5, the weighted smoothed value of the matching efficiency index of Exchange 2 is 8, and the weighted smoothed value of the matching efficiency index of Exchange 3 is 14 (indicating that Exchange 1 has the highest matching efficiency, followed by Exchange 2, and finally Exchange 3). Since the weighted smoothed value of the matching efficiency index of Exchange 1 is the smallest, S min =5; Secondly, the ratio p corresponding to Exchange 1 = weighted smoothed value of the matching efficiency index of Exchange 1 / S min =5 / 5=1, the ratio p corresponding to Exchange 2 = weighted smoothed value of the matching efficiency index of Exchange 2 / S min =8 / 5≈2 and the corresponding ratio of Exchange 3 p=weighted smoothed value of the matching efficiency index of Exchange 3 / S min =14 / 5≈3.

[0094] If the above reciprocal method is used to determine the shares corresponding to each exchange: the reciprocal of the ratio P corresponding to exchange 1 1, the reciprocal of the ratio P corresponding to exchange 2 for The reciprocal of the ratio P corresponding to exchange 3 for therefore For the sake of convenience, integers are used to express the shares corresponding to each exchange. The numerator of is the sum of the shares corresponding to each exchange, which is 11. Since the number of shares corresponding to the exchange is positively correlated with the matching efficiency, it is determined that the exchange 1 with the highest matching efficiency has the largest number of shares corresponding to 6, the number of shares corresponding to exchange 2 is 3, and the number of shares corresponding to exchange 3 is 2.

[0095] If the above-mentioned common multiple method is used to determine the shares corresponding to each exchange: the ratio p corresponding to Exchange 1 is 1, the ratio p corresponding to Exchange 2 is 2, and the ratio p corresponding to Exchange 3 is 3. The common multiple of these three ratios p is 6, then the number of shares corresponding to Exchange 1 = common multiple / exchange ratio p = 6 / 1 = 6, the number of shares corresponding to Exchange 2 = common multiple / exchange ratio p = 6 / 2 = 3, and the number of shares corresponding to Exchange 3 = common multiple / exchange ratio p = 6 / 3 = 2.

[0096] The share ring corresponding to Exchange 1 to Exchange 3 is as follows Figure 3 As shown, Figure 3 The shares marked with number 1 are the shares corresponding to exchange 1. Similarly, the shares marked with number 2 are the shares corresponding to exchange 2, and the shares marked with number 3 are the shares corresponding to exchange 3.

[0097] One point that needs to be explained is that the above-mentioned method of determining the shares corresponding to each exchange is only an example. In actual applications, other methods can also be used to determine the shares corresponding to each exchange according to the matching efficiency of each exchange, as long as the number of shares is positively correlated with the matching efficiency. This application does not limit the method of determining the shares corresponding to each exchange.

[0098] In addition, the share ring also includes shares with potential attributes. The number of shares with potential attributes in the share ring is usually set to 1. The potential attributes correspond to exchanges registered with the blockchain system within the matching efficiency calculation cycle. For example, the exchanges registered with the blockchain system are assumed to be exchanges 1 to 3, and the potential attributes correspond to exchanges other than exchanges 1 to 3; or, the potential attributes correspond to exchanges that have not completed N matched transaction pairs. In other words, the potential attributes correspond to exchanges that have processed a small number of matched transaction pairs that have not reached N. For example, assuming N is 3, the number of matched transaction pairs processed by exchange 2 is 2, which has not reached N, then the potential attributes correspond to exchange 2; or, the potential attributes correspond to each exchange registered with the blockchain system, that is, exchange 1 to exchange 3. Figure 3 The share ring shown in the figure adds a share with potential attributes such as Figure 4 As shown, Figure 4 The shares without numbers in the table represent shares with potential attributes.

[0099] For example, the shares corresponding to each exchange may be continuously distributed on the share ring, such as Figure 3 and Figure 4 As shown, Figure 3 For example, Figure 3 The number of shares held by Exchange 1 is 6, and these 6 shares are connected and continuously distributed; in addition, the shares corresponding to each exchange can also be distributed at intervals on the share ring, which is specifically manifested in that the shares corresponding to each exchange are not adjacent to each other. The share ring determined by the share interval distribution can also be called the "most discrete ring" or "most discrete share ring".

[0100] The interval distribution of the shares corresponding to each exchange on the share ring can be achieved in the following way:

[0101] (1) Sort the number of shares of each exchange in the share ring from large to small, and process the exchange with the largest number of shares first;

[0102] (2) When the nth exchange is processed, the shares occupied by the previous n-1 exchanges are removed from the share ring;

[0103] (3) All share rings corresponding to the nth exchange are allocated in this sub-ring so that the difference between the sum of the number of shares between the shares of the nth exchange and the average value of the sum of the number of shares is minimized;

[0104] (4) Reassemble the shares removed in step (2) into the share ring in the original clockwise traversal order.

[0105] The following combination Figure 4 The share ring explanation shown shows how to obtain the most discrete ring. Figure 4 The order of the number of shares of the included exchanges is Exchange 1>Exchange 2>Exchange 3, therefore:

[0106] ① Start from Exchange 1. Since Exchange 1 is the first exchange to be processed, step (2) is skipped. Accordingly, step (4) is also skipped. No matter how the 6 shares corresponding to Exchange 1 are allocated to the share ring, the sum of their distances is equal to the total number of shares (12) minus the number of shares corresponding to Exchange 1, which is 6. The average value of the sum of the number of shares = 6 / the number of shares corresponding to Exchange 1 = 6 / 6 = 1. Therefore, if these 6 shares are placed evenly with one share between them, the difference between the sum of the number of shares between the shares and the average value of the sum of the number of shares can be minimized to 0. If these 6 share arcs are placed with one share between them, the shares of Exchange 1 are placed as follows: Figure 5 As shown;

[0107] ② Then process Exchange 2. First, Figure 5 The shares of exchange 1 are removed, and the share cycle after removal is as follows Figure 6 As shown, similarly, placing the three shares of Exchange 2 evenly with one share between them can minimize the difference between the sum of the number of shares between them and the average value of the sum of the number of shares. The shares of Exchange 2 are placed as follows Figure 7 As shown; then assemble the shares corresponding to exchange 1 into the share ring, the share ring is composed of Figure 7 Updated to Figure 8 ;

[0108] ③Finally, the exchange 3 and the shares with potential attributes are processed, and the final most discrete ring is as follows Fig. 9 shown.

[0109] For example, after obtaining the share ring or the most discrete ring, the target exchange can be determined based on the share ring or the most discrete ring, and the pointer of the share ring is rotated according to a preset angle, and the exchange corresponding to the share pointed to by the pointer when it stops rotating is determined as the target exchange, wherein the starting position of the pointer can be randomly determined, and the preset angle is the angle corresponding to each share. Fig.10 Take the share ring shown as an example. Fig.10The arrow shown by the dotted line in the middle indicates the pointer before rotation, and the arrow shown by the solid line indicates the pointer after rotation by an angle corresponding to one unit. Fig.10 It can be seen that the exchange corresponding to the share pointed to by the pointer when it stops rotating is Exchange 1, so Exchange 1 is determined as the target exchange. Fig.11 Taking the most discrete ring shown as an example, Fig.11 The arrow shown by the dotted line in the middle indicates the pointer before rotation, and the arrow shown by the solid line indicates the pointer after rotation by an angle corresponding to one unit. Fig.11 It can be seen that the exchange corresponding to the share pointed to by the pointer when it stops rotating is Exchange 2, so Exchange 2 is determined as the target exchange.

[0110] Further illustratively, after the target exchange is determined, the transaction to be matched is allocated to the target exchange, and a transaction request is generated based on the transaction to be matched and the target exchange. The main information included in the transaction request is shown in Table 1:

[0111]

[0112] Table 1

[0113] According to Table 1, the transaction request includes the transaction information of the transaction to be matched and the address information of the target exchange, wherein the transaction information of the transaction to be matched is the client address, the buy and sell quantity and the client signature in Table 1, and the address information of the target exchange is the allocated exchange address in Table 1. Further, when the transaction request is propagated in the blockchain system, after any exchange receives the transaction request, it matches the address information of the target exchange included in the transaction request with its own address information. If it is determined that the address information of the exchange indicated in the transaction request is the same as its own address information, the transaction to be matched is matched; if it is determined that the address information of the exchange indicated in the transaction request is different from its own address information, there is no need to process the transaction request.

[0114] The above is the way in which blockchain nodes broadcast transaction requests. After determining the target exchange, the blockchain node can also send the transaction request to the target exchange in a single point. The exchange that receives the transaction request directly matches the pending transactions corresponding to the transaction request without matching the address information.

[0115] The most discrete ring proposed in this application discretizes the shares of the same exchange as much as possible, so that it can avoid continuously allocating the pending matching transactions to the same exchange as much as possible, and can effectively solve the problem of consecutively allocating the pending matching transactions to a faulty exchange, resulting in matching timeout or matching failure of the pending matching transactions, thereby improving the reliability of the blockchain system.

[0116] Step 203: receiving the matching transaction pair for the to-be-matched transaction returned by the target exchange, and completing the matching transaction pair through the blockchain system; the matching transaction pair is used to update the matched transaction pair corresponding to the target exchange.

[0117] Exemplarily, after receiving the transaction request sent by the blockchain system, the target exchange matches the pending transactions corresponding to the transaction request, and returns the obtained matching transaction pairs to the blockchain system after matching. On the one hand, the smart contract deployed on the blockchain node of the blockchain system completes the splitting of the matching transaction pairs and other processing to complete the matching transaction pairs; on the other hand, the blockchain system can update the matched transaction pairs corresponding to the target exchange according to the matching transaction pairs for the pending transactions returned by the target exchange, so that the blockchain system always calculates the matching efficiency of the target exchange based on the latest matched transaction pairs, thereby improving the accuracy and real-time performance of the matching efficiency.

[0118] In addition, this application also provides a share ring update mechanism:

[0119] Update mechanism ①: If no matching transaction pair is received for the pending matching transaction within the set time, the target exchange is determined to have timed out. If the number of transactions that have timed out for any exchange meets the matching failure condition, the corresponding share of the exchange is removed from the share ring, and the allocation of pending matching transactions to the exchange is stopped. For example, assuming that the set time is 10 blocks, the pending matching transaction is allocated to Exchange 1 at the 5th block, and the matching transaction pair for the pending matching transaction returned by Exchange 1 is still not received at the 20th block, then Exchange 1 is considered to have timed out; if the number of matching timed out transactions is greater than 3, it is considered to meet the matching failure condition. For example, assuming that the number of matching timed out transactions for Exchange 1 is 5, then Exchange 1's share is removed from the share ring, and the allocation of pending matching transactions to Exchange 1 is stopped.

[0120] Update mechanism ②: Remove the shares corresponding to the exchange with the lowest matching efficiency from the share ring, and stop allocating pending matching transactions to the exchange with the lowest matching efficiency. For example, assuming that among exchanges 1 to 3, exchange 3 has the lowest matching efficiency, then remove the shares of exchange 3 from the share ring, and stop allocating pending matching transactions to exchange 3.

[0121] The blockchain transaction allocation method proposed in this application effectively avoids the problem of repeated matching between exchanges, saving resources of the blockchain system and the exchange; compared with the existing static order allocation scheme, the blockchain transaction allocation method proposed in this application can quickly respond to situations such as new registration of exchanges to the blockchain system or withdrawal of exchanges, making the blockchain system more flexible and robust; and the most discrete ring proposed in this application can better deal with the problem of exchange failures, thereby improving the reliability of the blockchain system.

[0122] Fig.12 and Fig.13 A schematic diagram of the structure of a possible blockchain transaction allocation device provided for an embodiment of the present application. These blockchain transaction allocation devices can be used to implement the functions of the blockchain nodes in the above method embodiments, and thus can also achieve the beneficial effects possessed by the above method embodiments.

[0123] like Fig.12 As shown, the blockchain transaction allocation device 1200 includes a processing unit 1210 and a transceiver unit 1220. The blockchain transaction allocation device 1200 is used to implement the above Figure 2 The functions of the blockchain node in the method embodiment shown are:

[0124] The transceiver unit 1220 is used to obtain the transaction to be matched submitted to the blockchain system;

[0125] The processing unit 1210 is used to determine a target exchange according to the matching efficiency of at least one exchange registered with the blockchain system, and allocate the to-be-matched transaction to the target exchange; the matching efficiency of any exchange is calculated based on at least one matched transaction pair processed by the exchange;

[0126] The transceiver unit 1220 is further used to receive the matching transaction pair for the to-be-matched transaction returned by the target exchange, and the processing unit 1210 is further used to complete the matching transaction pair through the blockchain system; the matching transaction pair is used to update the matched transaction pair corresponding to the target exchange.

[0127] In a possible design, when the processing unit 1210 is used to allocate the transaction to be matched to the target exchange, it is specifically used to: generate a transaction request based on the transaction to be matched and the target exchange, wherein the transaction request includes the transaction information indicated by the transaction to be matched and the address information of the target exchange; propagate the transaction request in the blockchain system, and any exchange is used to match the transaction to be matched when it is determined that the address information of the exchange indicated in the transaction request is the same as its own address information.

[0128] In a possible design, the matching efficiency of any exchange is determined by the block height of the buy transaction, the block height of the sell transaction, and the block height of the matched transaction pair in any matched transaction pair matched by the exchange, to determine the matching time of the matched transaction pair; the matching efficiency of the exchange is determined based on the matching time of the most recent N matched transaction pairs; N is a positive integer.

[0129] In one possible design, the processing unit 1210 is used to determine the matching efficiency of the exchange based on the matching times of the most recent N matched trading pairs, and is specifically used to: determine the average matching time of the exchange based on the matching times of the most recent N matched trading pairs; determine the matching efficiency of the exchange using the exponentially weighted moving average method EWMA based on the matching times of the most recent N matched trading pairs and the average matching time.

[0130] In one possible design, if no matching transaction pair for the transaction to be matched is received within a set time period, the processing unit 1210 is also used to determine that the target exchange has timed out for matching; and if the number of transactions with timed out matching in any exchange meets the matching failure condition, the processing unit 1210 stops allocating transactions to be matched to the exchange.

[0131] In a possible design, when determining the target exchange according to the matching efficiency of at least one exchange registered with the blockchain system, the processing unit 1210 is specifically used to: determine the matching efficiency of each exchange according to the N matched transaction pairs corresponding to each exchange registered with the blockchain system in each matching efficiency calculation cycle; determine a share ring according to the matching efficiency of each exchange, wherein each share on the share ring has its own corresponding exchange, and the number of shares of any exchange is positively correlated with the matching efficiency of the exchange; rotate the pointer of the share ring according to a preset angle, and determine the exchange corresponding to the share pointed to by the pointer when the pointer stops rotating as the target exchange, wherein the preset angle is the angle corresponding to each share.

[0132] In a possible design, the shares corresponding to each exchange are continuously distributed on the share ring; or, the shares corresponding to each exchange are distributed at intervals on the share ring.

[0133] In a possible design, the share ring also includes shares with potential attributes; the potential attributes correspond to exchanges registered with the blockchain system within the matching efficiency calculation cycle, and / or the potential attributes correspond to exchanges that have not completed N matched transaction pairs, and / or the potential attributes correspond to each exchange registered with the blockchain system.

[0134] In a possible design, the processing unit 1210 is specifically used to: if the number of matching timeout transactions of any exchange meets the matching failure condition, remove the share corresponding to the exchange from the share ring.

[0135] For a more detailed description of the processing unit 1210 and the transceiver unit 1220, please refer to Figure 2The relevant description in the method embodiment shown is directly obtained and will not be repeated here.

[0136] like Fig.13 As shown, the blockchain transaction allocation device 1300 includes a processor 1310 and an interface circuit 1320. The processor 1310 and the interface circuit 1320 are coupled to each other. It is understood that the interface circuit 1320 can be a transceiver or an input-output interface. Optionally, the blockchain transaction allocation device 1300 may also include a memory 1330 for storing instructions executed by the processor 1310 or storing input data required by the processor 1310 to run the instructions or storing data generated after the processor 1310 runs the instructions.

[0137] When the blockchain transaction allocation device 1300 is used to implement Figure 2 When the method is shown, the processor 1310 is used to implement the function of the above-mentioned processing unit 1210, and the interface circuit 1320 is used to implement the function of the above-mentioned transceiver unit 1220.

[0138] The division of units in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional unit in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0139] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0140] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A blockchain transaction allocation method, characterized in that: The method is applied to a blockchain node, including: Obtain pending transactions submitted to the blockchain system; Determine a target exchange according to the matching efficiency of at least one exchange registered with the blockchain system, and assign the to-be-matched transaction to the target exchange; the matching efficiency of any exchange is calculated based on at least one matched transaction pair processed by the exchange; Receive the matching transaction pair for the to-be-matched transaction returned by the target exchange, and complete the matching transaction pair through the blockchain system; the matching transaction pair is used to update the matched transaction pair corresponding to the target exchange.

2. The method according to claim 1, characterized in that Allocating the to-be-matched transaction to the target exchange includes: Based on the transaction to be matched and the target exchange, a transaction request is generated, wherein the transaction request includes transaction information of the transaction to be matched and address information of the target exchange; The transaction request is propagated in the blockchain system, and any exchange is used to match the to-be-matched transaction when it is determined that the address information of the exchange indicated in the transaction request is the same as its own address information.

3. The method according to claim 1, characterized in that The matching efficiency of any exchange is determined by the block height of the buy transaction, the block height of the sell transaction and the block height of the matched transaction pair in any matched transaction pair matched by the exchange, to determine the matching time of the matched transaction pair; the matching efficiency of the exchange is determined based on the matching time of the most recent N matched transaction pairs; N is a positive integer.

4. The method according to claim 3, characterized in that Determine the matching efficiency of the exchange based on the matching duration of the most recent N matched trading pairs, including: Determine the average matching time of the exchange according to the matching time of the most recent N matched trading pairs; According to the matching durations of the most recent N matched trading pairs and the average matching duration, the exponentially weighted moving average method EWMA is used to determine the matching efficiency of the exchange.

5. The method according to claim 1, characterized in that The method further comprises: If no matching transaction pair for the to-be-matched transaction is received within the set time period, it is determined that the matching of the target exchange has timed out; If the number of transactions that have timed out on any exchange meets the matching failure conditions, the allocation of pending matching transactions to the exchange will be stopped.

6. The method according to any one of claims 1 to 5, characterized in that Determining a target exchange according to the matching efficiency of at least one exchange registered with the blockchain system includes: In each matching efficiency calculation cycle, the matching efficiency of each exchange is determined according to the N matched transaction pairs corresponding to each exchange registered in the blockchain system; a share ring is determined according to the matching efficiency of each exchange, each share on the share ring has its own corresponding exchange, and the number of shares of any exchange is positively correlated with the matching efficiency of the exchange; The pointer of the share ring is rotated according to a preset angle, and the exchange corresponding to the share pointed to by the pointer when the pointer stops rotating is determined as the target exchange, wherein the preset angle is the angle corresponding to each share.

7. The method according to claim 6, characterized in that The shares corresponding to each exchange are continuously distributed on the share ring; or, the shares corresponding to each exchange are distributed at intervals on the share ring.

8. The method according to claim 6, characterized in that The share ring also includes shares with potential attributes; the potential attributes correspond to exchanges registered with the blockchain system within the matching efficiency calculation cycle, and / or the potential attributes correspond to exchanges that have not completed N matched transaction pairs, and / or the potential attributes correspond to each exchange registered with the blockchain system.

9. The method according to claim 6, characterized in that If the number of transactions that have timed out on any exchange meets the matching failure conditions, the allocation of pending matching transactions to the exchange will be stopped, including: If the number of matching timeout transactions of any exchange meets the matching failure condition, the share corresponding to the exchange will be removed from the share ring.

10. A blockchain transaction allocation device, characterized in that: The device is applied to a blockchain node, and includes a processing unit and a transceiver unit; The transceiver unit is used to obtain the transaction to be matched submitted to the blockchain system; The processing unit is used to determine a target exchange according to the matching efficiency of at least one exchange registered with the blockchain system, and allocate the to-be-matched transaction to the target exchange; the matching efficiency of any exchange is calculated based on at least one matched transaction pair processed by the exchange; The transceiver unit is further used to receive the matching transaction pair for the to-be-matched transaction returned by the target exchange, and the processing unit is further used to complete the matching transaction pair through the blockchain system; the matching transaction pair is used to update the matched transaction pair corresponding to the target exchange.

11. A blockchain transaction allocation device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 9 when executed by a processor.

13. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 9 when being executed by a processor.