Block processing method, block chain system and readable storage medium
By determining the total number of verification times and selection rules of new blocks in the blockchain system, the verification process is optimized, and the participation of verification nodes across the network is reduced, the problem of slow blockchain block generation is solved, and processing performance is improved.
Patent Information
- Application Number
- CN202510622185.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2025-08-22
AI Technical Summary
The verification process of new blocks in the existing blockchain system requires verification by all nodes participating in accounting, resulting in slow block production speed and serious resource consumption, which affects processing performance.
After generating a new block, determine the total number of verifications, and select the verification nodes in turn according to the preset selection rules to verify, until the number of verifications reaches the total number of verifications and the results are all passed, and then the link operation is carried out to reduce the participation of the verification nodes across the network.
It speeds up the block production speed of blockchain, reduces the loss of resources by the verification process, and improves the processing performance of blockchain.
Smart Images

Figure CN120524497A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and specifically relates to a block processing method, a blockchain system, and a readable storage medium. Background Art
[0002] In related technologies, after a new blockchain block is generated, it is typically required to be verified by all participating nodes in the blockchain network. Only after each node passes verification is the new block added to the local distributed ledger. This requirement for verification by all participating nodes can result in slow block generation. Summary of the Invention
[0003] The purpose of the embodiments of the present application is to provide a block processing method, a blockchain system, and a readable storage medium to solve the problem of slow block generation in existing blockchains.
[0004] In order to solve the above technical problems, this application is implemented as follows:
[0005] In a first aspect, a block processing method is provided, comprising:
[0006] After a new block is generated by a ledger node, the total number of verifications required before the new block is put on the blockchain is determined;
[0007] Selecting verification nodes for the new block in sequence according to the total number of verifications and a preset selection rule, and verifying the new block through the selected verification nodes;
[0008] When the number of verifications of the new block reaches the total number of verifications and all verification results of the new block are passed, the new block is put on the chain.
[0009] In a second aspect, a block processing device is provided, comprising:
[0010] A determination module, configured to determine the total number of verifications required before a new block is uploaded to the blockchain after the accounting node generates the new block;
[0011] a processing module, configured to select verification nodes for the new block in sequence according to the total number of verifications and a preset selection rule, and verify the new block through the selected verification nodes;
[0012] The chain-up module is used to perform a chain-up operation on the new block when the number of verification times of the new block reaches the total number of verification times and the verification results of the new block are all passed.
[0013] In a third aspect, a blockchain system is provided, comprising a plurality of nodes, wherein the plurality of nodes are divided into accounting nodes and verification nodes; wherein:
[0014] The accounting node is used to: generate a new block, determine the total number of verifications required for the new block before it is put on the chain, and select a verification node for the new block based on the total number of verifications and a preset selection rule;
[0015] The verification node is used to: verify the new block and select the next verification node for the new block based on the total number of verifications and a preset selection rule;
[0016] The verification node is further configured to: when the number of times the new block has been verified reaches the total number of times of verification and the verification results of the new block are all passed, perform an on-chain operation on the new block.
[0017] In a fourth aspect, an electronic device is provided, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.
[0018] In a fifth aspect, a readable storage medium is provided, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0019] In a sixth aspect, a computer program product is provided, comprising computer instructions, which, when executed by a processor, implement the steps of the method described in the first aspect.
[0020] In an embodiment of the present application, the total number of verifications required before a new block is put on the blockchain can be determined. Based on the total number of verifications and a preset selection rule, verification nodes are sequentially selected for the new block, and the new block is verified by the selected verification nodes. When the number of verifications for the new block reaches the total number of verifications, and all verification results for the new block are passed, the new block is put on the blockchain. This eliminates the need for all nodes participating in bookkeeping to verify the new block, thereby speeding up the block generation process, reducing resource consumption during the verification process, and improving the processing performance of the blockchain. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a flowchart of a block processing method provided by an embodiment of the present application;
[0022] Figure 2 It is a schematic diagram of the blockchain system in an embodiment of the present application;
[0023] Figure 3 This is a schematic structural diagram of a block processing device provided in an embodiment of the present application;
[0024] Figure 4 This is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0026] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.
[0027] In order to facilitate understanding of the embodiments of the present application, the following contents are first described.
[0028] Blockchain technology involves multiple computing devices participating in a distributed ledger and jointly maintaining a complete, distributed intelligent database. Due to its decentralized, transparent nature, the ability of every computing device to participate in database records, and the ability to rapidly synchronize data and ensure consistent execution across devices, blockchain technology has found widespread application in fields such as finance, manufacturing, and healthcare. However, existing blockchains suffer from issues such as slow block generation, resulting in low performance and severely limiting their application in various business scenarios.
[0029] In order to solve the problem of slow block generation in existing blockchains, the solution in this application optimizes the verification mechanism for new blocks in the blockchain. The specific process is as follows: determining the total number of verifications required for a new block before it is put on the chain, selecting verification nodes for the new block in sequence based on the total number of verifications and preset selection rules, and verifying the new block through the selected verification nodes. When the number of verifications for the new block reaches the total number of verifications and the verification results for the new block are all passed, the new block is put on the chain. As a result, there is no need for all nodes participating in the bookkeeping to verify the new block, thereby speeding up the block generation speed of the blockchain.
[0030] Optionally, the solution in this application can be applied to blockchain platforms, such as Bitcoin, Ethereum, etc.
[0031] The following, in conjunction with the accompanying drawings, describes in detail the block processing method, blockchain system, and readable storage medium provided in the embodiments of the present application through specific embodiments and their application scenarios.
[0032] See Figure 1 , Figure 1 This is a flowchart of a block processing method provided by an embodiment of the present application, which is applied to a blockchain system, etc. Figure 1 As shown, the method includes the following steps:
[0033] Step 11: After the accounting node generates a new block, determine the total number of verifications required before the new block is put on the chain;
[0034] Step 12: Select verification nodes for the new block in sequence according to the total number of verifications and a preset selection rule, and verify the new block through the selected verification nodes;
[0035] Step 13: When the number of verifications of the new block reaches the total number of verifications and the verification results of the new block are all passed, the new block is put on the chain.
[0036] In the embodiments of the present application, the accounting nodes and verification nodes can be understood as blockchain nodes, computing nodes, computing devices, etc. The blockchain nodes in the blockchain system are connected through the network and compete for accounting rights through a consensus process. They verify whether the new blocks generated by the accounting rights nodes meet the rules. If the verification is successful, the new blocks are added to the local distributed ledger. If the verification fails, the generation of new blocks is rejected.
[0037] The total number of verifications required before a new block is put on the chain can be determined by the accounting node (i.e. the generation node of the new block) based on the importance of the new block, such as a total number of verifications of 2 or 3.
[0038] The preset selection rule may be determined based on actual needs, for example, the blockchain node with the largest computing power may be selected as the verification node, or a blockchain node may be randomly selected as the verification node.
[0039] Regarding the verification of new blocks, in the embodiment of the present application, it is possible to verify whether the hash value of the block header is less than the target difficulty to confirm that the proof of work has been executed. It is also possible to verify whether the block timestamp is a preset time (for example, two hours) earlier than the verification time. This application does not limit the verification method of new blocks, and it can be selected based on actual needs.
[0040] Blockchains are distributed ledgers used to store data. Each blockchain node maintains a local copy of the distributed ledger, and new blocks that pass verification are added to this local copy. Specifically, the blockchain node adds the verified new blocks to its local copy of the distributed ledger.
[0041] The solution of the embodiment of the present application can determine the total number of verifications required before a new block is put on the chain. Based on the total number of verifications and a preset selection rule, verification nodes are selected for the new block in sequence. The new block is then verified by the selected verification nodes. When the number of verifications for the new block reaches the total number of verifications and all verification results for the new block are passed, the new block is put on the chain. This eliminates the need for all nodes participating in the bookkeeping to verify the new block, thereby speeding up the block generation speed of the blockchain, reducing resource consumption during the verification process, and improving the processing performance of the blockchain.
[0042] Optionally, selecting verification nodes for the new block in sequence according to the total number of verifications and a preset selection rule, and verifying the new block through the selected verification nodes may include:
[0043] The following steps are executed repeatedly until the number of verifications of the new block reaches the total number of verifications;
[0044] Determining multiple nodes connected to a first node, wherein the first node is the accounting node or the current verification node; the multiple nodes are specifically blockchain nodes; and the multiple nodes can be understood as multiple connected nodes of the first node;
[0045] A target verification node is selected from the plurality of nodes, and the new block is verified by the target verification node. In this way, through the above-mentioned cyclic process, suitable verification nodes can be selected for the new block in turn.
[0046] In the embodiment of the present application, a verification node may be selected by assigning a random number. The above-mentioned selection of a target verification node from the plurality of nodes may include:
[0047] Assigning a random number to each of the plurality of nodes respectively; for example, a random number may be assigned to each node by a node number generation module;
[0048] The node assigned the largest random number among the multiple nodes is determined as the target verification node, or the node assigned the smallest random number among the multiple nodes is determined as the target verification node. This allows for random selection of verification nodes, thereby reducing the possibility of nodes intentionally acting maliciously and improving the accuracy of verification results.
[0049] Optionally, verifying the new block by the target verification node may include: comparing, by the target verification node, the number of verifications of the new block with the total number of verifications, and verifying the new block if the number of verifications of the new block is less than the total number of verifications. If the number of verifications of the new block reaches the total number of verifications, then stopping verification of the new block, and uploading the new block to the blockchain if all verification results are positive.
[0050] In an embodiment of the present application, in order to optimize the verification mechanism of new blocks in the blockchain, the message header of the new block can be improved. For example, based on the existing new block structure (such as the version, parent block hash value, Merkle root, timestamp, difficulty target, nonce (number used once) and other fields), the following three fields are added / extended: total verification times (total_verified_times), verified times (verified_times) and verification result (verified_result).
[0051] Optionally, the header information of the new block in the embodiment of the present application may include the following content:
[0052] The total number of verifications of the new block;
[0053] The number of times the new block has been verified;
[0054] The verification result of the new block.
[0055] In this way, with the help of the header information of the new block, the total number of verifications, the number of verifications and the verification results of the new block can be determined.
[0056] In one implementation, the content of the message header of the new block in this solution may be as shown in Table 1 below:
[0057] Table 1
[0058] Field size describe Version 4 bytes Version number, used to track software / protocol updates Parent block hash value 32 bytes References the hash of the parent block in the blockchain Merkle root 32 bytes The hash value of the Merkle tree root representing the transactions in the corresponding block Timestamp 4 bytes Represents the approximate time when the corresponding block was generated Difficulty Target 4 bytes Characterizing the difficulty target of the block proof-of-work algorithm nonce 4 bytes Counter used in the proof-of-work algorithm Total verification times 4 bytes The total number of verifications used to verify whether the new block is legal Verified times 4 bytes The number of verifications used to verify whether the new block is legal Verify the results 4 bytes Store the results of each new block verification
[0059] In the embodiment of the present application, since the new block does not need to be verified across the entire network, different new blocks can be verified in parallel, with independent verification paths during parallel verification. Optionally, when the new block includes a first new block and a second new block that are associated with each other, determining the total number of verifications required before the new block is put on the chain may include:
[0060] Determine a first total verification count and a second total verification count required for each of the first and second new blocks before being uploaded to the blockchain. For example, the respective total verification counts may be determined based on the importance of the first and second new blocks. The first and second total verification counts may be the same or different.
[0061] Selecting verification nodes for the new block in sequence according to the total number of verifications and a preset selection rule, and verifying the new block through the selected verification nodes may include:
[0062] According to the first total number of verification times and a preset selection rule, verification nodes are selected in sequence for the first new block, and the first new block is verified by the selected verification nodes; at the same time, according to the second total number of verification times and a preset selection rule, verification nodes are selected in sequence for the second new block, and the second new block is verified by the selected verification nodes; wherein the verification node selected for the first new block is different from the verification node selected for the second new block; the specific process / method of selecting verification nodes for the first new block and the second new block can be as described in the above embodiment.
[0063] When the number of verifications of the new block reaches the total number of verifications and all verification results of the new block are passed, the operation of uploading the new block to the chain may include:
[0064] When the first new block has been verified the first total number of times, the second new block has been verified the second total number of times, and both the first and second new blocks have passed verification, the first and second new blocks are sequentially put on the chain. For example, if the first new block was generated before the second new block, or if the second new block depends on the first new block, the first new block can be put on the chain first, followed by the second new block.
[0065] As a result, different new blocks can be verified in parallel before being put on the chain, and each has its own independent verification path during parallel verification. After passing the verification, different new blocks are put on the chain in sequence, thereby effectively improving the processing performance of the blockchain.
[0066] Optionally, when the number of verifications for the first new block reaches the first total number of verifications, the number of verifications for the second new block reaches the second total number of verifications, and the verification results for the first new block or the second new block are not both passed, the unverified new blocks are removed from the cache, and when the cache time of the verified new blocks reaches a preset threshold, the verified new blocks are put on the chain. This can avoid putting new blocks that fail verification on the chain.
[0067] Optionally, the processing method in the embodiment of the present application may further include:
[0068] Record the number of successful and failed verifications of the verification node;
[0069] Verification nodes are rewarded or penalized based on the number of successful and / or failed verifications. This reward and penalty mechanism can mitigate security risks associated with nodes intentionally engaging in malicious activities due to simplified verification processes. This approach has a wide range of application scenarios for platforms with high demands for block production performance.
[0070] For example, the verification mechanism management module can record the number of successful and failed verifications (failed verifications when they should have been successful, or failed verifications when they were successful) of the verification node, and perform reward and punishment operations. For example, if the number of successful verifications of a node exceeds a preset threshold, the node can be awarded one accounting right. If the number of failed verifications of a node exceeds a preset threshold, the number of successful verifications of the node can be reset to zero, and further, a punitive deduction count can be performed as a punishment. If a node redeems the next accounting right through the number of successful verifications, the next round of accounting rights will no longer be competed for through the consensus algorithm, but the accounting right will be directly given to the node. If no node in the next round redeems through the number of successful verifications, the consensus algorithm currently used by the blockchain will be used to compete for the accounting right.
[0071] The present application is described below with reference to specific embodiments.
[0072] The system architecture diagram provided in the specific embodiment of this application can be as follows Figure 2 As shown, it mainly includes:
[0073] (1) Node 1-Node N: Blockchain nodes, connected through the network, compete for the right to record accounts through the consensus process, verify whether the new block generated by the node that obtains the right to record accounts meets the rules, and add the new block to the local distributed ledger if the verification is passed. If the verification fails, the generation of the new block is rejected. In the scenario of large amounts of data, the new block data is supported to be verified based on multiple independent node links in parallel and synchronously according to the node data rules. It should be noted that Figure 2Node 1.1, node 1.2, node 2.1, node 2.2, node N.1, and node N.2 in the figure represent nodes from node 1 to node N. They are referred to as node 1.1, node 1.2, node 2.1, node 2.2, node N.1, and node N.2 only for the convenience of indicating the connection with node 1, node 2, and node N.
[0074] (2) 1-M: Distributed ledger. Blockchain is a distributed ledger used to store data. Each blockchain node saves a local copy of the distributed ledger, and new blocks that pass verification are added to the local copy.
[0075] (3) Node number generation module: used to generate node numbers. When a new block is broadcast to other nodes, a random number (i.e., a random number) is generated for each interconnected node. The node assigned the largest or smallest random number obtains the right to verify whether the new block in this round meets the rules. If the verification is passed, the new block is added to the local copy.
[0076] (4) Verification mechanism management module: This module manages the node verification mechanism for the generation of new blocks, and determines whether to use directed node verification or the blockchain default verification mechanism of full network broadcast. In addition, the verification success and verification failure of the nodes participating in the verification (should have been successful, but failed, or should have failed but succeeded) are counted and sorted. After the nodes with more successful verifications reach the threshold conditions, they can directly redeem the accounting rights once. For those with failed verifications, the count of their successful verifications is cleared, and the cumulative verification success count starts from 0. The verification node path before each new block is put on the chain is recorded to ensure that the verification nodes are not repeated during the synchronous and parallel verification process of the new block.
[0077] With the help of Figure 2 In the system architecture shown, this embodiment uses a node number generation module to assign random numbers to connected nodes that have obtained accounting rights. The node assigned the highest or lowest random number is then given the opportunity to verify the new block on the blockchain in this round. The block header is then extended to record the total number of block verifications, the number of verifications completed, and the verification results. After a new block message with a verification count that reaches the total number of verifications and passes each verification result is broadcast, the receiving node does not need to re-verify it each time. This significantly reduces the resource consumption of data verification for accounting nodes across the entire network and accelerates the blockchain's block generation speed. Furthermore, because new blocks do not need to be verified across the entire network, parallel verification can be performed simultaneously, with each independent verification path, effectively improving the blockchain's processing performance. Furthermore, by introducing a reward and punishment mechanism, the security issue of nodes intentionally acting maliciously due to the simplified verification process can be reduced.
[0078] like Figure 2 As shown, the specific interaction process may include:
[0079] S1: Blockchain nodes 1-N each store a copy of the distributed ledger. When a new block is generated (i.e., a new block), each blockchain node needs to verify the new block message before adding it to its local copy of the distributed ledger.
[0080] S2: In this round of competition for bookkeeping rights, assuming that node 2 obtains the bookkeeping rights through the consensus process, after node 2 generates a new block 3, it determines the number of times that the new block 3 needs to be verified by blockchain nodes before it is put on the chain, based on the importance of the data stored in the new block 3. That is, the total number of verifications required before it is put on the chain, for example, the total number of verifications is 2.
[0081] S3: Assign a random number to each node connected to node 2 through the node number generation module; for example, the nodes connected to node 2 include node 1, node 2.1, node 2.2, and node N, and the random number of node 1 is 4, the random number of node 2.1 is 2, the random number of node 2.2 is 3, and the random number of node N is 1.
[0082] S4: Node 2 compares the size of the random numbers of each node connected to it. Since the random number 4 assigned to node 1 is the largest, it only sends the new block 3 to node 1 for verification of data validity, accounting rights, etc., which requires the message field of the sent block header to be expanded. Since the total number of verifications in this round is 2, the total number of verifications is filled in with 2, the number of verifications is filled in with 0, and the verification result is filled in with 0.
[0083] S5: After receiving the new block 3, node 1 compares the total number of verifications with the number of verifications. Since the number of verifications 0 is less than the total number of verifications 2, the new block 3 is verified. For example, the hash value of the verification block header is less than the target difficulty to confirm that the proof of work has been executed, and the verification block timestamp is two hours earlier than the verification time. After the verification is successful, node 1 accepts the new block on the chain and caches the verified new block 3 locally.
[0084] S6: After node 1 is verified, if the number of verifications added by 1 is still less than the total number of verifications of 2, a random number needs to be assigned to each node connected to node 1 through the node number generation module; for example, the nodes connected to node 1 include node 1.1 and node 1.2, and node 1.1 is assigned random number 1, and node 1.2 is assigned random number 2.
[0085] S7: Node 1 compares the random numbers of each node connected to it. Since the random number 2 assigned to node 1.2 is the largest, node 1 sends a new block 3 to node 1.2. The total number of verifications in the message field of the block header is still filled with 2, the number of verifications is filled with 1, and the verification result is filled with 1 (indicating that the verification passed).
[0086] S8: After receiving new block 3, node 1.2 compares the total verification count with the verified count. Since the verified count (1) is less than the total verification count (2), it verifies new block 3. If verification is successful, it adds the new block to node 1.2's local cache, increments the verified count by 1 (to 2), and sets the verification result to 3. Converted to binary, this is 11, indicating that both node 1 and node 1.2 passed verification. The verification mechanism management module records the verification path of new block 3, including node 1 and node 1.2.
[0087] S9: Node 1.2 broadcasts the block message that has passed both verifications (i.e., new block 3). The total number of verifications is 2, the number of verified times is 2, and the verification result is 3 (11 in binary). Each node that receives the block message checks that the number of verified times is equal to the total number of verifications, and then no longer verifies the new block. The verification result is 3 (11 in binary), and it is directly cached locally.
[0088] S10: If the node that receives the message broadcast by node 1.2 finds that the number of verifications is equal to the total number of verifications, it will no longer verify the new block. If the verification result is not 3, it will directly reject the new block and will not cache it locally.
[0089] S11: Optionally, if node 2 also generates a new block 4, then new block 3 and new block 4 can be verified synchronously and in parallel. Specifically, a random number is assigned to each node connected to node 2 through the node number generation module; for example, the random number of node 1 is 4, the random number of node 2.1 is 2, the random number of node 2.2 is 1, and the random number of node N is 3; then node 1, which has already been used for the new block 3 stored in the verification mechanism management module, is excluded. Among the remaining three nodes, since the random number 3 assigned to node N is the largest, new block 4 is first sent to node N for verification of data validity, accounting rights, etc. Among them, the new block 4 is verified for data validity, accounting rights, etc. synchronously and in parallel through the node N and node N.2 paths.
[0090] S12: When the new block 3 and the new block 4 are being verified synchronously and in parallel, each blockchain node that receives the verification results will cache the verified data of the new block 3 and the new block 4 in order, and only when the blockchain node receives the verification results of the new block 3 and the new block 4 that are verified synchronously and in parallel will it process the uploading of the new block 3 and the new block 4 to the chain.
[0091] S13: Optionally, if only one of the new blocks 3 and 4 passes verification, the unverified block is removed from the cache, and after the on-chain cache time reaches the threshold, only the verified block data is uploaded to the chain. If both new blocks 3 and 4 pass verification, after the on-chain cache time reaches the threshold, the cached new block 3 and new block 4 data are uploaded to the chain in order.
[0092] S14: In order to prevent node 1 from intentionally judging the new block message sent by node 2 as illegal, even if node 1 judges the new block as illegal, it needs to continue forwarding the new block until the number of forwardings is equal to the total number of verifications.
[0093] S15: Optionally, if node 1 determines that the new block sent by node 2 is illegal, and node 1.2 determines that the new block forwarded by node 1 is legal, that is, there is an inconsistency in the judgment results of the blockchain nodes on the new block message, then the directed node verification is closed through the verification mechanism management module, and the default verification mechanism for the blockchain new block is started, and the new block message is broadcast to the entire network. Each node needs to perform a rule verification when adding a new block to the local copy, and only blocks that meet the new block data rules are added to the local copy.
[0094] S16: Optionally, the verification mechanism management module records the number of successful verifications and failed verifications of the nodes participating in the verification; as shown in Table 2 below, if the number of successful verifications of blockchain node 1 is 12 times, because it is greater than the preset threshold value of 10, it can be exchanged for 1 accounting right, the exchange consumption value is 10, and there are 2 successful verifications remaining; if the number of successful verifications of blockchain node 1.2 is 13 times, because it is greater than the preset threshold value of 10, it can be exchanged for 1 accounting right, the exchange consumption value is 10, and since there is 1 verification failure, the remaining 3 successful verifications are cleared to zero, and the count is deducted by 3 as a penalty.
[0095] Table 2
[0096]
[0097] S17: If a node has exchanged the next accounting right through the number of successful verifications, the next accounting right will no longer be competed for through the consensus algorithm; if no node has exchanged through the number of successful verifications in the next round, the consensus algorithm currently used by the blockchain will be used to compete for the accounting right.
[0098] It should be noted that the block processing method provided in the embodiments of the present application can be executed by a block processing device, or a control module in the block processing device for executing the block processing method. In the embodiments of the present application, the block processing device provided in the embodiments of the present application is described by taking the block processing device executing the block processing method as an example.
[0099] See Figure 3 , Figure 3 This is a schematic diagram of the structure of a block processing device provided by an embodiment of the present application. Figure 3 As shown, the block processing device 30 includes:
[0100] Determination module 31, for determining the total number of verifications required before a new block is uploaded to the blockchain after the accounting node generates the new block;
[0101] A processing module 32 is configured to select verification nodes for the new block in sequence according to the total number of verifications and a preset selection rule, and verify the new block through the selected verification nodes;
[0102] The chaining module 33 is configured to perform a chaining operation on the new block when the number of verification times of the new block reaches the total number of verification times and the verification results of the new block are all passed.
[0103] Optionally, the processing module 32 is further configured to: loop through the following steps until the number of verifications of the new block reaches the total number of verifications;
[0104] Determining a plurality of nodes connected to a first node, wherein the first node is the accounting node or the current verification node;
[0105] A target verification node is selected from the multiple nodes, and the new block is verified by the target verification node.
[0106] Optionally, selecting a target verification node from the multiple nodes includes:
[0107] A random number is assigned to each of the multiple nodes respectively; the node assigned to the largest random number among the multiple nodes is determined as the target verification node, or the node assigned to the smallest random number among the multiple nodes is determined as the target verification node.
[0108] Optionally, verifying the new block by the target verification node includes:
[0109] The target verification node compares the number of times the new block has been verified with the total number of times of verification, and verifies the new block if the number of times the new block has been verified is less than the total number of times of verification.
[0110] Optionally, the message header information of the new block includes the following content:
[0111] The total number of verifications of the new block;
[0112] The number of times the new block has been verified;
[0113] The verification result of the new block.
[0114] Optionally, in a case where the new block includes a first new block and a second new block having an associated relationship, the determining module 31 is specifically configured to: respectively determine a first total number of verifications and a second total number of verifications required for the first new block and the second new block before being put on the chain;
[0115] The processing module 32 is specifically configured to: sequentially select verification nodes for the first new block based on the first total verification count and a preset selection rule, and verify the first new block through the selected verification nodes; and simultaneously, sequentially select verification nodes for the second new block based on the second total verification count and a preset selection rule, and verify the second new block through the selected verification nodes; wherein the verification node selected for the first new block is different from the verification node selected for the second new block;
[0116] The chain-up module 33 is specifically configured to perform chain-up operations on the first new block and the second new block in sequence when the number of verifications of the first new block reaches the first total number of verifications, the number of verifications of the second new block reaches the second total number of verifications, and the verification results of both the first new block and the second new block are passed.
[0117] Optionally, the chain module 33 is also used for: when the number of verifications of the first new block reaches the first total verification number, the number of verifications of the second new block reaches the second total verification number, and the verification results of the first new block or the second new block are not all passed, the new blocks that have not passed the verification are removed from the cache, and when the cache time of the new blocks that have passed the verification reaches a preset threshold, the new blocks that have passed the verification are put on the chain.
[0118] Optionally, the block processing device 30 further includes:
[0119] A recording module, configured to record the number of successful and failed verifications of the verification node;
[0120] A reward and punishment module is used to reward or punish the verification node according to the number of successful verifications and / or the number of failed verifications.
[0121] The block processing device 30 of the embodiment of the present application can realize the above Figure 1 The various processes of the method embodiment shown can achieve the same technical effect, and to avoid repetition, they will not be described again here.
[0122] The present application also provides a blockchain system, including multiple nodes, wherein the multiple nodes are divided into accounting nodes and verification nodes; wherein:
[0123] The accounting node is used to: generate a new block, determine the total number of verifications required for the new block before it is put on the chain, and select a verification node for the new block based on the total number of verifications and a preset selection rule;
[0124] The verification node is used to: verify the new block and select the next verification node for the new block based on the total number of verifications and a preset selection rule;
[0125] The verification node is further configured to: when the number of times the new block has been verified reaches the total number of times of verification and the verification results of the new block are all passed, perform an on-chain operation on the new block.
[0126] Optionally, the blockchain system further includes a node number generation module, the node number generation module being configured to assign a random number to each of a plurality of nodes connected to a first node, where the first node is the accounting node or the current verification node;
[0127] The accounting node or the current verification node is used to determine the node assigned to the largest random number among the multiple nodes as the target verification node, or to determine the node assigned to the smallest random number among the multiple nodes as the target verification node.
[0128] Optionally, the message header information of the new block includes the following content:
[0129] The total number of verifications of the new block;
[0130] The number of times the new block has been verified;
[0131] The verification result of the new block.
[0132] Optionally, the blockchain system further includes a verification mechanism management module, which is used to record the number of successful verifications and the number of failed verifications of the verification node, and to reward or punish the verification node based on the number of successful verifications and / or the number of failed verifications.
[0133] Optional, such as Figure 4 As shown, an embodiment of the present application also provides an electronic device 40, including a processor 41, a memory 42, and a program or instruction stored in the memory 42 and executable on the processor 41. When the program or instruction is executed by the processor 41, each process of the above-mentioned block processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0134] An embodiment of the present application also provides a computer program product, including computer instructions. When the computer instructions are executed by a processor, the various processes of the above-mentioned block processing method embodiment can be implemented and the same technical effect can be achieved. To avoid repetition, they will not be repeated here.
[0135] An embodiment of the present application also provides a readable storage medium on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned block processing method embodiment can be implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0136] Computer-readable media includes both permanent and non-permanent, removable and non-removable media, and can be implemented using any method or technology for information storage. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change RAM (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.
[0137] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0138] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0139] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a service classification device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0140] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A block processing method, characterized in that: include: After a new block is generated by a ledger node, the total number of verifications required before the new block is put on the blockchain is determined; Selecting verification nodes for the new block in sequence according to the total number of verifications and a preset selection rule, and verifying the new block through the selected verification nodes; When the number of verifications of the new block reaches the total number of verifications and all verification results of the new block are passed, the new block is put on the chain.
2. The method according to claim 1, characterized in that The selecting verification nodes for the new block in sequence according to the total number of verifications and a preset selection rule, and verifying the new block through the selected verification nodes, includes: The following steps are executed repeatedly until the number of verifications of the new block reaches the total number of verifications; Determining a plurality of nodes connected to a first node, wherein the first node is the accounting node or the current verification node; A target verification node is selected from the multiple nodes, and the new block is verified by the target verification node.
3. The method according to claim 2, characterized in that The selecting a target verification node from the plurality of nodes comprises: Assigning a random number to each of the plurality of nodes; A node assigned to the largest random number among the multiple nodes is determined as the target verification node, or a node assigned to the smallest random number among the multiple nodes is determined as the target verification node.
4. The method according to claim 2, characterized in that The verifying the new block by the target verification node includes: The target verification node compares the number of times the new block has been verified with the total number of times of verification, and verifies the new block if the number of times the new block has been verified is less than the total number of times of verification.
5. The method according to any one of claims 1 to 4, characterized in that The header information of the new block includes the following: The total number of verifications of the new block; The number of times the new block has been verified; The verification result of the new block.
6. The method according to claim 1, characterized in that In a case where the new block includes a first new block and a second new block having an associated relationship, determining the total number of verifications required before the new block is uploaded to the chain includes: Determining a first total number of verifications and a second total number of verifications required for the first new block and the second new block before being uploaded to the blockchain, respectively; The step of selecting verification nodes for the new block in sequence according to the total number of verifications and a preset selection rule, and verifying the new block through the selected verification nodes, includes: selecting verification nodes for the first new block in sequence based on the first total number of verifications and a preset selection rule, and verifying the first new block through the selected verification nodes; and simultaneously selecting verification nodes for the second new block in sequence based on the second total number of verifications and a preset selection rule, and verifying the second new block through the selected verification nodes; wherein the verification node selected for the first new block is different from the verification node selected for the second new block; Wherein, when the number of verifications of the new block reaches the total number of verifications and the verification results of the new block are all passed, the new block is put on the chain, including: When the number of verifications of the first new block reaches the first total number of verifications, the number of verifications of the second new block reaches the second total number of verifications, and the verification results of the first new block and the second new block are both passed, the first new block and the second new block are sequentially put on the chain.
7. The method according to claim 6, characterized in that The method further comprises: When the number of verifications of the first new block reaches the first total number of verifications, the number of verifications of the second new block reaches the second total number of verifications, and the verification results of the first new block or the second new block are not all passed, the new blocks that have not passed the verification are removed from the cache, and when the cache time of the new blocks that have passed the verification reaches a preset threshold, the new blocks that have passed the verification are put on the chain.
8. The method according to claim 1, characterized in that The method further comprises: Record the number of successful and failed verifications of the verification node; The verification node is rewarded or punished based on the number of successful verifications and / or the number of failed verifications.
9. A blockchain system, characterized in that: The system comprises a plurality of nodes, wherein the plurality of nodes are divided into accounting nodes and verification nodes; wherein: The accounting node is used to: generate a new block, determine the total number of verifications required for the new block before it is put on the chain, and select a verification node for the new block based on the total number of verifications and a preset selection rule; The verification node is used to: verify the new block and select the next verification node for the new block based on the total number of verifications and a preset selection rule; The verification node is further configured to: when the number of times the new block has been verified reaches the total number of times of verification and the verification results of the new block are all passed, perform an on-chain operation on the new block.
10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.