Transaction processing method and apparatus based on a blockchain system, and related devices

CN117011033BActive Publication Date: 2026-09-22TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210454695.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-27
Publication Date
2026-09-22
Estimated Expiration
2042-04-27

AI Technical Summary

Technical Problem

这种交易处理方式,要把每笔交易广播至其他所有节点,很容易导致网络消息拥塞,尤其是在高并发时,另外,由于要把所有交易相关数据打包进区块,也意味着区块的传输消息体较大

Benefits of technology

[0010]相应地,本申请实施例还提供了一种计算机程序,上述计算机程序包括计算机指令,上述计算机指令存储在计算机可读存储介质中,计算机设备的处理器从上述计算机可读存储介质读取上述计算机指令,上述处理器执行上述计算机指令,使得上述计算机设备执行本申请实施例提供的基于区块链系统的交易处理方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117011033B_ABST
    Figure CN117011033B_ABST
Patent Text Reader

Abstract

A transaction processing method and device based on a blockchain system and related equipment can be applied to various fields or scenarios such as cloud technology, artificial intelligence, blockchain, Internet of Vehicles, intelligent transportation, smart home, etc. The method comprises: when a block generation condition is met, packing batch identifiers of M transaction batches in a transaction pool of a first node into a first block, each transaction batch included in the transaction pool of the first node matching an auxiliary value corresponding to the first node; generating a first processing instruction based on the first block, the first processing instruction comprising the first block; sending the first processing instruction to a second node, the first processing instruction being used to instruct the second node to obtain a second block corresponding to the first block after consensus of the first block is passed, and write the second block into a blockchain, the second block comprising transaction content data and transaction result data corresponding to the M transaction batches. Through the method of the present application, the transaction processing performance of the blockchain system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a transaction processing method based on a blockchain system, a transaction processing device based on a blockchain system, a computer device, a computer-readable storage medium, and a computer program product. Background Technology

[0002] Currently, in a blockchain system, each node broadcasts every received transaction to notify all other nodes. Each node adds the transaction to its own transaction pool. When packaging transactions, a specified number of transactions are selected from the pool to generate a block, which is then broadcast to all nodes for consensus before being added to the blockchain. This transaction processing method, which broadcasts every transaction to all other nodes, can easily lead to network congestion, especially under high concurrency. Furthermore, packaging all transaction-related data into a block means that the block's transmission message body is quite large.

[0003] Therefore, it is necessary to design a new transaction processing mechanism to improve the transaction processing performance of the blockchain system. Summary of the Invention

[0004] This application provides a transaction processing method, apparatus, and related equipment based on a blockchain system, which can design a new transaction processing mechanism based on transaction batches to improve the transaction processing performance of the blockchain system.

[0005] On one hand, embodiments of this application provide a transaction processing method based on a blockchain system, applied to a first node in the blockchain system, the method comprising: When the block production condition is met, the batch identifiers of the target transaction batch in the transaction pool of the first node are packaged to obtain the first block. The first block includes the batch identifiers of M transaction batches. The transactions in each transaction batch included in the transaction pool of the first node are matched with the auxiliary value corresponding to the first node, where M is a positive integer. A first processing instruction is generated based on the first block, and the first processing instruction includes the first block; The first processing instruction is sent to the second node in the blockchain system. The first processing instruction is used to instruct the second node to obtain the second block corresponding to the first block after the consensus on the first block is passed, and to write the second block into the blockchain. The second block includes transaction content data and transaction result data corresponding to the M transaction batches.

[0006] On one hand, embodiments of this application provide a transaction processing device based on a blockchain system, applied to a first node in the blockchain system, the device comprising: The processing unit is used to package the batch identifiers of the target transaction batch in the transaction pool of the first node to obtain a first block when the block production conditions are met. The first block includes batch identifiers of M transaction batches. The transactions in each transaction batch included in the transaction pool of the first node are matched with the auxiliary value corresponding to the first node, where M is a positive integer. The processing unit is further configured to generate a first processing instruction based on the first block, wherein the first processing instruction includes the first block; The sending unit is used to send the first processing instruction to the second node in the blockchain system. The first processing instruction is used to instruct the second node to obtain the second block corresponding to the first block after the consensus on the first block is passed, and to write the second block into the blockchain. The second block includes transaction content data and transaction result data corresponding to the M transaction batches.

[0007] On one hand, embodiments of this application provide a computer device, which includes a processor, a communication interface, and a memory. The processor, communication interface, and memory are interconnected. The memory stores a computer program, and the processor is used to call the computer program to execute a transaction processing method based on a blockchain system according to any of the above possible implementations.

[0008] On one hand, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements a transaction processing method based on a blockchain system in any possible implementation manner.

[0009] Accordingly, this application also provides a computer program product, which includes a computer program or computer instructions. The computer program or computer instructions are executed by a processor to implement the steps of the transaction processing method based on the blockchain system provided in this application.

[0010] Accordingly, this application also provides a computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the transaction processing method based on the blockchain system provided in this application.

[0011] The transaction processing method based on a blockchain system provided in this application designs a novel transaction processing mechanism. In this mechanism, the transaction pool of the first node only stores transactions that match the auxiliary value corresponding to the first node. Therefore, each transaction can be directly forwarded to a designated node without broadcasting to all nodes, which can solve the problem of network message congestion caused by transaction broadcasting. In addition, the first node in the blockchain system can package the batch identifiers of M transaction batches in the transaction pool of the first node into a first block, and generate a first processing instruction based on the first block. The second node in the blockchain system responds to the first processing instruction. After consensus is reached on the first block, a second block including the transaction content data and transaction result data corresponding to the M transaction batches is written into the blockchain. Therefore, this application only needs to package one or more batch identifiers into the first block and then broadcast the first block to each node, which can solve the problem of large block transmission message bodies and effectively improve the transaction processing performance of the blockchain system. Attached Figure Description

[0012] To more clearly illustrate the technical methods of the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 This application provides a schematic diagram of the system architecture of a blockchain system. Figure 2 A schematic diagram of a block structure provided in an embodiment of this application; Figure 3 A schematic diagram of a single transaction pool scheme provided in an embodiment of this application; Figure 4 A schematic diagram illustrating the generation of blocks from packaged transactions, provided as an embodiment of this application; Figure 5 A flowchart illustrating a transaction processing method based on a blockchain system provided in this application embodiment. Figure 1 ; Figure 6 A flowchart illustrating a transaction processing method based on a blockchain system provided in this application embodiment. Figure 2 ; Figure 7 A schematic diagram illustrating a transaction forwarding method provided in an embodiment of this application; Figure 8 A flowchart illustrating a transaction processing method based on a blockchain system provided in this application embodiment. Figure 3 ; Figure 9A flowchart illustrating a transaction processing method based on a blockchain system provided in this application embodiment. Figure 4 ; Figure 10 A flowchart illustrating a transaction processing method based on a blockchain system provided in this application embodiment. Figure 5 ; Figure 11 A flowchart illustrating a transaction processing method based on a blockchain system provided in this application embodiment. Figure 6 ; Figure 12 A flowchart illustrating a transaction processing method based on a blockchain system provided in this application embodiment. Figure 7 ; Figure 13 A schematic diagram of the structure of a transaction processing device based on a blockchain system provided in this application embodiment; Figure 14 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0014] The technical methods in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0015] The system involved in the embodiments of this application can be a distributed system formed by connecting a client and multiple nodes (any form of computing device in the network, such as a server or user terminal) through network communication.

[0016] Taking a distributed system as an example, see blockchain system. Figure 1 , Figure 1 This is an optional structural diagram of the distributed system 100 provided in this application embodiment applied to a blockchain system. It consists of multiple nodes (any form of computing device in the network, such as servers or user terminals) and clients, forming a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). In the distributed system, any machine, such as a server or terminal, can join and become a node. A node includes a hardware layer, a middleware layer, an operating system layer, and an application layer.

[0017] See Figure 1 The functions of each node in the blockchain system shown include: 1) Routing: A basic function of nodes used to support communication between nodes.

[0018] In addition to routing capabilities, nodes can also have the following functions: 2) Applications are deployed in the blockchain to implement specific business needs. They record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system. When other nodes successfully verify the source and integrity of the record data, they add the record data to a temporary block.

[0019] For example, the business logic implemented by the application includes: 2.1) A wallet is used to provide the function of trading digital assets, including initiating a transaction (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system. After the other nodes successfully verify the transaction, they store the transaction record data in a temporary block of the blockchain as a response to acknowledge the validity of the transaction).

[0020] 2.2) Shared ledger, used to provide functions such as storage, query and modification of ledger data. It sends the record data of the operation on the ledger data to other nodes in the blockchain system. After the other nodes verify the validity, as a response to acknowledge the validity of the ledger data, they store the record data in a temporary block. They can also send confirmation to the node that initiated the operation.

[0021] 2.3) Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented through code deployed on a shared ledger that executes when certain conditions are met. Based on actual business needs, the code is used to complete automated transactions, such as querying the logistics status of goods purchased by a buyer and transferring the buyer's digital assets to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions; they can also execute contracts for processing received information.

[0022] 3) A blockchain consists of a series of blocks that are sequentially generated. Once a new block is added to the blockchain, it will not be removed. The blocks contain the data submitted by the nodes in the blockchain system.

[0023] See Figure 2 , Figure 2This is an optional schematic diagram of the block structure provided in this application embodiment. Each block includes the hash value of the transaction records stored in this block (the hash value of this block) and the hash value of the previous block. The blocks are connected through their hash values ​​to form a blockchain. Additionally, the block may include information such as a timestamp when it was generated. A blockchain is essentially a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains relevant information used to verify the validity of the information (anti-counterfeiting) and to generate the next block.

[0024] A ledger node is a node in a blockchain system that possesses block-producing and consensus-building capabilities. It can be a full node that stores the complete blockchain data. Ledger nodes in a blockchain system can be divided into master nodes and slave nodes. A master node is the ledger node currently responsible for producing blocks (i.e., generating blocks), while a slave node is any other ledger node in the blockchain system besides the master node. Ledger nodes can be computer devices such as terminals or servers. Servers can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Terminals can be smartphones (such as Android phones, iOS phones, etc.), tablets, laptops, desktop computers, smart speakers, smartwatches, etc., but are not limited to these.

[0025] Currently, the industry's trading pools use a single trading pool solution. (See [link / reference]). Figure 3 Node A broadcasts each received transaction to notify all other nodes, and each node adds the received transactions to its own transaction pool. When the master node generates a block, such as... Figure 4As shown, the master node packages a specified number of transactions (e.g., m transactions) from the transaction pool to generate a target block. Based on this target block, it generates a block proposal and broadcasts the proposal to all slave nodes in the blockchain system. The slave nodes can then reach a consensus on the target block. Once consensus is reached, the target block is written to their local blockchain. During the consensus process, slave nodes can vote on the target block, such as on the legality of the transaction data within the block and / or the execution order of the corresponding transactions. Voting results include "yes" and "no." When the ratio of the number of "yes" votes to the number of accounting nodes in the blockchain system exceeds a preset ratio (e.g., 2 / 3), the consensus on the target block is considered successful. For example, if more than 2 / 3 of the votes are in favor, the master node receives the voting results from the slave nodes. If more than 2 / 3 of the votes are in favor, the master node considers the slave nodes to agree to put the target block on the blockchain and can add it to the stored blockchain. Additionally, nodes can also obtain the voting results of other nodes in the blockchain system regarding the target block, and determine whether to add the target block to the local blockchain based on the voting results.

[0026] The above transaction processing method requires broadcasting each transaction to all other nodes, which can easily lead to network message congestion, especially under high concurrency, and will affect the overall transaction processing performance. In addition, since all transaction data must be packaged into a block, it also means that the block transmission message body is large when broadcasting the block to other slave nodes, which is not conducive to block broadcasting.

[0027] To address the aforementioned issues, this application provides a transaction processing method based on a blockchain system, which generally includes: In a blockchain system, each node maintains a mapping between auxiliary values ​​and node identifiers. When any node receives a transaction to be processed, it determines the matching auxiliary value and then uses the maintained mapping to obtain the node identifier corresponding to that auxiliary value. If the node identifier points to the specified node, that node stores the transaction in its own transaction pool; otherwise, it can directly send the transaction to the node indicated by the identifier. This method allows each transaction to be forwarded directly to a designated node without broadcasting it to all nodes, thus resolving the network message congestion problem caused by transaction broadcasting.

[0028] When the block production conditions are met, the master node in the blockchain system (i.e., the node responsible for producing blocks) can package the batch identifiers of transaction batches in its transaction pool into the first block, generate a first processing instruction based on the first block, and further broadcast the first processing instruction to each slave node in the blockchain system. Each slave node responds to the first processing instruction, and after consensus is reached on the first block, writes a second block, including the transaction content data corresponding to M transaction batches and the transaction result data, into the blockchain. Using this method, the master node can package only one or more batch identifiers into the first block and then broadcast the first block, which can solve the problem of the large transmission message body of the block.

[0029] Meanwhile, when reaching consensus on the first block, each slave node retrieves the M transaction batches from its memory using the batch identifier in the first block. Consensus on the first block is then based on the transactions within these M batches. Each node can execute the transactions in the M batches in parallel. Consensus on the first block is achieved when the execution results of all nodes are consistent. In existing schemes, transactions can only be executed sequentially, while this scheme allows for parallel execution of each transaction batch, fully utilizing the capabilities of multi-core CPUs and improving transaction processing performance and efficiency.

[0030] In addition, after a block is submitted or uploaded to the blockchain, it is necessary to delete the transactions that have been packaged into the block from the transaction pool. The current solution can only delete them one by one, that is, it is necessary to compare and delete each transaction in the block one by one, which is inefficient. However, this application can obtain the batch identifier of the block and use the batch identifier to delete the transaction batch in the transaction pool, which can realize the batch deletion of transactions and thus improve the efficiency of transaction deletion.

[0031] In summary, the transaction processing method based on a blockchain system provided in this application designs a new transaction processing mechanism. This mechanism involves the entire process from receiving and packaging a transaction to deleting it from the transaction pool after packaging, which can effectively improve the transaction processing performance of the blockchain system.

[0032] The following section elaborates on the specific implementation of transaction processing methods based on blockchain systems.

[0033] Please see Figure 5 , Figure 5 A flowchart illustrating a transaction processing method based on a blockchain system provided in this application embodiment. Figure 1 This method is applied to the first node in the aforementioned blockchain system, and includes, but is not limited to, the following steps: S501. When the block production condition is met, the batch identifiers of the target transaction batches in the transaction pool of the first node are packaged to obtain the first block. The first block includes the batch identifiers of M transaction batches. The transactions in each transaction batch included in the transaction pool of the first node are matched with the auxiliary value corresponding to the first node, where M is a positive integer.

[0034] In this embodiment, the first node is the ledger node responsible for producing blocks in the current stage of the blockchain system. A ledger node refers to a node in the blockchain system that has both block production and consensus functions. If the ledger nodes in the blockchain system produce blocks in a preset order, then the first node is the ledger node that is polled in the current stage; or, each ledger node may have a block production cycle, and the first node is the ledger node whose current block production cycle has arrived.

[0035] In a blockchain system, each node can maintain a mapping between auxiliary values ​​and node identifiers. When any node receives a transaction to be processed, it can determine the matching auxiliary value that matches the transaction. Then, using the maintained mapping, it obtains the node identifier corresponding to that auxiliary value. If the node identifier points to the node in question, that node stores the transaction in its own transaction pool; otherwise, it can send the transaction directly to the node indicated by the node identifier. Therefore, all transactions in each batch within the first node's transaction pool match the auxiliary value corresponding to the first node. This method allows each transaction to be forwarded directly to a designated node without broadcasting it to all nodes, thus resolving the network message congestion problem caused by transaction broadcasting.

[0036] In one implementation, the first node can obtain the transaction batches to be processed from the transaction pool of the first node according to the order in which each transaction batch was created. If the first block can accommodate the transaction batch to be processed, then the transaction batch to be processed is taken as the target transaction batch, and the batch identifier of the target transaction batch is packaged into the first block. This step can be repeated until the first block can no longer accommodate the next transaction batch to be processed. Finally, the first block can include the batch identifiers of M transaction batches, where M is a positive integer.

[0037] S502. Generate a first processing instruction based on the first block, wherein the first processing instruction includes the first block.

[0038] The first node can generate a first processing instruction based on the first block. In one embodiment, the first processing instruction may include the first block and a first digital signature. The first digital signature may be obtained by the first node encrypting the digest data of the first block using the first node's private key. The digest data of the first block may be obtained by the first node hashing the first block according to a preset hash algorithm.

[0039] S503. Send the first processing instruction to the second node in the blockchain system. The first processing instruction is used to instruct the second node to obtain the second block corresponding to the first block after the consensus on the first block is passed, and to write the second block into the blockchain. The second block includes transaction content data and transaction result data corresponding to M transaction batches.

[0040] The second node is the ledger node in the blockchain system other than the first node. In one implementation, when the first processing instruction includes the first block and the first digital signature, the second node can encrypt the first block according to a preset hash algorithm to obtain the first hash data, and decrypt the first digital signature using the public key of the first node to obtain the first decrypted data. If the first hash data and the first decrypted data are consistent, then consensus is reached on the first block.

[0041] The second node's memory includes the transaction batches broadcast from the transaction pools of other nodes. In one feasible implementation, the second node's memory includes the aforementioned M transaction batches. When reaching consensus on the first block, the second node can obtain the block identifier included in the first block, use this block identifier to retrieve the aforementioned M transaction batches from its memory, and execute the transactions in the M transaction batches to obtain the transaction result data corresponding to the M transaction batches. The second node can obtain the transaction result data obtained by other nodes in the blockchain system for the M transaction batches. If the transaction result data obtained by other nodes is consistent with the transaction result data obtained by the second node, then the second node can determine that the consensus on the first block has passed, and package the transaction content data (i.e., the content data included in the transaction itself) and the transaction result data corresponding to the M transaction batches into the first block, specifically into the block body of the first block, to obtain the second block corresponding to the first block, and then write the second block onto the local blockchain. In addition, the first node can also obtain the transaction result data obtained by each second node for M transaction batches. If the transaction result data obtained by the second nodes are consistent, the first node can write the second block onto its local blockchain.

[0042] In this embodiment, when the block production condition is met, the first node in the blockchain system can package the batch identifiers of M transaction batches in its transaction pool into a first block, and generate a first processing instruction based on the first block. By sending the first processing instruction to the second node in the blockchain system, the second node can respond to the first processing instruction. After consensus is reached on the first block, a second block including the transaction content data and transaction result data corresponding to the M transaction batches is written into the blockchain. Using the method of this application, only one or more batch identifiers can be packaged into the first block, avoiding the problem of a large block transmission message body. Simultaneously, each node's transaction pool only stores transactions matching the auxiliary value corresponding to each node, allowing each transaction to be directly forwarded to a designated node, solving the network message congestion problem caused by transaction broadcasting, and effectively improving the transaction processing performance of the blockchain system.

[0043] Please see Figure 6 , Figure 6 A flowchart illustrating a transaction processing method based on a blockchain system provided in this application embodiment. Figure 2 This method is executed jointly by the first and second nodes in the blockchain system, and includes, but is not limited to, the following steps: S601. When the block production condition is met, the first node in the blockchain system packages the batch identifiers of the target transaction batches in the transaction pool of the first node to obtain the first block. The first block includes the batch identifiers of M transaction batches. The transactions in each transaction batch included in the transaction pool of the first node are matched with the auxiliary value corresponding to the first node, where M is a positive integer.

[0044] In one implementation, the first node can obtain the transaction to be processed. This transaction can be sent to the first node from the terminal where the blockchain account resides, or it can be sent to the first node from other nodes in the blockchain system. Further, it can obtain the transaction identifier of the transaction to be processed. This identifier can specifically be the key value of the transaction to be processed, which can be a string used to uniquely identify the transaction. Then, the first node can use the transaction identifier to determine the modulus corresponding to the transaction to be processed. Specifically, it converts the transaction identifier (e.g., the key value) into a binary number, divides it by the number of ledger nodes in the blockchain system minus 1, and uses the remainder obtained by dividing the binary number by (the number of ledger nodes in the blockchain system minus 1) as the modulus corresponding to the transaction to be processed.

[0045] In a feasible implementation, the first node can obtain the transaction to be processed and the second digital signature. The second digital signature is obtained by encrypting the digest data of the transaction to be processed using the private key of the sender of the transaction to be processed. The digest data of the transaction to be processed can be obtained by hashing the transaction to be processed according to a preset hash algorithm. The first node decrypts the second digital signature using the sender's public key to obtain the second decrypted data, and hashes the transaction to be processed according to the preset hash algorithm to obtain the second hash data. If the second hash data is consistent with the second decrypted data, the step of obtaining the transaction identifier of the transaction to be processed described above is executed.

[0046] In one embodiment, if the modulus value corresponding to the transaction to be processed is inconsistent with the auxiliary value corresponding to the first node, a third node in the blockchain system that matches the modulus value corresponding to the transaction to be processed is obtained, and the transaction to be processed is sent to the third node. After the third node verifies the transaction to be processed, it can write the transaction to be processed into the transaction pool of the third node.

[0047] In one feasible implementation, the first node can use its private key to encrypt the digest data of the transaction to be processed to obtain a third digital signature. The digest data of the transaction to be processed can be obtained by hashing the transaction according to a preset hash algorithm. The third digital signature and the transaction to be processed are then sent to the third node. The third node uses the first node's public key to decrypt the third digital signature to obtain the third decrypted data. It then hashes the transaction to be processed according to the preset hash algorithm to obtain the third hash data. If the third hash data and the third decrypted data are consistent, the transaction identifier of the transaction to be processed is used to obtain the modulus value of the transaction to be processed. If it is determined that the modulus value of the transaction to be processed is consistent with the auxiliary value corresponding to the first node, then the transaction to be processed is verified as passed.

[0048] In another embodiment, if the modulus value corresponding to the transaction to be processed is consistent with the auxiliary value corresponding to the first node, the first node can determine that the transaction to be processed matches the auxiliary value corresponding to the first node, and add the transaction to be processed to the first batch of transactions to be broadcast on the first node. The first batch of transactions to be broadcast is the latest batch of transactions that has not been broadcast in the transaction pool of the first node or a newly created batch of transactions.

[0049] Specifically, when the first node determines that the transaction to be processed matches the auxiliary value corresponding to the first node, it can obtain the latest transaction batch from the transaction pool. If the latest transaction batch has not been broadcast, it can use the unbroadcast latest transaction batch as the first transaction batch to be broadcast and add the transaction to be processed to the first transaction batch to be broadcast. If the latest transaction batch has been broadcast, it can create a new transaction batch, use the newly created transaction batch as the first transaction batch to be broadcast, and add the transaction to be processed to the first transaction batch to be broadcast.

[0050] In one implementation, the latest transaction batch can refer to the transaction batch in the transaction pool whose creation time is closest to the current time, or it can refer to multiple unbroadcasted transaction batches in the transaction pool whose number of transactions is less than a preset number. When the latest transaction batch is the transaction batch in the transaction pool whose creation time is closest to the current time, each received transaction is added to this closest transaction batch. If the number of transactions in this closest transaction batch is equal to the preset number, or when the broadcast period for this closest transaction batch arrives, this closest transaction batch is broadcast to the nodes in the blockchain system. When the latest transaction batch refers to multiple unbroadcasted transaction batches in the transaction pool whose number of transactions is less than the preset number, the received transaction can be added to any one of these unbroadcasted transaction batches. When the number of transactions in any one of these transaction batches is equal to the preset number, or when the broadcast period for this one transaction batch arrives, this one transaction batch is broadcast to the nodes in the blockchain system.

[0051] Furthermore, if the number of transactions in the first batch of transactions to be broadcast meets the preset broadcast conditions, such as the number of transactions in the first batch of transactions to be broadcast being equal to the preset number, or the preset broadcast period being reached, then the first batch of transactions to be broadcast is sent to the second node, and the second node then writes the first batch of transactions to be broadcast into the memory of the second node.

[0052] In one feasible approach, the first node can use its private key to encrypt the digest data of the first batch of transactions to be broadcast, obtaining a fourth digital signature. The digest data of the first batch of transactions to be broadcast is obtained by hashing the first batch of transactions to be broadcast according to a preset hash algorithm. The first node can send the fourth digital signature and the first batch of transactions to be broadcast to the second node. The second node uses the first node's public key to decrypt the fourth digital signature, obtaining fourth decrypted data. It then uses the preset hash algorithm to hash the first batch of transactions to be broadcast, obtaining fourth hash data. The second node then checks whether the fourth decrypted data and the fourth hash data are consistent. If they are consistent, the second node writes the first batch of transactions to be broadcast into its memory.

[0053] In one embodiment, the second node writes the first batch of transactions to be broadcast into its memory. Specifically, the second node receives the first batch of transactions to be broadcast sent by the first node, and uses the transaction identifier of the first transaction in the first batch to determine whether the first transaction matches the auxiliary value corresponding to the first node. That is, it uses the transaction identifier of the first transaction to obtain the modulus value corresponding to the first transaction. If the modulus value corresponding to the first transaction is consistent with the auxiliary value corresponding to the first node, then they match; if the modulus value corresponding to the first transaction is inconsistent with the auxiliary value corresponding to the first node, then they do not match. Further, if the first transaction matches the auxiliary value corresponding to the first node, the second node uses the batch identifier of the first batch of transactions to be broadcast to determine whether the first batch of transactions to be broadcast exists in its memory. The batch identifier of the first batch of transactions to be broadcast is generated based on the transaction identifier of the first transaction in the first batch of transactions to be broadcast. It can be that the transaction identifier of the first transaction in the first batch of transactions to be broadcast is used as the batch identifier of the first batch of transactions to be broadcast. If the transaction identifier of the first transaction of each batch in the memory of the second node is not the batch identifier of the first batch of transactions to be broadcast, then it is determined that the first batch of transactions to be broadcast does not exist in the memory of the second node, and the first batch of transactions to be broadcast can be written into the memory of the second node.

[0054] Understandably, the memory of the second node will contain various transaction batches broadcast from the transaction pools of other nodes. The second node can use the transaction batches stored in the memory of the second node to obtain the above M transaction batches in order to reach consensus on the first block and obtain the second block corresponding to the first block.

[0055] In a specific implementation, such as Figure 7 As shown, when node A receives a transaction, it can perform a modulo operation on the transaction's key value. This involves converting the key value into a binary number, dividing it by (the number of ledger nodes in the blockchain system - 1) to obtain the remainder, and using this remainder as the modulo value for the transaction. The modulo value indicates which node's auxiliary value it matches, and the transaction is then sent to that node. Therefore, this application can solve the network message congestion problem caused by transaction broadcasting by determining the modulo of the transaction's key value before sending the transaction to the corresponding designated node.

[0056] Furthermore, when the first batch of transactions is broadcast to the second node, it is transmitted in the form of serialized data. Therefore, the second node in the blockchain system needs to deserialize the serialized data to obtain the first batch of transactions. In one embodiment, nodes in the blockchain system can broadcast multiple batches of transactions to other nodes in the blockchain system in parallel. Nodes in the blockchain system can also deserialize multiple deserialized data in parallel to obtain multiple broadcast batches of transactions. For example, multiple threads can be started to deserialize the serialized data corresponding to multiple broadcast batches of transactions. It can be seen that based on transaction batches, the capabilities of multi-core CPUs can be fully utilized, improving the transaction processing performance of the blockchain system and reducing resource consumption.

[0057] Serialized data refers to data obtained by serializing transaction batches. Serialization is the process of converting objects or data structures into a specific format so that they can be transmitted over a network. Deserialization is the opposite of serialization, which can restore objects from serialized data.

[0058] In one embodiment, a first node packages the batch identifiers of target transaction batches in its transaction pool to obtain a first block. Specifically, this includes: the first node obtaining a first transaction batch from its transaction pool, the first transaction batch comprising a first number of transactions. The first transaction batch can be the earliest created transaction batch obtained from the transaction pool according to the order in which they were created. Further, the first node can obtain the transactions included in the packaged transaction batches in the first block, and use the sum of the transaction quantities of the packaged transaction batches in the first block as the second number of transactions included in the packaged transaction batches in the first block. If the sum of the first number and the second number is less than or equal to a preset quantity threshold (which can be manually set or determined according to the default settings of the blockchain system), then the first transaction batch is determined as the target transaction batch, and the batch identifier of the target transaction batch is packaged into the first block; if the sum of the first number and the second number is greater than the quantity threshold, then the packaging is considered complete, and the first block is obtained. In this embodiment, when packaging transaction batches from the transaction pool into the same block, it is necessary to ensure that the number of transactions in the block does not exceed the preset quantity threshold.

[0059] S602. The first node generates a first processing instruction based on the first block and sends the first processing instruction to the second node in the blockchain system. The first processing instruction includes the first block.

[0060] In one embodiment, the first processing instruction may include a first block and a first digital signature. The first digital signature may be obtained by the first node encrypting the digest data of the first block using the first node's private key. The digest data of the first block may be obtained by the first node hashing the first block according to a preset hash algorithm. Furthermore, the first node may send the first processing instruction to a second node in the blockchain system.

[0061] S603, the second node receives the first processing instruction sent by the first node in the blockchain system.

[0062] In one embodiment, when the first processing instruction includes a first block and a first digital signature, the second node can encrypt the first block according to a preset hash algorithm to obtain first hash data, and use the public key of the first node to decrypt the first digital signature to obtain first decrypted data. If the first hash data and the first decrypted data are consistent, consensus is reached on the first block.

[0063] S604. The second node uses the batch identifier included in the first block to obtain M transaction batches from the memory of the second node, and performs consensus on the first block based on the transactions in the M transaction batches.

[0064] In one embodiment, when the second node reaches consensus on the first block, it can retrieve M transaction batches from its memory using the batch identifiers included in the first block. Specifically, the batch identifier for each transaction batch can be the transaction identifier of the first transaction in each batch. The second node can check whether the transaction identifiers of the first transactions of each batch in its memory match the batch identifiers included in the first block. If they match, the corresponding transaction batch is selected as one of the M transaction batches.

[0065] Furthermore, the second node reaches consensus on the first block based on the transactions in the M transaction batches. Specifically, the second node can use a parallel approach to start M threads to execute the transactions in the M transaction batches respectively, obtain the transaction result data corresponding to the M transaction batches, and then obtain the transaction result data obtained by other nodes in the blockchain system for the transactions in the M transaction batches. Based on the transaction result data obtained by other nodes, the second node verifies the transaction result data obtained by the second node. If the transaction result data obtained by other nodes is consistent with the transaction result data obtained by the second node, the verification is successful, and it can be determined that the consensus on the first block is successful.

[0066] In a feasible implementation, for any transaction batch among the M transaction batches, the second node can execute any transaction in that transaction batch, obtain the transaction result data corresponding to that transaction, and then obtain the transaction result data obtained by other nodes for that transaction. If the transaction result data obtained by the second node and other nodes for that transaction are consistent, then the next transaction in that transaction batch is executed to obtain the transaction result data of the next transaction, and consistency is compared with other nodes again. When it is determined that the transaction result data of all transactions in the M transaction batches are consistent, the verification is passed, and the consensus on the first block is determined to be passed.

[0067] If each node's memory contains M transaction batches, each transaction includes transaction content data and transaction result data, then the second node can use the transaction content data (transaction input) and transaction result data (transaction output) of each transaction in the M transaction batches to check whether the transaction input and output are correct. If correct, the vote result for the first block consensus is "yes". The second node can obtain the vote results of other nodes for the first block consensus. If the ratio of the number of votes in favor to the number of accounting nodes in the blockchain system is greater than a preset ratio (e.g., 2 / 3), or if the number of votes in favor is greater than the number of votes against, then the consensus for the first block can be determined to be passed.

[0068] S605. If consensus is reached on the first block, the second node will package the transaction content data and transaction result data corresponding to the M transaction batches into the first block to obtain the second block, and write the second block into the blockchain.

[0069] In one embodiment, after the second node passes consensus on the first block, it can package the transaction content data and transaction result data corresponding to the M transaction batches into the first block, and delete the block identifier included in the first block to obtain the second block, and write the second block into its local blockchain. Alternatively, the first node can also obtain the transaction result data obtained by each node for the M transaction batches. If the transaction result data obtained by each node is consistent, the first node can write the second block into its local blockchain.

[0070] In one embodiment, the first node can obtain the batch identifier included in the first block after the second block is added to the chain, or after the first block is generated. Using the batch identifier included in the first block, M transaction batches can be deleted from the transaction pool of the first node. The batch identifier that has been packaged into the block can be obtained, and the transaction batch in the transaction pool can be deleted using the batch identifier. This embodiment of the application can realize the batch deletion of transactions and improve the efficiency of transaction deletion.

[0071] In a feasible implementation, after the second block is uploaded to the chain, the second node can obtain the batch identifier included in the first block, and use the batch identifier included in the first block to delete M transaction batches from the memory of the second node. It can obtain the batch identifier that has been packaged into the block, and use the batch identifier to delete the transaction batch in memory, thereby realizing the batch deletion of transactions and improving the efficiency of transaction deletion.

[0072] The transaction processing method based on a blockchain system provided in this application designs a novel transaction processing mechanism. This mechanism involves the entire process from receiving and packaging a transaction to deleting it from the transaction pool or memory after packaging. It can change the way transactions are placed in the transaction pool from an independent (single) manner to a batch manner, thereby reducing the number of transactions traversed during packaging. Furthermore, deletion does not require traversing all transactions; only the specified batch of transactions needs to be deleted based on the batch identifier, thus improving transaction processing performance. Each transaction can be forwarded to a designated node, effectively reducing network performance loss and congestion during transaction broadcasting, and significantly improving the transaction processing performance of the blockchain system.

[0073] Please see Figure 8 , Figure 8 A flowchart illustrating a transaction processing method based on a blockchain system provided in this application embodiment. Figure 3 This method is executed by the first node in the blockchain system, and includes, but is not limited to, the following steps: S801. Receive the second processing instruction sent by the fourth node in the blockchain system. The second processing instruction includes a third block. The third block is obtained by the fourth node packaging the batch identifiers of the reference transaction batches in the transaction pool of the fourth node when the block production conditions are met. The third block includes the batch identifiers of N transaction batches, where N is a positive integer.

[0074] In this embodiment, the fourth node is the ledger node responsible for producing blocks in the current stage of the blockchain system. The first node is any ledger node in the blockchain system other than the fourth node.

[0075] In one embodiment, when the block production conditions are met, the fourth node can package the batch identifier of the reference transaction batch in its transaction pool to obtain the third block. Specifically, the fourth node obtains a second transaction batch from its transaction pool. The second transaction batch includes a third number of transactions. The second transaction batch can be the earliest created transaction batch obtained from the fourth node's transaction pool in the order in which the transaction batches were created. Further, the fourth number of transactions included in the packaged transaction batches in the third block is obtained, that is, the sum of the transaction numbers included in the packaged transaction batches in the third block is taken as the fourth number. If the sum of the third number and the fourth number is less than or equal to a preset number threshold (which can be manually set or determined according to the default settings of the blockchain system), then the second transaction batch is determined as the reference transaction batch, and the batch identifier of the reference transaction batch is packaged into the third block. If the sum of the third number and the fourth number is greater than the number threshold, then the packaging is determined to be complete, and the third block is obtained. That is, when packaging transaction batches in the transaction pool into the same block, it is necessary to ensure that the number of transactions in the block does not exceed the preset number threshold. Next, the fourth node can obtain a second processing instruction based on the third block. This second processing instruction may include the third block and a fifth digital signature. The fifth digital signature can be obtained by encrypting the digest data of the third block using the fourth node's private key. The digest data of the fourth block is obtained by hashing the fourth block according to a preset hash algorithm. The first node can decrypt the fifth digital signature using the fourth node's public key to obtain the fifth decrypted data, and hash the third block according to the preset hash algorithm to obtain the fifth hash data. If the fifth hash data matches the fifth decrypted data, then S802 is executed.

[0076] In one embodiment, the first node can receive a second batch of transactions to be broadcast sent by the fourth node. This second batch of transactions is sent when the number of transactions in the second batch meets a preset broadcast condition, such as the number of transactions equaling a preset quantity, or when a preset broadcast period arrives. The first node can use the transaction identifier of the first transaction in the second batch to determine whether the first transaction matches the auxiliary value corresponding to the fourth node. Specifically, it uses the transaction identifier of the first transaction to obtain the modulus value corresponding to the first transaction. If the modulus value of the first transaction matches the auxiliary value corresponding to the fourth node, they match; otherwise, they do not match. If the first transaction matches the auxiliary value corresponding to the fourth node, the first node uses the batch identifier of the second batch of transactions to determine whether the second batch of transactions exists in its memory. Specifically, the batch identifier of the second batch of transactions to be broadcast is generated based on the transaction identifier of the first transaction in the second batch of transactions to be broadcast. It can be that the transaction identifier of the first transaction in the second batch of transactions to be broadcast is used as the transaction identifier of the first transaction in the second batch of transactions to be broadcast. If the transaction identifier of the first transaction of each batch in the memory of the first node is not the batch identifier of the second batch of transactions to be broadcast, it is determined that the second batch of transactions to be broadcast does not exist in the memory of the first node, and the second batch of transactions to be broadcast can be written into the memory of the first node.

[0077] In one feasible approach, the fourth node can use its private key to encrypt the digest data of the second batch of transactions to be broadcast, obtaining a sixth digital signature. The digest data of the second batch of transactions to be broadcast is obtained by hashing the second batch of transactions to be broadcast according to a preset hash algorithm. The fourth node can send the sixth digital signature and the second batch of transactions to be broadcast to the first node. The first node uses the fourth node's public key to decrypt the sixth digital signature, obtaining the sixth decrypted data. The first node then uses the preset hash algorithm to hash the second batch of transactions to be broadcast, obtaining the sixth hash data. If the sixth decrypted data and the sixth hash data match, the first node writes the second batch of transactions to be broadcast into its memory.

[0078] S802. Use the batch identifiers included in the third block to obtain N transaction batches from the memory of the first node, and perform consensus on the third block based on the transactions in the N transaction batches.

[0079] In one embodiment, the first node can execute transactions in N transaction batches to obtain transaction result data corresponding to the N transaction batches. Specifically, it can adopt a parallel approach, starting N threads to execute the transactions in the N transaction batches respectively to obtain transaction result data. Then, for the transactions in the N transaction batches, it obtains the transaction result data obtained by other nodes in the blockchain system. Based on the transaction result data obtained by other nodes, it verifies the transaction result data obtained by the first node. If the transaction result data obtained by other nodes is consistent with the transaction result data obtained by the first node, the verification is successful, and it can be determined that the consensus on the third block has passed.

[0080] S803. If consensus is reached on the third block, the transaction content data and transaction result data corresponding to N transaction batches are packaged into the third block to obtain the fourth block, and the fourth block is written into the blockchain.

[0081] In one embodiment, after the first node passes consensus on the third block, it can package the transaction content data and transaction result data corresponding to N transaction batches into the third block. It can also delete the block identifier included in the third block to obtain a fourth block, and write the fourth block into its local blockchain. Alternatively, the fourth node can also obtain the transaction result data obtained by each node for the N transaction batches. If the transaction result data obtained by each node is consistent, the fourth node can also write the fourth block into its local blockchain.

[0082] In one embodiment, the fourth node can obtain the batch identifier included in the third block after the fourth block is added to the chain or after the third block is generated, and use the batch identifier included in the third block to delete N transaction batches from the transaction pool of the fourth node.

[0083] In a feasible implementation, after the fourth block is uploaded to the chain, the first node can obtain the batch identifier included in the third block, and use the batch identifier included in the third block to delete N transaction batches from the memory of the first node.

[0084] The transaction processing method based on a blockchain system provided in this application designs a novel transaction processing mechanism. This mechanism involves the entire process from receiving and packaging a transaction to deleting it from the transaction pool or memory after packaging. It can change the way transactions are placed in the transaction pool from an independent (single) manner to a batch manner, thereby reducing the number of transactions traversed during packaging. Furthermore, deletion does not require traversing all transactions; only the specified batch of transactions needs to be deleted based on the batch identifier, thus improving transaction processing performance. Each transaction can be forwarded to a designated node, effectively reducing network performance loss and congestion during transaction broadcasting, and significantly improving the transaction processing performance of the blockchain system.

[0085] Please see Figure 9 , Figure 9 A flowchart illustrating a transaction processing method based on a blockchain system provided in this application embodiment. Figure 4 This method is executed by the current node in the blockchain system that receives the transaction to be processed, and the method includes: When the current node receives a transaction to be processed, it can perform signature verification. Signature verification is the process in S601 that checks whether the second hash data and the second decrypted data are consistent. If the second hash data and the second decrypted data are consistent, the signature verification passes; if they are inconsistent, the signature verification fails, and the transaction to be processed can be discarded. If the signature verification passes, the modulo value of the key value of the transaction to be processed can be taken to obtain the modulo value.

[0086] If the modulus value is inconsistent with the current node (i.e., inconsistent with the auxiliary value corresponding to the current node), a specified node with the same modulus value (i.e., a specified node whose auxiliary value matches the modulus value) can be obtained. The node information of the specified node, such as its address, can then be acquired. The transaction to be processed is then signed using the current node's private key, and finally sent to the specified node using its address. The specified node can write the transaction to be processed into its memory after the signature verification is successful.

[0087] If the modulus is consistent with the current node (i.e., consistent with the auxiliary value corresponding to the current node), the latest transaction batch can be obtained from the current node's transaction pool. It is then determined whether the latest transaction batch has been broadcast. If not, the pending transaction is added to the latest transaction batch, and it is further determined whether this pending transaction is the last item in the latest batch (i.e., whether the transaction data in the latest batch equals the preset quantity). If the pending transaction is the last item in the latest transaction batch, it is designated as the target transaction batch. After signing the target transaction batch, it is broadcast to other nodes in the blockchain system. If the pending transaction is not the last item in the latest transaction batch, no processing is performed. If the latest transaction batch has been broadcast, a new transaction batch is created, and the pending transaction is added to the new batch. When the broadcast period arrives, it is determined whether the new transaction batch has been broadcast. If not, it is designated as the target transaction batch. After signing the target transaction batch, it is broadcast to other nodes in the blockchain system. The core of this process is that the transaction pool stores transaction batches. To ensure that the transaction batches can be broadcast to other nodes in a timely manner, a timer is set for the transaction batches. The batches will be broadcast when the broadcast period indicated by the timer is reached or when the transaction batch is full.

[0088] In one embodiment, when the transaction to be processed is the first transaction in the target transaction batch, the key value of the transaction to be processed can be used as the batch identifier of the target transaction batch.

[0089] See Figure 10 When other nodes receive the broadcast target transaction batch, they can verify the target transaction batch. This involves checking if the fourth decrypted data and the fourth hash data are consistent, as described in S601. If they are consistent, the verification passes; otherwise, it fails. If the verification passes, the initial transaction's key value can be used for validity verification. This involves taking the modulo of the initial transaction's key value and comparing it with the auxiliary value corresponding to the node that sent the target transaction batch. If they match, the verification passes; otherwise, it fails. If the verification passes, it can be checked whether the target transaction batch is present in memory. For example, it can be checked if the key value of the target transaction batch's initial transaction matches the key values ​​of the initial transactions of each other in memory. If they do not match, the target transaction batch is not present in memory and can be added to memory.

[0090] When the block production conditions are met, refer to Figure 11 The master node can iterate through the transaction batches in the transaction pool, either in the order they were created. It obtains the first number of transactions in each batch and the second number of transactions in the batches already packaged in the first block. It then checks if these numbers exceed a preset threshold. If they are less than or equal to the threshold, the master node can package the batch identifier of the encountered transaction batch into the first block and continue iterating. If they exceed the threshold, the packaging is complete, the master node obtains the first block, and can broadcast it to other slave nodes in the blockchain system. Other slave nodes, after reaching consensus on the first block, obtain the corresponding second block and write it into their local blockchain.

[0091] Once the second block is uploaded to the blockchain, each node can delete the transactions already packaged in the second block from the transaction pool or memory. See also... Figure 12 Each node can obtain a set of batch identifiers, which can be obtained based on the batch identifiers included in the first block. It can traverse the batch identifiers in the set and determine whether the memory or transaction pool contains the transaction batch corresponding to the traversed batch identifier. If it contains the batch identifier, the transaction batch corresponding to the traversed batch identifier is deleted from the memory or transaction pool. If it does not contain the batch identifier, the traversal continues.

[0092] The method described in this application presents a novel transaction processing mechanism that covers the entire process from receiving and packaging a transaction to deleting it from the transaction pool after packaging, which can effectively improve the transaction processing performance of the blockchain system.

[0093] It is understood that in the specific implementation of this application, the digital assets and other related data of the buyer are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0094] The methods of the embodiments of this application have been described in detail above. To facilitate better implementation of the methods of the embodiments of this application, the apparatus of the embodiments of this application is provided below. Please refer to... Figure 13 , Figure 13 This is a schematic diagram of a transaction processing device based on a blockchain system provided in an embodiment of this application. Applied to the first node in the blockchain system, the transaction processing device 130 may include: Processing unit 1301 is used to package the batch identifiers of the target transaction batch in the transaction pool of the first node to obtain a first block when the block production conditions are met. The first block includes batch identifiers of M transaction batches. The transactions in each transaction batch included in the transaction pool of the first node are matched with the auxiliary value corresponding to the first node, where M is a positive integer. The processing unit 1301 is further configured to generate a first processing instruction based on the first block, wherein the first processing instruction includes the first block; The sending unit 1302 is used to send the first processing instruction to the second node in the blockchain system. The first processing instruction is used to instruct the second node to obtain the second block corresponding to the first block after the consensus on the first block is passed, and to write the second block into the blockchain. The second block includes transaction content data and transaction result data corresponding to the M transaction batches.

[0095] In one embodiment, the transaction processing device 130 includes an acquisition unit 1303, which is used to: acquire a transaction to be processed; the processing unit 1301 is specifically used to: determine the modulus value corresponding to the transaction to be processed using the transaction identifier of the transaction to be processed; if the modulus value corresponding to the transaction to be processed is inconsistent with the auxiliary value corresponding to the first node, then acquire a third node in the blockchain system that matches the modulus value corresponding to the transaction to be processed, and send the transaction to be processed to the third node, so that after the third node verifies the transaction to be processed, it writes the transaction to be processed into the transaction pool of the third node.

[0096] In one embodiment, the processing unit 1301 is specifically configured to: if the modulus value corresponding to the transaction to be processed is consistent with the auxiliary value corresponding to the first node, then determine that the transaction to be processed matches the auxiliary value corresponding to the first node, and add the transaction to be processed to the first batch of transactions to be broadcast on the first node, wherein the first batch of transactions to be broadcast is the latest unbroadcast batch or a newly created batch of transactions in the transaction pool of the first node; if the number of transactions in the first batch of transactions to be broadcast meets the preset broadcast conditions, or the preset broadcast period arrives, then send the first batch of transactions to be broadcast to the second node, so that the second node writes the first batch of transactions to be broadcast into the memory of the second node, wherein the transaction batch stored in the memory of the second node is used for consensus on the first block and for obtaining the second block corresponding to the first block.

[0097] In one embodiment, the acquisition unit 1303 is specifically used to: acquire a first transaction batch from the transaction pool of the first node, the first transaction batch including a first number of transactions; acquire a second number of transactions included in the transaction batches already packaged in the first block; the processing unit 1301 is specifically used to: if the sum of the first number and the second number is less than or equal to a preset number threshold, then determine the first transaction batch as a target transaction batch, and package the batch identifier of the target transaction batch into the first block; if the sum of the first number and the second number is greater than the number threshold, then determine that the packaging is complete, and obtain the first block.

[0098] In one embodiment, the acquisition unit 1303 is specifically used to: acquire the batch identifier included in the first block; the processing unit 1301 is specifically used to: use the batch identifier included in the first block to delete the M transaction batches from the transaction pool of the first node.

[0099] In one embodiment, the acquisition unit 1303 is specifically used to: receive a second processing instruction sent by a fourth node in the blockchain system, the second processing instruction including a third block, the third block being obtained by the fourth node packaging the batch identifiers of reference transaction batches in the transaction pool of the fourth node when the block production conditions are met, the third block including batch identifiers of N transaction batches, where N is a positive integer; the processing unit 1301 is specifically used to: obtain the N transaction batches from the memory of the first node using the batch identifiers included in the third block, and perform consensus on the third block based on the transactions in the N transaction batches; the processing unit 1301 is specifically used to: if the consensus on the third block is passed, package the transaction content data and transaction result data corresponding to the N transaction batches into the third block to obtain a fourth block, and write the fourth block into the blockchain.

[0100] In one embodiment, the acquisition unit 1303 is specifically used to: receive a second batch of transactions to be broadcast sent by the fourth node, wherein the second batch of transactions to be broadcast is sent by the fourth node when the number of transactions in the second batch of transactions to be broadcast meets a preset broadcast condition, or when a preset broadcast period arrives; the processing unit 1301 is specifically used to: use the transaction identifier of the first transaction in the second batch of transactions to be broadcast to determine whether the first transaction matches the auxiliary value corresponding to the fourth node; if they match, use the batch identifier of the second batch of transactions to be broadcast to determine whether the second batch of transactions to be broadcast exists in the memory of the first node, wherein the batch identifier of the second batch of transactions to be broadcast is generated based on the transaction identifier of the first transaction in the second batch of transactions to be broadcast; if it does not exist, write the second batch of transactions to be broadcast into the memory of the first node.

[0101] In one embodiment, the processing unit 1301 is specifically configured to: execute transactions in the N transaction batches to obtain transaction result data; for the transactions in the N transaction batches, obtain transaction result data obtained by other nodes in the blockchain system; verify the transaction result data obtained by the first node based on the transaction result data obtained by the other nodes; if the verification is successful, determine that the consensus on the third block has been passed.

[0102] In one embodiment, the acquisition unit 1303 is specifically used to: acquire the batch identifier included in the third block; the processing unit 1301 is specifically used to: use the batch identifier included in the third block to delete the N transaction batches from the memory of the first node.

[0103] It is understood that the functions of each functional unit of the transaction processing device based on the blockchain system described in the embodiments of this application can be specifically implemented according to the methods in the above method embodiments. The specific implementation process can be referred to the relevant descriptions in the above method embodiments, which will not be repeated here.

[0104] The transaction processing method based on a blockchain system provided in this application designs a novel transaction processing mechanism. In this mechanism, the transaction pool of the first node only stores transactions that match the auxiliary value corresponding to the first node. Therefore, each transaction can be directly forwarded to a designated node without broadcasting to all nodes, which can solve the problem of network message congestion caused by transaction broadcasting. In addition, the first node in the blockchain system can package the batch identifiers of M transaction batches in the transaction pool of the first node into a first block, and generate a first processing instruction based on the first block. The second node in the blockchain system responds to the first processing instruction. After consensus is reached on the first block, a second block including the transaction content data and transaction result data corresponding to the M transaction batches is written into the blockchain. Therefore, this application only needs to package one or more batch identifiers into the first block and then broadcast the first block to each node, which can solve the problem of large block transmission message bodies and effectively improve the transaction processing performance of the blockchain system.

[0105] like Figure 14 As shown, Figure 14 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The internal structure of the computer device 140 is as follows: Figure 14 As shown, it includes: one or more processors 1401, memory 1402, and communication interface 1403. The processors 1401, memory 1402, and communication interface 1403 can be connected via bus 1404 or other means. This embodiment of the application takes the connection via bus 1404 as an example.

[0106] The processor 1401 (or CPU, Central Processing Unit) is the computing and control core of the computer device 140. It can parse various instructions within the computer device 140 and process various data. For example, the CPU can parse power-on / off commands sent by the user to the computer device 140 and control the computer device 140 to perform power-on / off operations; it can also transmit various interactive data between internal structures within the computer device 140, and so on. The communication interface 1403 may optionally include a standard wired interface or a wireless interface (such as Wi-Fi, mobile communication interface, etc.), controlled by the processor 1401 for sending and receiving data. The memory 1402 (Memory 14) is the storage device in the computer device 140, used to store computer programs and data. It can be understood that the memory 1402 here can include both the computer device 140's built-in memory and any extended memory supported by the computer device 140. The memory 1402 provides storage space for the operating system of the computer device 140, which may include, but is not limited to, Windows, Linux, Android, iOS, etc., and this application does not limit this to any particular system. The computer device 140 is used as the first node in the blockchain system. The processor 1401 executes the following operations by running the computer program stored in the memory 1402: When the block production condition is met, the batch identifiers of the target transaction batch in the transaction pool of the first node are packaged to obtain the first block. The first block includes the batch identifiers of M transaction batches. The transactions in each transaction batch included in the transaction pool of the first node are matched with the auxiliary value corresponding to the first node, where M is a positive integer. A first processing instruction is generated based on the first block, and the first processing instruction includes the first block; The first processing instruction is sent to the second node in the blockchain system. The first processing instruction is used to instruct the second node to obtain the second block corresponding to the first block after the consensus on the first block is passed, and to write the second block into the blockchain. The second block includes transaction content data and transaction result data corresponding to the M transaction batches.

[0107] In one embodiment, the processor 1401 is specifically configured to: acquire a transaction to be processed; determine the modulus value corresponding to the transaction to be processed using the transaction identifier of the transaction to be processed; if the modulus value corresponding to the transaction to be processed is inconsistent with the auxiliary value corresponding to the first node, acquire a third node in the blockchain system that matches the modulus value corresponding to the transaction to be processed, and send the transaction to be processed to the third node, so that after the third node verifies the transaction to be processed, it writes the transaction to be processed into the transaction pool of the third node.

[0108] In one embodiment, the processor 1401 is specifically configured to: if the modulus value corresponding to the transaction to be processed is consistent with the auxiliary value corresponding to the first node, then determine that the transaction to be processed matches the auxiliary value corresponding to the first node, and add the transaction to be processed to the first batch of transactions to be broadcast on the first node, wherein the first batch of transactions to be broadcast is the latest unbroadcast batch or a newly created batch of transactions in the transaction pool of the first node; if the number of transactions in the first batch of transactions to be broadcast meets a preset broadcast condition, or the preset broadcast period arrives, then send the first batch of transactions to be broadcast to the second node, so that the second node writes the first batch of transactions to be broadcast into the memory of the second node, wherein the transaction batch stored in the memory of the second node is used for consensus on the first block and for obtaining the second block corresponding to the first block.

[0109] In one embodiment, the processor 1401 is specifically configured to: obtain a first transaction batch from the transaction pool of the first node, the first transaction batch including a first number of transactions; obtain a second number of transactions included in the transaction batches already packaged in the first block; if the sum of the first number and the second number is less than or equal to a preset number threshold, then determine the first transaction batch as a target transaction batch, and package the batch identifier of the target transaction batch into the first block; if the sum of the first number and the second number is greater than the number threshold, then determine that the packaging is complete, and obtain the first block.

[0110] In one embodiment, the processor 1401 is specifically configured to: obtain the batch identifier included in the first block; and use the batch identifier included in the first block to delete the M transaction batches from the transaction pool of the first node.

[0111] In one embodiment, the processor 1401 is specifically configured to: receive a second processing instruction sent by a fourth node in the blockchain system, the second processing instruction including a third block, the third block being obtained by the fourth node packaging the batch identifiers of reference transaction batches in the transaction pool of the fourth node when the block production conditions are met, the third block including batch identifiers of N transaction batches, where N is a positive integer; retrieve the N transaction batches from the memory of the first node using the batch identifiers included in the third block, and perform consensus on the third block based on the transactions in the N transaction batches; if the consensus on the third block is passed, package the transaction content data and transaction result data corresponding to the N transaction batches into the third block to obtain a fourth block, and write the fourth block into the blockchain.

[0112] In one embodiment, the processor 1401 is specifically configured to: receive a second batch of transactions to be broadcast sent by the fourth node, wherein the second batch of transactions to be broadcast is sent by the fourth node when the number of transactions in the second batch of transactions to be broadcast meets a preset broadcast condition, or when a preset broadcast period arrives; determine whether the first transaction matches the auxiliary value corresponding to the fourth node using the transaction identifier of the first transaction in the second batch of transactions to be broadcast; if they match, determine whether the second batch of transactions to be broadcast exists in the memory of the first node using the batch identifier of the second batch of transactions to be broadcast, wherein the batch identifier of the second batch of transactions to be broadcast is generated based on the transaction identifier of the first transaction in the second batch of transactions to be broadcast; if it does not exist, write the second batch of transactions to be broadcast into the memory of the first node.

[0113] In one embodiment, the processor 1401 is specifically configured to: execute transactions in the N transaction batches to obtain transaction result data; for the transactions in the N transaction batches, obtain transaction result data obtained by other nodes in the blockchain system; verify the transaction result data obtained by the first node based on the transaction result data obtained by the other nodes; if the verification is successful, determine that the consensus on the third block has been passed.

[0114] In one embodiment, the processor 1401 is specifically configured to: obtain the batch identifier included in the third block; and delete the N transaction batches from the memory of the first node using the batch identifier included in the third block.

[0115] In specific implementations, the processor 1401, memory 1402, and communication interface 1403 described in the embodiments of this application can execute the implementation method described in the transaction processing method based on a blockchain system provided in the embodiments of this application, or the implementation method described in the transaction processing device based on a blockchain system provided in the embodiments of this application, which will not be repeated here.

[0116] The transaction processing method based on a blockchain system provided in this application designs a novel transaction processing mechanism. In this mechanism, the transaction pool of the first node only stores transactions that match the auxiliary value corresponding to the first node. Therefore, each transaction can be directly forwarded to a designated node without broadcasting to all nodes, which can solve the problem of network message congestion caused by transaction broadcasting. In addition, the first node in the blockchain system can package the batch identifiers of M transaction batches in the transaction pool of the first node into a first block, and generate a first processing instruction based on the first block. The second node in the blockchain system responds to the first processing instruction. After consensus is reached on the first block, a second block including the transaction content data and transaction result data corresponding to the M transaction batches is written into the blockchain. Therefore, this application only needs to package one or more batch identifiers into the first block and then broadcast the first block to each node, which can solve the problem of large block transmission message bodies and effectively improve the transaction processing performance of the blockchain system.

[0117] This application also provides a computer-readable storage medium storing a computer program that, when run on a computer device, causes the computer device to execute the transaction processing method based on the blockchain system described in any of the possible implementations above. Specific implementation details are provided above and will not be repeated here.

[0118] This application also provides a computer program product, which includes a computer program or computer instructions. When executed by a processor, the computer program or computer instructions implement the steps of the transaction processing method based on a blockchain system provided in this application. The specific implementation method can be found in the foregoing description and will not be repeated here.

[0119] This application also provides a computer program comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the transaction processing method based on a blockchain system provided in this application. The specific implementation can be found in the preceding description and will not be repeated here.

[0120] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0121] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.

[0122] The above-disclosed embodiments are only some of the embodiments of this application, and should not be construed as limiting the scope of this application. Therefore, any equivalent changes made in accordance with the claims of this application shall still fall within the scope of this application.

Claims

1. A transaction processing method based on a blockchain system, characterized in that, The method, applied to the first node in the blockchain system, includes: When the block production conditions are met, a first batch of transactions is obtained from the transaction pool of the first node, and a second number of transactions included in the transaction batches already packaged in the first block is obtained, wherein the first batch of transactions includes the first number of transactions. If the sum of the first quantity and the second quantity is less than or equal to a preset quantity threshold, then the first transaction batch is determined as the target transaction batch, and the batch identifier of the target transaction batch is packaged into the first block; If the sum of the first quantity and the second quantity is greater than the quantity threshold, then the packaging is determined to be complete, and the first block is obtained. The first block includes batch identifiers of M transaction batches. The transactions in each transaction batch included in the transaction pool of the first node are matched with the auxiliary value corresponding to the first node, where M is a positive integer. A first processing instruction is generated based on the first block, and the first processing instruction includes the first block; The first processing instruction is sent to the second node in the blockchain system. The first processing instruction is used to instruct the second node to obtain the second block corresponding to the first block after the consensus on the first block is passed, and to write the second block into the blockchain. The second block includes transaction content data and transaction result data corresponding to the M transaction batches.

2. The method according to claim 1, characterized in that, The method further includes: Get pending transactions; The modulus value corresponding to the pending transaction is determined using the transaction identifier of the pending transaction; If the modulus value corresponding to the transaction to be processed is inconsistent with the auxiliary value corresponding to the first node, then a third node in the blockchain system that matches the modulus value corresponding to the transaction to be processed is obtained, and the transaction to be processed is sent to the third node, so that after the third node verifies the transaction to be processed, it writes the transaction to be processed into the transaction pool of the third node.

3. The method according to claim 2, characterized in that, The method further includes: If the modulus value corresponding to the transaction to be processed is consistent with the auxiliary value corresponding to the first node, then it is determined that the transaction to be processed matches the auxiliary value corresponding to the first node, and the transaction to be processed is added to the first batch of transactions to be broadcast in the first node. The first batch of transactions to be broadcast is the latest batch of transactions that has not been broadcast in the transaction pool of the first node or a newly created batch of transactions. If the number of transactions in the first batch of transactions to be broadcast meets the preset broadcast conditions, or the preset broadcast period arrives, the first batch of transactions to be broadcast is sent to the second node so that the second node writes the first batch of transactions to be broadcast into the memory of the second node. The transaction batch stored in the memory of the second node is used to reach consensus on the first block and to obtain the second block corresponding to the first block.

4. The method according to any one of claims 1-3, characterized in that, After obtaining the first block, the method further includes: Obtain the batch identifier included in the first block; Using the batch identifier included in the first block, the M transaction batches are deleted from the transaction pool of the first node.

5. The method according to claim 1, characterized in that, The method further includes: The system receives a second processing instruction sent by a fourth node in the blockchain system. The second processing instruction includes a third block, which is obtained by the fourth node through packaging. The third block includes batch identifiers for N transaction batches, where N is a positive integer. The N transaction batches are retrieved from the memory of the first node using the batch identifier included in the third block, and consensus is reached on the third block based on the transactions in the N transaction batches. If consensus is reached on the third block, the transaction content data and transaction result data corresponding to the N transaction batches are packaged into the third block to obtain the fourth block, and the fourth block is written into the blockchain. The process of the fourth node packaging the third block includes: when the block production conditions are met, obtaining a second transaction batch from the transaction pool of the fourth node; when the sum of the third number of transactions contained in the second transaction batch and the fourth number of transactions contained in the transaction batches already packaged in the third block is less than or equal to the quantity threshold, determining the second transaction batch as a reference transaction batch, and packaging the batch identifier of the reference transaction batch into the third block; and when the sum of the third number and the fourth number is greater than the quantity threshold, determining that the packaging is complete, and obtaining the third block.

6. The method according to claim 5, characterized in that, The method further includes: The fourth node receives a second batch of transactions to be broadcast, which is sent by the fourth node when the number of transactions in the second batch of transactions to be broadcast meets a preset broadcast condition, or when a preset broadcast period arrives. Using the transaction identifier of the first transaction in the second batch of transactions to be broadcast, determine whether the first transaction matches the auxiliary value corresponding to the fourth node; If a match is found, the batch identifier of the second batch of transactions to be broadcast is used to determine whether the second batch of transactions to be broadcast exists in the memory of the first node. The batch identifier of the second batch of transactions to be broadcast is generated based on the transaction identifier of the first transaction in the second batch of transactions to be broadcast. If it does not exist, the second batch of transactions to be broadcast is written into the memory of the first node.

7. The method according to claim 5 or 6, characterized in that, The consensus-building process for the third block based on transactions from the N transaction batches includes: Execute the transactions in the N transaction batches to obtain transaction result data; For each of the N transaction batches, obtain the transaction result data obtained by other nodes in the blockchain system; The transaction result data obtained by the first node is verified based on the transaction result data obtained by the other nodes. If the verification passes, then the consensus on the third block is confirmed to be successful.

8. The method according to claim 5 or 6, characterized in that, After packaging the transaction content data and transaction result data corresponding to the N transaction batches into the third block to obtain the fourth block, the method further includes: Obtain the batch identifier included in the third block; Using the batch identifier included in the third block, the N transaction batches are deleted from the memory of the first node.

9. A transaction processing device based on a blockchain system, characterized in that, The device, applied to the first node in the blockchain system, comprises: The processing unit is configured to, when the block production conditions are met, obtain a first transaction batch from the transaction pool of the first node, and obtain a second number of transactions included in the already packaged transaction batches in the first block, wherein the first transaction batch includes a first number of transactions; if the sum of the first number and the second number is less than or equal to a preset number threshold, then the first transaction batch is determined as a target transaction batch, and the batch identifier of the target transaction batch is packaged into the first block; if the sum of the first number and the second number is greater than the number threshold, then the packaging is determined to be complete, and the first block is obtained, wherein the first block includes batch identifiers of M transaction batches, and the transactions in each transaction batch included in the transaction pool of the first node are matched with the auxiliary value corresponding to the first node, wherein M is a positive integer; The processing unit is further configured to generate a first processing instruction based on the first block, wherein the first processing instruction includes the first block; The sending unit is used to send the first processing instruction to the second node in the blockchain system. The first processing instruction is used to instruct the second node to obtain the second block corresponding to the first block after the consensus on the first block is passed, and to write the second block into the blockchain. The second block includes transaction content data and transaction result data corresponding to the M transaction batches.

10. A computer device, characterized in that, The computer device includes a memory, a communication interface, and a processor, wherein the memory, the communication interface, and the processor are interconnected; the memory stores a computer program, and the processor calls the computer program stored in the memory to implement the transaction processing method based on the blockchain system as described in any one of claims 1-8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the transaction processing method based on a blockchain system as described in any one of claims 1-8.

12. A computer program product, characterized in that, The computer program product includes a computer program or computer instructions, which, when executed by a processor, implement the transaction processing method based on a blockchain system as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Method and device for confirming transaction in blockchain network

    CN111813795A

  • Transaction data processing method and device, equipment and storage medium

    CN112396423A