Transaction processing method and device, electronic equipment and storage medium
By obtaining the block height and number of anchored blocks of blockchain B on the main node of blockchain A, dynamically adjusting the transaction pool, the transaction query and verification process of blockchain A is optimized, and blockchain A is solved The inefficiency problem of query efficiency caused by multiple blocks being anchored to the same block of blockchain B improves the speed of transaction authenticity verification.
Patent Information
- Application Number
- CN202411340109.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-01-07
AI Technical Summary
In the blockchain cross-chain transaction scenario, when the block yield speed of blockchain A is much higher than that of blockchain B, multiple blocks of blockchain A are anchored to the same block of blockchain B. , the efficiency of querying transaction information is low, which in turn affects the speed of transaction authenticity verification.
Before creating a new block of blockchain A, obtain the block height of blockchain B, query the number of anchored blocks, and judge whether transactions are frequently queried based on the threshold, allocate transactions to different transaction pools to optimize the query and verification process .
It improves transaction query and verification efficiency in block anchoring scenarios, reduces the scope of query and verification, and improves the speed of transaction authenticity verification.
Smart Images

Figure CN119273360A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and more specifically, to a transaction processing method, device, electronic device and storage medium. Background Art
[0002] In the cross-chain transaction scenario of blockchain, a block of one blockchain can be anchored to another blockchain, for example, multiple transactions in a block of blockchain A can be recorded in a block of blockchain B. In this case, the authenticity of the transaction can be verified by querying the transaction information recorded in blockchain B. However, when the block generation speed of blockchain B is much lower than that of blockchain A, many blocks of blockchain A will be anchored to the same block of blockchain B. Therefore, when verifying the authenticity of the transaction by querying the transaction information recorded in blockchain B, the query efficiency will be low, which will in turn lead to a slow speed of verifying the authenticity of the transaction. Summary of the invention
[0003] In response to the above problems, the present application provides a transaction processing method, device, electronic device and storage medium, the purpose of which is to improve the transaction query and verification efficiency in the block anchoring scenario.
[0004] A first aspect of an embodiment of the present application provides a transaction processing method, which is applied to a master node of a first blockchain, and includes: Before creating a first new block of the first blockchain, obtaining a block height of a second new block being created of the second blockchain; According to the block height, query the number of anchor blocks in the first blockchain, where the anchor block refers to a block that records the block height information; When the number of anchored blocks is less than or equal to the first threshold, at least one transaction is taken from the first transaction pool of the master node, and the following operations are performed for each transaction: Determine whether the transaction has a frequent query attribute; If the transaction has a frequent query attribute, determine whether the number of anchor blocks reaches the latest first threshold; if so, put the transaction into the second transaction pool; if not, record the transaction into the first new block and update the first threshold; If the transaction does not have the frequent query attribute, the transaction is recorded in the first new block.
[0005] Optionally, updating the first threshold includes: The first threshold is updated according to the total number of transactions with the frequent query attribute in all anchor blocks; wherein the total number is negatively correlated with the first threshold.
[0006] Optionally, the method further comprises: If the number of anchor blocks queried is equal to 1, at least one transaction is taken out from the second transaction pool, and the taken out transaction is recorded in the first new block, and the first threshold is updated.
[0007] Optionally, taking out at least one transaction from the second transaction pool includes: If the number of remaining transactions in the second transaction pool is greater than or equal to N, then N transactions are taken from the second transaction pool, where N is equal to the number of transactions that need to be recorded in each block of the second blockchain; If the number of remaining transactions in the second transaction pool is less than N, all transactions in the second transaction pool are taken out.
[0008] Optionally, the method further comprises: When the second transaction pool is empty and the first new block is not filled, the step of taking out at least one target transaction from the first transaction pool of the master node is started.
[0009] Optionally, the method further comprises: Submit the hash value of each transaction in each anchor block to the master node of the second blockchain, so that the master node of the second blockchain creates the second new block of the second blockchain according to the received hash value.
[0010] Optionally, the method further comprises: After the first new block of the first blockchain is created, if the number of anchor blocks has reached the latest first threshold, the creation of the first new block is suspended until the second new block of the second blockchain is created.
[0011] A second aspect of an embodiment of the present application provides a transaction processing device, which is applied to a master node of a first blockchain, and includes: A block height acquisition module, used for acquiring the block height of a second new block being created in the second blockchain before creating a first new block in the first blockchain; An anchor block query module, used to query the number of anchor blocks in the first blockchain according to the block height, where the anchor block refers to a block that records the block height information; The transaction processing module is used to take out at least one transaction from the first transaction pool of the master node when the number of anchor blocks is less than or equal to the first threshold, and perform the following operations for each transaction: Determine whether the transaction has a frequent query attribute; If the transaction has a frequent query attribute, determine whether the number of anchor blocks reaches the latest first threshold; if so, put the transaction into the second transaction pool; if not, record the transaction into the first new block and update the first threshold; If the transaction does not have the frequent query attribute, the transaction is recorded in the first new block.
[0012] A third aspect of an embodiment of the present application provides an electronic device, the electronic device comprising a memory and a processor; The memory is used to store application programs; The processor is used to run the application stored in the memory to implement any of the transaction processing methods described above.
[0013] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein an application is stored in the computer-readable storage medium, and when the application is executed by a processor, it is used to implement any of the transaction processing methods described above.
[0014] According to the transaction processing method provided by the present application, before creating the first new block of the first blockchain, the master node of the first blockchain obtains the block height of the second new block being created of the second blockchain, and queries the number of anchor blocks in the first blockchain according to the block height (the anchor block refers to the block that records the block height information); when the number of anchor blocks is less than or equal to the first threshold, at least one transaction is taken out from the first transaction pool of the master node, and for each transaction, the following operations are performed: determine whether the transaction has a frequent query attribute; if the transaction has a frequent query attribute, determine whether the number of anchor blocks reaches the latest first threshold; if so, put the transaction into the second transaction pool; if not, record the transaction in the first new block being created, and update the first threshold. In this way, for transactions of the first blockchain with frequent query attributes, they will not be anchored to the same block of the second blockchain in large quantities with other transactions of the first blockchain, so when it is necessary to query and verify these transactions from the second blockchain, the scope of query and verification is small, and the query and verification efficiency is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application 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 any creative labor.
[0016] Figure 1 It is a flowchart of a transaction processing method provided by an embodiment of the present application; Figure 2 is a flowchart of a transaction processing method provided by another embodiment of the present application; Figure 3 It is a structural diagram of a transaction processing device provided by an embodiment of the present application; Figure 4 It is a structural block diagram of an electronic device proposed in one embodiment of the present disclosure. DETAILED DESCRIPTION
[0017] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0018] In the related art, multiple transactions in a block of blockchain A can be recorded in a block of blockchain B. In this case, the authenticity of the transaction can be verified by querying the transaction information recorded in blockchain B. However, when the block generation speed of blockchain B is much lower than that of blockchain A, many blocks of blockchain A will be anchored to the same block of blockchain B. Therefore, when verifying the authenticity of the transaction by querying the transaction information recorded in blockchain B, the query efficiency will be low, which will in turn lead to a slow verification speed of the authenticity of the transaction.
[0019] In order to improve the transaction query efficiency in the block anchoring scenario, the present application provides a transaction processing method through the following embodiments, and the transaction processing method is applied to the master node of the first blockchain. Figure 1 , Figure 1 is a flow chart of a transaction processing method provided by an embodiment of the present application. Figure 1 As shown, the transaction processing method includes the following steps:
[0020] S110: Before creating a first new block of the first blockchain, obtain a block height of a second new block being created of the second blockchain.
[0021] In this application, the first new block refers to the new block being created in the first blockchain, and the second new block refers to the new block being created in the second blockchain. The block of the first blockchain needs to be anchored to the second blockchain, and the first new block to be created by the first blockchain will also be anchored to the second new block being created in the second blockchain. Specifically, the transaction hash of the block of the first blockchain needs to be recorded in the block of the second blockchain, and the block header of the block of the first blockchain needs to record the block height information of a block of the second blockchain. Exemplarily, for the 8 blocks with block heights of 1005, 1006, 1007, 1008, 1009, 1010, 1011, and 1012 of the first blockchain, the hashes of multiple transactions in these 8 blocks are recorded in the block with a block height of 166 of the second blockchain, and the block height information of the second blockchain "166" needs to be recorded in these 8 blocks.
[0022] Before creating the first new block of the first blockchain, the master node of the first blockchain needs to query the block height of the second new block being created in the second blockchain. The master node of the first blockchain can communicate with the master node of the second blockchain and obtain the block height of the second new block being created in the second blockchain from the master node of the second blockchain.
[0023] S120: According to the block height, query the number of anchor blocks in the first blockchain, where the anchor block refers to a block that records the block height information.
[0024] In some specific implementations, the master node of the first blockchain can query the block header of each block of the first blockchain, and find the number of blocks that record the block height from multiple blocks of the first blockchain as the number of anchor blocks. Relative to the anchor block, the second new block being created in the second blockchain is the anchored block.
[0025] In some other specific implementations, the master node of the first blockchain can record and update the number of anchor blocks through a variable. The master node updates the variable after each block is created. When the master node needs to query the number of anchor blocks, it only needs to query the variable to obtain the number of anchor blocks. For ease of understanding, using the above example, for the 8 blocks with block heights of 1005, 1006, 1007, 1008, 1009, 1010, 1011, and 1012 of the first blockchain, these 8 blocks are anchored to the block with a block height of 166 of the second blockchain. Before the master node creates a block with a block height of 1005, the variable is initialized to 0. When the master node starts to create a block with a block height of 1005, the variable is updated to 1. When the master node starts to create a block with a block height of 1006, the variable is updated to 2. When the master node starts to create a block with a block height of 1007, the variable is updated to 3... When the master node starts to create a block with a block height of 1012, the variable is updated to 8. It can be seen that the variable represents the number of blocks with the height information "166" recorded.
[0026] In the present application, the first new block currently being created in the first blockchain also records the block height information of the next block of the second blockchain in its block header, so the queried anchor block includes the first new block currently being created.
[0027] S130: When the number of anchored blocks is less than or equal to the first threshold, at least one transaction is taken from the first transaction pool of the master node, and the following operations are performed for each transaction: S130-1: Determine whether the transaction has a frequent query attribute.
[0028] In this application, if a transaction has a frequent query attribute, it means that the transaction will be frequently queried. In other words, the authenticity of the transaction may need to be verified frequently. In some specific implementations, it is possible to determine whether a transaction has a frequent query attribute based on the transaction type, such as large transactions and smart contract deployment transactions. It is also possible to determine whether a transaction has a frequent query attribute based on the account information involved in the transaction. Specifically, the query frequency of each account can be counted, and a list of accounts that frequently perform query operations can be generated based on the statistical information. If the account involved in the transaction is on the list of accounts, it is determined that the transaction has a frequent query attribute.
[0029] S130-2: If the transaction has a frequent query attribute, determine whether the number of anchored blocks reaches the latest first threshold; if so, put the transaction into the second transaction pool; if not, record the transaction in the first new block being created and update the first threshold.
[0030] In the present application, the first threshold value is dynamically updated. Specifically, as more and more transactions with the frequently queried attribute are recorded in the anchor block of the second new block, the first threshold value gradually decreases. When the first threshold value decreases to a sufficiently small value, the number of anchor blocks may just be equal to the first threshold value.
[0031] For transactions with frequent query attributes, it is necessary to decide whether to record the transaction to the first new block based on the relationship between the number of anchored blocks and the first threshold. Specifically, if the number of anchored blocks is less than the first threshold, it means that only a small number of blocks in the first blockchain are currently anchored to the second new block of the second blockchain. Even if the current transaction with frequent query attributes is recorded in the first new block, the number of anchored blocks is still small. When performing subsequent transaction inquiries and authenticity verifications, large-scale inquiries and verifications will not be performed, and the efficiency of inquiries and verifications is relatively high. However, if the number of anchored blocks is equal to the first threshold, it means that there are currently more blocks in the first blockchain that are anchored to the second new block of the second blockchain. In this case, this application will no longer record the transaction to the first new block, thereby reducing the probability of querying these current anchored blocks from the second blockchain, and thus improving the efficiency of inquiries and verifications as a whole.
[0032] The second transaction pool is specifically used to store transactions with frequent query attributes that have not yet been recorded in the first new block. Compared with the second transaction pool, the first transaction pool is used to store all transactions.
[0033] In some specific embodiments, when the first threshold needs to be updated, the first threshold can be updated according to the total number of transactions with frequent query attributes in all anchor blocks. Among them, the total number is negatively correlated with the first threshold. For example, the total number of transactions with frequent query attributes can be set to multiple intervals, and each interval corresponds to a first threshold. Exemplarily, when the total number of transactions is less than or equal to 2, the corresponding first threshold is 10, when the total number of transactions is greater than 2 and less than or equal to 5, the corresponding first threshold is 8, when the total number of transactions is greater than 5 and less than or equal to 10, the corresponding first threshold is 6, when the total number of transactions is greater than 10 and less than or equal to 20, the corresponding first threshold is 4, when the total number of transactions is greater than 20 and less than or equal to 50, the corresponding first threshold is 2, and when the total number of transactions is greater than 50, the corresponding first threshold is 1. It should be noted that this application does not limit how to update the first threshold according to the total number of transactions, and it only needs to satisfy the relationship that "the total number is negatively correlated with the first threshold".
[0034] S130-3: If the transaction does not have a frequent query attribute, the transaction is recorded in the first new block.
[0035] In some specific embodiments, the number of transactions that can be recorded in each block of the first blockchain is fixed. For example, the number of transactions that need to be recorded in each block is 50. When the number of transactions recorded in the first new block reaches 50, the master node will package the 50 transactions into a new block and broadcast the new block to other blockchain nodes for consensus.
[0036] In the present application, before creating the first new block of the first blockchain, the master node of the first blockchain obtains the block height of the second new block being created of the second blockchain, and queries the number of anchor blocks in the first blockchain according to the block height (the anchor block refers to the block that records the block height information); when the number of anchor blocks is less than or equal to the first threshold, at least one transaction is taken out from the first transaction pool of the master node, and for each transaction, the following operations are performed: determine whether the transaction has a frequent query attribute; if the transaction has a frequent query attribute, determine whether the number of anchor blocks reaches the latest first threshold; if so, put the transaction into the second transaction pool; if not, record the transaction in the first new block being created, and update the first threshold. In this way, for transactions of the first blockchain with frequent query attributes, they will not be anchored to the same block of the second blockchain in large quantities with other transactions of the first blockchain, so when it is necessary to query these transactions from the second blockchain, the query range is small and the query efficiency is high.
[0037] In some specific embodiments, the master node also submits the hash value of each transaction in each anchored block to the master node of the second blockchain, so that the master node of the second blockchain creates a second new block of the second blockchain according to the received hash value. Specifically, after the master node of the first blockchain completes the creation of a new block, it will synchronize the hash value of the transaction recorded in the new block to the master node of the second blockchain, and the master node of the second blockchain will build a Merkle tree based on the hash values of these transactions and the hash values of the transactions of the second blockchain itself. The master node of the second blockchain will record the root node hash of the Merkle tree to the block header of the second new block. Among them, for multiple transactions anchored to the same block, the same Merkle tree will be built. For ease of understanding, illustratively, assuming that the block heights of the first blockchain are 8 blocks of 1005, 1006, 1007, 1008, 1009, 1010, 1011, and 1012, and these 8 blocks are all anchored to the second new block of the second blockchain with a block height of 166, then the master node of the second blockchain will build a Merkle tree based on the hash value of each transaction in the 8 first blocks and the hash value of the transaction in the second new block, and record the root node hash of the Merkle tree to the block header of the second new block. When the authenticity of a transaction in these 8 blocks needs to be verified, it can be queried and verified through the Merkle tree.
[0038] In addition, after the first new block of the first blockchain is created, if the number of anchor blocks has reached the latest first threshold, the creation of the first new block is suspended until the second new block of the second blockchain is created. In the present application, as more and more transactions with frequent query attributes are recorded in the anchor block of the second new block, the first threshold will gradually decrease. When the first threshold is reduced to the same as the current number of anchor blocks. The master node of the first blockchain will not start the step of creating the first new block, but will wait until the second new block currently being created in the second blockchain is created, so that the number of anchor blocks of the next second new block returns to zero, and then start the step of creating the next first new block.
[0039] refer to Figure 2 , Figure 2 FIG. 1 is a flow chart of a transaction processing method provided by another embodiment of the present application. Figure 2 As shown, the transaction processing method includes the following steps: S201: Before creating a first new block of a first blockchain, obtain a block height of a second new block being created of a second blockchain.
[0040] S202: According to the block height, query the number of anchor blocks in the first blockchain, where the anchor block refers to a block that records the block height information.
[0041] S203: Determine whether the number of anchor blocks is equal to 1.
[0042] S204: If the number of anchor blocks queried is equal to 1, at least one transaction is taken out from the second transaction pool, and the taken out transaction is recorded in the first new block, and the first threshold is updated.
[0043] In the present application, if the number of anchored blocks is equal to 1, it means that this unique anchored block is exactly the first new block currently being created. In this case, if the number of remaining transactions in the second transaction pool is greater than or equal to N, N transactions are taken out from the second transaction pool, where N is equal to the number of transactions that need to be recorded in each block of the second blockchain; if the number of remaining transactions in the second transaction pool is less than N, all transactions in the second transaction pool are taken out. All the taken out transactions are recorded in the first new block, and then the first threshold is updated according to the number of taken out transactions. In addition, if the first new block has been filled (in other words, the number of transactions taken out from the second transaction pool is equal to N), the updated first threshold is equal to 1, and the first threshold is exactly equal to the number of anchored blocks. Therefore, the master node of the first blockchain suspends the creation of the first new block until the second new block of the second blockchain is created.
[0044] S205: When the second transaction pool is empty and the first new block is not filled, start executing the step of taking out at least one target transaction from the first transaction pool of the master node.
[0045] In other words, if the number of remaining transactions in the second transaction pool is less than N, all transactions in the second transaction pool are taken out and recorded in the first new block. The first new block is still not filled, and it is necessary to start taking out transactions from the second transaction pool.
[0046] S206: If the number of anchored blocks queried is greater than 1, at least one transaction is taken from the first transaction pool of the master node, and the following operations are performed for each transaction: S206-1: Determine whether the transaction has a frequent query attribute; S206-2: If the transaction has a frequent query attribute, determine whether the number of anchor blocks reaches the latest first threshold; S206-3: If yes, put the transaction into the second transaction pool; S206-4: If not, record the transaction into the first new block and update the first threshold; S206-5: If the transaction does not have a frequent query attribute, the transaction is recorded in the first new block.
[0047] Based on the same inventive concept, the present application also provides a transaction processing device, which is applied to the master node of the first blockchain, referring to Figure 3 , Figure 3 Schematic diagram of the structure of a transaction processing device provided by an embodiment of the present application. Figure 3 As shown, the device comprises: The block height acquisition module 310 is used to acquire the block height of the second new block being created in the second blockchain before creating the first new block of the first blockchain; Anchor block query module 320, used to query the number of anchor blocks in the first blockchain according to the block height, where the anchor block refers to a block that records the block height information; The transaction processing module 330 is used to take out at least one transaction from the first transaction pool of the master node when the number of anchor blocks is less than or equal to the first threshold, and perform the following operations for each transaction: Determine whether the transaction has a frequent query attribute; If the transaction has a frequent query attribute, determine whether the number of anchored blocks reaches the latest first threshold; if so, put the transaction into the second transaction pool; if not, record the transaction in the first new block and update the first threshold; If the transaction does not have the frequent query attribute, the transaction is recorded in the first new block.
[0048] Optionally, the transaction processing module 330 updates the first threshold by: The first threshold is updated according to the total number of transactions with the frequent query attribute in all anchor blocks; wherein the total number is negatively correlated with the first threshold.
[0049] Optionally, the transaction processing module 330 is further configured to: If the number of anchor blocks queried is equal to 1, at least one transaction is taken out from the second transaction pool, and the taken out transaction is recorded in the first new block, and the first threshold is updated.
[0050] Optionally, when taking out at least one transaction from the second transaction pool, the transaction processing module 330 is specifically configured to: If the number of remaining transactions in the second transaction pool is greater than or equal to N, then N transactions are taken from the second transaction pool, where N is equal to the number of transactions that need to be recorded in each block of the second blockchain; If the number of remaining transactions in the second transaction pool is less than N, all transactions in the second transaction pool are taken out.
[0051] Optionally, the transaction processing module 330 is further configured to:
[0052] When the second transaction pool is empty and the first new block is not filled, the step of taking out at least one target transaction from the first transaction pool of the master node is started.
[0053] Optionally, the transaction processing device also includes a submission module for submitting the hash value of each transaction in each anchor block to the master node of the second blockchain, so that the master node of the second blockchain creates a second new block of the second blockchain based on the received hash value.
[0054] Optionally, the transaction processing module 330 is further configured to: After the first new block of the first blockchain is created, if the number of anchor blocks has reached the latest first threshold, the creation of the first new block is suspended until the second new block of the second blockchain is created.
[0055] See also Figure 4 , Figure 4 It is a structural block diagram of an electronic device proposed in an embodiment of the present disclosure, wherein the electronic device 400 includes a processor 410, a memory 420, and one or more applications, wherein the one or more applications are stored in the memory 420 and are configured to be executed by the one or more processors 410, and the one or more programs are configured to execute the above-mentioned transaction processing method.
[0056] The processor 410 may include one or more processing cores. The processor 410 uses various interfaces and lines to connect the various parts of the entire electronic device 400, and executes various functions and processes data of the electronic device 400 by running or executing instructions, programs, code sets or instruction sets stored in the memory 420, and calling data stored in the memory 420. Optionally, the processor 410 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 410 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 410, but may be implemented separately through a communication chip.
[0057] The memory 420 may include a random access memory (RAM) or a read-only memory (ROM). The memory 420 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 420 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc. The data storage area may also store data created by the electronic device 400 during use, etc.
[0058] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0059] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit its protection scope. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the field should understand that after reading the present invention, those skilled in the art can still make various changes, modifications or equivalent substitutions to the specific implementation methods of the invention, but these changes, modifications or equivalent substitutions are all within the protection scope of the pending claims of the invention.
Claims
1. A transaction processing method, characterized in that: The method is applied to a master node of a first blockchain, and the method includes: Before creating a first new block of the first blockchain, obtaining a block height of a second new block being created of the second blockchain; According to the block height, query the number of anchor blocks in the first blockchain, where the anchor block refers to a block that records the block height information; When the number of anchored blocks is less than or equal to the first threshold, at least one transaction is taken from the first transaction pool of the master node, and the following operations are performed for each transaction: Determine whether the transaction has a frequent query attribute; If the transaction has a frequent query attribute, determine whether the number of anchor blocks reaches the latest first threshold; if so, put the transaction into the second transaction pool; if not, record the transaction into the first new block and update the first threshold; If the transaction does not have the frequent query attribute, the transaction is recorded in the first new block.
2. The method according to claim 1, characterized in that The updating of the first threshold comprises: The first threshold is updated according to the total number of transactions with the frequent query attribute in all anchor blocks; wherein the total number is negatively correlated with the first threshold.
3. The method according to claim 1, characterized in that: The method further comprises: If the number of anchor blocks queried is equal to 1, at least one transaction is taken out from the second transaction pool, and the taken out transaction is recorded in the first new block, and the first threshold is updated.
4. The method according to claim 3, characterized in that The taking out at least one transaction from the second transaction pool comprises: If the number of remaining transactions in the second transaction pool is greater than or equal to N, then N transactions are taken from the second transaction pool, where N is equal to the number of transactions that need to be recorded in each block of the second blockchain; If the number of remaining transactions in the second transaction pool is less than N, all transactions in the second transaction pool are taken out.
5. The method according to claim 3, characterized in that: The method further comprises: When the second transaction pool is empty and the first new block is not filled, the step of taking out at least one target transaction from the first transaction pool of the master node is started.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Submit the hash value of each transaction in each anchor block to the master node of the second blockchain, so that the master node of the second blockchain creates the second new block of the second blockchain according to the received hash value.
7. The method according to claim 6, characterized in that The method further comprises: After the first new block of the first blockchain is created, if the number of anchor blocks has reached the latest first threshold, the creation of the first new block is suspended until the second new block of the second blockchain is created.
8. A transaction processing device, characterized in that: The device is applied to a master node of a first blockchain, and the device includes: A block height acquisition module, used for acquiring the block height of a second new block being created in the second blockchain before creating a first new block in the first blockchain; An anchor block query module, used to query the number of anchor blocks in the first blockchain according to the block height, where the anchor block refers to a block that records the block height information; The transaction processing module is used to take out at least one transaction from the first transaction pool of the master node when the number of anchor blocks is less than or equal to the first threshold, and perform the following operations for each transaction: Determine whether the transaction has a frequent query attribute; If the transaction has a frequent query attribute, determine whether the number of anchor blocks reaches the latest first threshold; if so, put the transaction into the second transaction pool; if not, record the transaction into the first new block and update the first threshold; If the transaction does not have the frequent query attribute, the transaction is recorded in the first new block.
9. An electronic device, comprising a memory and a processor; The memory is used to store application programs; The processor is used to run the application stored in the memory to implement the transaction processing method described in any one of claims 1 to 7.
10. A computer-readable storage medium, wherein an application is stored in the computer-readable storage medium, and when the application is executed by a processor, it is used to implement the transaction processing method according to any one of claims 1 to 7.