Block generation method and device, equipment, readable storage medium and program product
By determining the target packaging strategy based on the packaging configuration information in the blockchain network, obtaining and aggregating transaction data from the transaction pool stored in the tree structure, and generating proposal blocks, the problem of single and low flexibility in the acquisition of transaction data in the existing technology is solved, and efficient and flexible block generation and resource conservation are achieved.
Patent Information
- Application Number
- CN202311498181.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-10
- Publication Date
- 2025-05-13
AI Technical Summary
The transaction data acquisition method in the existing blockchain network is single, with low flexibility, and cannot be adjusted according to different application needs, resulting in low block generation efficiency and resource utilization efficiency.
By determining the target packaging strategy based on the packaging configuration information, pending transaction data is obtained from the transaction pool stored in the tree structure, and aggregation is performed to generate a proposal block. This method supports a variety of packaging strategies, including horizontal and vertical packaging strategies, which can be dynamically adjusted to meet different application needs.
It improves the flexibility and efficiency of block generation, can meet different application needs, reduces the amount of block data, and saves storage and network resources.
Smart Images

Figure CN119989391A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a block generation method, a block generation device, a computer device, a computer-readable storage medium, and a computer program product. Background Art
[0002] Blockchain is a chain of blocks in the order of their generation time, and each block stores some transaction data. Blockchain is stored in all nodes of the blockchain network. As long as there is one node in the entire blockchain network that can work normally, the entire blockchain is safe. Blockchain has two characteristics: data is difficult to tamper with and decentralized. Based on these two characteristics, the transaction information recorded by the blockchain is more authentic and reliable, which can help solve the problem of mutual distrust.
[0003] In a blockchain network, the transaction pool usually stores transaction data in chronological order. When generating a block, one or more transaction data will be obtained from the transaction pool according to a fixed packaging strategy, and a proposal block will be generated based on the obtained transaction data. This method has low flexibility, a single transaction data acquisition method, and cannot be adjusted according to different application requirements. Summary of the invention
[0004] The embodiments of the present application provide a block generation method, apparatus, device, readable storage medium and program product, which can adopt a non-fixed packaging strategy to determine transaction data and generate a proposal block based on the aggregated transaction data. It is flexible and can meet different application requirements, while reducing the amount of block data and effectively saving resources.
[0005] On the one hand, an embodiment of the present application provides a block generation method, the method comprising:
[0006] Determine a target packaging strategy according to the packaging configuration information, where the target packaging strategy is any one of the first horizontal packaging strategy, the second horizontal packaging strategy, and the vertical packaging strategy;
[0007] At least one piece of to-be-processed transaction data is obtained from the transaction pool according to the target packaging strategy; the transaction data in the transaction pool is stored in a tree structure, and the transaction data includes compressed transaction parameters, which are obtained by compressing initial transaction parameters; in the tree structure, a root node is associated with one or more first-level nodes, the first-level nodes are associated with one or more second-level nodes, the second-level nodes are associated with one or more third-level nodes, and the third-level nodes are associated with a transaction data sequence;
[0008] Aggregate the at least one transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data;
[0009] A proposal block is generated according to the aggregated transaction data.
[0010] On the one hand, an embodiment of the present application provides a block generation device, the device comprising:
[0011] A determination unit, configured to determine a target packaging strategy according to the packaging configuration information, wherein the target packaging strategy is any one of a first horizontal packaging strategy, a second horizontal packaging strategy, and a vertical packaging strategy;
[0012] an acquisition unit, configured to acquire at least one piece of to-be-processed transaction data from a transaction pool according to the target packaging strategy; the transaction data in the transaction pool is stored in a tree structure, the transaction data includes compressed transaction parameters, and the compressed transaction parameters are obtained by compressing initial transaction parameters; in the tree structure, a root node is associated with one or more first-level nodes, the first-level nodes are associated with one or more second-level nodes, the second-level nodes are associated with one or more third-level nodes, and the third-level nodes are associated with a transaction data sequence;
[0013] A processing unit, configured to perform aggregation processing on the at least one transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data;
[0014] The processing unit is further used to generate a proposal block based on the aggregated transaction data.
[0015] On the one hand, an embodiment of the present application provides a computer device, including: a processor, a communication interface and a memory, wherein the processor, the communication interface and the memory are interconnected, wherein the memory stores an executable program code, and the processor is used to call the executable program code to implement the block generation method provided in the embodiment of the present application.
[0016] Accordingly, an embodiment of the present application further provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is executed on a computer, the computer implements the block generation method provided in the embodiment of the present application.
[0017] Accordingly, the embodiment of the present application further provides a computer program product, the computer program product includes a computer program or a computer instruction, and the computer program or the computer instruction is stored in a computer-readable storage medium. The processor of the computer device reads the computer program or the computer instruction from the computer-readable storage medium, and the processor executes the computer program or the computer instruction, so that the computer device implements the block generation method provided in the embodiment of the present application.
[0018] Through the block generation method provided by the embodiment of the present application, the target packaging strategy can be determined from a variety of packaging strategies according to the packaging configuration information, so that the pending transaction data obtained according to the target packaging strategy can better meet different application requirements and improve the overall experience; the pending transaction data can be determined from the transaction data stored in the tree structure, which effectively improves the efficiency of obtaining the pending transaction data and reduces the time spent on obtaining the transaction data, which is beneficial to improving the generation efficiency of the block; the pending transaction data including compressed transaction data can be obtained, thereby effectively reducing the storage resources and network resources consumed by the transaction data, thereby reducing the cost; the acquired pending transaction data can be aggregated according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data, thereby generating a proposal block, which effectively improves the generation efficiency of the block, reduces the data volume of the block, effectively saves storage resources, and is also beneficial to improving the processing efficiency of the transaction data in the block. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 It is a schematic diagram of the system architecture of a block generation system provided in an embodiment of the present application;
[0021] Figure 2 It is a flowchart of a block generation method provided in an embodiment of the present application;
[0022] Figure 3 is a schematic diagram of a tree structure provided in an embodiment of the present application;
[0023] Figure 4 It is a schematic diagram of a vertical packaging strategy provided in an embodiment of the present application;
[0024] Figure 5 is a schematic diagram of a first horizontal packaging strategy provided in an embodiment of the present application;
[0025] Figure 6 is a schematic diagram of a second horizontal packaging strategy provided in an embodiment of the present application;
[0026] Figure 7 is a schematic diagram of a rearrangement method provided in an embodiment of the present application;
[0027] Figure 8 is a schematic diagram of another block generation method provided in an embodiment of the present application;
[0028] Fig. 9 is a schematic diagram of a tree structure rearrangement method provided in an embodiment of the present application;
[0029] Fig.10 It is a schematic diagram of a blockchain network processing flow provided by an embodiment of the present application;
[0030] Fig.11 It is a structural block diagram of a block generation device provided in an embodiment of the present application;
[0031] Fig.12 It is a structural block diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0033] It should be noted that the descriptions of "first", "second", etc. involved in the embodiments of the present application are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the technical features defined as "first" or "second" may explicitly or implicitly include at least one of the features.
[0034] In a blockchain network, the client generates transaction data and sends it to the nodes of the blockchain network. The nodes receive the transaction data and store it in the transaction pool in chronological order. When a block needs to be generated, the node obtains at least one pending transaction data from the transaction pool in a fixed order and generates a block based on the pending transaction data obtained. This method has low flexibility and can only obtain transaction data in a fixed order, which cannot meet different application requirements.
[0035] Based on this, the embodiment of the present application provides a block generation method, which can determine the target packaging strategy according to the packaging configuration information, and the target packaging strategy is any one of the first horizontal packaging strategy, the second horizontal packaging strategy and the vertical packaging strategy; obtain at least one pending transaction data from the transaction pool according to the target packaging strategy; the transaction data in the transaction pool is stored in a tree structure, and the transaction data includes compressed transaction parameters, which are obtained by compressing the initial transaction parameters; in the tree structure, the root node is associated with one or more first-level nodes, the first-level node is associated with one or more second-level nodes, the second-level node is associated with one or more third-level nodes, and the third-level node is associated with a transaction data sequence; according to the aggregation processing strategy corresponding to the target packaging strategy, at least one pending transaction data is aggregated to obtain aggregated transaction data; and a proposal block is generated according to the aggregated transaction data. Through the method provided by the embodiment of the present application, a variety of non-fixed packaging strategies can be used to obtain pending transaction data from the transaction data stored in the tree structure, which has good flexibility and can meet different application requirements. At the same time, the transaction data includes compressed transaction parameters obtained by compressing the initial transaction parameters, and the proposal block is generated according to the aggregated transaction data, which can effectively save storage resources and network resources.
[0036] The block generation method provided in the embodiment of the present application can be applied to the field of cloud storage. Cloud storage (cloud storage), that is, a distributed cloud storage system (hereinafter referred to as the storage system), refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of storage devices of various types (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide data storage and business access functions to the outside world. The block generation method provided in the present application can be implemented based on cloud storage technology: the device storing transaction data in the embodiment of the present application can be a cloud storage device. After determining the target packaging strategy, at least one pending transaction data can be obtained from the transaction pool in the cloud storage device according to the target packaging strategy. The transaction data in the transaction pool is stored in a tree structure, and the transaction data includes a compressed transaction parameter, which is obtained by compressing the initial transaction parameter; at least one pending transaction data can be aggregated according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data, and a proposal block is generated based on the aggregated transaction data. The method provided in the embodiment of the present application has good flexibility, can meet different application requirements, and can effectively save storage resources and network resources.
[0037] The block generation method provided in this application can be applied to the field of blockchain. Blockchain is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.
[0038] The underlying blockchain platform can include object management, basic services, smart contracts, and operation monitoring processing modules. Among them, the object management module is responsible for the identity information management of all blockchain participants, including maintaining public and private key generation (account management), key management, and the maintenance of the correspondence between the user's real identity and the blockchain address (authority management), etc., and, under authorization, monitors and audits the transactions of certain real identities and provides risk control rule configuration (risk control audit); the basic service module is deployed on all blockchain node devices to verify the validity of business requests, and records valid requests to storage after consensus is reached. For a new business request, the basic service first performs interface adaptation analysis and authentication processing (interface adaptation), and then encrypts the business information through the consensus algorithm (consensus management). The smart contract module is responsible for the registration and issuance of contracts, as well as contract triggering and contract execution. Developers can define the contract logic in a programming language and publish it to the blockchain (contract registration). According to the logic of the contract terms, the key or other events are called to trigger the execution and complete the contract logic. It also provides the function of contract upgrade and cancellation. The operation monitoring module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation and real-time status visualization output of the product during the product release process, such as alarm, network status monitoring, node equipment health status monitoring, etc.
[0039] The platform product service layer provides the basic capabilities and implementation framework of typical applications. Developers can superimpose business features based on these basic capabilities to complete the blockchain implementation of business logic. The application service layer provides application services based on blockchain solutions for business participants to use.
[0040] The following will introduce the architecture of the block generation system provided in the embodiment of the present application in conjunction with the accompanying drawings.
[0041] See also Figure 1 , which is a schematic diagram of the system architecture of a block generation system provided in an embodiment of the present application, wherein the block generation system includes a client 101, a node of a blockchain network ( Figure 1In the figure, there are nodes 102, 103 and 104, each node forms a peer-to-peer network, and the peer-to-peer protocol is an application layer protocol running on the Transmission Control Protocol (TCP). Client 101 can interact with nodes in the blockchain network, and node 102 includes a transaction pool.
[0042] in:
[0043] The client 101 can generate transaction data and send the transaction data to the nodes of the blockchain network, can interact with objects, and can also receive prompt information sent by the nodes of the blockchain network. The client 101 can be a handheld device (such as a smart phone, a tablet computer), a computing device (such as a personal computer (PC), a vehicle terminal, an aircraft, an intelligent voice interaction device, a wearable device or other intelligent device with transaction data generation and communication functions, but is not limited thereto.
[0044] The nodes of the blockchain network (i.e. Figure 1 Node 102, node 103 and node 104) in the block chain network can be a server, and the nodes of the block chain network include a hardware layer, an intermediate layer, an operating system layer and an application layer. Figure 1 The figure shows the functions of each blockchain node in the block generation system, which mainly include three functions: routing, application and blockchain storage. The routing function is a basic function of the node, which is used to support communication between nodes; the application function is used to be deployed in the blockchain node to implement specific business according to actual business needs, record the data related to the implementation function to form record data, carry a digital signature in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system for other nodes to add the record data to the temporary block when they successfully verify the source and integrity of the record data; the device corresponding to the blockchain storage function includes a series of blocks (Block) that are connected to each other in the order of generation. Once a new block is added to the blockchain, it will not be removed. The block records the record data submitted by the nodes in the blockchain system. Figure 1 The nodes of the blockchain network include multiple blocks, and each block includes data associated with transaction data. Node 102 also includes a transaction pool, which can use a tree structure to store transaction data sent by the client; when a block needs to be generated, the node can obtain at least one transaction data to be processed from the transaction pool, and generate a block based on the obtained transaction data to be processed.
[0045] The following will explain in detail Figure 1 Here’s how the block generation system works:
[0046] The client 101 can generate initial transaction data by interacting with the object, and the initial transaction data may include initial transaction parameters. The client 101 compresses the initial transaction parameters to obtain compressed transaction parameters, and generates transaction data according to the compressed transaction parameters. The client 101 sends the transaction data to the node 102 of the blockchain network, and the node 102 stores the received transaction data in the transaction pool. The transaction data in the transaction pool is stored in a tree structure; in the tree structure, there is a root node, the root node is associated with one or more first-level nodes, the first-level node is associated with one or more second-level nodes, the second-level node is associated with one or more third-level nodes, and the third-level node is associated with a transaction data sequence; the node 102 can determine the target packaging strategy according to the packaging configuration information, and the target packaging strategy is any one of the first horizontal packaging strategy, the second horizontal packaging strategy, and the vertical packaging strategy. After determining the target packaging strategy, node 102 can obtain at least one pending transaction data from the transaction pool according to the target packaging strategy (the pending transaction data obtained includes the transaction data sent by client 101), and according to the aggregation processing strategy corresponding to the target packaging strategy, aggregate the at least one pending transaction data obtained from the transaction pool to obtain aggregated transaction data; generate a proposal block according to the aggregated transaction data. According to the proposal block, the execution result of the transaction corresponding to the transaction data is obtained, and node 102 sends the prompt information determined according to the execution result to client 101. Through the block generation method provided in the embodiment of the present application, the initial transaction parameters can be compressed to obtain compressed transaction data, thereby obtaining transaction data, and the aggregated transaction data can be used to generate a proposal block, reduce the data volume of the block, and save the storage resources and network resources consumed by the transaction data; the tree structure can be used to store the transaction data, thereby realizing the classified storage of the transaction data in the transaction pool, which is conducive to improving the storage efficiency and acquisition efficiency of the transaction data; the target packaging strategy can be determined from a variety of packaging strategies, so that the transaction data packaging result is more in line with the application requirements and has good flexibility.
[0047] It is understandable that the block generation system architecture diagram described in the embodiment of the present application is to more clearly illustrate the block generation method of the embodiment of the present application, and does not constitute a limitation on the block generation method provided in the embodiment of the present application. For example, the block generation method provided in the embodiment of the present application can be executed by node 102, and can also be executed by other nodes that are different from node 102 and can communicate with client 101. It is known to those skilled in the art that Figure 1 The number of clients 101 and nodes in the blockchain network is only illustrative. Any number of devices and nodes can be configured according to business implementation needs. Moreover, with the evolution of system architecture and the emergence of new business scenarios, the block generation method provided in the embodiment of the present application is also applicable to similar technical problems.
[0048] The relevant data collection and processing in this application should be strictly in accordance with the requirements of relevant laws and regulations when applied in examples, and the informed consent or separate consent of the personal information subject should be obtained, and subsequent data use and processing should be carried out within the scope of authorization of laws and regulations and the personal information subject.
[0049] See also Figure 2 , Figure 2 A flowchart of a block generation method provided in an embodiment of the present application. The block generation method can be implemented by the node 102 of the above-mentioned blockchain network, or by other nodes. The process of the block generation method provided in the embodiment of the present application includes but is not limited to:
[0050] S201. Determine a target packaging strategy according to packaging configuration information, where the target packaging strategy is any one of a first horizontal packaging strategy, a second horizontal packaging strategy, and a vertical packaging strategy.
[0051] In an embodiment of the present application, the client can send transaction data to the node of the blockchain network, and the node stores the transaction data in the transaction pool. When a block needs to be generated, the node will selectively obtain the pending transaction data from the transaction pool according to a specific packaging strategy, and generate a block based on the acquired pending transaction data. The present application provides three different packaging strategies, namely a first horizontal packaging strategy, a second horizontal packaging strategy, and a vertical packaging strategy; the three packaging strategies can be applied to different application scenarios. The node can determine the target packaging strategy from the three packaging strategies according to the packaging configuration information, and the packaging configuration information can be determined according to the actual application requirements. Through the method provided in the embodiment of the present application, the target packaging strategy can be determined, which is convenient for the subsequent targeted acquisition of transaction data from the transaction pool according to the target packaging strategy, improves the efficiency of acquiring transaction data, and can also make the acquired transaction data meet the needs and have good flexibility.
[0052] In one embodiment, the implementation method of determining the target packaging strategy according to the packaging configuration information can be: obtaining the reference selection ratio included in the packaging configuration information, the target selection ratio is the selection ratio that the horizontal packaging strategy and the vertical packaging strategy need to reach within the target time; the horizontal packaging strategy includes the first horizontal packaging strategy and the second horizontal packaging strategy; if the vertical packaging strategy is selected according to the reference selection ratio, the vertical packaging strategy is determined as the target packaging strategy; if the horizontal packaging strategy is selected according to the reference selection ratio, the first horizontal packaging strategy or the second horizontal packaging strategy is selected as the target packaging strategy according to the application scenario information included in the packaging configuration information. Before determining the target packaging strategy, the node can obtain the reference selection ratio in the packaging configuration information, the reference selection ratio is the selection ratio that the horizontal packaging strategy and the vertical packaging strategy need to reach within the target time, and the horizontal packaging strategy includes the first horizontal packaging strategy and the second horizontal packaging strategy. The target time can be a set time period (for example: five minutes, one hour, etc.), and the selection ratio that the horizontal packaging strategy and the vertical packaging strategy need to reach within the target time is the ratio of the number of times the horizontal packaging strategy is selected within the set time period to the number of times the vertical packaging strategy is selected. The horizontal packing strategy or the vertical packing strategy can be selected according to the reference selection ratio. For example, if the reference selection ratio is 1, the target time is five minutes, and the current time is 12:00, the reference selection ratio indicates that during the target time of 11:50-12:00, the ratio of the number of times the node selects the horizontal packing strategy to the number of times the node selects the vertical packing strategy should be 1:1; if during the target time of 11:50-12:00, the node has selected the horizontal packing strategy 3 times and the vertical packing strategy 2 times, the vertical packing strategy can be selected according to the reference selection ratio; if during the target time of 11:50-12:00, the node has selected the horizontal packing strategy 3 times and the vertical packing strategy 4 times, the horizontal packing strategy can be selected according to the reference selection ratio.
[0053] If the vertical packaging strategy is selected according to the reference selection ratio, the vertical packaging strategy can be directly determined as the target packaging strategy; if the horizontal packaging strategy is selected according to the reference selection ratio, the first horizontal packaging strategy or the second horizontal packaging strategy can be further selected as the target packaging strategy according to the application scenario information in the packaging configuration information. The first horizontal packaging strategy is applicable to scenarios where the number of transaction data contained in each transaction data sequence in the transaction pool is roughly the same. The first horizontal packaging strategy can make the execution opportunities of the transaction data in each transaction data sequence the same, which can improve the overall processing efficiency of the transaction data; the second horizontal packaging strategy is applicable to scenarios where some transaction data sequences have higher priority than other transaction data sequences. The second horizontal packaging strategy can optimize the utilization of storage resources. For example: the transaction pool includes 5 transaction data sequences, and the 5 transaction data sequences each include 10 transaction data. The first horizontal packaging strategy can be determined as the target packaging strategy. If the priority order of the 5 transaction data sequences is decreasing from left to right, the second horizontal packaging strategy can be determined as the target packaging strategy. Through the method provided in the embodiment of the present application, the target packaging strategy can be determined according to the reference selection ratio and application scenario information, which is conducive to ensuring that the transaction data to be processed obtained according to the target packaging strategy can meet the application requirements and can also effectively save storage resources and network resources.
[0054] It should be noted that the reference selection ratio can be dynamically adjusted according to the storage space of the nodes of the blockchain network and the processing efficiency of the transaction data. The horizontal packaging strategy can increase the execution speed of the transaction data, and the vertical packaging strategy can save the storage space of the nodes. Therefore, the reference selection ratio can be dynamically adjusted according to the processing efficiency and storage space of the nodes, thereby achieving a balance between saving storage space and improving execution efficiency, and effectively improving the overall flexibility and adaptability of the system.
[0055] S202. Obtain at least one piece of to-be-processed transaction data from the transaction pool according to the target packaging strategy; the transaction data in the transaction pool is stored in a tree structure, and the transaction data includes compressed transaction parameters, which are obtained by compressing initial transaction parameters; in the tree structure, a root node is associated with one or more first-level nodes, the first-level node is associated with one or more second-level nodes, the second-level node is associated with one or more third-level nodes, and the third-level node is associated with a transaction data sequence.
[0056] In an embodiment of the present application, at least one piece of pending transaction data can be obtained from the transaction pool according to the determined target packaging strategy, and the at least one piece of pending transaction data can be one or more pending transaction data. Multiple transaction data are stored in the transaction pool, and the transaction data includes compressed transaction parameters, which are obtained by compressing the initial transaction parameters. The transaction data in the transaction pool is stored in a tree structure, in which a root node is included, and the root node is associated with one or more first-level nodes, each first-level node is associated with one or more second-level nodes, each second-level node is associated with one or more third-level nodes, each third-level node is associated with a transaction data sequence, and the transaction data sequence includes one or more transaction data. Through the method provided in the embodiment of the present application, the unification of the transaction data storage format can be achieved, and the efficiency of obtaining the pending transaction data can be improved, thereby improving the efficiency of generating blocks.
[0057] In one embodiment, one or more next-level nodes associated with a target node in a tree structure are arranged in an arrangement order in a first direction, and the arrangement order is determined according to the amount of transaction data associated with each next-level node. The target node is any one of the root node, the first-level node, and the second-level node. For example, one or more third-level nodes associated with a second-level node are arranged in an arrangement order in the first direction, and the arrangement order is determined by the amount of transaction data associated with each third-level node associated with the second-level node.
[0058] See also Figure 3 , which is a schematic diagram of a tree structure provided by an embodiment of the present application. In the transaction pool of a node in a blockchain network, transaction data is stored in a tree structure, such as Figure 3 As shown, the tree structure includes a root node, a first-level node A and a first-level node B. The first-level node A is associated with two second-level nodes, namely, the second-level node C and the second-level node D; the first-level node B is associated with one second-level node, namely, the second-level node E; the second-level node C is associated with three third-level nodes, namely, the third-level node F, the third-level node G and the third-level node H; the second-level node D is associated with two third-level nodes, namely, the third-level node I and the third-level node J; the second-level node E is associated with two third-level nodes, namely, the third-level node K and the third-level node L. Each third-level node is associated with a transaction data sequence, wherein the transaction data sequence associated with the third-level node F includes transaction data 1-4; the transaction data sequence associated with the third-level node G includes transaction data 5 and 6; the transaction data sequence associated with the third-level node H includes transaction data 7 and 8; the transaction data sequence associated with the third-level node I includes transaction data 9-12; the transaction data sequence associated with the third-level node J includes transaction data 12 and 13; the transaction data sequence associated with the third-level node K includes transaction data 15-18; the transaction data sequence associated with the third-level node L includes transaction data 19 and 20. Figure 3For the nodes in the first direction, the direction from left to right can be used. One or more next-level nodes associated with any one of the root nodes, first-level nodes, and second-level nodes are arranged from left to right in an arrangement order, which is determined according to the number of transaction data associated with each next-level node: for example, the number of transaction data corresponding to the three third-level nodes (third-level nodes F, G, and H) associated with the second-level node C is 4, 2, and 2, respectively, so the arrangement order of these three third-level nodes from left to right is third-level node F, third-level node G, and third-level node H; for example, the number of transaction data corresponding to the two second-level nodes (secondary nodes C and D) associated with the first-level node A is 8 and 6, respectively, so the arrangement order of these two second-level nodes from left to right is second-level node C and second-level node D. Through the method provided in the embodiment of the present application, transaction data can be stored in a classified manner, which is conducive to improving the access efficiency of transaction data, thereby improving the generation efficiency of blocks.
[0059] In one embodiment, the first-level node can be determined according to the smart contract identifier, the second-level node can be determined according to the contract method identifier, and the third-level node can be determined according to the object identifier of the transaction initiating object. Then, after the node of the blockchain network receives the transaction data, the implementation method of storing it in the tree structure can be: obtaining the target transaction data of the target transaction initiating object, the target transaction data includes: compressed transaction parameters obtained by compressing the initial transaction parameters, compression type, and the smart contract identifier and contract method identifier involved in the transaction corresponding to the target transaction data; determining the sequence of transaction data to be written according to the smart contract identifier and contract method identifier included in the target transaction data and the object identifier of the target transaction initiating object; writing the target transaction data into the sequence of transaction data to be written. The target transaction initiating object can be the object that generates the target transaction data. The sequence of transaction data to be written can be determined according to the smart contract identifier and contract method identifier included in the target transaction data and the object identifier of the target transaction initiating object, and the target transaction data is written to the end of the sequence of transaction data to be written.
[0060] For example: As mentioned above Figure 3In the tree structure shown, the first-level node A is determined according to the smart contract identifier X1, the second-level node C is determined according to the contract method identifier X2, and the third-level node F is determined according to the object identifier X3 of the transaction initiating object; the node receives the transaction data 21 sent by the transaction initiating object (the object identifier is X3), and the transaction data 21 includes the compressed transaction parameters obtained by compressing the initial transaction parameters, the compression type, and the smart contract identifier (X1) and the contract method identifier (X2) involved in the transaction corresponding to the execution target transaction data; then, according to the smart contract identifier and the contract method identifier included in the transaction data and the object identifier of the target transaction initiating object, it can be determined that the transaction data sequence to be written is the transaction data sequence associated with the third-level node F, and then the transaction data 21 can be added to the end of the transaction data sequence, so that the transaction data sequence includes transaction data 1-4 and transaction data 21.
[0061] In some cases, if the tree structure of the transaction pool does not contain the corresponding node, the corresponding node can be recreated, and the transaction data can be written into the transaction data sequence corresponding to the transaction node. For example: the transaction initiation object (X4) sends transaction data 22 to the node, and the transaction data 22 includes the smart contract identifier (X1) and the contract method identifier (X2). Then the transaction data 22 is stored under the secondary node C associated with the primary node A. Because there is no third-level node corresponding to the transaction initiation object X4, a third-level node corresponding to the transaction initiation object X4 can be created. The third-level node is associated with the secondary node C, and the transaction data 22 is stored in the transaction data sequence associated with the third-level node. After the third-level node is added, the third-level nodes associated with the secondary node C are arranged in the first direction according to the arrangement order. When there is no corresponding first-level node or second-level node in the tree structure, its implementation method is similar to the above-mentioned method of constructing the third-level node. Through the method provided in the embodiment of the present application, the classified storage of transaction data can be realized according to the smart contract, the contract method and the transaction initiation object, which is conducive to improving the access efficiency of transaction data.
[0062] In one embodiment, the specific content included in the transaction data may be shown in Table 1 below.
[0063] Table 1
[0064] Data Fields meaning Chain number Blockchain network Transaction Type Corresponding transaction type Transaction number The unique number of the corresponding transaction Transaction initiation time The time when the corresponding transaction was initiated Transaction expiration time The time when the corresponding transaction expires Contract Name Name of the smart contract involved Method Name The name of the contract method involved Compressed transaction parameters Corresponding transaction parameters Compression Type The type of compression to perform Limit quantity Maximum number of computing resources
[0065] In Table 1, a transaction data includes multiple different data fields, each of which has a different meaning: the chain number indicates the blockchain network to which the transaction data belongs; the transaction type indicates the type of transaction corresponding to the transaction data, which can be any of the configuration transaction, system transaction, and user transaction; the transaction number indicates the unique number of the transaction corresponding to the transaction data; the transaction initiation time indicates the time when the corresponding transaction is initiated; the transaction expiration time indicates the time when the corresponding transaction becomes invalid; the contract name indicates the name of the smart contract involved in the execution of the corresponding transaction, and the method name indicates the name of the contract method involved in the execution of the corresponding transaction; the compressed transaction parameter indicates the relevant parameters of the corresponding transaction; the compression type indicates the compression type of the initial transaction parameters; and the limit quantity indicates the maximum number of computing resources consumed by the execution of the corresponding transaction. Among them, the compressed transaction parameter is obtained by compressing the initial transaction parameter, and the compression type of the initial transaction parameter can be determined according to the value of the compression type data field.
[0066] The value of the compression type data field can be any one of "no compression" (i.e. no compression), "LZ4", "GZIP" and "Snappy". "LZ4" means that the initial transaction parameters are compressed using the Lempel-Ziv4 (LZ4) algorithm; LZ4 is a fast lossless compression algorithm that uses dictionary compression technology to reduce the amount of compressed data as much as possible by reusing byte sequences that have already appeared in the data. It is much faster than other commonly used algorithms in terms of compression and decompression speeds, while maintaining a high compression ratio. "GZIP" means that the initial transaction parameters are compressed using the GZIP algorithm; GZIP is based on the lossless data compression algorithm DEFLATE model, uses the Lempel-Ziv coding algorithm and the Huffman coding algorithm to achieve data compression, and achieves the purpose of compressing data by storing and modifying information such as duplicates, matches and strings in the data. "Snappy" means that the initial transaction data is compressed using the Snappy algorithm; Snappy is an open source fast compression and decompression algorithm. The compression principle of Snappy mainly adopts dictionary compression technology, and uses a double pointer scanning data method to find the repeated parts in the data and compress it into a dictionary sequence of position and length. Through the method provided in the embodiment of the present application, different compression algorithms can be determined according to actual needs to compress the initial transaction parameters, so that the amount of transaction data determined according to the compressed transaction parameters is reduced, thereby reducing the storage resources consumed when storing transaction data and reducing the network resources consumed when transmitting transaction data.
[0067] In one embodiment, the target packaging strategy is a vertical packaging strategy, and the implementation method of obtaining at least one transaction data to be processed from the transaction pool according to the target packaging strategy can be: determining a target third-level node, the target third-level node is the third-level node ranked first in the first direction in the tree structure; obtaining transaction data from the first transaction data sequence associated with the target third-level node according to a reference quantity; if a reference quantity of transaction data is obtained from the first transaction data sequence, the reference quantity of transaction data obtained from the first transaction data sequence is determined as the transaction data to be processed. When the target packaging strategy is a vertical packaging strategy, the target third-level node can be determined, and the target third-level node is the third-level node ranked first in the first direction in the tree structure, as described above Figure 3 In the tree structure shown, it can be determined that the target third-level node is the third-level node F. The reference quantity is used to indicate the quantity of transaction data to be obtained. The transaction data can be obtained from the first transaction data sequence associated with the target third-level node according to the reference quantity. If the reference quantity of transaction data is obtained from the first transaction data sequence, the reference quantity of transaction data obtained from the first transaction data sequence is determined as the transaction data to be processed. For example: the reference quantity is 3, as mentioned above Figure 3 In the tree structure shown, the target third-level node is determined to be the third-level node F, and the transaction data is obtained from the transaction data sequence associated with the third-level node F to obtain transaction data 1, transaction data 2 and transaction data 3, and the obtained transaction data 1-3 can be determined as the transaction data to be processed. Since the arrangement order of each node in the tree structure is determined according to the number of transaction data corresponding to it, in the tree structure, the nodes with a large number of associated transaction data will be arranged on the left, and the nodes with a small number of associated transaction data will be arranged on the right; the vertical packaging strategy starts to obtain transaction data from the third-level node on the far left (i.e., the first in the first direction), that is, starting to obtain transaction data from the third-level node with a large number of associated transaction data, so that the transaction data with a large number of transaction data can be taken out and processed first, which can improve the efficiency of data acquisition and the efficiency of block generation. In addition, if some of the transaction data in the same transaction data sequence are the same (for example, when the first-level node is determined based on the smart contract identifier, the second-level node is determined based on the contract method identifier, and the third-level node is determined based on the object identifier of the transaction initiation object, the smart contract name, contract method name, and transaction initiation object name of each transaction data in the transaction data sequence are the same), then these identical data can be stored only once, thereby effectively saving storage resources. Through the method provided in the embodiment of the present application, transaction data can be quickly acquired, the efficiency of acquiring transaction data can be improved, and the storage resources consumed by transaction data can be effectively saved.
[0068] In one embodiment, the target packaging strategy is a vertical packaging strategy, and the implementation method can also be: if the first quantity of transaction data obtained from the first transaction data sequence is less than the reference quantity, then determine the adjacent third-level node of the target third-level node, the adjacent third-level node is the third-level node ranked second in the first direction in the tree structure; obtain transaction data from the second transaction data sequence associated with the adjacent third-level node according to the second quantity, the second quantity is determined based on the reference quantity and the first quantity; determine the transaction data to be processed based on the transaction data obtained from the first transaction data sequence and the second transaction data sequence. If the first quantity of transaction data obtained from the first transaction data sequence is less than the reference data, then determine the first adjacent third-level node of the target third-level node, the first adjacent third-level node is the third-level node ranked second in the first direction in the tree structure, for example: as described above Figure 3 In the tree structure shown, if the target third-level node is the third-level node F, then the first adjacent third-level node can be determined to be the third-level node G. Transaction data can be obtained from the second transaction data sequence associated with the first adjacent third-level node according to the second quantity, and the second quantity is determined according to the reference quantity and the first quantity; the transaction data to be processed is determined according to the transaction data obtained from the first transaction data sequence and the second transaction data sequence. If the quantity of transaction data obtained from the first transaction data sequence and the second transaction data sequence is still less than the reference quantity, the transaction data is obtained from the transaction data sequence associated with the third-level node ranked third in the first direction, and so on, until the reference quantity of transaction data is obtained. Through the method provided in the embodiment of the present application, the application block can be satisfied so that the acquired transaction data has the same data field, thereby reducing the storage resources consumed by the transaction data and saving storage resources.
[0069] See also Figure 4 , which is a schematic diagram of a vertical packaging strategy provided by an embodiment of the present application. The reference number is 6, as mentioned above Figure 3The tree structure shown can determine that the target third-level node is the third-level node F. The first quantity (4) of the transaction data (transaction data 1-4) obtained from the first transaction data sequence associated with the target third-level node is less than the reference quantity, then the first adjacent third-level node of the target third-level node can be determined to be the third-level node G; the second quantity can be determined to be 6-4=2; transaction data is obtained from the second transaction data sequence associated with the third-level node G according to the second quantity to obtain transaction data 5 and transaction data 6; the transaction data (i.e., transaction data 1-6) obtained from the first transaction data sequence and the second transaction data sequence are determined as the transaction data to be processed. Through the method provided in the embodiment of the present application, the transaction data stored in the tree structure can be vertically obtained, which is conducive to improving the efficiency of obtaining transaction data, and because the transaction data in the same transaction data sequence have the same data fields, the storage resources consumed by the obtained transaction data can be reduced.
[0070] In one embodiment, the target packaging strategy is the first horizontal packaging strategy, and the implementation method of obtaining at least one transaction data to be processed from the transaction pool according to the target packaging strategy can be: according to the reference quantity, the first transaction data is obtained from the transaction data sequence associated with each third-level node in the tree structure in sequence according to the second direction, the second direction is the opposite direction of the first direction, and the first transaction data is ranked first in the corresponding transaction data sequence; if the reference quantity of the first transaction data is obtained, the reference quantity of the first transaction data obtained is determined as the transaction data to be processed; if the third quantity of the obtained first transaction data is less than the reference quantity, according to the fourth quantity, the second transaction data is obtained from the transaction data sequence associated with each third-level node in the tree structure in sequence according to the second direction, and the transaction data to be processed is determined according to the obtained first transaction data and the second transaction data; the second transaction data is ranked second in the corresponding transaction data sequence, and the fourth quantity is determined according to the reference quantity and the third quantity. The second direction is the opposite direction of the first direction. According to the reference quantity, the first transaction data can be obtained from the transaction data sequence associated with each third-level node in the tree structure in sequence according to the second direction. The first transaction data is ranked first in the corresponding transaction data sequence. If the reference quantity of first transaction data is obtained, the reference quantity of first transaction data obtained is determined as the transaction data to be processed. For example, if the first direction is from left to right, the second direction is from right to left. The reference quantity is 3. For the above Figure 3 In the tree structure shown, by obtaining the first-ranked transaction data from the data sequence associated with each third-level node in the tree structure from right to left, transaction data 19, transaction data 15 and transaction data 13 can be obtained, and transaction data 19, transaction data 15 and transaction data 13 can be determined as transaction data to be processed.
[0071] If the third quantity of the first transaction data obtained is less than the reference quantity, then according to the fourth quantity, the second transaction data is obtained from the transaction data sequence associated with each third-level node in the tree structure in the second direction, and the transaction data to be processed is determined according to the first transaction data and the second transaction data obtained; the second transaction data is ranked second in the corresponding transaction data sequence, and the fourth quantity is determined according to the reference quantity and the third quantity. If the quantity of the first transaction data and the second transaction data obtained is still less than the reference quantity, then according to the second direction, the transaction data ranked third in the corresponding transaction data sequence is obtained from the transaction data sequence associated with each third-level node in the tree structure, and so on, until the quantity of the acquired transaction data is equal to the reference quantity. The first horizontal packaging strategy can ignore the number of transaction data in the transaction data sequence, and obtain transaction data from each transaction data sequence in a balanced manner, which can avoid the situation that some transaction data sequences cannot be obtained by the vertical packaging method because the number of transaction data contained is small and they are always arranged on the right. Through the method provided in the embodiment of the present application, the acquired transaction data to be processed can meet the application requirements, and can also effectively improve the efficiency of acquiring transaction data, which is conducive to improving the processing efficiency of transaction data in the future.
[0072] See also Figure 5 , which is a schematic diagram of a first horizontal packaging strategy provided by an embodiment of the present application. The reference number is 10, the first direction is from left to right, and the second direction is from right to left. Figure 3 The tree structure shown can sequentially obtain the first transaction data ranked first in the corresponding transaction sequence in the transaction data sequence associated with each third-level node from right to left, and obtain transaction data 19, 15, 13, 9, 7, 5 and 1, a total of 7 transaction data; the number of the first transaction data obtained is less than the reference number, then the fourth number can be determined to be 10-7=3; the second transaction data ranked second in the corresponding transaction data sequence in the transaction data sequence associated with each third-level node from right to left is obtained, and transaction data 20, 16 and 14 are obtained; then the obtained transaction data 19, 15, 13, 9, 7, 5, 1, 20, 16 and 14 can be determined as the transaction data to be processed. Through the method provided in the embodiment of the present application, it can be ensured that the transaction data in different transaction data sequences can be obtained fairly, avoiding the long-term blocking of the transaction data in a certain transaction data sequence and being unable to be obtained, and at the same time facilitating the processing of the transaction data.
[0073] In one embodiment, the target packaging strategy is the second horizontal packaging strategy, and the implementation method of obtaining at least one to-be-processed transaction data from the transaction pool according to the target packaging strategy can be: determining a target secondary node, and determining a reference third-level node from the third-level nodes associated with the target secondary node, the target secondary node is the second-level node ranked first in the first direction in the tree structure, the reference third-level node is the third-level node ranked first in the second direction among the third-level nodes associated with the target secondary node, and the second direction is the opposite direction of the first direction; obtaining transaction data from a third transaction data sequence associated with the reference third-level node according to the reference quantity; if the reference third-level node is from the third transaction data sequence, the reference third-level node is the third-level node ranked first in the second direction among the third-level nodes associated with the target secondary node, and the second direction is the opposite direction of the first direction. If a reference amount of transaction data is obtained from the sequence, the reference amount of transaction data obtained from the third transaction data sequence is determined as the transaction data to be processed; if the fifth amount of transaction data obtained from the third transaction data sequence is less than the reference amount, the transaction data is obtained from the fourth transaction data sequence associated with the adjacent third-level node according to the sixth amount, and the transaction data to be processed is determined according to the transaction data obtained from the third transaction data sequence and the fourth transaction data sequence; the sixth amount is determined according to the reference amount and the fifth amount; the adjacent third-level node is the third-level node ranked second in the second direction among one or more third-level nodes associated with the target second-level node. When performing the second horizontal packaging strategy, the target second node can be determined, and the target second node is the second-level node ranked first in the first direction in the tree structure; the reference third-level node can be determined from one or more third-level nodes associated with the target second-level node, and the reference third-level node is the third-level node ranked first in the second direction among one or more third-level nodes associated with the target second-level node, and the second direction is the opposite direction of the first direction, for example: the first direction is from left to right, and the second direction is from right to left, as mentioned above Figure 3 From the tree structure shown, it can be determined that the target second-level node is the second-level node C. The second-level node C is associated with three third-level nodes. These three third-level nodes are, from left to right, third-level node F, third-level node G, and third-level node H. Then, it can be determined that the reference third-level node is the third-level node H (the first one from right to left).
[0074] Transaction data can be obtained from the third transaction data sequence associated with the reference third-level node according to the reference quantity. If the reference quantity of transaction data is obtained from the third transaction data sequence, the reference quantity of transaction data obtained from the third transaction data sequence is determined as the transaction data to be processed. For example: the reference quantity is 2, the reference third-level node is determined to be the third-level node H, and transaction data 7 and transaction data 8 are obtained from the transaction data sequence associated with the third-level node H, then transaction data 7 and transaction data 8 can be determined as the transaction data to be processed.
[0075] If the fifth quantity of transaction data obtained from the third transaction data sequence is less than the reference quantity, the sixth quantity can be determined based on the reference quantity and the fifth quantity, and the second adjacent third-level node is the third-level node ranked second in the second direction among one or more third-level nodes associated with the target second-level node; transaction data can be obtained from the fourth transaction data sequence associated with the second adjacent third-level node according to the sixth quantity, and the transaction data to be processed can be determined based on the transaction data obtained from the third transaction data sequence and the fourth transaction data sequence. For example: the reference quantity is 3, for the above Figure 3 From the tree structure shown, it can be determined that the reference third-level node is the third-level node H, and transaction data 7 and transaction data 8 can be obtained from the transaction data sequence associated with the third-level node H, so that the sixth quantity can be determined to be 3-2=1, and the second adjacent third-level node can be determined to be the third-level node G; transaction data can be obtained from the transaction data sequence associated with the third-level node G to obtain transaction data 5, and transaction data 7, 8 and 5 can be determined as transaction data to be processed.
[0076] If the number of transaction data obtained from the third transaction data sequence and the fourth transaction data sequence is still less than the reference number, then continue to sequentially obtain the transaction data corresponding to the third-level nodes associated with the target second-level node according to the above method. If the number of transaction data corresponding to the target second-level node is less than the reference number, determine the adjacent second-level node of the target second-level node, and obtain transaction data from the transaction data sequence corresponding to the third-level node associated with the adjacent second-level node. Figure 3 The tree structure shown can determine that the target secondary node is the secondary node C, and the transaction data in the transaction data sequence associated with the third-level node H, the third-level node G and the third-level node F are obtained in sequence by the above method to obtain transaction data 1-8; if the number of acquired transaction data is less than the reference number, the adjacent secondary node of the target secondary node is determined, and the adjacent secondary node is the second-level node D; the third-level node J can be determined from the two third-level nodes associated with the adjacent second-level node D, and the transaction data is obtained from the transaction data sequence associated with the third-level node J to obtain transaction data 13 and transaction data 14. At this time, the number of acquired transaction data is 10, which is less than the reference number, and then the transaction data is obtained from the transaction data sequence associated with the third-level node I to obtain transaction data 9, and transaction data 1-9, 13 and 14 can be determined as pending transaction data. Through the method provided in the embodiment of the present application, the method of only acquiring transaction data from right to left in the first horizontal packaging strategy can be optimized, so that the acquired transaction data can save storage resources to a certain extent, meet application requirements, and improve the processing efficiency of transaction data to a certain extent.
[0077] See also Figure 6, which is a schematic diagram of a second horizontal packaging strategy provided by an embodiment of the present application. The first direction is from left to right, the second direction is from right to left, and the reference number is 7. Figure 3 From the tree structure shown, it can be determined that the leftmost first-level node is the first-level node A. The first-level node A is associated with two second-level nodes C and second-level node D, so the second-level node C can be determined as the target second-level node; the second-level node C is associated with three third-level nodes, which are third-level nodes F, G and H from left to right, so the reference third-level node can be determined to be the third-level node H. Transaction data is obtained from the transaction data sequence associated with the third-level node H, and transaction data 7 and 8 are obtained; at this time, the number of transaction data obtained (2) is less than the reference number, and the sixth number is determined to be 7-2=5; the second adjacent third-level node of the reference third-level node is determined, and the second adjacent third-level node is the third-level node G, and transaction data is obtained from the transaction data sequence associated with the third-level node G, and transaction data 5 and 6 are obtained; at this time, the number of transaction data obtained (2+2=4) is less than the reference data, and the adjacent third-level node of the second adjacent third-level node is determined, and the adjacent third-level node is the third-level node F, and transaction data is obtained from the transaction data sequence associated with the third-level node F, and transaction data 1, 2, and 3 are obtained. Therefore, transaction data 1, 2, 3, 5, 6, 7, and 8 can be determined as transaction data to be processed. Through the method provided in the embodiment of the present application, the efficiency of obtaining transaction data can be effectively improved, and the obtained transaction data can save storage resources to a certain extent, and the processing efficiency of transaction data can be improved to a certain extent.
[0078] In one embodiment, after acquiring transaction data from the tree structure, the tree structure may be rearranged to facilitate acquiring transaction data from the tree structure next time. The implementation method of rearranging the tree structure may be: removing each pending transaction data from the corresponding transaction data sequence to obtain a new transaction data sequence associated with each third-level node; determining the number of transaction data associated with each leaf node in the tree structure, where the leaf node is any node under the root node; for one or more next-level nodes associated with the target node, determining a new arrangement order of the next-level nodes associated with the target node in descending order of the number of transaction data associated with each next-level node; generating an updated tree structure according to the new arrangement order of the first-level nodes associated with the root node, the new arrangement order of the second-level nodes associated with each first-level node, the new arrangement order of the third-level nodes associated with each second-level node, and the new transaction data sequence associated with each third-level node; the updated transaction data in the transaction pool is stored using the updated tree structure. After determining at least one transaction data to be processed, each transaction data to be processed can be removed from the corresponding transaction data sequence to obtain a new transaction data sequence associated with each third-level node; the number of transaction data associated with each leaf node in the tree structure can be determined, and the leaf node is any node under the root node, and the leaf node can include each first-level node, each second-level node, and each third-level node. For one or more next-level nodes associated with the target node, the new arrangement order of the next-level nodes associated with the target node can be determined in descending order of the number of transaction data associated with each next-level node, and the target node is any node among the root node, the first-level node, and the second-level node; according to the new arrangement order of the first-level nodes associated with the root node, the new arrangement order of the second-level nodes associated with each first-level node, the new arrangement order of the third-level nodes associated with each second-level node, and the new transaction data sequence associated with each third-level node, an updated tree structure can be generated; the updated tree structure is used to store the updated transaction data in the transaction pool. Through the method provided in the embodiment of the present application, the tree structure can be rearranged according to the amount of transaction data associated with each node, which is beneficial for obtaining transaction data from the tree structure next time and improves the efficiency of obtaining transaction data.
[0079] See also Figure 7 , which is a schematic diagram of a rearrangement method provided in an embodiment of the present application. The reference number is 7, and the target packaging strategy is the second horizontal packaging method. Figure 3 The tree structure shown in FIG. 1 obtains transaction data from the transaction pool to obtain pending transaction data. The pending transaction data is as described above. Figure 6As shown, it is transaction data 1-3, 5-8; each piece of transaction data to be processed is removed from the corresponding transaction data sequence to obtain a new transaction data sequence associated with each third-level node. In the new transaction data sequence associated with each third-level node, the new transaction data sequence associated with the third-level node F includes transaction data 4, the number of transaction data included in the new transaction data sequence associated with the third-level node G and the third-level node H is 0, and the new transaction data sequences associated with other third-level nodes are the same as the original associated transaction data sequences. The number of transaction data associated with each node in the tree structure can be determined. The number of transaction data associated with the first-level node A is 7, and the number of transaction data associated with the first-level node B is 6; the number of transaction data associated with the second-level node C is 1; the number of transaction data associated with the second-level node D is 6; the number of transaction data associated with the second-level node E is 6; the number of transaction data associated with the third-level node F is 1; the number of transaction data associated with the third-level node G is 0; the number of transaction data associated with the third-level node H is 0; the number of transaction data associated with the third-level node I is 4; the number of transaction data associated with the third-level node J is 2; the number of transaction data associated with the third-level node K is 4; the number of transaction data associated with the third-level node L is 2. When the target node is the root node, the order of the two first-level nodes from left to right can be determined as first-level node A and first-level node B according to the number of associated transaction data; when the target node is first-level node A, the order of the two second-level nodes from left to right can be determined as second-level node D and second-level node C according to the number of associated transaction data, and so on, the new order of the next-level node associated with the target node can be determined. According to the new order of the first-level nodes associated with the root node, the new order of the second-level nodes associated with each first-level node, the new order of the third-level nodes associated with each second-level node, and the new transaction data sequence associated with each third-level node, the following can be obtained: Figure 7 The updated tree structure shown in . Through the method provided in the embodiment of the present application, the tree structure can be rearranged to facilitate the acquisition of transaction data next time, which is conducive to improving the efficiency of acquiring transaction data and further improving the efficiency of generating blocks.
[0080] It should be noted that, in some cases, after the received transaction data is written into the transaction data sequence corresponding to the tree structure, the tree structure may also be rearranged, and the rearrangement method is similar to the method described in the above embodiment.
[0081] S203: Aggregate the at least one transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data.
[0082] In an embodiment of the present application, after obtaining at least one piece of pending transaction data from the transaction pool, the at least one piece of pending transaction data can be aggregated according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data. Different target packaging strategies correspond to different aggregation processing strategies. Aggregated transaction data is used to generate proposal blocks, which can reduce the network resources consumed by transmitting data. Through the method provided in the embodiment of the present application, the pending transaction data can be aggregated in a targeted manner to obtain aggregated transaction data, thereby further saving network resources.
[0083] In one embodiment, the implementation method of performing aggregation processing on at least one to-be-processed transaction data according to the aggregation processing strategy corresponding to the target packaging strategy to obtain the aggregated transaction data can be: for the to-be-processed transaction data with the same attribute in at least one to-be-processed transaction data, extracting public data from the to-be-processed transaction data with the same attribute, and the to-be-processed transaction data with the same attribute is the to-be-processed transaction data belonging to the same transaction data sequence; compressing the data except the public data in the to-be-processed transaction data with the same attribute to obtain compressed data; and determining the aggregated transaction data according to the public data and the compressed data. When the target packaging strategy is the vertical packaging strategy, the first horizontal packaging strategy, and the second horizontal packaging strategy, the to-be-processed transaction data with the same attribute may exist in the at least one to-be-processed transaction data obtained, and the to-be-processed transaction data with the same attribute is the to-be-processed transaction data belonging to the same transaction data sequence. Part of the data of the two to-be-processed transaction data with the same attribute is the same, that is, the public data. Therefore, in order to save storage space, the public data of the to-be-processed transaction data with the same attribute can be extracted and stored separately, while the data except the public data in the to-be-processed transaction data with the same attribute can be stored separately. Public data can be extracted from the pending transaction data with the same attributes. For example, the first-level node is determined according to the smart contract identifier, the second-level node is determined according to the contract method identifier, and the third-level node is determined according to the object identifier of the transaction initiating object. If the transaction data in the same transaction data sequence have the same contract name, method name and object identifier of the transaction initiating object, then these three data in multiple pending transaction data with the same attributes can be extracted and stored separately once, while the remaining data in multiple pending transaction data with the same attributes are stored independently. The data except the public data in the pending transaction data with the same attributes is compressed to obtain compressed data; and the aggregated transaction data is determined based on the compressed data and the public data. Through the method provided in the embodiment of the present application, the characteristics of the data stored in the tree structure can be utilized to extract the public data for separate processing, thereby further saving storage resources. Compression processing of other data can also effectively reduce the consumption of network resources.
[0084] S204. Generate a proposal block according to the aggregated transaction data.
[0085] In the embodiment of the present application, a proposal block can be generated based on the aggregated transaction, and the proposal block can be broadcast to other nodes of the blockchain network, or processed by relevant functional modules in the node. The method provided by the embodiment of the present application can effectively improve the efficiency of block generation and effectively reduce the network resources and storage resources consumed by generating blocks.
[0086] In one embodiment, the node can parse the proposal block to obtain aggregated transaction data, and can execute the transaction corresponding to the aggregated transaction data. The implementation method can be: if the target packaging strategy is the target horizontal packaging strategy, the transaction corresponding to the aggregated transaction data in the proposal block is executed in parallel to obtain the first transaction execution result, and the proposal block is updated according to the first transaction execution result, and the target horizontal packaging strategy is the first horizontal packaging strategy or the second horizontal packaging strategy; if the target packaging strategy is the vertical packaging strategy, the transaction corresponding to the aggregated transaction data in the proposal block is executed serially to obtain the second transaction execution result, and the proposal block is updated according to the second transaction execution result. If the target packaging strategy is the target horizontal packaging strategy, and the target horizontal packaging strategy is the first horizontal packaging strategy or the second horizontal packaging strategy, it means that there are two transaction data to be processed that do not involve public data, so the transaction corresponding to the aggregated transaction data in the proposal block can be executed in parallel (the transaction corresponding to the aggregated transaction data matches the transaction corresponding to the transaction data to be processed), and the first transaction execution result is obtained, and the proposal block can be updated according to the first transaction execution result. The number of transactions executed in parallel can be determined according to the actual application requirements and the hardware conditions of the device. For example, the number of concurrently executed transactions can be determined according to 4 times the number of cores of the central processing unit (CPU) in the node. Concurrently executing transactions can effectively improve the processing efficiency of transactions. If the target packaging strategy is a vertical packaging strategy, there is public data in the transaction data to be processed, and these transactions need to be executed serially in the startup order to prevent potential conflicts. Through the method provided in the embodiment of the present application, different processing methods can be adopted for the proposal blocks obtained by different packaging strategies, which greatly improves the processing efficiency of transactions.
[0087] Through the block generation method provided by the embodiment of the present application, the reference selection ratio can be determined according to the storage space and processing efficiency, so as to determine a non-fixed packaging strategy, and the transaction data in the transaction pool can be reasonably selected so that the acquired transaction data meets different application requirements and has good flexibility; the transaction data can be acquired by adopting a vertical packaging strategy, so as to effectively save storage space and network resources, or the transaction data can be acquired by adopting a first or second horizontal packaging strategy, so as to effectively improve the transaction processing efficiency; the transaction data can be stored in a tree structure, so as to realize the classified storage of the transaction data, and no conversion is required when acquiring the transaction data, so as to improve the storage and access efficiency of the transaction data, and thus improve the generation efficiency of the block; after acquiring the transaction data, the tree structure can be updated to facilitate the subsequent acquisition of the transaction data and ensure the stability of the system; the transaction data to be processed is aggregated to obtain the aggregated transaction data, and a proposal block is generated according to the aggregated transaction data, so as to reduce the data volume of the proposal block and save storage resources and network resources; the reference selection ratio of the target packaging strategy can be dynamically adjusted, so as to realize the adaptability of the acquisition of the transaction data and effectively improve the overall processing efficiency.
[0088] See also Figure 8 , Figure 8 A flowchart of another block generation method provided in an embodiment of the present application. The block generation method can be Figure 1 The block generation system shown is implemented. The process of the block generation method provided in the embodiment of the present application includes but is not limited to:
[0089] S801. Receive target transaction data sent by a client, where the target transaction data includes compressed transaction parameters, which are obtained by compressing initial transaction parameters.
[0090] In an embodiment of the present application, the client can be the transaction initiator object in the above embodiment, and the client can generate target transaction data and send the target transaction data to the node of the blockchain network. The target transaction data may include compressed transaction parameters, which may be obtained by compressing the initial transaction parameters. The target transaction data may also include data such as the compression type, the smart contract identifier and the contract method identifier involved in the transaction corresponding to the target transaction data. The data fields included in the target transaction data may be as shown in Table 1 above. By the method provided in the embodiment of the present application, the target transaction data can be obtained. Since the target transaction data includes compressed transaction parameters, the target transaction data can effectively save storage resources and network resources.
[0091] In one embodiment, after receiving the target transaction data, the node may verify the transaction initiation object corresponding to the target transaction data, and write the verified target transaction data into the transaction pool.
[0092] S802. Write the target transaction data into a transaction pool, wherein the transaction data in the transaction pool is stored in a tree structure; in the tree structure, a root node is associated with one or more first-level nodes, the first-level nodes are associated with one or more second-level nodes, the second-level nodes are associated with one or more third-level nodes, and the third-level nodes are associated with a transaction data sequence.
[0093] In an embodiment of the present application, the target transaction data can be stored in a tree structure according to the data included in the target transaction data. The transaction data in the transaction pool is stored in a tree structure, in which a root node is included, the root node is associated with one or more first-level nodes, each first-level node is associated with one or more second-level nodes, each second-level node is associated with one or more third-level nodes, each third-level node is associated with a transaction data sequence, and the transaction data sequence includes one or more transaction data. Through the method provided in the embodiment of the present application, the unification of the transaction data storage format can be achieved, the efficiency of obtaining the transaction data to be processed can be improved, and thus the efficiency of generating blocks can be improved.
[0094] In one embodiment, one or more next-level nodes associated with the target node in the tree structure are arranged in a first direction according to an arrangement order, and the arrangement order is determined according to the amount of transaction data associated with each next-level node. The target node is any one of the root node, the first-level node and the second-level node. The tree structure in the transaction pool can be as described above. Figure 3 shown.
[0095] In one embodiment, the first-level node can be determined according to the smart contract identifier, the second-level node can be determined according to the contract method identifier, and the third-level node can be determined according to the object identifier of the transaction initiation object. Then, the implementation method of writing the target transaction data into the transaction pool can be: obtaining the target transaction data of the target transaction initiation object, the target transaction data including: compressed transaction parameters obtained by compressing the initial transaction parameters, compression type, and the smart contract identifier and contract method identifier involved in the transaction corresponding to the target transaction data; determining the sequence of transaction data to be written according to the smart contract identifier and contract method identifier included in the target transaction data and the object identifier of the target transaction initiation object; writing the target transaction data into the sequence of transaction data to be written. The target transaction initiation object can be the object that generates the target transaction data. The target transaction data can include the compressed transaction parameters obtained by compressing the initial transaction parameters, the compression type, and the smart contract identifier and contract method identifier involved in the transaction corresponding to the target transaction data. The sequence of transaction data to be written can be determined according to the smart contract identifier and contract method identifier included in the target transaction data and the object identifier of the target transaction initiation object, and the target transaction data is written to the end of the sequence of transaction data to be written. In some cases, if the tree structure of the transaction pool does not contain the corresponding node, the corresponding node can be recreated, and the transaction data can be written into the transaction data sequence corresponding to the transaction node. Through the method provided in the embodiment of the present application, the classified storage of transaction data can be realized according to the smart contract, contract method and transaction initiation object, which is conducive to improving the storage and access efficiency of transaction data.
[0096] S803: Determine a target packaging strategy according to the packaging configuration information, where the target packaging strategy is any one of the first horizontal packaging strategy, the second horizontal packaging strategy, and the vertical packaging strategy.
[0097] In an embodiment of the present application, the node will selectively obtain pending transaction data from the transaction pool according to a specific packaging strategy, and generate blocks based on the acquired pending transaction data. The target packaging strategy can be any one of the first horizontal packaging strategy, the second horizontal packaging strategy, and the vertical packaging strategy; these three packaging strategies can be applied to different application scenarios. The node can determine the target packaging strategy from the three packaging strategies based on the packaging configuration information, and the packaging configuration information can be determined according to actual application requirements. Through the method provided in the embodiment of the present application, the target packaging strategy can be determined, which is convenient for the subsequent targeted acquisition of transaction data from the transaction pool according to the target packaging strategy, thereby improving the efficiency of acquiring transaction data.
[0098] In one embodiment, the implementation method of determining the target packaging strategy according to the packaging configuration information can be: obtaining the reference selection ratio included in the packaging configuration information, the target selection ratio is the selection ratio that the horizontal packaging strategy and the vertical packaging strategy need to reach within the target time; the horizontal packaging strategy includes the first horizontal packaging strategy and the second horizontal packaging strategy; if the vertical packaging strategy is selected according to the reference selection ratio, the vertical packaging strategy is determined as the target packaging strategy; if the horizontal packaging strategy is selected according to the reference selection ratio, the first horizontal packaging strategy or the second horizontal packaging strategy is selected as the target packaging strategy according to the application scenario information included in the packaging configuration information. Before determining the target packaging strategy, the node can obtain the reference selection ratio included in the packaging configuration information, the reference selection ratio is the selection ratio that the horizontal packaging strategy and the vertical packaging strategy need to reach within the target time, and the horizontal packaging strategy includes the first horizontal packaging strategy and the second horizontal packaging strategy. The target time can be a set time period (for example: ten minutes, etc.), and the selection ratio that the horizontal packaging strategy and the vertical packaging strategy need to reach within the target time period is the ratio of the number of times the horizontal packaging strategy is selected to the number of times the vertical packaging strategy is selected within the set time period. The horizontal packaging strategy or the vertical packaging strategy can be selected according to the reference selection ratio. If the vertical packaging strategy is selected according to the reference selection ratio, the vertical packaging strategy can be directly determined as the target packaging strategy; if the horizontal packaging strategy is selected according to the reference selection ratio, the first horizontal packaging strategy or the second horizontal packaging strategy can be further selected as the target packaging strategy according to the application scenario information included in the packaging configuration information. The first horizontal packaging strategy is applicable to scenarios where the number of transaction data contained in each transaction data sequence in the transaction pool is roughly the same. The first horizontal packaging strategy can make the execution opportunities of the transaction data in each transaction data sequence the same, which can improve the overall processing efficiency of the transaction data; the second horizontal packaging strategy is applicable to scenarios where some transaction data sequences have a higher priority than other transaction data sequences. The second horizontal packaging strategy can optimize the utilization of storage resources.
[0099] S804: Obtain at least one piece of transaction data to be processed from the transaction pool according to the target packaging strategy.
[0100] In the embodiment of the present application, at least one piece of transaction data to be processed can be obtained from the transaction pool according to the determined target packaging strategy, and the at least one piece of transaction data to be processed can be one or more pieces of transaction data to be processed. Through the method provided in the embodiment of the present application, the efficiency of obtaining the transaction data to be processed can be improved, thereby improving the efficiency of generating blocks.
[0101] In one embodiment, the target packaging strategy is a vertical packaging strategy, and the implementation method of obtaining at least one transaction data to be processed from the transaction pool according to the target packaging strategy can be: determining a target third-level node, the target third-level node is the third-level node ranked first in the first direction in the tree structure; obtaining transaction data from the first transaction data sequence associated with the target third-level node according to a reference quantity; if a reference quantity of transaction data is obtained from the first transaction data sequence, the reference quantity of transaction data obtained from the first transaction data sequence is determined as the transaction data to be processed. When the target packaging strategy is a vertical packaging strategy, the target third-level node can be determined, and the target third-level node is the third-level node ranked first in the first direction in the tree structure, as described above Figure 3 In the tree structure shown, it can be determined that the target third-level node is the third-level node F. The reference quantity is used to indicate the number of transaction data that needs to be obtained. The transaction data can be obtained from the first transaction data sequence associated with the target third-level node according to the reference quantity. If the reference quantity of transaction data is obtained from the first transaction data sequence, the reference quantity of transaction data obtained from the first transaction data sequence is determined as the transaction data to be processed. Since the arrangement order of each node in the tree structure is determined according to the number of transaction data corresponding to it, the transaction data with a larger number can be taken out and processed first, which can improve the data acquisition efficiency and the block generation efficiency. In addition, if part of the transaction data in the same transaction data sequence is the same, these same data can be stored only once, thereby effectively saving storage resources. Through the method provided in the embodiment of the present application, transaction data can be quickly acquired, the acquisition efficiency of transaction data can be improved, and the storage resources consumed by transaction data can be effectively saved.
[0102] In one embodiment, the target packaging strategy is a vertical packaging strategy, and the implementation method can also be: if the first quantity of transaction data obtained from the first transaction data sequence is less than the reference quantity, then determine the adjacent third-level node of the target third-level node, the adjacent third-level node is the third-level node ranked second in the first direction in the tree structure; obtain transaction data from the second transaction data sequence associated with the adjacent third-level node according to the second quantity, the second quantity is determined according to the reference quantity and the first quantity; determine the transaction data to be processed according to the transaction data obtained from the first transaction data sequence and the second transaction data sequence. If the first quantity of transaction data obtained from the first transaction data sequence is less than the reference data, then determine the first adjacent third-level node of the target third-level node, the first adjacent third-level node is the third-level node ranked second in the first direction in the tree structure. The transaction data can be obtained from the second transaction data sequence associated with the first adjacent third-level node according to the second quantity, the second quantity is determined according to the reference quantity and the first quantity; determine the transaction data to be processed according to the transaction data obtained from the first transaction data sequence and the second transaction data sequence. If the amount of transaction data obtained from the first transaction data sequence and the second transaction data sequence is still less than the reference amount, then the transaction data is obtained from the transaction data sequence associated with the third-level node ranked third in the first direction, and so on, until the reference amount of transaction data is obtained. Through the method provided in the embodiment of the present application, the obtained transaction data can have the same data field, thereby reducing the storage resources consumed by the transaction data, thereby saving storage resources.
[0103] In one embodiment, the target packaging strategy is the first horizontal packaging strategy, and the implementation method of obtaining at least one transaction data to be processed from the transaction pool according to the target packaging strategy can be: according to the reference quantity, the first transaction data is obtained from the transaction data sequence associated with each third-level node in the tree structure in sequence according to the second direction, the second direction is the opposite direction of the first direction, and the first transaction data is ranked first in the corresponding transaction data sequence; if the reference quantity of the first transaction data is obtained, the reference quantity of the first transaction data obtained is determined as the transaction data to be processed; if the third quantity of the obtained first transaction data is less than the reference quantity, according to the fourth quantity, the second transaction data is obtained from the transaction data sequence associated with each third-level node in the tree structure in sequence according to the second direction, and the transaction data to be processed is determined according to the obtained first transaction data and the second transaction data; the second transaction data is ranked second in the corresponding transaction data sequence, and the fourth quantity is determined according to the reference quantity and the third quantity. The second direction is the opposite direction of the first direction. According to the reference quantity, the first transaction data can be obtained from the transaction data sequence associated with each third-level node in the tree structure in sequence according to the second direction. The first transaction data is ranked first in the corresponding transaction data sequence. If the reference quantity of first transaction data is obtained, the obtained reference quantity of first transaction data is determined as the transaction data to be processed.
[0104] If the third quantity of the first transaction data obtained is less than the reference quantity, then according to the fourth quantity, the second transaction data is obtained from the transaction data sequence associated with each third-level node in the tree structure in the second direction, and the transaction data to be processed is determined according to the first transaction data and the second transaction data obtained; the second transaction data is ranked second in the corresponding transaction data sequence, and the fourth quantity is determined according to the reference quantity and the third quantity. If the quantity of the first transaction data and the second transaction data obtained is still less than the reference quantity, then according to the second direction, the transaction data ranked third in the corresponding transaction data sequence is obtained from the transaction data sequence associated with each third-level node in the tree structure, and so on, until the quantity of the acquired transaction data is equal to the reference quantity. The first horizontal packaging strategy can ignore the number of transaction data in the transaction data sequence, and obtain transaction data from each transaction data sequence in a balanced manner, which can avoid the situation that some transaction data sequences cannot be obtained by the vertical packaging method because the number of transaction data contained is small and they are always arranged on the right. The method provided by the embodiment of the present application can effectively improve the efficiency of obtaining transaction data, and is also conducive to improving the efficiency of processing transaction data in the future.
[0105] In one embodiment, the target packaging strategy is the second horizontal packaging strategy, and the implementation method of obtaining at least one to-be-processed transaction data from the transaction pool according to the target packaging strategy can be: determining a target secondary node, and determining a reference third-level node from the third-level nodes associated with the target secondary node, the target secondary node is the second-level node ranked first in the first direction in the tree structure, the reference third-level node is the third-level node ranked first in the second direction among the third-level nodes associated with the target secondary node, and the second direction is the opposite direction of the first direction; obtaining transaction data from a third transaction data sequence associated with the reference third-level node according to the reference quantity; if the reference third-level node is from the third transaction data sequence, the reference third-level node is the third-level node ranked first in the second direction among the third-level nodes associated with the target secondary node, and the second direction is the opposite direction of the first direction. If a reference quantity of transaction data is obtained from the sequence, the reference quantity of transaction data obtained from the third transaction data sequence is determined as the transaction data to be processed; if the fifth quantity of transaction data obtained from the third transaction data sequence is less than the reference quantity, transaction data is obtained from the fourth transaction data sequence associated with the adjacent third-level node according to the sixth quantity, and the transaction data to be processed is determined according to the transaction data obtained from the third transaction data sequence and the fourth transaction data sequence; the sixth quantity is determined based on the reference quantity and the fifth quantity; the adjacent third-level node is the third-level node ranked second in the second direction among one or more third-level nodes associated with the target second-level node.
[0106] In one embodiment, after acquiring transaction data from the tree structure, the tree structure may be rearranged to facilitate acquiring transaction data from the tree structure next time. The implementation method of rearranging the tree structure may be: removing each pending transaction data from the corresponding transaction data sequence to obtain a new transaction data sequence associated with each third-level node; determining the number of transaction data associated with each leaf node in the tree structure, where the leaf node is any node under the root node; for one or more next-level nodes associated with the target node, determining a new arrangement order of the next-level nodes associated with the target node in descending order of the number of transaction data associated with each next-level node; generating an updated tree structure according to the new arrangement order of the first-level nodes associated with the root node, the new arrangement order of the second-level nodes associated with each first-level node, the new arrangement order of the third-level nodes associated with each second-level node, and the new transaction data sequence associated with each third-level node; the updated transaction data in the transaction pool is stored using the updated tree structure. Through the method provided in the embodiment of the present application, the tree structure can be rearranged according to the amount of transaction data associated with each node, which is beneficial for obtaining transaction data from the tree structure next time and improves the efficiency of obtaining transaction data.
[0107] See also Fig. 9, this figure is a schematic diagram of a tree structure rearrangement method provided in an embodiment of the present application. After the proposal block is generated, the tree structure rearrangement function can be triggered; the entire tree structure is traversed, and the number of transaction data associated with each leaf node is determined, and the leaf node is any node under the root node; the nodes in the tree structure are converted into an ordered list; the ordered list is sorted according to the number of transaction data, so that the number of transaction data is arranged from large to small; the tree structure is rebuilt according to the sorted ordered list to obtain an updated tree structure. Through the method provided in the embodiment of the present application, the tree structure can be rearranged, which is convenient for improving the efficiency of acquiring transaction data and ensuring the stability of the system.
[0108] S805: Aggregate the at least one transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data.
[0109] In an embodiment of the present application, after obtaining at least one piece of pending transaction data from the transaction pool, the at least one piece of pending transaction data can be aggregated according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data. Different target packaging strategies correspond to different aggregation processing strategies. Aggregated transaction data is used to generate proposal blocks, which can reduce the network resources consumed by transmitting data. Through the method provided in the embodiment of the present application, the pending transaction data can be aggregated in a targeted manner to obtain aggregated transaction data, thereby further saving network resources.
[0110] In one embodiment, the implementation method of aggregating at least one piece of transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data can be: for the same attribute of the transaction data to be processed in at least one piece of transaction data to be processed, extracting public data from the transaction data to be processed with the same attribute, the transaction data to be processed with the same attribute being the transaction data to be processed belonging to the same transaction data sequence; compressing the data except the public data in the transaction data to be processed with the same attribute to obtain compressed data; and determining the aggregated transaction data based on the public data and the compressed data.
[0111] S806. Generate a proposal block according to the aggregated transaction data.
[0112] In the embodiment of the present application, a proposal block can be generated based on the aggregated transaction, and the proposal block can be broadcast to other nodes of the blockchain network, or processed by relevant functional modules in the node. The method provided by the embodiment of the present application can effectively improve the efficiency of block generation and effectively reduce the network resources and storage resources consumed by generating blocks.
[0113] S807: Execute the transaction corresponding to the aggregated transaction data in the proposal block, and send prompt information to the client according to the execution result.
[0114] In an embodiment of the present application, if the target packaging strategy is a target horizontal packaging strategy, the transactions corresponding to the aggregated transaction data in the proposal block are executed in parallel to obtain the first transaction execution result, and the proposal block is updated according to the first transaction execution result, and the target horizontal packaging strategy is the first horizontal packaging strategy or the second horizontal packaging strategy; if the target packaging strategy is a vertical packaging strategy, the transactions corresponding to the aggregated transaction data in the proposal block are executed serially to obtain the second transaction execution result, and the proposal block is updated according to the second transaction execution result. The updated proposal block can be broadcast to other nodes of the blockchain network for block consensus; when enough votes are obtained, the consensus is completed, and the updated proposal block can be submitted to the blockchain, and the prompt information of the completion of the transaction execution is sent to the client. The method provided by the embodiment of the present application can effectively improve the overall processing efficiency of the blockchain network and save storage resources and network resources.
[0115] See also Fig.10 , this figure is a schematic diagram of a blockchain network processing flow provided by an embodiment of the present application. The object can interact with the client (the client can be a transaction initiator object, and the software development kit (Software Development Kit, SDK) associated with the blockchain can be deployed in the client) to generate data containing initial transaction parameters; the initial transaction parameters can be compressed to obtain compressed transaction parameters, and the transaction data can be determined based on the compressed transaction parameters. The client sends the transaction data to the remote procedure call service (Remote Procedure Call, RPC) of the node. The remote call service will provide verification information and send the transaction data to the permission module. The permission module will perform permission verification on the transaction data and add the transaction data to the transaction pool after the verification passes. The transaction data in the transaction pool of the node is stored in a tree structure, as mentioned above Figure 3As shown. The target packaging strategy can be determined, and at least one pending transaction data (including the transaction data sent by the client) can be obtained from the transaction pool according to the target packaging strategy, and data compression processing is performed according to the pending transaction data to obtain a proposal block; the proposal block is sent to the core engine module, and the core engine module sends the proposal block to the virtual machine module; the virtual machine module includes a parallel execution module and a serial execution module, and the virtual machine module can perform data decompression processing on the data in the aggregation module, and use different execution modules to execute the corresponding transactions in the proposal block according to the target packaging strategy, and obtain the transaction execution result, and fill the transaction execution result into the proposal block; the core engine module can initiate a block consensus, and the consensus module will obtain the voting information of other nodes; obtain enough votes, and after the consensus is completed, the core engine module can submit the proposal block to the blockchain to realize the addition of data on the blockchain; the prompt information of the completion of the transaction execution can be sent to the client through a remote procedure call. Through the method provided by the embodiment of the present application, the overall processing efficiency of the blockchain network can be effectively improved, storage resources and network resources can be effectively saved, and the processing efficiency of transactions can be improved.
[0116] The block generation method provided by the embodiment of the present application can determine the reference selection ratio according to the storage space and processing efficiency, thereby determining the target packaging strategy, and can reasonably select the transaction data from the transaction pool so that the acquired transaction data meets different application requirements and has good flexibility; the vertical packaging strategy can be adopted to acquire transaction data, thereby effectively saving storage space and network resources, and the first or second horizontal packaging strategy can be adopted to acquire transaction data, thereby effectively improving the transaction processing efficiency; the transaction data can be stored in a tree structure, which realizes the classified storage of transaction data, and there is no need to convert when acquiring transaction data, thereby improving the access efficiency of transaction data, and thus improving the generation efficiency of blocks; after acquiring the transaction data, the tree structure can be updated to facilitate the subsequent acquisition of transaction data and ensure the stability of the system; the transaction data to be processed is aggregated to obtain aggregated transaction data, and a proposal block is generated based on the aggregated transaction data, which can reduce the data volume of the proposal block and save storage resources and network resources; the reference selection ratio of the target packaging strategy can be dynamically adjusted, the adaptability of transaction data acquisition is realized, and the overall processing efficiency is effectively improved; the optimization of the transaction data processing flow in the blockchain network can be realized, and the overall transaction data processing performance can be greatly improved.
[0117] See also Fig.11 , Fig.11 This is a structural block diagram of a block generation device provided in an embodiment of the present application. The device includes:
[0118] A determination unit 1101 is configured to determine a target packaging strategy according to the packaging configuration information, wherein the target packaging strategy is any one of a first horizontal packaging strategy, a second horizontal packaging strategy, and a vertical packaging strategy;
[0119] The acquisition unit 1102 is used to acquire at least one piece of to-be-processed transaction data from the transaction pool according to the target packaging strategy; the transaction data in the transaction pool is stored in a tree structure, and the transaction data includes compressed transaction parameters, which are obtained by compressing initial transaction parameters; in the tree structure, a root node is associated with one or more first-level nodes, the first-level node is associated with one or more second-level nodes, the second-level node is associated with one or more third-level nodes, and the third-level node is associated with a transaction data sequence;
[0120] A processing unit 1103 is configured to perform aggregation processing on the at least one transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data;
[0121] The processing unit 1103 is further configured to generate a proposal block according to the aggregated transaction data.
[0122] In one embodiment, in the tree structure, one or more next-level nodes associated with the target node are arranged in an arrangement order in a first direction, and the arrangement order is determined according to the amount of transaction data associated with each next-level node. The target node is any one of the root node, the first-level node and the second-level node.
[0123] In one embodiment, the target packaging strategy is the vertical packaging strategy. When the acquisition unit 1102 acquires at least one piece of transaction data to be processed from the transaction pool according to the target packaging strategy, it is specifically used to: determine a target third-level node, where the target third-level node is the first third-level node in the tree structure in the first direction; acquire transaction data from a first transaction data sequence associated with the target third-level node according to a reference quantity; if the reference quantity of transaction data is acquired from the first transaction data sequence, the reference quantity of transaction data acquired from the first transaction data sequence is determined as the transaction data to be processed.
[0124] In one embodiment, the acquisition unit 1102 is further used to: if a first quantity of transaction data acquired from the first transaction data sequence is less than the reference quantity, determine an adjacent third-level node of the target third-level node, the adjacent third-level node being the third-level node ranked second in the first direction in the tree structure; acquire transaction data from a second transaction data sequence associated with the adjacent third-level node according to a second quantity, the second quantity being determined based on the reference quantity and the first quantity; and determine transaction data to be processed based on the transaction data acquired from the first transaction data sequence and the second transaction data sequence.
[0125] In one embodiment, the target packaging strategy is the first horizontal packaging strategy. When the acquisition unit 1102 acquires at least one transaction data to be processed from the transaction pool according to the target packaging strategy, it is specifically used to: acquire first transaction data from the transaction data sequence associated with each third-level node in the tree structure in sequence according to a second direction according to a reference quantity, the second direction is the opposite direction of the first direction, and the first transaction data is ranked first in the corresponding transaction data sequence; if the reference quantity of first transaction data is acquired, the reference quantity of first transaction data acquired is determined as the transaction data to be processed; if the third quantity of the first transaction data acquired is less than the reference quantity, acquire second transaction data from the transaction data sequence associated with each third-level node in the tree structure in sequence according to the second direction according to a fourth quantity, and determine the transaction data to be processed according to the acquired first transaction data and the second transaction data; the second transaction data is ranked second in the corresponding transaction data sequence, and the fourth quantity is determined according to the reference quantity and the third quantity.
[0126] In one embodiment, the target packaging strategy is the second horizontal packaging strategy. When the acquisition unit 1102 acquires at least one to-be-processed transaction data from the transaction pool according to the target packaging strategy, it is specifically used to: determine a target secondary node, and determine a reference third-level node from the third-level nodes associated with the target secondary node, wherein the target secondary node is the second-level node ranked first in the first direction in the tree structure, and the reference third-level node is the third-level node ranked first in the second direction among the third-level nodes associated with the target secondary node, and the second direction is the opposite direction of the first direction; acquire transaction data from a third transaction data sequence associated with the reference third-level node according to a reference quantity; if the reference third-level node is from the third transaction data sequence, the reference third-level node is the third-level node ranked first in the second direction among the third-level nodes associated with the target secondary node. If the reference quantity of transaction data is obtained from the third transaction data sequence, the reference quantity of transaction data obtained from the third transaction data sequence is determined as the transaction data to be processed; if the fifth quantity of transaction data obtained from the third transaction data sequence is less than the reference quantity, transaction data is obtained from the fourth transaction data sequence associated with the adjacent third-level node according to the sixth quantity, and the transaction data to be processed is determined according to the transaction data obtained from the third transaction data sequence and the fourth transaction data sequence; the sixth quantity is determined based on the reference quantity and the fifth quantity; the adjacent third-level node is a third-level node ranked second in the second direction among one or more third-level nodes associated with the target second-level node.
[0127] In one embodiment, the acquisition unit 1102 is also used to: remove each of the pending transaction data from the corresponding transaction data sequence to obtain a new transaction data sequence associated with each of the third-level nodes; determine the number of transaction data associated with each leaf node in the tree structure, the leaf node being any node under the root node; for one or more next-level nodes associated with the target node, determine the new arrangement order of the next-level nodes associated with the target node in descending order of the number of transaction data associated with each next-level node; generate an updated tree structure based on the new arrangement order of the first-level nodes associated with the root node, the new arrangement order of the second-level nodes associated with each of the first-level nodes, the new arrangement order of the third-level nodes associated with each of the second-level nodes, and the new transaction data sequence associated with each of the third-level nodes; the updated transaction data in the transaction pool is stored using the updated tree structure.
[0128] In one embodiment, when the processing unit 1103 aggregates the at least one transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data, it is specifically used to: extract public data from the transaction data to be processed with the same attributes in the at least one transaction data to be processed, where the transaction data to be processed with the same attributes are transaction data to be processed belonging to the same transaction data sequence; compress the data in the transaction data to be processed with the same attributes except the public data to obtain compressed data; and determine the aggregated transaction data based on the public data and the compressed data.
[0129] In one embodiment, the processing unit 1103 is also used for: if the target packaging strategy is a target horizontal packaging strategy, then executing the transactions corresponding to the aggregated transaction data in the proposal block in parallel to obtain a first transaction execution result, and updating the proposal block according to the first transaction execution result, and the target horizontal packaging strategy is the first horizontal packaging strategy or the second horizontal packaging strategy; if the target packaging strategy is a vertical packaging strategy, then executing the transactions corresponding to the aggregated transaction data in the proposal block in serial to obtain a second transaction execution result, and updating the proposal block according to the second transaction execution result.
[0130] In one embodiment, when the determination unit 1101 determines the target packaging strategy according to the packaging configuration information, it is specifically used to: obtain a reference selection ratio included in the packaging configuration information, the reference selection ratio being the selection ratio that the horizontal packaging strategy and the vertical packaging strategy need to reach within the target time; the horizontal packaging strategy includes a first horizontal packaging strategy and a second horizontal packaging strategy; if the vertical packaging strategy is selected according to the reference selection ratio, the vertical packaging strategy is determined as the target packaging strategy; if the horizontal packaging strategy is selected according to the reference selection ratio, the first horizontal packaging strategy or the second horizontal packaging strategy is selected as the target packaging strategy according to the application scenario information included in the packaging configuration information.
[0131] In one embodiment, the first-level node is determined according to the smart contract identifier, the second-level node is determined according to the contract method identifier, and the third-level node is determined according to the object identifier of the transaction initiating object. The acquisition unit 1102 is also used to: obtain target transaction data of the target transaction initiating object, the target transaction data including: compressed transaction parameters obtained by compressing the initial transaction parameters, compression type, and smart contract identifier and contract method identifier involved in executing the transaction corresponding to the target transaction data; determine the transaction data sequence to be written according to the smart contract identifier and contract method identifier included in the target transaction data and the object identifier of the target transaction initiating object; and write the target transaction data into the transaction data sequence to be written.
[0132] It can be understood that the functions of the functional units of the block generation device in the embodiment of the present application can be specifically implemented according to the block generation method in the above method embodiment. The specific implementation process can refer to the relevant description in the above block generation method embodiment, which will not be repeated here.
[0133] The block generation device provided by the embodiment of the present application can determine the reference selection ratio according to the storage space and processing efficiency, thereby determining the target packaging strategy, and can reasonably select the transaction data from the transaction pool so that the acquired transaction data meets different application requirements and has good flexibility; the vertical packaging strategy can be adopted to acquire transaction data, thereby effectively saving storage space and network resources, and the first or second horizontal packaging strategy can be adopted to acquire transaction data, thereby effectively improving the transaction processing efficiency; the transaction data can be stored in a tree structure, which realizes the classified storage of transaction data, and there is no need to convert when acquiring transaction data, thereby improving the access efficiency of transaction data, and thus improving the generation efficiency of blocks; after acquiring the transaction data, the tree structure can be updated to facilitate the subsequent acquisition of transaction data and ensure the stability of the system; the transaction data to be processed is aggregated to obtain aggregated transaction data, and a proposal block is generated according to the aggregated transaction data, which can reduce the data volume of the proposal block and save storage resources and network resources; the reference selection ratio of the target packaging strategy can be dynamically adjusted, the adaptability of transaction data acquisition is realized, and the overall processing efficiency is effectively improved; the transaction data processing flow in the blockchain network can be optimized, and the overall transaction data processing performance can be greatly improved.
[0134] See also Fig.12 , Fig.12 A block diagram of a computer device provided in an embodiment of the present application. The computer device described in the embodiment of the present application includes: a processor 1201, a communication interface 1202, and a memory 1203. The processor 1201, the communication interface 1202, and the memory 1203 may be connected via a bus or other means, and the embodiment of the present application takes the connection via a bus as an example.
[0135] Among them, the processor 1201 (or CPU (Central Processing Unit)) is the computing core and control core of the computer device, which can parse various instructions in the computer device and process various data of the computer device. For example, the CPU can be used to parse the power on and off instructions sent by the user to the computer device, and control the computer device to perform power on and off operations; for another example, the CPU can transmit various interactive data between the internal structures of the computer device, and so on. The communication interface 1202 can optionally include a standard wired interface, a wireless interface (such as Wi-Fi, a mobile communication interface, etc.), which is controlled by the processor 1201 to send and receive data. The memory 1203 (Memory) is a memory device in the computer device for storing programs and data. It can be understood that the memory 1203 here can include both the built-in memory of the computer device and the extended memory supported by the computer device. The memory 1203 provides a storage space, which stores the operating system of the computer device, which may include but is not limited to: Android system, iOS system, Windows Phone system, etc., and this application does not limit this.
[0136] In the embodiment of the present application, the computer device may be a node of a blockchain network, and the processor 1201 performs the following operations by running the executable program code in the memory 1203:
[0137] Determine a target packaging strategy according to the packaging configuration information, where the target packaging strategy is any one of the first horizontal packaging strategy, the second horizontal packaging strategy, and the vertical packaging strategy;
[0138] At least one piece of to-be-processed transaction data is obtained from the transaction pool according to the target packaging strategy; the transaction data in the transaction pool is stored in a tree structure, and the transaction data includes compressed transaction parameters, which are obtained by compressing initial transaction parameters; in the tree structure, a root node is associated with one or more first-level nodes, the first-level nodes are associated with one or more second-level nodes, the second-level nodes are associated with one or more third-level nodes, and the third-level nodes are associated with a transaction data sequence;
[0139] Aggregate the at least one transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data;
[0140] A proposal block is generated according to the aggregated transaction data.
[0141] In one embodiment, in the tree structure, one or more next-level nodes associated with the target node are arranged in an arrangement order in a first direction, and the arrangement order is determined according to the amount of transaction data associated with each next-level node. The target node is any one of the root node, the first-level node and the second-level node.
[0142] In one embodiment, the target packaging strategy is the vertical packaging strategy. When the processor 1201 obtains at least one transaction data to be processed from the transaction pool according to the target packaging strategy, it is specifically used to: determine a target third-level node, where the target third-level node is the first third-level node in the tree structure in the first direction; obtain transaction data from a first transaction data sequence associated with the target third-level node according to a reference quantity; if the reference quantity of transaction data is obtained from the first transaction data sequence, the reference quantity of transaction data obtained from the first transaction data sequence is determined as the transaction data to be processed.
[0143] In one embodiment, the processor 1201 is further used to: if a first quantity of transaction data obtained from the first transaction data sequence is less than the reference quantity, determine an adjacent third-level node of the target third-level node, the adjacent third-level node being the third-level node ranked second in the first direction in the tree structure; obtain transaction data from a second transaction data sequence associated with the adjacent third-level node according to a second quantity, the second quantity being determined based on the reference quantity and the first quantity; and determine transaction data to be processed based on the transaction data obtained from the first transaction data sequence and the second transaction data sequence.
[0144] In one embodiment, the target packaging strategy is the first horizontal packaging strategy. When the processor 1201 obtains at least one transaction data to be processed from the transaction pool according to the target packaging strategy, it is specifically used to: obtain the first transaction data from the transaction data sequence associated with each third-level node in the tree structure in sequence according to the second direction according to the reference quantity, the second direction is the opposite direction of the first direction, and the first transaction data is ranked first in the corresponding transaction data sequence; if the first transaction data of the reference quantity is obtained, the first transaction data of the reference quantity obtained is determined as the transaction data to be processed; if the third quantity of the first transaction data obtained is less than the reference quantity, according to the fourth quantity, obtain the second transaction data from the transaction data sequence associated with each third-level node in the tree structure in sequence according to the second direction, and determine the transaction data to be processed according to the obtained first transaction data and the second transaction data; the second transaction data is ranked second in the corresponding transaction data sequence, and the fourth quantity is determined according to the reference quantity and the third quantity.
[0145] In one embodiment, the target packaging strategy is the second horizontal packaging strategy. When the processor 1201 obtains at least one to-be-processed transaction data from the transaction pool according to the target packaging strategy, it is specifically used to: determine a target secondary node, and determine a reference third-level node from the third-level nodes associated with the target secondary node, wherein the target secondary node is the second-level node ranked first in the first direction in the tree structure, and the reference third-level node is the third-level node ranked first in the second direction among the third-level nodes associated with the target secondary node, and the second direction is the opposite direction of the first direction; obtain transaction data from a third transaction data sequence associated with the reference third-level node according to a reference quantity; if the reference third-level node is from the third transaction data sequence, the reference third-level node is the third-level node ranked first in the second direction among the third-level nodes associated with the target secondary node. If the reference quantity of transaction data is obtained from the third transaction data sequence, the reference quantity of transaction data obtained from the third transaction data sequence is determined as the transaction data to be processed; if the fifth quantity of transaction data obtained from the third transaction data sequence is less than the reference quantity, transaction data is obtained from the fourth transaction data sequence associated with the adjacent third-level node according to the sixth quantity, and the transaction data to be processed is determined according to the transaction data obtained from the third transaction data sequence and the fourth transaction data sequence; the sixth quantity is determined based on the reference quantity and the fifth quantity; the adjacent third-level node is a third-level node ranked second in the second direction among one or more third-level nodes associated with the target second-level node.
[0146] In one embodiment, the processor 1201 is further used to: remove each of the pending transaction data from the corresponding transaction data sequence to obtain a new transaction data sequence associated with each of the third-level nodes; determine the number of transaction data associated with each leaf node in the tree structure, the leaf node being any node under the root node; for one or more next-level nodes associated with the target node, determine the new arrangement order of the next-level nodes associated with the target node in descending order of the number of transaction data associated with each next-level node; generate an updated tree structure based on the new arrangement order of the first-level nodes associated with the root node, the new arrangement order of the second-level nodes associated with each of the first-level nodes, the new arrangement order of the third-level nodes associated with each of the second-level nodes, and the new transaction data sequence associated with each of the third-level nodes; the updated transaction data in the transaction pool is stored using the updated tree structure.
[0147] In one embodiment, when the processor 1201 aggregates the at least one transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data, it is specifically used to: extract public data from the transaction data to be processed with the same attributes in the at least one transaction data to be processed, where the transaction data to be processed with the same attributes are transaction data to be processed belonging to the same transaction data sequence; compress the data in the transaction data to be processed with the same attributes except the public data to obtain compressed data; and determine the aggregated transaction data based on the public data and the compressed data.
[0148] In one embodiment, the processor 1201 is further used to: if the target packaging strategy is a target horizontal packaging strategy, execute the transactions corresponding to the aggregated transaction data in the proposal block in parallel to obtain a first transaction execution result, and update the proposal block according to the first transaction execution result, and the target horizontal packaging strategy is the first horizontal packaging strategy or the second horizontal packaging strategy; if the target packaging strategy is a vertical packaging strategy, execute the transactions corresponding to the aggregated transaction data in the proposal block in serial to obtain a second transaction execution result, and update the proposal block according to the second transaction execution result.
[0149] In one embodiment, when the processor 1201 determines the target packing strategy according to the packing configuration information, it is specifically used to: obtain a reference selection ratio included in the packing configuration information, the reference selection ratio being the selection ratio that the horizontal packing strategy and the vertical packing strategy need to reach within the target time; the horizontal packing strategy includes a first horizontal packing strategy and a second horizontal packing strategy; if the vertical packing strategy is selected according to the reference selection ratio, the vertical packing strategy is determined as the target packing strategy; if the horizontal packing strategy is selected according to the reference selection ratio, the first horizontal packing strategy or the second horizontal packing strategy is selected as the target packing strategy according to the application scenario information included in the packing configuration information.
[0150] In one embodiment, the first-level node is determined based on the smart contract identifier, the second-level node is determined based on the contract method identifier, and the third-level node is determined based on the object identifier of the transaction initiation object. The processor 1201 is also used to: obtain target transaction data of the target transaction initiation object, the target transaction data including: compressed transaction parameters obtained by compressing the initial transaction parameters, compression type, and smart contract identifier and contract method identifier involved in executing the transaction corresponding to the target transaction data; determine the transaction data sequence to be written based on the smart contract identifier and contract method identifier included in the target transaction data and the object identifier of the target transaction initiation object; and write the target transaction data into the transaction data sequence to be written.
[0151] In a specific implementation, the processor 1201, the communication interface 1202, and the memory 1203 described in the embodiment of the present application can execute the implementation method of the node of the blockchain network described in a block generation method provided in an embodiment of the present application, and can also execute the implementation method described in a block generation device provided in an embodiment of the present application, which will not be repeated here.
[0152] The computer device provided by the embodiment of the present application can determine the reference selection ratio according to the storage space and processing efficiency, thereby determining the target packaging strategy, and can reasonably select the transaction data from the transaction pool so that the acquired transaction data meets different application requirements and has good flexibility; the vertical packaging strategy can be adopted to acquire transaction data, thereby effectively saving storage space and network resources, and the first or second horizontal packaging strategy can be adopted to acquire transaction data, thereby effectively improving the transaction processing efficiency; the transaction data can be stored in a tree structure, which realizes the classified storage of transaction data, and there is no need to convert when acquiring transaction data, thereby improving the access efficiency of transaction data, and then improving the generation efficiency of blocks; after acquiring the transaction data, the tree structure can be updated to facilitate the subsequent acquisition of transaction data and ensure the stability of the system; the transaction data to be processed is aggregated to obtain aggregated transaction data, and a proposal block is generated according to the aggregated transaction data, which can reduce the data volume of the proposal block and save storage resources and network resources; the reference selection ratio of the target packaging strategy can be dynamically adjusted, the adaptability of transaction data acquisition is realized, and the overall processing efficiency is effectively improved; the transaction data processing flow in the blockchain network can be optimized, and the overall transaction data processing performance can be greatly improved.
[0153] The embodiment of the present application also provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is run on a computer, the computer executes the block generation method as described in the embodiment of the present application. The specific implementation method can be referred to the above description, which will not be repeated here.
[0154] The embodiment of the present application also provides a computer program product, the computer program product includes a computer program or a computer instruction, and the computer program or the computer instruction is stored in a computer-readable storage medium. The processor of the computer device reads the computer program or the computer instruction from the computer-readable storage medium, and the processor executes the computer program or the computer instruction, so that the computer device executes the block generation method as described in the embodiment of the present application. The specific implementation method can be referred to the above description, which will not be repeated here.
[0155] It should be noted that, for the above-mentioned various method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0156] In the above embodiments, the description of each embodiment has its own emphasis. For the part that is not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a computer, a server or a network device, etc., specifically a processor in a computer device) to perform all or part of the steps of the above methods of each embodiment of the present application. Among them, the aforementioned storage medium may include: U disk, mobile hard disk, magnetic disk, optical disk, read-only memory (English: Read-Only Memory, abbreviated: ROM) or random access memory (English: Random Access Memory, abbreviated: RAM) and other media that can store program codes.
[0157] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, it should be understood that the technical solutions recorded in the aforementioned embodiments can still be modified, or some of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A block generation method, characterized in that: The method comprises: Determine a target packaging strategy according to the packaging configuration information, where the target packaging strategy is any one of the first horizontal packaging strategy, the second horizontal packaging strategy, and the vertical packaging strategy; At least one piece of to-be-processed transaction data is obtained from the transaction pool according to the target packaging strategy; the transaction data in the transaction pool is stored in a tree structure, and the transaction data includes compressed transaction parameters, which are obtained by compressing initial transaction parameters; in the tree structure, a root node is associated with one or more first-level nodes, the first-level nodes are associated with one or more second-level nodes, the second-level nodes are associated with one or more third-level nodes, and the third-level nodes are associated with a transaction data sequence; Aggregate the at least one transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data; A proposal block is generated according to the aggregated transaction data.
2. The method according to claim 1, characterized in that In the tree structure, one or more next-level nodes associated with the target node are arranged in an arrangement order in a first direction, and the arrangement order is determined according to the amount of transaction data associated with each next-level node. The target node is any one of the root node, the first-level node and the second-level node.
3. The method according to claim 2, characterized in that The target packaging strategy is the vertical packaging strategy, and obtaining at least one piece of to-be-processed transaction data from the transaction pool according to the target packaging strategy includes: Determine a target third-level node, where the target third-level node is a third-level node that ranks first in the first direction in the tree structure; Acquire transaction data from a first transaction data sequence associated with the target third-level node according to a reference quantity; If the reference amount of transaction data is obtained from the first transaction data sequence, the reference amount of transaction data obtained from the first transaction data sequence is determined as the transaction data to be processed.
4. The method according to claim 3, characterized in that The method further comprises: If the first quantity of transaction data acquired from the first transaction data sequence is less than the reference quantity, determining an adjacent third-level node of the target third-level node, the adjacent third-level node being a third-level node ranked second in the first direction in the tree structure; Acquire transaction data from a second transaction data sequence associated with the adjacent third-level node according to a second quantity, wherein the second quantity is determined according to the reference quantity and the first quantity; The transaction data to be processed is determined according to the transaction data acquired from the first transaction data sequence and the second transaction data sequence.
5. The method according to claim 2, characterized in that: The target packaging strategy is the first horizontal packaging strategy, and obtaining at least one piece of to-be-processed transaction data from the transaction pool according to the target packaging strategy includes: According to the reference quantity, first transaction data is acquired from the transaction data sequences associated with each third-level node in the tree structure in sequence along a second direction, wherein the second direction is opposite to the first direction, and the first transaction data is ranked first in the corresponding transaction data sequence; If the reference amount of first transaction data is obtained, determining the reference amount of first transaction data obtained as transaction data to be processed; If the third quantity of the first transaction data obtained is less than the reference quantity, then according to the fourth quantity, the second transaction data is obtained from the transaction data sequence associated with each third-level node in the tree structure in sequence along the second direction, and the transaction data to be processed is determined according to the first transaction data and the second transaction data obtained; the second transaction data is ranked second in the corresponding transaction data sequence, and the fourth quantity is determined based on the reference quantity and the third quantity.
6. The method according to claim 2, characterized in that The target packaging strategy is the second horizontal packaging strategy, and obtaining at least one piece of to-be-processed transaction data from the transaction pool according to the target packaging strategy includes: Determine a target secondary node, and determine a reference third-level node from the third-level nodes associated with the target secondary node, wherein the target secondary node is the second-level node ranked first in the first direction in the tree structure, and the reference third-level node is the third-level node ranked first in the second direction among the third-level nodes associated with the target secondary node, and the second direction is the opposite direction of the first direction; Obtaining transaction data from a third transaction data sequence associated with the reference third-level node according to the reference quantity; If the reference amount of transaction data is obtained from the third transaction data sequence, determining the reference amount of transaction data obtained from the third transaction data sequence as the transaction data to be processed; If the fifth quantity of transaction data obtained from the third transaction data sequence is less than the reference quantity, transaction data is obtained from the fourth transaction data sequence associated with an adjacent third-level node according to the sixth quantity, and transaction data to be processed is determined according to the transaction data obtained from the third transaction data sequence and the fourth transaction data sequence; the sixth quantity is determined based on the reference quantity and the fifth quantity; the adjacent third-level node is a third-level node ranked second in the second direction among one or more third-level nodes associated with the target second-level node.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: Eliminate each of the to-be-processed transaction data from the corresponding transaction data sequence to obtain a new transaction data sequence associated with each of the third-level nodes; Determine the amount of transaction data associated with each leaf node in the tree structure, wherein the leaf node is any node under the root node; For one or more next-level nodes associated with the target node, determine a new arrangement order of the next-level nodes associated with the target node according to the order of the amount of transaction data associated with each next-level node from large to small; An updated tree structure is generated based on the new arrangement order of the first-level nodes associated with the root node, the new arrangement order of the second-level nodes associated with each of the first-level nodes, the new arrangement order of the third-level nodes associated with each of the second-level nodes, and the new transaction data sequence associated with each of the third-level nodes; the updated transaction data in the transaction pool is stored using the updated tree structure.
8. The method according to claim 3 or 4, characterized in that: The step of aggregating the at least one piece of transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data includes: For the at least one piece of transaction data to be processed with the same attribute, extracting public data from the transaction data to be processed with the same attribute, wherein the transaction data to be processed with the same attribute is the transaction data to be processed belonging to the same transaction data sequence; Compressing the data except the public data in the to-be-processed transaction data with the same attribute to obtain compressed data; Aggregated transaction data is determined based on the public data and the compressed data.
9. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: If the target packaging strategy is the target horizontal packaging strategy, the transactions corresponding to the aggregated transaction data in the proposal block are executed in parallel to obtain a first transaction execution result, and the proposal block is updated according to the first transaction execution result. The target horizontal packaging strategy is the first horizontal packaging strategy or the second horizontal packaging strategy; If the target packaging strategy is a vertical packaging strategy, the transactions corresponding to the aggregated transaction data in the proposal block are executed serially to obtain a second transaction execution result, and the proposal block is updated according to the second transaction execution result.
10. The method according to any one of claims 1 to 6, characterized in that: Determining the target packaging strategy according to the packaging configuration information includes: Obtaining a reference selection ratio included in the packaging configuration information, where the reference selection ratio is a selection ratio that needs to be achieved by the horizontal packaging strategy and the vertical packaging strategy within a target time; the horizontal packaging strategy includes a first horizontal packaging strategy and a second horizontal packaging strategy; If the vertical packaging strategy is selected according to the reference selection ratio, the vertical packaging strategy is determined as the target packaging strategy; If the horizontal packaging strategy is selected according to the reference selection ratio, the first horizontal packaging strategy or the second horizontal packaging strategy is selected as the target packaging strategy according to the application scenario information included in the packaging configuration information.
11. The method according to any one of claims 1 to 6, characterized in that: The first-level node is determined according to the smart contract identifier, the second-level node is determined according to the contract method identifier, and the third-level node is determined according to the object identifier of the transaction initiator object. The method further includes: Obtain target transaction data of the target transaction initiator, the target transaction data including: compressed transaction parameters obtained by compressing initial transaction parameters, compression type, smart contract identifier and contract method identifier involved in executing the transaction corresponding to the target transaction data; Determine a sequence of transaction data to be written according to the smart contract identifier and contract method identifier included in the target transaction data and the object identifier of the target transaction initiation object; The target transaction data is written into the sequence of transaction data to be written.
12. A block generation device, characterized in that: The device comprises: A determination unit, configured to determine a target packaging strategy according to the packaging configuration information, wherein the target packaging strategy is any one of a first horizontal packaging strategy, a second horizontal packaging strategy, and a vertical packaging strategy; an acquisition unit, configured to acquire at least one piece of to-be-processed transaction data from a transaction pool according to the target packaging strategy; the transaction data in the transaction pool is stored in a tree structure, the transaction data includes compressed transaction parameters, and the compressed transaction parameters are obtained by compressing initial transaction parameters; in the tree structure, a root node is associated with one or more first-level nodes, the first-level nodes are associated with one or more second-level nodes, the second-level nodes are associated with one or more third-level nodes, and the third-level nodes are associated with a transaction data sequence; A processing unit, configured to perform aggregation processing on the at least one transaction data to be processed according to the aggregation processing strategy corresponding to the target packaging strategy to obtain aggregated transaction data; The processing unit is further used to generate a proposal block based on the aggregated transaction data.
13. A computer device, characterized in that: include: A processor, a communication interface and a memory, wherein the processor, the communication interface and the memory are connected to each other, wherein the memory stores an executable program code, and the processor is used to call the executable program code to implement the block generation method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, which, when executed on a computer, enable the computer to implement the block generation method according to any one of claims 1 to 11.
15. A computer program product, characterized in that The computer program product comprises a computer program or a computer instruction, and when the computer program or the computer instruction is executed by a processor, the block generation method according to any one of claims 1 to 11 is implemented.