Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary system architecture 100 to which embodiments of the disclosed method for generating information or apparatus for generating information may be applied.
As shown in fig. 1, system architecture 100 may include electronic devices 101, 102, 103 and network 104. The network 104 is used to provide a medium for communication links between the electronic devices 101, 102, 103. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the electronic devices 101, 102, 103 to interact with other network 104 connected electronic devices to receive or send messages, etc. The electronic devices 101, 102, 103 may have installed thereon various communication client applications, such as a blockchain accounting-type application, a digital money wallet-type application, a web browser application, a shopping-type application, a search-type application, an instant messenger, a mailbox client, social platform software, and the like.
The electronic devices 101, 102, and 103 may be hardware or software. When the electronic devices 101, 102, 103 are hardware, they may be various electronic devices with information processing capabilities, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like. When the electronic devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. Which may be implemented as multiple software or software modules (e.g., to provide blockchain accounting services or to provide digital money wallet services) or as a single software or software module. And is not particularly limited herein.
Each electronic device in the system architecture 100 forms a blockchain system, and each electronic device in the system architecture 100 stores data using a distributed data blockchain.
It should be noted that the method for generating information provided in the embodiments of the present application is generally executed by the electronic devices 101, 102, and 103, and accordingly, the apparatus for generating information is generally disposed in the electronic devices 101, 102, and 103.
It should be understood that the number of electronic devices and networks in fig. 1 is merely illustrative. There may be any number of electronic devices and networks, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for generating information in accordance with the present disclosure is shown. The method for generating information comprises the following steps:
step 201, a target transaction cluster sequence is obtained.
In this embodiment, the execution subject of the method for generating information (e.g., the electronic devices 101, 102, 103 shown in fig. 1) may acquire the target transaction cluster sequence by a wired connection manner or a wireless connection manner. The target transaction cluster sequence is to be processed to generate a transaction cluster sequence of the block. The target transaction cluster sequence may include at least two transaction clusters. Each transaction cluster is used to generate a block. The transaction cluster may include a target number of transactions. The target amount may be an amount predetermined by a technician or an amount determined based on a predetermined block capacity and the data amount of each transaction (the sum of the data amounts of each transaction in a transaction cluster is less than or equal to the block capacity).
In practice, a transaction in the blockchain domain refers to the transfer of funds from one user to another, and further, a transaction typically includes two attributes, input and output, respectively. Input refers to an input party of funds and output refers to a receiving party of funds.
It should be noted that, for convenience of expression, the present disclosure refers to transactions and transaction data generated by the transactions collectively as transactions. It will be understood that the actual transaction is indicative of an action, and that in packaging the transaction to generate the block, the packaged is essentially the transaction data resulting from this action.
In this embodiment, the transaction clusters in the target transaction cluster sequence are arranged in the target order. The target sequence may be a sequence designated by the user using the execution subject (for example, a sequence designated by the user based on the amount of the mine excavation prize money corresponding to the transaction in the transaction cluster), or may be a sequence determined according to the occurrence time of the transaction in the transaction cluster.
As an example, for transaction cluster a and transaction cluster B, transaction cluster a includes transaction a1 and transaction a 2; transaction Cluster B includes transaction B1 and transaction B2. The occurrence time of the transaction a1, the transaction a2, the transaction b1 and the transaction b2 is 6 days in 5 and 6 months in 2019, 7 days in 5 and 7 months in 2019, 8 days in 5 and 8 months in 2019 and 9 days in 5 and 9 months in 2019 respectively. The occurrence time of the transaction in the transaction cluster a is earlier than the occurrence time of the transaction in the transaction cluster B, and further, the transaction cluster a may be arranged before the transaction cluster B. Thus, a target transaction cluster sequence "transaction cluster a" can be obtained; transaction cluster B ".
In practice, an unacknowledged transaction in the blockchain network is usually stored in a local memory of each blockchain node, and the execution main body serves as one blockchain node and can acquire transactions from the local memory, so that the acquired transactions are divided into at least two transaction clusters based on a target number, and then the acquired at least two transaction clusters are arranged according to a target sequence to acquire a target transaction cluster sequence; or, the local memory may store the transaction cluster sequence in advance, and further, the execution main body may directly obtain the transaction cluster sequence from the local memory as the target transaction cluster sequence.
Step 202, aiming at the transaction in the target transaction cluster sequence, executing the following determination steps: determining whether a pre-dependent transaction of the transaction is included in the sequence of target transaction clusters, and in response to not including the pre-dependent transaction, determining an encrypted result of the transaction.
In this embodiment, the executing entity may execute the determining step for the transaction in the target transaction cluster sequence obtained in step 201. The transaction cluster to which the preposed dependent transaction belongs is arranged before the transaction cluster to which the transaction belongs, and the preposed dependent transaction has a dependency relationship with the transaction. Specifically, the dependency relationship of the pre-dependent transaction with the transaction refers to the execution of the transaction, which depends on the execution of the pre-dependent transaction.
As an example, transaction cluster a includes transaction a "first transfers funds in amount of 10 to second"; transaction B includes transaction B "B transfers funds in the amount of 10. If the initial state of b is no funds, then the execution of transaction b is dependent on the execution of transaction a, i.e. transaction a needs to be executed before transaction b, otherwise transaction b will not be executed. Here, transaction a is the pre-dependency transaction of transaction b.
In practice, for a pre-dependent transaction having a dependency relationship and the transaction, the output of the pre-dependent transaction is typically the input of the transaction. Referring to the above example, transaction a is a pre-dependent transaction of transaction b, and the output of transaction a is the same as the input of transaction b, and is B.
Typically, the blockchain node computes the encryption result for valid transactions, which are then packed into blocks. In the prior art, in order to reduce the possibility of packing invalid transactions into blocks, encryption results are generally calculated in sequence for transactions belonging to different transaction clusters. For example, the target transaction cluster sequence is "transaction cluster a; the transaction cluster B ″ then generally calculates the encryption result of the transaction in the transaction cluster a first, and then calculates the encryption result of the transaction in the transaction cluster B. In practice, most of the transactions in the adjacent transaction clusters do not have dependency relationship. For transactions for which no dependency exists, there is no need to compute the encryption results in order. Therefore, for the transaction without the pre-dependency transaction in the target transaction cluster sequence, the encryption result of the transaction can be directly determined, so that the calculation efficiency of the encryption result of the transaction in the target transaction cluster sequence can be improved, the block generation efficiency can be further improved, and the performance of a block chain is favorably improved.
It is appreciated that the present disclosure provides a method for parallel computation of encryption results for transactions that do not have a dependency in a target transaction cluster sequence. Specifically, the executing agent may execute the determining step synchronously for all or part of the transactions in the target transaction cluster sequence, so that parallel computation of the encryption result for the transactions without dependency relationship may be implemented.
In this embodiment, the encryption result of the transaction may be a result obtained by calculating the transaction using various encryption algorithms.
In some optional implementations of this embodiment, the encryption result may be a hash value.
Here, the execution body may calculate a hash value of the transaction using a hash algorithm. In practice, the hash algorithm is a method of mapping a binary value of an arbitrary length to a smaller binary value of a fixed length, where the smaller binary value is a hash value.
Particularly, if the target transaction cluster sequence includes a corresponding transaction of a pre-dependency transaction, the executing entity may determine the encryption result of the transaction in various ways, for example, may directly determine the encryption result of the transaction; alternatively, the encryption result of the transaction may be determined after the encryption result determination of the pre-dependent transaction is completed.
Step 203, in response to obtaining the target transaction cluster, determining an encryption result of a block corresponding to the target transaction cluster based on the encryption result of the transaction in the target transaction cluster.
In this embodiment, the execution subject may determine, in response to obtaining the target transaction cluster, an encryption result of a block corresponding to the target transaction cluster based on an encryption result of a transaction in the target transaction cluster. Wherein the target transaction cluster is the transaction cluster for which the encryption result of each transaction included has been determined. The block corresponding to the target transaction cluster is a block which can be generated by using the target transaction cluster.
Specifically, the execution main body may combine the encryption results of the transactions in the target transaction cluster two by two, further perform encryption calculation, and finally obtain a combined encryption result as the encryption result of the block corresponding to the target transaction cluster.
As an example, the target transaction cluster includes "transaction A; transaction B; transaction C; transaction D', the encryption result of transaction A is a; the encryption result of transaction B is B; the encryption result of transaction C is C; the encryption result of transaction D is D. The execution body may first combine the encryption result a and the encryption result b and perform encryption calculation to obtain an encryption result e. Then, the encryption result c and the encryption result d are combined and subjected to encryption calculation to obtain an encryption result f. Finally, the execution body may combine the encryption result e and the encryption result f and perform encryption calculation to obtain an encryption result g as an encryption result of a block corresponding to the target transaction cluster.
It should be noted that, since the encryption results may be calculated in parallel for the transactions without dependency relationship in step 202, the encryption results of the transactions in the transaction cluster of the present disclosure are not calculated in sequence (according to the sequence of the transaction cluster in the target transaction cluster sequence), and further, there may be a case that the encryption results of the transactions in the transaction cluster after the sequence are calculated preferentially. Therefore, the execution main body may continuously detect the transaction cluster in the target transaction cluster sequence, and calculate the completed transaction cluster (i.e., the target transaction cluster) each time the encryption result of each transaction included in the detected transaction cluster is detected, that is, the encryption result of the block corresponding to the transaction cluster may be generated based on the encryption result of the transaction included in the transaction cluster.
Step 204, for the target transaction cluster for which the encryption result of the corresponding block is determined, in response to that the encryption result of the previous block of the block corresponding to the target transaction cluster is determined to be completed, generating the block corresponding to the target transaction cluster based on the encryption result of the block corresponding to the target transaction cluster and the encryption result of the previous block.
In this embodiment, for the target transaction cluster based on the encryption result of the block determined in step 203, the executing entity may generate the block corresponding to the target transaction cluster based on the encryption result of the block corresponding to the target transaction cluster and the encryption result of the previous block in response to that the encryption result of the previous block of the block corresponding to the target transaction cluster has been determined to be completed. The pre-block is a block which is arranged in front of the block corresponding to the target transaction cluster in the target block chain and is adjacent to the block corresponding to the target transaction cluster. The target block chain is a block chain for adding the generated block.
Specifically, the execution main body may generate a block header of a block corresponding to the target transaction cluster based on an encryption result of the block corresponding to the target transaction cluster and an encryption result of a previous block, generate a block body of the block corresponding to the target transaction cluster based on a transaction in the target transaction cluster, and further generate a block including the generated block header and the block body.
It can be understood that, since the encryption results may be calculated in parallel for the transactions without dependency relationship in step 202, the target transaction clusters of the present disclosure are not obtained in sequence, and further the encryption results of the blocks corresponding to the target transaction clusters are not determined to be completed in sequence, so there may be a case that the encryption results of the blocks corresponding to the transaction clusters that are sorted later are determined to be completed preferentially. Furthermore, in the process of generating the block based on the encryption result of the block, the executive owner needs to first determine whether the encryption result of the previous block of the block is determined to be completed, and if the encryption result of the previous block is determined to be completed, the block can be directly generated based on the encryption result of the block and the encryption result of the previous block.
In some optional implementation manners of this embodiment, for a target transaction cluster in which an encryption result of a corresponding block is determined, the executing body may further generate the block corresponding to the target transaction cluster based on the encryption result of the block corresponding to the target transaction cluster and the encryption result of the previous block of the block corresponding to the target transaction cluster after the encryption result of the previous block of the block corresponding to the target transaction cluster is determined to be completed, in response to that the encryption result of the previous block of the block corresponding to the target transaction cluster is not determined to be completed.
The implementation mode can wait for the determination of the encryption result of the front block under the condition that the encryption result of the block corresponding to the target transaction cluster is determined to be finished but the encryption result of the front block is not determined to be finished, and further generate the block corresponding to the target transaction cluster based on the encryption result of the block corresponding to the target transaction cluster and the encryption result of the front block after the encryption result of the front block is determined to be finished. Thus, the efficiency of generating a block can be improved, and the recording of parent-child information for the generated block can be ensured. In the block chain, for two connected blocks, the previous block is a parent block, the next block is a child block, and the child block can record information of the parent block, so that the connection order of the blocks can be recorded, which is helpful for preventing the blocks from being tampered.
It is understood that, for a target transaction cluster sequence, the leading block of the block corresponding to the transaction cluster ordered at the first position of the target transaction cluster sequence is the block currently located at the end of the target block chain (i.e., the block on the target block chain that can be connected to the newly generated block), while for other transaction clusters in the target transaction cluster sequence (except for the transaction cluster ordered at the first position), the leading block of the block corresponding to the transaction cluster may be the block corresponding to the transaction cluster arranged before the transaction cluster in the target transaction cluster sequence.
As an example, the target transaction cluster sequence is "transaction cluster a; a transaction cluster B', the front block of the block corresponding to the transaction cluster A is the block currently positioned at the tail of the target block chain; the front block of the block corresponding to the transaction cluster B is the block corresponding to the transaction cluster A.
In some optional implementation manners of this embodiment, after the block is generated, the execution main body may add the generated block to the target block chain according to an arrangement order of the transaction clusters corresponding to the generated block in the target transaction cluster sequence.
As an example, the target transaction cluster sequence is "transaction cluster a; a transaction cluster B', wherein the transaction cluster A corresponds to the generated block A; the transaction cluster B corresponds to the generated block B. The original target blockchain may be "block 1-block 2". The target blockchain to which the generated blocks are added may be 'block 1-block 2-block a-block B' in the order of the arrangement of the transaction clusters.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the method for generating information according to the present embodiment. In the application scenario of fig. 3, the electronic device 301 may first acquire a target transaction cluster sequence 302, where the target transaction cluster sequence 302 includes transaction clusters 3021 and 3022, the transaction cluster 3021 is arranged before the transaction cluster 3022, and the transaction clusters 3021 and 3022 are respectively used to generate different blocks.
Then, the electronic device 301 may perform the following determination steps for the transactions in the target transaction cluster sequence 302 (i.e., the transactions in the transaction cluster 3021 and the transaction cluster 3022): it is determined whether a pre-dependent transaction of the transaction is included in the target transaction cluster sequence 302, and in response to not including the pre-dependent transaction, a hash value for the transaction is determined.
Next, the electronic device 301 may determine the hash value 304 of the block corresponding to the target transaction cluster 303 based on the hash value of the transaction in the target transaction cluster 303 in response to obtaining the target transaction cluster 303, where the target transaction cluster 303 is the transaction cluster 3021 where the hash value of the included transaction has been determined. Further, for the target transaction cluster 303, the electronic device 301 may generate the block 305 corresponding to the target transaction cluster 303 based on the hash value 304 of the block corresponding to the target transaction cluster 303 and the hash value of the previous block in response to the hash value of the previous block (i.e., the block currently located at the end of the target block chain) of the block corresponding to the target transaction cluster 303 having been determined to be completed.
Meanwhile, the electronic device 301 may also determine the hash value 307 of the block corresponding to the target transaction cluster 306 based on the hash value of the transaction in the target transaction cluster 306 in response to obtaining the target transaction cluster 306, where the target transaction cluster 306 is the transaction cluster 3022 in which the hash value of the included transaction has been determined. Further, for the target transaction cluster 306, the electronic device 301 may generate a block 308 corresponding to the target transaction cluster 306 based on the hash value 307 of the block corresponding to the target transaction cluster 306 and the hash value of the previous block in response to the hash value of the previous block (i.e., the block corresponding to the transaction cluster 3021) of the block corresponding to the target transaction cluster 306 being determined to be completed.
The method provided by the above embodiment of the present disclosure can perform parallel computation on the encryption result of the transaction without dependency relationship (i.e., the transaction without pre-dependency transaction) in the target transaction cluster sequence in the block generation process, and compared with a serial computation manner for transactions belonging to different blocks in the prior art, the method can improve the block generation efficiency, thereby contributing to improving the overall performance of the block chain.
With further reference to fig. 4, a flow 400 of yet another embodiment of a method for generating information is shown. The flow 400 of the method for generating information comprises the steps of:
step 401, a target transaction cluster sequence is obtained.
In this embodiment, the execution subject of the method for generating information (e.g., the electronic devices 101, 102, 103 shown in fig. 1) may acquire the target transaction cluster sequence by a wired connection manner or a wireless connection manner. The target transaction cluster sequence is to be processed to generate a transaction cluster sequence of the block. The target transaction cluster sequence may include at least two transaction clusters. Each transaction cluster is used to generate a block. The transaction cluster may include a target number of transactions. The target quantity may be a quantity predetermined by a technician or a quantity determined based on a predetermined block size and data volume for each transaction. The transaction clusters in the target transaction cluster sequence are arranged according to a target sequence.
Step 402, for the transaction in the target transaction cluster sequence, executing the following determination steps: determining whether a pre-dependent transaction of the transaction is included in the sequence of target transaction clusters; in response to not including the pre-dependency transaction, determining an encryption result for the transaction; in response to including the pre-dependent transaction, determining whether an encrypted result of the pre-dependent transaction of the transaction has been determined to be complete; an encryption result for the transaction is determined in response to the encryption result for the pre-dependent transaction for the transaction having been determined to be complete.
In this embodiment, the executing entity may execute the determining step for the transaction in the target transaction cluster sequence obtained in step 401. The transaction cluster to which the preposed dependent transaction belongs is arranged before the transaction cluster to which the transaction belongs, and the preposed dependent transaction has a dependency relationship with the transaction. Specifically, the dependency relationship of the pre-dependent transaction with the transaction refers to the execution of the transaction, which depends on the execution of the pre-dependent transaction.
It can be understood that, here, the execution subject may perform parallel computation on the encryption result of the transaction in which the pre-dependent transaction does not exist in the target transaction cluster sequence, and for the transaction in which the pre-dependent transaction exists, the encryption result of the transaction may be computed when the encryption result of the pre-dependent transaction is determined to be completed, so that the validity of the transaction in which the encryption result is computed may be improved, which may further help to improve the validity of the generated block.
In some optional implementations of this embodiment, for a transaction in the target transaction cluster sequence, the executing entity may execute the determining step for the pre-dependent transaction of the transaction in response to the encryption result of the pre-dependent transaction of the transaction not being determined to be completed.
It is understood that, for a transaction in the target transaction cluster sequence, in the case that the encryption result of the pre-dependent transaction of the transaction is not determined to be completed, the implementation may determine the encryption result of the pre-dependent transaction based on the determination step, and then determine the encryption result of the transaction.
In step 403, in response to obtaining the target transaction cluster, an encryption result of a block corresponding to the target transaction cluster is determined based on an encryption result of a transaction in the target transaction cluster.
In this embodiment, the execution subject may determine, in response to obtaining the target transaction cluster, an encryption result of a block corresponding to the target transaction cluster based on an encryption result of a transaction in the target transaction cluster. Wherein the target transaction cluster is the transaction cluster for which the encryption result of each transaction included has been determined. The block corresponding to the target transaction cluster is a block which can be generated by using the target transaction cluster.
In step 404, for the target transaction cluster for which the encryption result of the corresponding block is determined, in response to that the encryption result of the previous block of the block corresponding to the target transaction cluster is determined to be completed, the block corresponding to the target transaction cluster is generated based on the encryption result of the block corresponding to the target transaction cluster and the encryption result of the previous block.
In this embodiment, for the target transaction cluster based on the encryption result of the block determined in step 403, the executing entity may generate the block corresponding to the target transaction cluster based on the encryption result of the block corresponding to the target transaction cluster and the encryption result of the previous block in response to that the encryption result of the previous block of the block corresponding to the target transaction cluster has been determined to be completed. The pre-block is a block which is arranged in front of the block corresponding to the target transaction cluster in the target block chain and is adjacent to the block corresponding to the target transaction cluster. The target block chain is a block chain for adding the generated block.
Step 401, step 403, and step 404 may be performed in a manner similar to that of step 201, step 203, and step 204 in the foregoing embodiment, respectively, and the above description for step 201, step 203, and step 204 also applies to step 401, step 403, and step 404, and is not described herein again.
As can be seen from fig. 4, compared with the embodiment corresponding to fig. 2, the flow 400 of the method for generating information in this embodiment highlights the steps of, for a transaction in the target transaction cluster sequence, in the case that the pre-dependent transaction of the transaction is included in the target transaction cluster sequence, first determining whether the encryption result of the pre-dependent transaction of the transaction has been determined to be completed, and further determining the encryption result of the transaction in response to the encryption result of the pre-dependent transaction of the transaction having been determined to be completed. Therefore, the scheme described in this embodiment can perform parallel computation on the encryption results of transactions without dependency in the target transaction cluster sequence, and perform serial computation on the encryption results of transactions with dependency, so that the accuracy of the encryption results of the block can be improved while the computation efficiency of the encryption results of the block is improved, which is beneficial to improving the effectiveness of the generated block.
With further reference to fig. 5, as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an apparatus for generating information, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable in various electronic devices.
As shown in fig. 5, the apparatus 500 for generating information of the present embodiment includes: an acquisition unit 501, a first determination unit 502, a second determination unit 503, and a first generation unit 504. The obtaining unit 501 is configured to obtain a target transaction cluster sequence, where transaction clusters in the target transaction cluster sequence are arranged according to a target sequence, and the transaction clusters are used for generating a block; the first determining unit 502 is configured to perform the following determining steps for the transactions in the target transaction cluster sequence: determining whether a pre-dependent transaction of the transaction is included in the sequence of target transaction clusters, and in response to not including the pre-dependent transaction, determining an encryption result of the transaction; the second determining unit 503 is configured to determine, in response to obtaining a target transaction cluster, an encryption result of a block corresponding to the target transaction cluster based on an encryption result of a transaction in the target transaction cluster, where the target transaction cluster is a transaction cluster for which the encryption result of the included transaction has been determined; the first generating unit 504 is configured to, for a target transaction cluster for which an encryption result of a corresponding block is determined, generate a block corresponding to the target transaction cluster based on an encryption result of a block corresponding to the target transaction cluster and an encryption result of a previous block in response to the encryption result of a previous block of a block corresponding to the target transaction cluster having been determined to be completed.
In this embodiment, the obtaining unit 501 of the apparatus 500 for generating information may obtain the target transaction cluster sequence through a wired connection manner or a wireless connection manner. The target transaction cluster sequence is to be processed to generate a transaction cluster sequence of the block. The target transaction cluster sequence may include at least two transaction clusters. Each transaction cluster is used to generate a block. The transaction cluster may include a target number of transactions. The target quantity may be a quantity predetermined by a technician or a quantity determined based on a predetermined block size and data volume for each transaction. The transaction clusters in the target transaction cluster sequence are arranged according to a target sequence.
In this embodiment, for the transactions in the target transaction cluster sequence obtained in the obtaining unit 501, the first determining unit 502 may perform the following determining steps: determining whether a pre-dependent transaction of the transaction is included in the sequence of target transaction clusters, and in response to not including the pre-dependent transaction, determining an encrypted result of the transaction. The transaction cluster to which the preposed dependent transaction belongs is arranged before the transaction cluster to which the transaction belongs, and the preposed dependent transaction has a dependency relationship with the transaction. Specifically, the dependency relationship of the pre-dependent transaction with the transaction refers to the execution of the transaction, which depends on the execution of the pre-dependent transaction.
In this embodiment, the second determining unit 503 may determine, in response to obtaining the target transaction cluster, an encryption result of a block corresponding to the target transaction cluster based on an encryption result of a transaction in the target transaction cluster. Wherein the target transaction cluster is the transaction cluster for which the encryption result of each transaction included has been determined. The block corresponding to the target transaction cluster is a block which can be generated by using the target transaction cluster.
In this embodiment, for a target transaction cluster based on the encryption result of the block determined by the second determining unit 503, the first generating unit 504 may generate the block corresponding to the target transaction cluster based on the encryption result of the block corresponding to the target transaction cluster and the encryption result of the previous block in response to the encryption result of the previous block of the block corresponding to the target transaction cluster having been determined to be completed. The pre-block is a block which is arranged in front of the block corresponding to the target transaction cluster in the target block chain and is adjacent to the block corresponding to the target transaction cluster. The target block chain is a block chain for adding the generated block.
In some optional implementations of this embodiment, the first determining unit 502 may be further configured to: in response to determining that the pre-dependent transaction of the transaction is included in the sequence of target transaction clusters, determining whether an encryption result of the pre-dependent transaction of the transaction has been determined to be complete; an encryption result for the transaction is determined in response to the encryption result for the pre-dependent transaction for the transaction having been determined to be complete.
In some optional implementations of this embodiment, the apparatus 500 may further include: a third determining unit (not shown in the figure) configured to perform the determining step for the pre-dependent transaction of the transaction in response to the encryption result of the pre-dependent transaction of the transaction not being determined to be completed.
In some optional implementations of this embodiment, the apparatus 500 may further include: and a second generating unit (not shown in the figure) configured to generate the block corresponding to the target transaction cluster based on the encryption result of the block corresponding to the target transaction cluster and the encryption result of the previous block of the block corresponding to the target transaction cluster after the encryption result of the previous block of the block corresponding to the target transaction cluster is determined to be completed, in response to that the encryption result of the previous block of the block corresponding to the target transaction cluster is not determined to be completed.
In some optional implementations of this embodiment, the encryption result is a hash value.
In some optional implementations of the present embodiment, the first generating unit 504 is further configured to: generating a block head of a block corresponding to the target transaction cluster based on the encryption result of the block corresponding to the target transaction cluster and the encryption result of a front block; generating a block body of a block corresponding to the target transaction cluster based on an encryption result of the transaction in the target transaction cluster; and determining the block comprising the generated block head and the block body as the block corresponding to the target transaction cluster.
In some optional implementations of this embodiment, the apparatus 600 may further include: and an adding unit (not shown in the figure) configured to add the generated block to the target block chain according to the arrangement order of the transaction clusters corresponding to the generated block in the target transaction cluster sequence.
It is understood that the units described in the apparatus 500 correspond to the respective steps in the method described in fig. 2 or fig. 4. Thus, the operations, features and resulting advantages described above with respect to the method are also applicable to the apparatus 500 and the units included therein, and are not described herein again.
The apparatus 500 provided in the above embodiment of the present disclosure can perform parallel computation on the encryption result of the transaction without dependency relationship in the target transaction cluster sequence (i.e. there is no transaction with pre-dependency) in the block generation process, and compared with a serial computation manner for transactions belonging to different blocks in the prior art, the apparatus 500 can improve the block generation efficiency, thereby being helpful to improve the overall performance of the block chain.
Referring now to FIG. 6, a schematic diagram of an electronic device (e.g., electronic devices 101, 102, 103 of FIG. 1) 600 suitable for use in implementing embodiments of the present disclosure is shown. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile electronic devices such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and fixed electronic devices such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 6, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring a target transaction cluster sequence, wherein transaction clusters in the target transaction cluster sequence are arranged according to a target sequence, and the transaction clusters are used for generating blocks; for a transaction in the target transaction cluster sequence, performing the following determining steps: determining whether a pre-dependent transaction of the transaction is included in the sequence of target transaction clusters, and in response to not including the pre-dependent transaction, determining an encryption result of the transaction; in response to obtaining the target transaction cluster, determining an encryption result of a block corresponding to the target transaction cluster based on an encryption result of a transaction in the target transaction cluster, wherein the target transaction cluster is the transaction cluster for which the encryption result of the included transaction has been determined; and for the target transaction cluster of which the encryption result of the corresponding block is determined, generating the block corresponding to the target transaction cluster based on the encryption result of the block corresponding to the target transaction cluster and the encryption result of the front block in response to the fact that the encryption result of the front block of the block corresponding to the target transaction cluster is determined to be finished.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation on the unit itself, for example, the acquisition unit may also be described as a "unit to acquire a target transaction cluster sequence".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.