CN111131329A - Data consensus method and device for block chain system and hardware equipment - Google Patents
Data consensus method and device for block chain system and hardware equipment Download PDFInfo
- Publication number
- CN111131329A CN111131329A CN202010025028.6A CN202010025028A CN111131329A CN 111131329 A CN111131329 A CN 111131329A CN 202010025028 A CN202010025028 A CN 202010025028A CN 111131329 A CN111131329 A CN 111131329A
- Authority
- CN
- China
- Prior art keywords
- contract
- verification
- things
- consensus
- verified
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 40
- 238000012795 verification Methods 0.000 claims abstract description 238
- 238000012856 packing Methods 0.000 claims abstract description 9
- 238000004806 packaging method and process Methods 0.000 claims abstract description 7
- 238000004590 computer program Methods 0.000 claims description 13
- 238000005538 encapsulation Methods 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 238000004088 simulation Methods 0.000 description 3
- 230000001360 synchronised effect Effects 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 238000013461 design Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 238000005096 rolling process Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/12—Applying verification of the received information
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/08—Network architectures or network communication protocols for network security for authentication of entities
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/104—Peer-to-peer [P2P] networks
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/50—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Hardware Design (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The invention discloses a data consensus method, a data consensus device and hardware equipment of a block chain system, relates to the technical field of block chains, and is used for improving the data consensus efficiency of the block chain system. The main technical scheme is as follows: pushing contract things meeting the trigger condition to a queue to be verified according to a preset time interval; after the consensus time comes, determining a consensus level according to contract things in a queue to be verified within a preset time interval; packing contract things in a queue to be verified within a preset time interval into a contract set, calculating a hash value of the contract set, and packaging the hash value and the contract set into a block structure; broadcasting the block structure to a verification node corresponding to the consensus level so that the verification node corresponding to the consensus level verifies contract things in the block structure; and acquiring the contract things of which the passing number of the verification nodes exceeds the preset value, and confirming that the data consensus of the contract things of which the passing number of the verification nodes exceeds the preset value is successful.
Description
Technical Field
The present invention relates to the field of blockchain technologies, and in particular, to a data consensus method and apparatus for a blockchain system, and a hardware device.
Background
The block chain is a recording technology different from the traditional centralized accounting mode, participates in nodes on the block chain system, possibly does not belong to the same organization and does not need to trust each other; the blockchain data is maintained by all nodes together, and each node participating in maintenance can obtain a copy of the complete record. Compared with the traditional accounting technology, the method has the characteristics that: maintaining a chain which grows continuously, only adding records possibly, and the records which occur cannot be tampered; can achieve the consensus without centralized control.
Due to the high network latency in a peer-to-peer network, the transaction order observed by each node may not be completely consistent. Therefore, the blockchain system needs to design a mechanism to know the sequence of the transactions that occur in almost time. As the growing chains in the blockchain system result in low data consensus efficiency, a method for solving the problem of low data consensus efficiency in the blockchain system is needed.
Disclosure of Invention
The invention provides a data consensus method and device for a block chain system, computer equipment and a storage medium, which are used for improving the data consensus efficiency of the block chain system.
The embodiment of the invention provides a data consensus method of a block chain system, wherein the block chain system at least comprises a queue to be verified and a plurality of verification nodes, and the method comprises the following steps:
pushing contract things meeting the trigger condition to a queue to be verified according to a preset time interval; a plurality of contract things waiting for consensus are stored in the queue to be verified;
after the consensus time arrives, determining consensus levels according to contract things in the queue to be verified within the preset time interval, wherein each consensus level corresponds to a plurality of verification nodes, and different consensus levels correspond to different verification nodes;
packing contract things in the queue to be verified within the preset time interval into a contract set, calculating a hash value of the contract set, and packaging the hash value and the contract set into a block structure;
broadcasting the block structure to a verification node corresponding to the consensus level such that the verification node corresponding to the consensus level verifies contract things within the block structure;
receiving a verification contract set sent by verification nodes corresponding to the consensus level, wherein the verification contract set comprises contract things meeting the trigger condition, each contract thing corresponds to a verification node passing number, and the verification node passing number of the contract things is the number of the verification nodes which pass the verification of the contract things;
acquiring contract things of which the passing number of verification nodes exceeds a preset value in the verification contract set, wherein the preset value is determined according to the number of the verification nodes corresponding to the consensus level;
and confirming that the verification node succeeds in data consensus through the contract things of which the number exceeds the preset value.
The embodiment of the invention provides a data consensus device of a block chain system, wherein the block chain system at least comprises a queue to be verified and a plurality of verification nodes, and the device is characterized by comprising:
the pushing module is used for pushing the contract things meeting the triggering conditions to a queue to be verified according to a preset time interval; a plurality of contract things waiting for consensus are stored in the queue to be verified;
the determining module is used for determining consensus levels according to contract things in the to-be-verified queue within the preset time interval after the to-be-verified time arrives, each consensus level corresponds to a plurality of verification nodes, and different consensus levels correspond to different verification nodes;
the encapsulation module is used for encapsulating the contract things in the queue to be verified within the preset time interval into a contract set, calculating the hash value of the contract set, and encapsulating the hash value and the contract set into a block structure;
a broadcast module for broadcasting the block structure to a verification node corresponding to the consensus level so that the verification node corresponding to the consensus level verifies contract things within the block structure;
the receiving module is used for receiving a verification contract set sent by a verification node corresponding to the consensus level, the verification contract set comprises contract things meeting the trigger condition, each contract thing corresponds to a verification node passing number, and the verification node passing number of the contract things is the number of the verification nodes which pass the verification of the contract things;
the acquisition module is used for acquiring contract things of which the passing number of the verification nodes in the verification contract set exceeds a preset value, and the preset value is determined according to the number of the verification nodes corresponding to the consensus level;
the determining module is further configured to confirm that the verification node succeeds in data consensus of the contract things of which the number exceeds a preset value.
A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the data consensus method of the above-mentioned blockchain system when executing the computer program.
A computer-readable storage medium, which stores a computer program that, when executed by a processor, implements the data consensus apparatus of the above-described blockchain system.
The invention provides a data consensus method, a data consensus device, computer equipment and a storage medium of a block chain system, which are characterized in that firstly, contract things meeting triggering conditions are pushed to a queue to be verified according to a preset time interval; after the consensus time comes, determining a consensus level according to contract things in a queue to be verified within a preset time interval; then, packing contract things in a queue to be verified within a preset time interval into a contract set, calculating a hash value of the contract set, and packaging the hash value and the contract set into a block structure; broadcasting the block structure to a verification node corresponding to the consensus level so that the verification node corresponding to the consensus level verifies the contract thing in the block structure; and receiving a verification contract set sent by verification nodes corresponding to the consensus level, acquiring contract things of which the passing number of the verification nodes exceeds a preset value in the verification contract set, and finally confirming that the data consensus of the contract things of which the passing number of the verification nodes exceeds the preset value is successful. Compared with the prior art that data consensus requires all verification nodes to participate, the method determines the consensus level according to the contract things in the queue to be verified within the preset time interval, then verifies the contract things according to the verification nodes corresponding to the consensus level, and since the consensus level is determined according to the contract things, the method can verify the contract things based on the importance degree of the contract things, and therefore the efficiency of data consensus of the block chain system can be improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a flow chart of a data consensus method of a blockchain system according to an embodiment of the present invention;
FIG. 2 is a flow diagram of identifying contract things that satisfy a trigger condition in one embodiment of the invention;
FIG. 3 is a flow diagram of a verification node verifying contract transactions within a block structure in accordance with an embodiment of the present invention;
FIG. 4 is a schematic block diagram of a data consensus device of the blockchain system according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a computer device according to an embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In one embodiment, as shown in fig. 1, a data consensus method for a blockchain system is provided, where the blockchain system includes at least one queue to be verified and a plurality of verification nodes. Each queue to be verified may be used to verify a type of contract thing, or to verify a contract thing in a corresponding time period, and the like. The method comprises the following steps:
and S10, pushing the contract things meeting the trigger condition to a queue to be verified according to a preset time interval.
And a plurality of contract things waiting for consensus are stored in the queue to be verified. The preset time interval can be set according to actual conditions, for example, the more contract things in the block chain, the shorter the preset time interval can be set; the fewer contract things in the blockchain, the longer the preset time interval can be set. Specifically, the preset time interval may be set to 1 second, 3 seconds, and the like, and the embodiment of the present invention is not particularly limited.
In an embodiment provided by the present invention, as shown in fig. 2, the pushing, in step S10, contract things meeting the trigger condition to the to-be-verified queue according to the preset time interval includes:
and S101, traversing the state machine and the trigger condition corresponding to each contract thing item one by one.
The state machine records transaction states corresponding to the first-stage transaction nodes and the second-stage transaction nodes respectively; the triggering condition is that the first-stage transaction node and the second-stage transaction node both succeed in transaction. It should be noted that the blockchain system includes a first transaction stage and a second transaction stage, where the first transaction stage is a pre-commit stage: the caller sends the transaction to each node, for example, the transaction from account A transferring 10 Yuan to account B is sent to two nodes P1 and P2, the P1 and P2 nodes simulate the operation of A-10 and B +10 (the simulation execution refers to the check of business presetting, such as identity check, safety check, account check and the like, the results of A-10 and B +10 do not really fall into the bank, but simulate the transaction of real transfer to see whether the transaction can be successful, if the simulation is successful, the two accounts A, B are temporarily locked, namely A, B account can not be used for other transfer transaction), and each node records the state of the transaction into the bank; if the simulation fails, the lock is not locked, and only the transaction state is recorded.
The second transaction phase is a commit phase: and performing submission or rollback according to the result of the pre-submission of each node. Following the above example, if P1 succeeded in the first transaction phase and P2 failed in the second transaction phase, then the first phase transaction of P1 is rolled back (i.e., the lock on the account is released A, B and the transaction status of the transaction in the database is updated); if the first stages of P1 and P2 fail, rolling back; if the P1 and the P2 are successful in the first transaction stage and the second transaction stage, the submission is carried out (the data of A-10 and B +10 really fall into the database, the lock is released, and the transaction state is updated).
S102, pushing contract things of which the first-stage transaction node and the second-stage transaction node are successful to a queue to be verified.
In the embodiment of the invention, after traversing the state machine and the triggering condition corresponding to each contract thing one by one, the contract things which are successfully transacted by the nodes in the first transaction stage and the second transaction stage within the preset time interval are obtained, and then the obtained contracts are pushed to the queue to be verified, so that the verification node can verify the contract things in the queue to be verified, and whether the contract things reach consensus or not is confirmed.
In another embodiment provided by the present invention, before pushing the contract things meeting the trigger condition to the queue to be verified at a preset time interval, the method further includes: determining the type of the contract affair, and determining corresponding queues to be verified according to the type of the contract affair, wherein each queue to be verified correspondingly stores the contract affair of the corresponding type. The type of the contract event may be determined according to the transaction amount of the contract event, the transaction mode, the user level, or the security level, and the embodiment of the present invention is not limited specifically. It should be noted that, before determining the corresponding queue to be verified according to the type of the contract event, the embodiment of the present invention needs to set the corresponding queue to be verified for each type of contract event. Furthermore, while setting a corresponding queue to be verified for each type of contract thing, the embodiment of the invention can also configure the importance level of the queue to be verified according to the importance degree of the type of the contract thing, wherein the higher the importance degree of the type of the contract thing is, the higher the importance level is set, the higher the consensus level corresponding to the queue to be verified is set; the lower the importance degree of the contract thing type is, the lower the importance level setting is, and the lower the consensus level setting corresponding to the queue to be verified is.
For example, if the size of the transaction amount is determined according to the type of the contract event, three levels are set according to the transaction amount, respectively: 0-1000 yuan, 1000-5000 yuan and more than 5000 yuan, the corresponding three queues to be verified can be determined according to different transaction amounts, and a consensus grade is set for each queue to be verified according to the transaction amount, wherein if the high-level queue to be verified corresponds to more than 5000 yuan, the medium-level queue to be verified corresponds to 1000 yuan and the low-level queue to be verified corresponds to 0-1000 yuan.
Correspondingly, the pushing of the contract things meeting the trigger condition to the queue to be verified according to the preset time interval includes: and pushing the contract things meeting the trigger conditions to a to-be-verified queue corresponding to the type of the contract things according to a preset time interval. So that the verifying node verifies the contract things in the verification queue in the subsequent step. In the embodiment of the invention, after the corresponding to-be-verified queue is determined according to the type of the contract affair, the contract affair in the preset time interval is pushed into the corresponding to-be-verified queue according to the type of the contract affair, so that the contract affair is verified by the verification node in the consensus level corresponding to the to-be-verified queue.
And S20, after the time to be agreed comes, determining the consensus level according to contract things in the queue to be verified within a preset time interval.
And each consensus level corresponds to a plurality of verification nodes, and different consensus levels correspond to different verification nodes. It should be noted that, the number of corresponding verification nodes in different consensus levels is also different, and the higher the consensus level is, the more the number of verification nodes contained therein is; the lower the level of consensus, the fewer the number of verification nodes contained therein. Specifically, the embodiment of the present invention may determine the consensus level according to the user type level, the information security level, and the data type level of the contract thing, and the embodiment of the present invention is not particularly limited.
And S30, packing contract things in the queue to be verified within a preset time interval into a contract set, calculating the hash value of the contract set, and packing the hash value and the contract set into a block structure.
S40, broadcasting the block structure to the verification node corresponding to the consensus level so that the verification node corresponding to the consensus level verifies the contract thing within the block structure.
Specifically, after receiving the block structure, the verification node corresponding to the consensus level decomposes a contract set hash value in the block structure, and compares the hash value with a hash value under the hash set of the verification node; sending a contract set approved by the verification node to other verification nodes in the consensus level, and performing multi-round sending and comparison; all the verification nodes corresponding to the consensus level finally agree on the latest contract set within a specified time. The newly agreed contract sets are spread across the entire network in a block structure. Each block structure contains the following information: hash value of current block, hash value of previous block, timestamp when consensus is achieved, and other description information; the most important information of the block chain in the same time is a contract set with a group of agreed-upon contracts; and the nodes receiving the contract set verify each contract, and the verified contract is finally written into the block chain, wherein the verified content is mainly whether the private key signature of the contract participant is matched with the account.
In an embodiment provided by the present invention, as shown in fig. 3, the verifying node corresponding to the consensus level in step S40 verifies the contract thing in the block structure, including:
s401, determining the verification sequence of each verification node according to the computing capacity of the verification nodes.
In the embodiment of the present invention, after determining the verification order of each verification node according to the computing power of the verification node, the verification nodes need to be ordered, so as to verify the contract things in the block structure according to the order of the verification nodes in the subsequent steps.
S402, sequentially verifying the contract things in the block structure according to the verification sequence of the verification nodes.
Specifically, the sequentially verifying the contract things in the block structure according to the verification sequence of the verification nodes includes: verifying contract things in the block structure by a high-priority verification node, and determining a verification contract set, wherein the verification contract set comprises the contract things meeting the trigger condition, each contract thing corresponds to the number of verification nodes passing, and the number of the verification nodes passing of the contract things is the number of the verification nodes passing the verification of the contract things; and the high-priority verification node sends the verification contract set of the contract things to a next-highest-priority verification node, so that the next-highest-priority verification node verifies the contract things, edits the verification contract set of the contract things, and sends the edited verification contract set of the contract things to a next-level verification node for verification until all verification nodes corresponding to the consensus registration complete the verification of the contract things.
And S50, receiving the verification contract set sent by the verification node corresponding to the consensus level.
The contract things meeting the trigger condition are included in the verification contract set, each contract thing corresponds to the number of verification node passing, and the number of the verification node passing of the contract things is the number of the verification nodes which pass the verification of the contract things.
And S60, acquiring contract things of which the passing number of the verification nodes in the verification contract set exceeds a preset value.
The preset value is determined according to the number of verification nodes corresponding to the consensus level; the higher the consensus level is, the more the number of verification nodes contained in the consensus level is, and the larger the preset value is set; the lower the consensus level, the fewer the number of verification nodes contained therein, and the smaller the corresponding preset value setting.
And S70, confirming that the verification node successfully identifies the data of the contract things with the number exceeding the preset value.
The invention provides a data consensus method of a block chain system, which comprises the steps of firstly pushing contract things meeting triggering conditions into a queue to be verified according to a preset time interval; after the consensus time comes, determining a consensus level according to contract things in a queue to be verified within a preset time interval; then, packing contract things in a queue to be verified within a preset time interval into a contract set, calculating a hash value of the contract set, and packaging the hash value and the contract set into a block structure; broadcasting the block structure to a verification node corresponding to the consensus level so that the verification node corresponding to the consensus level verifies the contract thing in the block structure; and receiving a verification contract set sent by verification nodes corresponding to the consensus level, acquiring contract things of which the passing number of the verification nodes exceeds a preset value in the verification contract set, and finally confirming that the data consensus of the contract things of which the passing number of the verification nodes exceeds the preset value is successful. Compared with the prior art that data consensus requires all verification nodes to participate, the method determines the consensus level according to the contract things in the queue to be verified within the preset time interval, then verifies the contract things according to the verification nodes corresponding to the consensus level, and since the consensus level is determined according to the contract things, the method can verify the contract things based on the importance degree of the contract things, and therefore the efficiency of data consensus of the block chain system can be improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
In an embodiment of the present invention, a data consensus device of a blockchain system is provided, where the data consensus device of the blockchain system corresponds to the data consensus method of the blockchain system in the above embodiments one to one. As shown in fig. 4, the blockchain system at least includes a queue to be verified and a plurality of verification nodes, and the data consensus device of the blockchain system includes: the system comprises a pushing module 10, a determining module 20, an encapsulating module 30, a broadcasting module 40, a receiving module 50 and an acquiring module 60. The functional modules are explained in detail as follows:
the pushing module 10 is used for pushing the contract things meeting the triggering conditions to a queue to be verified according to a preset time interval; a plurality of contract things waiting for consensus are stored in the queue to be verified;
a determining module 20, configured to determine a consensus level according to a contract thing in the to-be-verified queue within the preset time interval after a to-be-consensus time arrives, where each consensus level corresponds to multiple verification nodes, and different consensus levels correspond to different verification nodes;
the encapsulation module 30 is configured to encapsulate the contract things in the queue to be verified within the preset time interval into a contract set, calculate a hash value of the contract set, and encapsulate the hash value and the contract set into a block structure;
a broadcast module 40 for broadcasting the block structure to a verification node corresponding to the consensus level so that the verification node corresponding to the consensus level verifies contract things within the block structure;
a receiving module 50, configured to receive a verification contract set sent by a verification node corresponding to the consensus level, where the verification contract set includes the contract things meeting the trigger condition, each contract thing corresponds to a verification node passing number, and the verification node passing number of the contract things is the number of verification nodes that verify the contract things;
an obtaining module 60, configured to obtain a contract thing in which the number of passing verification nodes in the verification contract set exceeds a preset value, where the preset value is determined according to the number of verification nodes corresponding to the consensus level;
the determining module 20 is further configured to confirm that the verification node succeeds in data consensus of the contract things of which the number exceeds a preset value.
Further, the pushing module 10 includes:
the traversing unit 11 is configured to traverse the state machine and the trigger condition corresponding to each contract thing item by item; the state machine records transaction states corresponding to the first-stage transaction node and the second-stage transaction node respectively; the triggering condition is that the first-stage transaction node and the second-stage transaction node both succeed in transaction;
and the pushing unit 12 is configured to push the contract things that the first-stage transaction and the second-stage transaction nodes both succeed in transaction into the queue to be verified.
Further, the determining module 20 is further configured to determine a type of the contract event, and determine corresponding queues to be verified according to the type of the contract event, where each queue to be verified stores a contract event of a corresponding type;
the pushing module 10 is specifically configured to push the contract things meeting the trigger condition to a to-be-verified queue corresponding to the type of the contract things according to a preset time interval.
The determining module 20 is specifically configured to determine a consensus level according to the user type level, the information security level, and the data type level of the contract thing.
Further, the apparatus further comprises:
the verification module 70 is configured to determine a verification sequence of each verification node according to the computing capability of the verification node; and verifying the contract things in the block structure according to the verification sequence of the verification nodes.
The verification module 70 is specifically configured to verify the contract things in the block structure by a high-priority verification node, and determine a verification contract set, where the verification contract set includes the contract things meeting the trigger condition, each contract thing corresponds to a verification node passing number, and the verification node passing number of the contract things is the number of verification nodes that verify the contract things; and the high-priority verification node sends the verification contract set of the contract things to a next-highest-priority verification node, so that the next-highest-priority verification node verifies the contract things, edits the verification contract set of the contract things, and sends the edited verification contract set of the contract things to a next-level verification node for verification until all verification nodes corresponding to the consensus registration complete the verification of the contract things.
For the specific limitation of the data consensus device of the blockchain system, reference may be made to the above limitation of the data consensus method of the blockchain system, which is not described herein again. The modules in the data consensus device of the above-described blockchain system may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 5. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a data consensus method for a blockchain system.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
pushing contract things meeting the trigger condition to a queue to be verified according to a preset time interval; a plurality of contract things waiting for consensus are stored in the queue to be verified;
after the consensus time arrives, determining consensus levels according to contract things in the queue to be verified within the preset time interval, wherein each consensus level corresponds to a plurality of verification nodes, and different consensus levels correspond to different verification nodes;
packing contract things in the queue to be verified within the preset time interval into a contract set, calculating a hash value of the contract set, and packaging the hash value and the contract set into a block structure;
broadcasting the block structure to a verification node corresponding to the consensus level such that the verification node corresponding to the consensus level verifies contract things within the block structure;
receiving a verification contract set sent by verification nodes corresponding to the consensus level, wherein the verification contract set comprises contract things meeting the trigger condition, each contract thing corresponds to a verification node passing number, and the verification node passing number of the contract things is the number of the verification nodes which pass the verification of the contract things;
acquiring contract things of which the passing number of verification nodes exceeds a preset value in the verification contract set, wherein the preset value is determined according to the number of the verification nodes corresponding to the consensus level;
and confirming that the verification node succeeds in data consensus through the contract things of which the number exceeds the preset value.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
pushing contract things meeting the trigger condition to a queue to be verified according to a preset time interval; a plurality of contract things waiting for consensus are stored in the queue to be verified;
after the consensus time arrives, determining consensus levels according to contract things in the queue to be verified within the preset time interval, wherein each consensus level corresponds to a plurality of verification nodes, and different consensus levels correspond to different verification nodes;
packing contract things in the queue to be verified within the preset time interval into a contract set, calculating a hash value of the contract set, and packaging the hash value and the contract set into a block structure;
broadcasting the block structure to a verification node corresponding to the consensus level such that the verification node corresponding to the consensus level verifies contract things within the block structure;
receiving a verification contract set sent by verification nodes corresponding to the consensus level, wherein the verification contract set comprises contract things meeting the trigger condition, each contract thing corresponds to a verification node passing number, and the verification node passing number of the contract things is the number of the verification nodes which pass the verification of the contract things;
acquiring contract things of which the passing number of verification nodes exceeds a preset value in the verification contract set, wherein the preset value is determined according to the number of the verification nodes corresponding to the consensus level;
and confirming that the verification node succeeds in data consensus through the contract things of which the number exceeds the preset value. It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.
Claims (10)
1. A data consensus method for a blockchain system, the blockchain system comprising at least one queue to be verified and a plurality of verification nodes, the method comprising:
pushing contract things meeting the trigger condition to a queue to be verified according to a preset time interval; a plurality of contract things waiting for consensus are stored in the queue to be verified;
after the consensus time arrives, determining consensus levels according to contract things in the queue to be verified within the preset time interval, wherein each consensus level corresponds to a plurality of verification nodes, and different consensus levels correspond to different verification nodes;
packing contract things in the queue to be verified within the preset time interval into a contract set, calculating a hash value of the contract set, and packaging the hash value and the contract set into a block structure;
broadcasting the block structure to a verification node corresponding to the consensus level such that the verification node corresponding to the consensus level verifies contract things within the block structure;
receiving a verification contract set sent by verification nodes corresponding to the consensus level, wherein the verification contract set comprises contract things meeting the trigger condition, each contract thing corresponds to a verification node passing number, and the verification node passing number of the contract things is the number of the verification nodes which pass the verification of the contract things;
acquiring contract things of which the passing number of verification nodes exceeds a preset value in the verification contract set, wherein the preset value is determined according to the number of the verification nodes corresponding to the consensus level;
and confirming that the verification node succeeds in data consensus through the contract things of which the number exceeds the preset value.
2. The data consensus method of the blockchain system of claim 1, wherein the pushing of the contract things meeting the trigger condition into the queue to be verified at a preset time interval comprises:
traversing the state machine and the triggering condition corresponding to each contract thing item one by one; the state machine records transaction states corresponding to the first-stage transaction node and the second-stage transaction node respectively; the triggering condition is that the first-stage transaction node and the second-stage transaction node both succeed in transaction;
and pushing the contract things of which the first-stage transaction and the second-stage transaction nodes are successful to the queue to be verified.
3. The data consensus method of a blockchain system according to claim 1, wherein before pushing the contractual matters satisfying the trigger condition into the queue to be verified at a preset time interval, the method further comprises:
determining the type of the contract affair, and determining corresponding queues to be verified according to the type of the contract affair, wherein each queue to be verified correspondingly stores the contract affair of the corresponding type;
the method for pushing the contract things meeting the trigger condition to the queue to be verified according to the preset time interval comprises the following steps:
and pushing the contract things meeting the trigger conditions to a to-be-verified queue corresponding to the type of the contract things according to a preset time interval.
4. The method for data consensus of a blockchain system according to claim 3, wherein said determining a consensus level according to a contract thing in the queue to be verified within the preset time interval comprises:
and determining a consensus level according to the user type level, the information security level and the data type level of the contract thing.
5. The method of claim 4, wherein verifying the contract things in the block structure by the verification node corresponding to the consensus level comprises:
determining the verification sequence of each verification node according to the computing capacity of the verification node;
and verifying the contract things in the block structure according to the verification sequence of the verification nodes.
6. The method for data consensus of a blockchain system according to claim 4, wherein said verifying contract things in the blockchain system according to the sequence of the verification order of the verification nodes comprises:
verifying contract things in the block structure by a high-priority verification node, and determining a verification contract set, wherein the verification contract set comprises the contract things meeting the trigger condition, each contract thing corresponds to the number of verification nodes passing, and the number of the verification nodes passing of the contract things is the number of the verification nodes passing the verification of the contract things;
and the high-priority verification node sends the verification contract set of the contract things to a next-highest-priority verification node, so that the next-highest-priority verification node verifies the contract things, edits the verification contract set of the contract things, and sends the edited verification contract set of the contract things to a next-level verification node for verification until all verification nodes corresponding to the consensus registration complete the verification of the contract things.
7. A data consensus device for a blockchain system, the blockchain system comprising at least one queue to be verified and a plurality of verification nodes, the device comprising:
the pushing module is used for pushing the contract things meeting the triggering conditions to a queue to be verified according to a preset time interval; a plurality of contract things waiting for consensus are stored in the queue to be verified;
the determining module is used for determining consensus levels according to contract things in the to-be-verified queue within the preset time interval after the to-be-verified time arrives, each consensus level corresponds to a plurality of verification nodes, and different consensus levels correspond to different verification nodes;
the encapsulation module is used for encapsulating the contract things in the queue to be verified within the preset time interval into a contract set, calculating the hash value of the contract set, and encapsulating the hash value and the contract set into a block structure;
a broadcast module for broadcasting the block structure to a verification node corresponding to the consensus level so that the verification node corresponding to the consensus level verifies contract things within the block structure;
the receiving module is used for receiving a verification contract set sent by a verification node corresponding to the consensus level, the verification contract set comprises contract things meeting the trigger condition, each contract thing corresponds to a verification node passing number, and the verification node passing number of the contract things is the number of the verification nodes which pass the verification of the contract things;
the acquisition module is used for acquiring contract things of which the passing number of the verification nodes in the verification contract set exceeds a preset value, and the preset value is determined according to the number of the verification nodes corresponding to the consensus level;
the determining module is further configured to confirm that the verification node succeeds in data consensus of the contract things of which the number exceeds a preset value.
8. The apparatus for data consensus of a blockchain system according to claim 7, wherein the push module comprises:
the traversing unit is used for traversing the state machine and the triggering condition corresponding to each contract thing one by one; the state machine records transaction states corresponding to the first-stage transaction node and the second-stage transaction node respectively; the triggering condition is that the first-stage transaction node and the second-stage transaction node both succeed in transaction;
and the pushing unit is used for pushing the contract things which are successfully transacted by the first-stage transaction node and the second-stage transaction node into the queue to be verified.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the data consensus method of the blockchain system of any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, implements a data consensus method of a blockchain system according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010025028.6A CN111131329A (en) | 2020-01-04 | 2020-01-04 | Data consensus method and device for block chain system and hardware equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010025028.6A CN111131329A (en) | 2020-01-04 | 2020-01-04 | Data consensus method and device for block chain system and hardware equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111131329A true CN111131329A (en) | 2020-05-08 |
Family
ID=70487897
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010025028.6A Pending CN111131329A (en) | 2020-01-04 | 2020-01-04 | Data consensus method and device for block chain system and hardware equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111131329A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112435120A (en) * | 2020-11-05 | 2021-03-02 | 德州职业技术学院(德州市技师学院) | Block chain data supervision method and system |
CN112598524A (en) * | 2021-02-26 | 2021-04-02 | 北京全息智信科技有限公司 | Processing method and device for conditional block chain transaction and electronic equipment |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180276668A1 (en) * | 2017-03-24 | 2018-09-27 | Alibaba Group Holding Limited | Method and apparatus for consensus verification |
CN109087111A (en) * | 2018-08-31 | 2018-12-25 | 深圳付贝科技有限公司 | Common recognition verification method, digging mine machine and block catenary system based on block chain |
CN110602116A (en) * | 2019-09-19 | 2019-12-20 | 腾讯科技(深圳)有限公司 | Block chain based data verification method, device and computer readable storage medium |
CN110647582A (en) * | 2019-09-17 | 2020-01-03 | 腾讯科技(深圳)有限公司 | Method and device for block chain network consensus checking, storage medium and computer equipment |
-
2020
- 2020-01-04 CN CN202010025028.6A patent/CN111131329A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180276668A1 (en) * | 2017-03-24 | 2018-09-27 | Alibaba Group Holding Limited | Method and apparatus for consensus verification |
CN109087111A (en) * | 2018-08-31 | 2018-12-25 | 深圳付贝科技有限公司 | Common recognition verification method, digging mine machine and block catenary system based on block chain |
CN110647582A (en) * | 2019-09-17 | 2020-01-03 | 腾讯科技(深圳)有限公司 | Method and device for block chain network consensus checking, storage medium and computer equipment |
CN110602116A (en) * | 2019-09-19 | 2019-12-20 | 腾讯科技(深圳)有限公司 | Block chain based data verification method, device and computer readable storage medium |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112435120A (en) * | 2020-11-05 | 2021-03-02 | 德州职业技术学院(德州市技师学院) | Block chain data supervision method and system |
CN112435120B (en) * | 2020-11-05 | 2023-01-31 | 德州职业技术学院(德州市技师学院) | Block chain data supervision method and system |
CN112598524A (en) * | 2021-02-26 | 2021-04-02 | 北京全息智信科技有限公司 | Processing method and device for conditional block chain transaction and electronic equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111061769B (en) | Consensus method of block chain system and related equipment | |
CN111382456B (en) | Proposal message processing method, device, equipment and storage medium | |
CN111026767B (en) | Block chain data storage method and device and hardware equipment | |
WO2022217807A1 (en) | Blockchain consensus node selection method and apparatus, and computer device and storage medium | |
CN112862490B (en) | Output consensus method under asynchronous network | |
CN110992178A (en) | Verification method and device for block chain node, computer equipment and storage medium | |
CN111080455A (en) | Cross-border transaction method and device based on block chain and hardware equipment | |
CN111131329A (en) | Data consensus method and device for block chain system and hardware equipment | |
CN111899019A (en) | Method and system for cross validation and sharing of blacklist and multiple parties | |
CN110599267A (en) | Electronic invoice billing method and device, computer readable storage medium and computer equipment | |
CN111260475A (en) | Data processing method, block chain node point equipment and storage medium | |
CN111311254A (en) | Service processing method, device and system based on block chain | |
CN112398949A (en) | Transaction confirmation method, system, device and computer equipment | |
CN109766316A (en) | File acquisition method, device, computer equipment and storage medium | |
CN115701078B (en) | Cross-chain transaction processing method, device, electronic equipment and storage medium | |
CN110933022A (en) | Block processing method and device, computer equipment and storage medium | |
CN113111125B (en) | Business evidence-storing method based on block chain | |
CN110647439A (en) | Method and device for confirming block chain system deployment, computer equipment and storage medium | |
CN114090693A (en) | Byzantine fault-tolerant-based block chain witness consensus method, system, equipment and storage medium | |
CN111524009A (en) | Transaction verification method and device for blockchain system and hardware equipment | |
CN115988001A (en) | Consensus voting processing method, device, equipment and medium for block chain system | |
CN117195129A (en) | Exception handling method based on sandbox system and related equipment | |
CN112700333A (en) | Electronic archive consensus method based on block chain | |
CN111552989A (en) | Service data processing method, device, equipment and storage medium based on block chain | |
CN111177262A (en) | Block chain consensus method, related device and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20200508 |