CN111507840A - Block chain consensus method, device, computer and readable storage medium - Google Patents

Block chain consensus method, device, computer and readable storage medium Download PDF

Info

Publication number
CN111507840A
CN111507840A CN202010295981.2A CN202010295981A CN111507840A CN 111507840 A CN111507840 A CN 111507840A CN 202010295981 A CN202010295981 A CN 202010295981A CN 111507840 A CN111507840 A CN 111507840A
Authority
CN
China
Prior art keywords
consensus
stage
block
result
local
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.)
Granted
Application number
CN202010295981.2A
Other languages
Chinese (zh)
Other versions
CN111507840B (en
Inventor
刘攀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tenpay Payment Technology Co Ltd
Original Assignee
Tenpay Payment Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Tenpay Payment Technology Co Ltd filed Critical Tenpay Payment Technology Co Ltd
Priority to CN202010295981.2A priority Critical patent/CN111507840B/en
Publication of CN111507840A publication Critical patent/CN111507840A/en
Application granted granted Critical
Publication of CN111507840B publication Critical patent/CN111507840B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction

Abstract

The embodiment of the application discloses a block chain consensus method, a block chain consensus device, a computer and a readable storage medium, wherein the block chain consensus method comprises the following steps: in a first-stage consensus period, obtaining first-stage consensus results aiming at the transaction blocks, which are sent by at least two consensus nodes; determining the number of the first-stage voting results according to the local consensus result, the first-stage consensus result and the first-stage consensus result aiming at the transaction block; if the number of the voting results of the first stage is smaller than a first number threshold, generating a local empty block of the second stage; broadcasting the second-stage local empty block to at least two consensus nodes in a second-stage consensus period to obtain second-stage consensus results sent by the at least two consensus nodes; and determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result. By the method and the device, the efficiency of block chain consensus can be improved.

Description

Block chain consensus method, device, computer and readable storage medium
Technical Field
The present application relates to the field of blockchain technologies, and in particular, to a blockchain consensus method, apparatus, computer and readable storage medium.
Background
With the increasing maturity of the blockchain technology and the characteristics of decentralization of the blockchain, the application of the blockchain is increasingly widespread, wherein at present, the acquired transaction blocks are identified together through a common identification node in the blockchain, and the uplink result of the transaction block is determined according to the common identification result, so as to ensure the security of blockchain data. Therefore, in order to better ensure the decentralized nature of the blockchain and the security of the blockchain data, the management of the blockchain consensus becomes an important issue. At present, when a transaction block is linked in a blockchain, a common identification node in a blockchain network performs common identification on the transaction block, only when the transaction block passes the common identification, the transaction block is added to the blockchain, the linking result of the transaction block is determined to be a successful linking result, and abnormal conditions (such as network factors and the like) may occur in the process of performing common identification on the transaction block by a common identification node, so that whether the transaction block passes the common identification or not cannot be determined, that is, the linking result of the transaction block cannot be determined, the common identification process for the transaction block is interrupted, and the efficiency of blockchain common identification is reduced.
Disclosure of Invention
The embodiment of the application provides a block chain consensus method and device, which can improve the block chain consensus efficiency.
An aspect of the present embodiment provides a block chain consensus method, including:
in a first-stage consensus period, obtaining first-stage consensus results aiming at the transaction blocks, which are sent by at least two consensus nodes;
determining the number of first-stage voting results according to the local consensus result aiming at the transaction block and the first-stage consensus result;
if the number of the voting results of the first stage is smaller than a first number threshold, generating a local empty block of the second stage; the second stage local empty block is a block with empty transaction data;
broadcasting the second-stage local empty block to the at least two consensus nodes in a second-stage consensus period to obtain second-stage consensus results sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period both belong to a consensus period for the transaction block, the first-stage consensus period being earlier than the second-stage consensus period;
and determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
Wherein, the method further comprises:
counting the number of first-stage voting empty blocks in the first-stage consensus result if the number of the first-stage voting results is greater than or equal to the first number threshold; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet a consensus condition from the at least two consensus nodes;
determining the number of first empty blocks according to the local consensus result and the number of the first-stage voting empty blocks;
and if the number of the first empty blocks is larger than a second number threshold, generating the second-stage local empty blocks.
Wherein, the determining the number of the first empty blocks according to the local consensus result and the number of the first-stage voting empty blocks includes:
determining the number of the first-stage voting empty blocks as the first empty block number if the local consensus result is a block voting success result for the transaction block;
and if the local consensus result is a first-stage local empty block, taking the sum of the number of the first-stage local empty blocks and the number of the first-stage voting empty blocks as the number of the first empty blocks.
Wherein, the method further comprises:
and if the transaction block is not acquired in the first-stage consensus period, generating the first-stage local null block, using the first-stage local null block as the local consensus result, and broadcasting the local consensus result to the at least two consensus nodes.
Wherein, the method further comprises:
if the transaction block is acquired in the first-stage consensus period, verifying the transaction block;
if the transaction block passes the verification, generating a block voting success result aiming at the transaction block, taking the block voting success result aiming at the transaction block as the local consensus result, and broadcasting the local consensus result to the at least two consensus nodes;
and if the transaction block is not verified, generating the first-stage local empty block, using the first-stage local empty block as the local consensus result, and broadcasting the local consensus result to the at least two consensus nodes.
Wherein, the method further comprises:
counting the number of first-stage voting success results in the first-stage consensus results if the number of the first-stage voting results is greater than or equal to the first number threshold; the successful result of the first-stage voting is generated by the consensus node which detects that the transaction block meets the consensus condition in the at least two consensus nodes;
determining a first voting success quantity according to the local consensus result and the quantity of the first-stage voting success results;
if the first voting success quantity is greater than or equal to the first quantity threshold, generating a second-stage local consensus success result, broadcasting the second-stage local consensus success result to the at least two consensus nodes, and acquiring second-stage consensus results sent by the at least two consensus nodes;
and determining the uplink result of the transaction block according to the second-stage local consensus success result and the second-stage consensus result.
Wherein, the determining a first voting success number according to the local consensus result and the number of the first-stage voting success results includes:
if the local consensus result is a block voting success result for the transaction block, taking the sum of the local consensus result and the number of the first-stage voting success results as the first voting success number;
and if the local consensus result is a first-stage local empty block, determining the number of the first-stage voting success results as the first voting success number.
Wherein the determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result includes:
taking the number of successful results of the second stage consensus in the second stage consensus results as a second successful voting number;
if the second voting success number is larger than or equal to the first number threshold, uploading the transaction block to a block chain, and determining the uplink result of the transaction block as an uplink success result;
if the second voting success number is smaller than the first number threshold, deleting the transaction block, and determining the uplink result of the transaction block as the uplink failure result.
Wherein the determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result includes:
counting the number of second-stage consensus null blocks in the second-stage consensus result;
taking the sum of the number of the second-stage local empty blocks and the number of the second-stage consensus empty blocks as the number of second empty blocks;
and if the second empty block quantity is larger than a second quantity threshold, deleting the transaction block, and determining the uplink result of the transaction block as an uplink failure result.
Wherein the determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result includes:
determining the number of voting results in the second stage according to the consensus results of the local empty blocks in the second stage and the second stage;
if the second-stage voting result quantity is smaller than the first quantity threshold, deleting the transaction block, and determining the uplink result of the transaction block as the uplink failure result.
Wherein, the method further comprises:
if the uplink result of the transaction block is an uplink failure result, acquiring a block generating node of the transaction block;
adding the block generating node to an authority limit node set; the permission limiting node set comprises common nodes without block generation permission;
and acquiring the storage duration of the block generation node in the permission limit set, and deleting the block generation node in the permission limit set and recovering the generated block permission of the block generation node if the storage duration is greater than the permission limit time.
An aspect of the present application provides a block chain consensus device, where the block chain consensus device includes:
the consensus acquisition module is used for acquiring first-stage consensus results aiming at the transaction blocks, which are sent by at least two consensus nodes, in a first-stage consensus period;
a voting quantity determining module, configured to determine a first-stage voting result quantity according to the local consensus result for the transaction block and the first-stage consensus result;
a first empty block generation module, configured to generate a second-stage local empty block if the number of the first-stage voting results is smaller than a first number threshold; the second stage local empty block is a block with empty transaction data;
a first consensus interaction module, configured to broadcast the second-stage local empty block to the at least two consensus nodes in a second-stage consensus period, and obtain second-stage consensus results sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period both belong to a consensus period for the transaction block, the first-stage consensus period being earlier than the second-stage consensus period;
and a cochain result determining module for determining a cochain result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
Wherein, above-mentioned device still includes:
a null block counting module, configured to count the number of first-stage voting null blocks in the first-stage consensus result if the number of first-stage voting results is greater than or equal to the first number threshold; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet a consensus condition from the at least two consensus nodes;
the empty block counting module is further configured to determine a first empty block number according to the local consensus result and the number of the first-stage voting empty blocks;
and the second empty block generation module is used for generating the second-stage local empty block if the number of the first empty blocks is greater than a second number threshold.
Wherein, in the aspect of determining the number of the first empty blocks according to the local consensus result and the number of the first-stage voting empty blocks, the empty block counting module includes:
a first number determining unit, configured to determine the number of the first-stage voting empty blocks as the first number of empty blocks if the local consensus result is a successful block voting result for the transaction block;
the first quantity determining unit is further configured to, if the local consensus result is a first-stage local empty block, determine a sum of the first-stage local empty block and the first-stage voting empty block as the first empty block quantity.
Wherein, above-mentioned device still includes:
and a second consensus interaction module, configured to generate the first-stage local null block if the transaction block is not obtained in the first-stage consensus period, use the first-stage local null block as the local consensus result, and broadcast the local consensus result to the at least two consensus nodes.
Wherein, above-mentioned device still includes:
the block verification module is used for verifying the transaction block if the transaction block is acquired in the first-stage consensus period;
a first result generating module, configured to generate a block voting success result for the transaction block if the transaction block is verified, use the block voting success result for the transaction block as the local consensus result, and broadcast the local consensus result to the at least two consensus nodes;
and a third empty block generation module, configured to generate the first-stage local empty block if the transaction block is not verified, use the first-stage local empty block as the local consensus result, and broadcast the local consensus result to the at least two consensus nodes.
Wherein, above-mentioned device still includes:
a success counting module, configured to count the number of first-stage voting success results in the first-stage consensus result if the number of first-stage voting results is greater than or equal to the first number threshold; the successful result of the first-stage voting is generated by the consensus node which detects that the transaction block meets the consensus condition in the at least two consensus nodes;
the success counting module is further configured to determine a first successful voting number according to the local consensus result and the number of the first-stage successful voting results;
a second result generation module, configured to generate a second-stage local consensus successful result if the first voting success number is greater than or equal to the first number threshold, broadcast the second-stage local consensus successful result to the at least two consensus nodes, and obtain a second-stage consensus result sent by the at least two consensus nodes;
the uplink result determining module is configured to determine the uplink result of the transaction block according to the second-stage local consensus success result and the second-stage consensus result.
Wherein, in the aspect of determining the first voting success number according to the local consensus result and the number of the first-stage voting success results, the success counting module includes:
a second quantity determination unit, configured to determine, if the local consensus result is a block voting success result for the transaction block, a sum of the local consensus result and the first-stage voting success result as the first voting success quantity;
the second quantity determining unit is further configured to determine, if the local consensus result is a first-stage local empty block, the quantity of the first-stage voting success results as the first voting success quantity.
Wherein, the uplink result determining module comprises:
a third quantity determining unit, configured to use the quantity of the second-stage consensus successful results in the second-stage consensus results as a second voting success quantity;
a successful uplink determining unit, configured to upload the transaction block into a block chain if the second voting success number is greater than or equal to the first number threshold, and determine that an uplink result of the transaction block is a successful uplink result;
and an uplink failure determining unit, configured to delete the transaction block if the second voting success number is smaller than the first number threshold, and determine that an uplink result of the transaction block is an uplink failure result.
Wherein, the uplink result determining module comprises:
a number counting unit of empty blocks, configured to count the number of second-stage consensus empty blocks in the second-stage consensus result;
the number statistical unit of the empty blocks is further configured to use a sum of the number of the second-stage local empty blocks and the number of the second-stage consensus empty blocks as a second empty block number;
the uplink failure determining unit is further configured to delete the transaction block if the second number of empty blocks is greater than a second number threshold, and determine that the uplink result of the transaction block is an uplink failure result.
Wherein, the uplink result determining module comprises:
a voting result counting unit, configured to determine the number of second-stage voting results according to the second-stage local empty block and the second-stage consensus result;
the uplink failure determining unit is further configured to delete the transaction block if the number of the second-stage voting results is smaller than the first number threshold, and determine that the uplink result of the transaction block is an uplink failure result.
Wherein, above-mentioned device still includes:
a generation node obtaining module, configured to obtain a block generation node of the transaction block if the uplink result of the transaction block is an uplink failure result;
a node adding module, configured to add the block generation node to an authority limit node set; the permission limiting node set comprises common nodes without block generation permission;
and the authority updating module is used for acquiring the storage duration of the block generating node in the authority limit set, deleting the block generating node in the authority limit set if the storage duration is longer than the authority limit time, and recovering the generated block authority of the block generating node.
One aspect of the embodiments of the present application provides a computer device, including a processor, a memory, and an input/output interface;
the processor is respectively connected to the memory and the input/output interface, where the input/output interface is used for data interaction of each node in a block chain, the memory is used for storing a program code, and the processor is used for calling the program code to execute the block chain consensus method implemented in one aspect of the embodiments of the present application.
An aspect of the present embodiments provides a computer-readable storage medium storing a computer program, where the computer program includes program instructions, and the program instructions, when executed by a processor, perform a block chain consensus method as implemented in an aspect of the present embodiments.
The embodiment of the application has the following beneficial effects:
in the embodiment of the application, the first-stage consensus results aiming at the transaction block and sent by at least two consensus nodes are obtained in the first-stage consensus period; determining the number of the first-stage voting results according to the local consensus result, the first-stage consensus result and the first-stage consensus result aiming at the transaction block; if the number of the voting results of the first stage is smaller than a first number threshold, generating a local empty block of the second stage; broadcasting the second-stage local empty block to at least two consensus nodes in a second-stage consensus period to obtain second-stage consensus results sent by the at least two consensus nodes; and determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result. The acquired transaction blocks are subjected to consensus twice, and each consensus stage limits time, namely the transaction blocks are subjected to consensus in the first stage consensus period and the second stage consensus period, so that even if an abnormal condition occurs in the consensus process of the transaction blocks, and a chain link result of the transaction blocks cannot be determined, the consensus process is not interrupted, a null block is generated, and the null block is used as a local consensus result of a corresponding stage, so that a local node can continuously execute a subsequent consensus process of the transaction blocks, and the efficiency of block chain consensus is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic diagram of a blockchain consensus network according to an embodiment of the present disclosure;
fig. 2 is a block chain consensus architecture diagram according to an embodiment of the present disclosure;
fig. 3 is a schematic diagram of a block chain consensus scenario provided in an embodiment of the present application;
fig. 4 is a flowchart of a block chain consensus method according to an embodiment of the present disclosure;
fig. 5 is a block chain consensus flowchart according to an embodiment of the present disclosure;
fig. 6 is a schematic diagram of a first-stage local consensus result generation scenario provided in an embodiment of the present application;
fig. 7 is a diagram illustrating an uplink result determination scenario according to an embodiment of the present application;
fig. 8 is a schematic diagram of a block chain consensus apparatus according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. 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 application.
In the embodiment of the present invention, blockchain consensus is performed, specifically, a received transaction block is verified by two stages of consensus, and when the transaction block passes after the two stages of consensus, the transaction block is linked up, wherein some of the terms mentioned in the embodiment of the present invention are introduced.
1. Block chains: in a narrow sense, a block chain is a chain data structure taking a block as a basic unit, and the prior transaction history is verified by utilizing a digital abstract in the block, so that the block chain is suitable for the requirements of tamper resistance and expandability under a distributed accounting scene; in a broad sense, blockchain also refers to distributed accounting techniques implemented by blockchain architecture, including distributed consensus, privacy and security protection, peer-to-peer communication techniques, network protocols, intelligent contracts, and the like. The goal of the blockchain is to implement a distributed data record ledger that allows only additions and not deletions. The basic structure of the ledger bottom layer is a linear linked list. The linked list is composed of a series of 'blocks', the Hash (Hash) value of the previous block is recorded in the subsequent block, and whether each block (and the transaction in the block) is legal or not can be quickly checked by calculating the Hash value. If a node in the network proposes to add a new block, the block must be acknowledged through a consensus mechanism.
2. Block (Block): all transactions and status results, etc. occurring over a period of time are recorded, which is a consensus on the current ledger status. Specifically, for a block chain, each time data is written, i.e. the above transaction process, a block is created. The block is composed of a block head and a block body, transaction data is stored in the block body, and the block head records a hash value, a block height, a time stamp and the like corresponding to the block body. The empty block in the embodiment of the present application is a block whose block body is empty, or a block whose block head and block body are both empty, or may be empty data.
3. And (3) consensus nodes: nodes that can agree on the received transaction block, each of which can be considered to form an agreement network. Wherein, each transaction block can be added into the block chain for storage only after passing the consensus of the consensus node.
Referring to fig. 1, fig. 1 is a schematic diagram of a blockchain consensus network according to an embodiment of the present disclosure, as shown in fig. 1, a consensus network 100 refers to a network for sharing data between consensus nodes and consensus nodes, and each of the consensus nodes can perform consensus on an obtained transaction block, where the consensus network 100 may include a plurality of consensus nodes 101, and the plurality of consensus nodes 101 may refer to each computer device in the consensus network 100. Wherein each consensus node 101 may receive input information during normal operation and maintain shared data within the consensus network 100 based on the received input information. In order to ensure information intercommunication in the consensus network 100, information connections may exist between the consensus nodes 101 in the consensus network 100, and information transmission may be performed between the consensus nodes 101 through the information connections. For example, when any consensus node in the consensus network 100 receives input information, other consensus nodes in the consensus network 100 acquire the input information according to a consensus algorithm, perform consensus on the input information, and after the input information is successfully identified, store the input information as data in shared data, so that the data stored in all the consensus nodes in the consensus network 100 are consistent, and the data stored in each consensus node is identified, thereby improving the security of the data in the block chain.
The computer device may be a server or a terminal device, or a system composed of a server and a terminal device, where the terminal device may be an electronic device including, but not limited to, a mobile phone, a tablet computer, a desktop computer, a notebook computer, a palm computer, a Mobile Internet Device (MID), a wearable device (e.g., a smart watch, a smart band, etc.), and the like.
Each of the consensus nodes 101 in the consensus network 100 may have a node identifier corresponding thereto, and each of the consensus nodes in the consensus network 100 stores node identifiers of other consensus nodes in the consensus network 100, so that the generated transaction block or the consensus result for the transaction block may be broadcast to other consensus nodes in the consensus network 100 according to the node identifiers of other consensus nodes in the following. For any one consensus node, a node identifier list may be maintained, where the node identifier list includes node identifiers of other consensus nodes in the consensus network 100, and a consensus node name corresponding to the node identifier. The node identifier may be an IP (Internet Protocol ) address and any other information (such as a factory identifier of the consensus node) that can be used to identify the consensus node. The common nodes 101 in the common network 100 may also interact with each other through other network interconnection methods.
Further, please refer to fig. 2, wherein fig. 2 is a block chain consensus architecture diagram according to an embodiment of the present application. The consensus network comprises a plurality of consensus nodes, and any one of the consensus nodes in the consensus network can be used as an execution subject in the embodiment of the present application, wherein when any one of the consensus nodes is used as the execution subject in the embodiment of the present application, each step in the embodiment of the present application can be executed to perform consensus on the transaction blocks. The plurality of consensus nodes included in the consensus network may include a local node and at least two consensus nodes, where the local node is any one of the plurality of consensus nodes, and the at least two consensus nodes belong to other consensus nodes except the local node among the plurality of consensus nodes in the consensus network.
Specifically, as shown in fig. 2, the plurality of consensus nodes included in the consensus network include a local node 201 and at least two consensus nodes, such as a consensus node 202a, a consensus node 202b, and a consensus node 202c, and data interaction may be performed between the consensus nodes. The local node 201 obtains a first-stage consensus result for the transaction block sent by at least two consensus nodes in a first-stage consensus period for performing consensus on the transaction block, wherein the at least two consensus nodes belong to other consensus nodes except the local node 201 in the plurality of consensus nodes. After the local node 201 obtains the first-stage consensus result of the consensus node 202a, the first-stage consensus result of the consensus node 202b, and the first-stage consensus result of the consensus node 202c, the sum of the local consensus result of the local node 201 for the transaction block and the number of the first-stage consensus results sent by at least two consensus nodes is used as the first-stage voting result number. When the number of the first-stage voting results is smaller than the first number threshold, the local node 201 generates a second-stage local empty block for the transaction block, where the second-stage local empty block is a block whose transaction data is empty, and the first number threshold is a minimum number of block voting success results of the consensus node that the transaction blocks need to acquire successfully agree, that is, the transaction block can be added to the block chain only when the number of the block voting success results for the transaction block reaches the first number threshold. When the consensus node 202a determines that the transaction block is correct (i.e., approves the transaction block), a block voting success result for the transaction block is generated.
In the second-stage consensus period, the local node 201 broadcasts the generated second-stage local null block to other consensus nodes in the consensus network except the local node 201 (that is, the local node 201 sends the second-stage local null block to the consensus node 202a, the consensus node 202b, and the consensus node 202c), and obtains second-stage consensus results sent by at least two consensus nodes. The local node 201 determines the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result, for example, when the number of the second-stage consensus success results in the second-stage consensus result is greater than or equal to the first number threshold, determining the uplink result of the transaction block as the uplink success result; and when the sum of the number of the second-stage local empty blocks and the second-stage common-identification empty blocks in the second-stage common-identification result is greater than a second number threshold, determining that the uplink result of the transaction block is an uplink failure result. In the embodiment of the present application, the time used for the consensus process for one transaction block may be regarded as a consensus period, the consensus period includes a first-stage consensus period and a second-stage consensus period, the consensus process includes a first stage and a second stage, the maximum duration corresponding to the first stage is the first-stage consensus period, and the maximum duration corresponding to the second stage is the second-stage consensus period.
It is understood that the method provided by the embodiment of the present application may be executed by a computer device, that is, the local node 201 may be a computer device, and other consensus nodes in the consensus network except the local node 201 may also be computer devices, and the computer devices include, but are not limited to, terminal devices or servers.
Further, please refer to fig. 3, wherein fig. 3 is a schematic diagram of a block chain consensus scenario provided in an embodiment of the present application. As shown in fig. 3, the consensus node 3011 generates a first-stage consensus result 3021 for the transaction block, and broadcasts the first-stage consensus result 3021 to other consensus nodes in the consensus network; the consensus node 3012 generates a first-stage consensus result 3022 for the transaction block, and broadcasts the first-stage consensus result 3022 to other consensus nodes in the consensus network; the consensus node 3013 generates a first-stage consensus result 3023 for the transaction block, and broadcasts the first-stage consensus result 3023 to other consensus nodes in the consensus network; the consensus node 3014 generates a first stage consensus result 3024 for the transaction block, and broadcasts the first stage consensus result 3024 to other consensus nodes in the consensus network. The first-stage consensus results may be the first-stage voting null blocks (e.g., the first-stage consensus result 3023), or the block voting success results (e.g., the first-stage consensus result 3021).
The local node 303 performs consensus on the acquired transaction blocks in the first-stage consensus period, and generates a local consensus result 3031 for the transaction blocks. When the local node 303 obtains the first-stage consensus results for the transaction blocks sent by the respective consensus nodes, the local consensus result 3031 and the first-stage consensus results (such as the first-stage consensus results 3021 to 3024) are recorded as the first-stage voting result set 304, and the number of the first-stage voting results corresponding to the first-stage voting result set 304 is determined. The local node 303 compares the first-stage voting result number with the first number threshold 305, and if the first-stage voting result number is smaller than the first number threshold 305, generates a second-stage local empty block 306, which is a block in which the transaction data is empty.
The local node 303 broadcasts the second-stage local dummy block 306 to at least two common nodes (including the common node 3011, the common node 3012, the common node 3013, the common node 3014, and the like) in the second-stage common period. The consensus node 3011 obtains a first-stage consensus result sent by the local node 303, the consensus node 3012, the consensus node 3013, the consensus node 3014, and the like in a first-stage consensus period, generates a second-stage consensus result 3071 according to the first-stage consensus result obtained by the consensus node 3011, and broadcasts the second-stage consensus result 3071 to other consensus nodes; the consensus node 3012 obtains a first-stage consensus result sent by the local node 303, the consensus node 3011, the consensus node 3013, the consensus node 3014, and the like in a first-stage consensus period, generates a second-stage consensus result 3072 according to the first-stage consensus result obtained by the consensus node 3012, and broadcasts the second-stage consensus result 3072 to other consensus nodes; the consensus node 3013 obtains a first-stage consensus result sent by the local node 303, the consensus node 3011, the consensus node 3012, the consensus node 3014, and the like in a first-stage consensus period, generates a second-stage consensus result 3073 according to the first-stage consensus result obtained by the consensus node 3013, and broadcasts the second-stage consensus result 3073 to other consensus nodes; the consensus node 3014 obtains the first-stage consensus result sent by the local node 303, the consensus node 3011, the consensus node 3012, the consensus node 3013, and the like in the first-stage consensus period, generates a second-stage consensus result 3074 according to the first-stage consensus result obtained by the consensus node 3014, and broadcasts the second-stage consensus result 3074 to other consensus nodes.
The local node 303 marks the second-stage consensus result sent by the second-stage local null block 306 and at least two consensus nodes (including the consensus node 3011, the consensus node 3012, the consensus node 3013, the consensus node 3014, and the like) as a second-stage voting result set 308, and determines the uplink result of the transaction block according to the second-stage voting result set 308. For example, if the second-stage consensus result of the consensus node 3011 is a second-stage consensus successful result, the second-stage consensus result of the consensus node 3012 is a second-stage consensus successful result, the second-stage consensus result of the consensus node 3013 is a second-stage consensus successful result, and the second-stage consensus result of the consensus node 3014 is a second-stage consensus null block, the number of second-stage consensus successful results included in the second-stage voting result set 308 is 3, where the first number threshold is 3 and the number of second-stage consensus successful results is equal to the first number threshold, it is determined that the uplink result of the transaction block is a uplink successful result; the second-stage consensus result of the consensus node 3011 is a second-stage consensus null block, the second-stage consensus result of the consensus node 3012 is a second-stage consensus null block, the second-stage consensus result of the consensus node 3013 is a second-stage consensus successful result, and the second-stage consensus result of the consensus node 3014 is a second-stage consensus successful result, and the number of the second-stage consensus null blocks included in the second-stage voting result set 308 is 3 (including the second-stage local null blocks), where the second number threshold is 2, and the number of the second-stage consensus null blocks is greater than the second number threshold, and it is determined that the uplink result of the transaction block is an uplink failure result.
When any one of the consensus nodes (e.g., the consensus node 3011, the consensus node 3012, the consensus node 3013, or the consensus node 3014) in the consensus network performs the block chain consensus process in this embodiment, the steps performed may be referred to the specific description of the local node 303. At this time, the consensus node as the execution subject may be regarded as a local node.
The method and the device have the advantages that the transaction blocks are identified in two stages, accuracy of the identification result of the transaction blocks can be improved, when the transaction blocks are identified, the first-stage identification result can be obtained in the first-stage identification period, the second-stage identification result can be obtained in the second-stage identification period, time limitation exists in the two stages, when the cochain result of the transaction blocks cannot be determined due to abnormal conditions in the process of identifying the transaction blocks, the identification process cannot be interrupted, the blank block is generated, the blank block serves as the local identification result of the corresponding stage, the local node can continue to execute the subsequent identification process, and accordingly the efficiency of block chain identification is improved. In the embodiment of the application, each consensus node in the consensus network can be used as a local node to execute the step of block chain consensus in the embodiment of the application, so that the consistency of consensus results of the consensus nodes and the consistency and the safety of stored data are guaranteed.
Further, please refer to fig. 4, wherein fig. 4 is a flowchart of a block chain consensus method according to an embodiment of the present application. As shown in fig. 4, the block chain consensus process described above with the computer device, which is referred to as a local node in the embodiment of the present application, as an execution subject includes the following steps:
step S401, in the first-stage consensus period, obtaining first-stage consensus results for the transaction block sent by at least two consensus nodes.
Specifically, the local node obtains the first-stage consensus result for the transaction block sent by at least two consensus nodes in the first-stage consensus period. The first-stage consensus period belongs to the consensus period for the transaction block, and the consensus period for the transaction block can be regarded as a time period for performing consensus on the transaction block. The at least two consensus nodes are other consensus nodes except the local node in the consensus network, and the first-stage consensus result obtained by the local node comprises a consensus result aiming at the transaction block sent by any one or more of the at least two consensus nodes. For example, when the local node obtains the first-stage consensus result for the transaction block sent by the at least two consensus nodes, the node B does not send the first-stage consensus result for the transaction block or is lost in the sending process, so that the node a obtains the first-stage consensus result sent by the node C and the node D. The first-stage consensus result may be a block voting success result, or a first-stage voting empty block, where the block voting success result is used to indicate that the corresponding consensus node passes the transaction block verification, and the first-stage voting empty block is used to indicate that the corresponding consensus node does not acquire the transaction block or fails the transaction block verification.
Specifically, the node B, the node C, and the node D included in the at least two common nodes are taken as an example. The node B generates a first-stage consensus result 1 aiming at the transaction block, and broadcasts the first-stage consensus result 1 to other consensus nodes except the node B; the node C generates a first-stage consensus result 2 aiming at the transaction block, and broadcasts the first-stage consensus result 2 to other consensus nodes except the node C; the node D generates a first-stage consensus result 3 for the transaction block, and broadcasts the first-stage consensus result 3 to other consensus nodes except the node D. And the local node acquires the first-stage consensus results aiming at the transaction blocks, which are sent by at least two consensus nodes, in the first-stage consensus period, and when the first-stage consensus period is finished, the local node acquires the first-stage consensus result 2 sent by the node C and does not continuously acquire the first-stage consensus results of the node B or the node D.
Step S402, determining the number of the first-stage voting results according to the local consensus result for the transaction block and the first-stage consensus result.
Specifically, the local node generates a local consensus result for the trading block, counts the sum of the local consensus result for the trading block and the number of the first-stage consensus results, and determines the sum of the local consensus result and the number of the first-stage consensus results as the number of the first-stage voting results. The first-stage voting result number is used to indicate the total number of the first-stage consensus results (including the local consensus result generated by the local node) obtained by the local node in the first-stage consensus period, and may be used to indicate an effective number of votes for the transaction block obtained by the local node.
In step S403, if the number of the first-stage voting results is smaller than the first number threshold, a second-stage local empty block is generated.
Specifically, the local node compares the number of the first-stage voting results with a first number threshold, and generates a second-stage local empty block if the number of the first-stage voting results is smaller than the first number threshold, where the second-stage local empty block is a block whose transaction data is empty, for example, a block whose block body is empty but whose block head is not empty, or a block whose block body and block head are both empty. The first quantity threshold is determined by a consensus algorithm and a consensus node included in a consensus network, and is used for representing the minimum quantity of block voting success results of the transaction blocks, which need to be acquired by the consensus of the transaction blocks. For example, assuming that the consensus algorithm is byzantine 2/3 and the consensus network includes 4 consensus nodes, the first number threshold is determined to be 3 by the consensus algorithm and the consensus network; in other words, in the first-stage consensus period, when the block voting success results for the transaction block generated by three or more consensus nodes are obtained, the first-stage consensus of the transaction block is considered to be successful; in the second-stage consensus period, when the second-stage consensus success results generated by three or more consensus nodes are obtained, the second-stage consensus of the transaction block is considered to be successful, and the transaction block can be linked.
When the number of the first-stage voting results is less than the first number threshold, it can be considered that the effective votes obtained by the local node all do not reach the minimum number of the block voting success results required when the transaction block consensus passes, and the number of the first-stage voting results is the total number of the obtained first-stage consensus results and the local consensus results, and includes the block voting success results and the first-stage voting empty blocks. Therefore, when the number of the voting results in the first stage is smaller than the first number threshold, the total number of the successful results of block voting is necessarily smaller than the first number threshold, that is, the condition that the transaction block is agreed and passed in the first stage is not met, the local node may consider that the transaction block is agreed and failed in the first stage, and generate a local empty block in the second stage, where the local empty block in the second stage is used to indicate that the local node is agreed and failed in the first stage on the transaction block. Wherein the second stage local empty block may be considered a second stage local consensus result of the local node.
Step S404, in the second-stage consensus period, broadcasting the second-stage local null block to the at least two consensus nodes, and obtaining second-stage consensus results sent by the at least two consensus nodes.
Specifically, the local node broadcasts the second-stage local empty block to the at least two consensus nodes in the second-stage consensus period, and obtains second-stage consensus results sent by the at least two consensus nodes. The second-stage consensus period belongs to the above-mentioned consensus period for the transaction block, i.e. both the first-stage consensus period and the second-stage consensus period belong to the consensus period for the transaction block, and the first-stage consensus period is earlier than the second-stage consensus period. Specifically, in step S403, after any one of the at least two consensus nodes generates the corresponding second-stage consensus result, the second-stage consensus result generated by the consensus node is broadcast to other consensus nodes in the consensus network. The local node acquires the second-stage consensus results sent by the at least two consensus nodes.
Step S405, determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
Specifically, the local node determines the uplink result of the transaction block according to the second-stage local empty block and the obtained second-stage consensus result. And the second-stage local empty block is used for indicating that the local node fails to verify the transaction block in the second-stage consensus period. The local node detects whether the second-stage local empty block and the second-stage consensus result meet the consensus condition or not, and when the second-stage local empty block and the second-stage consensus result meet the consensus condition, the uplink result of the transaction block is determined to be a successful uplink result; and when the second-stage local empty block and the second-stage consensus result do not meet the consensus condition, determining the uplink result of the transaction block as an uplink failure result. The consensus condition may be determined according to a consensus algorithm and a consensus network, the consensus algorithm may be byzantine 2/3, and the consensus condition is that the consensus node in the consensus network exceeding 2/3 verifies the transaction block.
According to the block chain consensus process, the first-stage consensus results aiming at the transaction blocks and sent by at least two consensus nodes are obtained in the first-stage consensus period; determining the number of the first-stage voting results according to the local consensus result, the first-stage consensus result and the first-stage consensus result aiming at the transaction block; if the number of the voting results of the first stage is smaller than a first number threshold, generating a local empty block of the second stage; broadcasting the second-stage local empty block to at least two consensus nodes in a second-stage consensus period to obtain second-stage consensus results sent by the at least two consensus nodes; and determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result. By carrying out two times of consensus on the acquired transaction blocks, and limiting the time of each consensus stage, namely the first-stage consensus period and the second-stage consensus period, the longest time required by the two times of consensus in each period for carrying out the consensus on the transaction blocks has an upper limit, so that even if an abnormal condition occurs in the consensus process of the transaction blocks and the cochain result of the transaction blocks cannot be determined, the consensus process cannot be interrupted by the local node, but a blank block in the corresponding stage is generated, and the subsequent consensus process is continuously executed based on the blank block, so that the time loss is reduced, and the efficiency of block chain consensus is improved.
Further, referring to fig. 5, fig. 5 is a block chain consensus flowchart provided in the embodiment of the present application. As shown in fig. 5, in the first-stage consensus period, the local node acquires the transaction block, if the transaction block is not acquired in the first-stage consensus period, step S501 is executed, and if the transaction block is acquired in the first-stage consensus period, step S502 is executed, which specifically includes the following steps:
in step S501, if the transaction block is not obtained in the first-stage consensus period, a first-stage local empty block is generated as a local consensus result.
Specifically, in the first-stage consensus period, a transaction block is obtained, if the transaction block is not obtained in the first-stage consensus period, in other words, when the first-stage consensus period ends, the local node still does not obtain the transaction block, the local node generates a first-stage local null block, uses the first-stage local null block as a local consensus result, broadcasts the local consensus result to at least two consensus nodes, and executes step S504 to obtain the first-stage consensus result for the transaction block sent by the at least two consensus nodes.
Specifically, referring to fig. 6, fig. 6 is a schematic diagram of a first-stage local consensus result generation scenario provided in the embodiment of the present application. As shown in fig. 6, one common node in the common network acquires transaction data, and marks the common node as a partition creation node 6011, where the partition creation node 6011 creates a transaction partition 602 according to the transaction data, and broadcasts the transaction partition 602 to common nodes in the common network except for the partition creation node 6011, including a common node 6012, a common node 6013, a common node 6014, and the like. Taking the common knowledge node 6012 as an example, the common knowledge node 6012 is denoted as a local node, the common knowledge node 6012 does not acquire the transaction block 602 sent by the block generating node 6011 in the first-stage common knowledge period, a first-stage local empty block 603 is generated, the first-stage local empty block 603 is used as a local common knowledge result, and the first-stage local empty block 603 is a block whose transaction data is empty. The consensus node 6012 broadcasts the local consensus result to other nodes in the consensus network, including the block generation node 6011, the consensus node 6013, and the consensus node 6014.
In step S502, if the transaction block is obtained in the first-stage consensus period, the transaction block is verified.
Specifically, if the local node acquires the transaction block in the first-stage consensus period, the transaction block is verified, specifically, the transaction data in the block body and the block header data in the block header of the transaction block are verified. For example, assuming that the block head of the transaction block includes a block height, a timestamp, a block head hash value, and the like, the local node acquires a preceding block with a largest timestamp from the block chain, acquires a preceding block height of the preceding block, and considers that the block height of the transaction block is correct when the preceding block height is smaller than the block height and a difference value between the two is 1; acquiring transaction data in a block body in a transaction block, generating a hash value according to data in a block head of the transaction block, and if the hash value is the same as the hash value of the block head, determining that the hash value of the block head of the transaction block is correct. The local block verifies the data in the block head and the transaction data in the block body of the transaction block, and if the data in the block head and the transaction data in the block body are both correct, the transaction block is determined to be verified; and if the data in the block header and the transaction data in the block body have wrong data, determining that the transaction block fails to be verified.
And step S503, generating a local consensus result according to the verification result.
Specifically, if the transaction block passes the verification, a block voting success result for the transaction block is generated, the block voting success result for the transaction block is used as a local consensus result, and the local consensus result is broadcasted to at least two consensus nodes; and if the transaction block is not verified, generating a first-stage local empty block, taking the first-stage local empty block as a local consensus result, and broadcasting the local consensus result to at least two consensus nodes. Wherein the block voting success result is used for indicating that the local node approves the transaction block in the first stage consensus period; the first-stage local empty block is used for indicating that the local node does not approve the transaction block or does not acquire the transaction block in the first-stage consensus period.
In step S504, the first-stage consensus results for the transaction block sent by the at least two consensus nodes are obtained.
Specifically, the local node obtains the first-stage consensus result for the transaction block sent by at least two consensus nodes, wherein a process of each consensus node generating the first-stage consensus result for the transaction block is the same as a process of the local node generating the first-stage local consensus result. When the consensus node is the block generation node, the transaction block is generated by the block generation node, so that the block generation node approves the transaction block and generates a block voting success result aiming at the transaction block as a first-stage consensus result of the block generation node.
Step S505, determining the number of the first-stage voting results according to the local consensus result and the first-stage consensus result.
Specifically, the sum of the local consensus result and the number of the first-stage consensus results is used as the number of the first-stage voting results. For example, the consensus network includes 6 consensus nodes, which are a consensus node a, a consensus node B, a consensus node C, a consensus node D, a consensus node E, and a consensus node F, wherein, assuming that the consensus node a is a local node, the local node obtains a first-stage consensus result 1 of the consensus node B and a first-stage consensus result 2 of the consensus node C, and the local node counts the number of the local consensus results and the first-stage consensus results to obtain a first-stage voting result number of 3, which includes the local consensus result, the first-stage consensus result 1, and the first-stage consensus result 2.
Step S506, comparing the number of the voting results of the first stage with the first number threshold, and generating a local consensus result of the second stage.
Specifically, a first quantity threshold is obtained, the number of the voting results in the first stage is compared with the first quantity threshold, and a local consensus result in the second stage is generated according to the comparison result. The first quantity threshold is determined according to a common-identity algorithm and a common-identity network, and the first quantity threshold is used for indicating the quantity of common-identity nodes of the approved transaction block required when the transaction block can be uplink. For example, taking the consensus network in step S505 as an example, the consensus network includes 6 consensus nodes, which are a consensus node a, a consensus node B, a consensus node C, a consensus node D, a consensus node E, and a consensus node F, wherein assuming that the consensus node a is a local node, when the consensus algorithm is byzantine 2/3, the first number threshold is 4.
Specifically, a second-stage local consensus result generation process: and if the number of the first-stage voting results is smaller than the first number threshold, generating a second-stage local empty block, and taking the second-stage local empty block as a second-stage local consensus result. For example, the first-stage consensus result 1 of the consensus node B and the first-stage consensus result 2 of the consensus node C are obtained, and the local node counts the number of the local consensus result and the first-stage consensus result, so as to obtain a first-stage voting result number of 3, which includes the local consensus result, the first-stage consensus result 1, and the first-stage consensus result 2. If the number of the first-stage voting results 3 is smaller than the first number threshold 4, the number of the first-stage voting success results is certainly smaller than the first number threshold 4, the local node generates a second-stage local empty block, and the second-stage local empty block is used as a second-stage local consensus result to indicate that the local node approves the transaction block in the second stage.
Another second stage local consensus result generation process; if the number of the first-stage voting results is greater than or equal to a first number threshold, counting the number of first-stage voting empty blocks in the first-stage consensus result; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet the consensus condition in at least two consensus nodes. Determining the number of first empty blocks according to the local consensus result and the number of the first-stage voting empty blocks; and if the number of the first empty blocks is larger than the second number threshold, generating second-stage local empty blocks, taking the second-stage local empty blocks as second-stage local consensus results, and broadcasting the second-stage local empty blocks to at least two consensus nodes.
When the number of the first empty blocks is determined, the local node detects the local consensus result, and if the local consensus result is a block voting success result aiming at the transaction block, the number of the first-stage voting empty blocks is determined as the number of the first empty blocks; and if the local consensus result is the first-stage local empty block, taking the sum of the number of the first-stage local empty blocks and the number of the first-stage voting empty blocks as the number of the first empty blocks.
A second stage local consensus result generation process: if the number of the first-stage voting results is greater than or equal to the first number threshold, counting the number of the first-stage voting success results in the first-stage consensus results; the successful result of the first stage voting is generated by the consensus node which detects that the transaction block meets the consensus condition in the at least two consensus nodes. Determining a first voting success quantity according to the quantity of the local consensus result and the first-stage voting success result; if the first voting success quantity is larger than or equal to the first quantity threshold value, generating a second-stage local consensus success result, taking the second-stage local consensus success result as a second-stage local consensus result of the local node, and broadcasting the second-stage local consensus success result to at least two consensus nodes; and if the first voting success quantity is smaller than the first quantity threshold value, generating a second-stage local empty block, taking the second-stage local empty block as a second-stage local consensus result, and broadcasting the second-stage local consensus result to at least two consensus nodes.
When the first voting success quantity is determined, if the local consensus result is the block voting success result aiming at the transaction block, taking the sum of the local consensus result and the quantity of the first-stage voting success results as the first voting success quantity; and if the local consensus result is the first-stage local empty block, determining the number of the first-stage voting success results as the first voting success number.
Specifically, when the number of the acquired first empty blocks is less than or equal to the second number threshold, a first voting success number may also be acquired, and if the first voting success number is greater than or equal to the first number threshold, a second-stage local consensus success result is generated, and the second-stage local consensus success result is used as a second-stage local consensus result of the local node; and if the successful number of the first votes is smaller than the threshold value of the first number, generating a second-stage local empty block, and taking the second-stage local empty block as a second-stage local consensus result.
The sum of the first quantity threshold and the second quantity threshold is the total quantity of the consensus nodes included in the consensus network, and therefore, when the first empty block quantity is greater than the second quantity threshold, the first voting success quantity is certainly smaller than the first quantity threshold, and the local node may determine that the consensus on the transaction block in the first stage does not pass, and generate a second-stage local empty block. For example, if the consensus network includes 6 consensus nodes and the consensus algorithm is byzantine 2/3, the first number threshold is determined to be 4 and the second number threshold is determined to be 2.
Step S507, obtaining the second-stage consensus results sent by the at least two consensus nodes.
Specifically, the second-stage consensus results sent by at least two consensus nodes are obtained. The process of generating the corresponding second-stage consensus result by each consensus node is the same as the process of generating the second-stage local consensus result by the local node in step S506, and is not repeated here.
Step S508, determining the uplink result of the transaction block according to the second-stage local consensus result and the second-stage consensus result.
Specifically, the uplink result of the transaction block is determined according to the second-stage local consensus success result and the second-stage consensus result.
Wherein, a process of determining uplink result: when the second-stage local consensus result of the local node is a second-stage local empty block, taking the number of second-stage consensus successful results in the second-stage consensus result as a second voting success number; and when the second-stage local consensus result of the local node is the second-stage local consensus success result, taking the sum of the second-stage local consensus result and the second-stage consensus success result as a second voting success number. If the second voting success quantity is larger than or equal to the first quantity threshold, uploading the transaction block to a block chain, and determining the uplink result of the transaction block as the uplink success result; if the second voting success quantity is smaller than the first quantity threshold, deleting the transaction block, and determining the uplink result of the transaction block as the uplink failure result.
Another uplink result determination process: when the second-stage local consensus result of the local node is a second-stage local empty block, counting the number of second-stage consensus empty blocks in the second-stage consensus result, and taking the sum of the number of the second-stage local empty blocks and the number of the second-stage consensus empty blocks as the number of the second empty blocks; and when the second-stage local consensus result of the local node is a second-stage local consensus success result, taking the number of the second-stage consensus null blocks as the number of the second null blocks. And if the second number of the empty blocks is larger than the second number threshold, deleting the transaction block, and determining the uplink result of the transaction block as the uplink failure result.
Yet another uplink result determination process: determining the number of voting results of the second stage according to the consensus results of the local empty blocks and the second stage; if the second stage voting result quantity is less than the first quantity threshold value, deleting the transaction block and determining the uplink result of the transaction block as the uplink failure result.
Specifically, referring to fig. 7, fig. 7 is a schematic diagram of a ul result determination scenario provided in an embodiment of the present application. As shown in fig. 7, the local node obtains the second-stage local consensus result and the second-stage consensus results sent by the at least two consensus nodes, including a second-stage consensus null block 7011, a second-stage consensus success result 7012, a second-stage consensus null block 7013, a second-stage consensus success result 7014, and the like, where the second-stage local null block is equivalent to the second-stage consensus null block for other consensus nodes, and the second-stage local consensus success result is equivalent to the second-stage consensus success result for other consensus nodes.
The local node may count the number of the second-stage consensus success results (including the second-stage consensus success result 7012, the second-stage consensus success result 7014, the second-stage consensus success result 701m, and the like) as a second voting success number m, where m is a positive integer. Deleting the transaction block 703 when the second voting success number m is smaller than the first number threshold, and determining that the uplink result of the transaction block is an uplink failure result; when the second voting success number m is greater than or equal to the first number threshold, the transaction block 703 is added to the blockchain 704, and the uplink result of the transaction block is determined to be the uplink success result.
The local node may also count the number of second-stage consensus null blocks (including the second-stage consensus null block 7011, the second-stage consensus null block 7013, and the second-stage consensus null block 701n), as the number n of second null blocks, where n is a positive integer. When the second number of empty blocks n is greater than the second number threshold, the transaction block 703 is deleted, and the uplink result of the transaction block is determined to be an uplink failure result. When the second empty block number n is less than or equal to the second number threshold, obtaining a second voting success number m, comparing the second voting success number m with the first number threshold, when the second voting success number m is less than the first number threshold, deleting the transaction block 703, and determining that the uplink result of the transaction block is an uplink failure result; when the second voting success number m is greater than or equal to the first number threshold, the transaction block 703 is added to the blockchain 704, and the uplink result of the transaction block is determined to be the uplink success result.
In step S509, when the uplink result is the uplink failure result, the generation block authority of the block generation node generating the transaction block is limited.
Specifically, if the uplink result of the transaction block is an uplink failure result, the block generation node of the transaction block is obtained. Adding the block generation node to the permission limit node set; the permission restriction node set comprises common nodes without permission for generating the block. And acquiring the storage time length of the block generation node in the permission limit set, and deleting the block generation node in the permission limit set and recovering the block generation permission of the block generation node if the storage time length is greater than the permission limit time. Optionally, when the local node acquires a new transaction block, the generation node and the permission limit node set of the new transaction block are acquired, and if the generation node of the new transaction block belongs to the permission limit node set, a block generation exception message is sent to the generation node of the new transaction block to notify that the generation node of the new transaction block has no generation block permission temporarily.
According to the embodiment of the application, the local node acquires the first-stage consensus results aiming at the transaction block, which are sent by at least two consensus nodes, in the first-stage period; verifying the transaction block, and generating a local consensus result according to the verification result; and determining the number of the voting results of the first stage according to the local consensus result and the consensus result of the first stage. When the number of the voting results of the first stage is smaller than a first number threshold, generating a local empty block of the second stage; and when the number of the first-stage voting results is greater than or equal to a first number threshold, generating a second-stage local consensus result according to the first-stage voting success result or the first-stage voting null block in the first-stage consensus result and the local consensus result. And determining the uplink result of the transaction block according to the second-stage local consensus result and the second-stage consensus results sent by the at least two consensus nodes. Through the process, the transaction block is subjected to two-stage consensus, the transaction block is directly subjected to consensus in the first stage, and the consensus results of all the consensus nodes in the first stage are subjected to consensus in the second stage, so that the safety and the reliability of the data of the transaction block are improved. Meanwhile, the two stages of consensus on the transaction blocks are limited in time, so that when the consensus result on the transaction blocks cannot be determined, the consensus process on the transaction blocks is not interrupted, a null block is generated, and the null block is used as the consensus result on the transaction blocks to continue to execute the subsequent consensus process, so that the time consumed by block chain consensus is reduced, and the efficiency of block chain consensus is improved.
Further, referring to fig. 8, fig. 8 is a schematic diagram of a block chain consensus apparatus according to an embodiment of the present disclosure. The blockchain consensus device may be a computer program (including program code) running on a computer device, for example, the blockchain consensus device is an application software; the apparatus may be used to perform the corresponding steps in the methods provided by the embodiments of the present application. As shown in fig. 8, the block chain consensus apparatus 80 can be applied to the computer device in the embodiment corresponding to fig. 4 or fig. 5, and specifically, the block chain consensus apparatus 80 can include: a common identification obtaining module 11, a vote number determining module 12, a first null block generating module 13, a first common identification interacting module 14, and a uplink result determining module 15.
The consensus acquisition module 11 is configured to acquire a first-stage consensus result for the transaction block sent by at least two consensus nodes in a first-stage consensus period;
a vote number determining module 12, configured to determine a number of first-stage voting results according to the local consensus result for the transaction block and the first-stage consensus result;
a first empty block generation module 13, configured to generate a second-stage local empty block if the number of the first-stage voting results is smaller than a first number threshold; the second stage local empty block is a block with empty transaction data;
a first consensus interaction module 14, configured to broadcast the second-stage local null block to the at least two consensus nodes in a second-stage consensus period, and obtain second-stage consensus results sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period both belong to a consensus period for the transaction block, the first-stage consensus period being earlier than the second-stage consensus period;
a uplink result determining module 15, configured to determine the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
Wherein, the above device 80 further comprises:
a blank block counting module 16, configured to count the number of first-stage voting blank blocks in the first-stage consensus result if the number of first-stage voting results is greater than or equal to the first number threshold; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet a consensus condition from the at least two consensus nodes;
the empty block counting module 16 is further configured to determine a first empty block number according to the local consensus result and the number of the first-stage voting empty blocks;
a second empty block generating module 17, configured to generate the second-stage local empty block if the number of the first empty blocks is greater than a second number threshold.
Wherein, in the aspect of determining the number of first empty blocks according to the local consensus result and the number of first-stage voting empty blocks, the empty block counting module 16 includes:
a first number determining unit 161, configured to determine the number of the first-stage voting empty blocks as the first number of empty blocks if the local consensus result is a successful block voting result for the transaction block;
the first quantity determining unit 161 is further configured to, if the local consensus result is a first-stage local empty block, determine a sum of the first-stage local empty block and the first-stage voting empty block as the first empty block quantity.
Wherein, the above device 80 further comprises:
a second consensus interacting module 18, configured to generate the first-stage local null block if the transaction block is not obtained in the first-stage consensus period, use the first-stage local null block as the local consensus result, and broadcast the local consensus result to the at least two consensus nodes.
Wherein, the above device 80 further comprises:
a block verification module 19, configured to verify the transaction block if the transaction block is obtained within the first-stage consensus period;
a first result generating module 20, configured to generate a block voting success result for the transaction block if the transaction block is verified, use the block voting success result for the transaction block as the local consensus result, and broadcast the local consensus result to the at least two consensus nodes;
a third empty block generating module 21, configured to generate the first-stage local empty block if the transaction block is not verified, use the first-stage local empty block as the local consensus result, and broadcast the local consensus result to the at least two consensus nodes.
Wherein, the above device 80 further comprises:
a success counting module 22, configured to count the number of successful first-stage voting results in the first-stage consensus results if the number of first-stage voting results is greater than or equal to the first number threshold; the successful result of the first-stage voting is generated by the consensus node which detects that the transaction block meets the consensus condition in the at least two consensus nodes;
the success counting module 22 is further configured to determine a first successful voting number according to the number of the local consensus result and the number of the first-stage successful voting results;
a second result generating module 23, configured to generate a second-stage local consensus successful result if the first voting success number is greater than or equal to the first number threshold, broadcast the second-stage local consensus successful result to the at least two consensus nodes, and obtain second-stage consensus results sent by the at least two consensus nodes;
the uplink result determining module 15 is configured to determine the uplink result of the transaction block according to the second-stage local consensus success result and the second-stage consensus result.
Wherein, in the aspect of determining the first voting success number according to the number of the local consensus result and the first-stage voting success result, the success counting module 22 includes:
a second quantity determination unit 221, configured to determine, as the first voting success quantity, a sum of the local consensus result and the quantity of the first-stage voting success results if the local consensus result is a block voting success result for the transaction block;
the second quantity determining unit 221 is further configured to determine, if the local consensus result is a first-stage local empty block, the quantity of the first-stage voting success results as the first voting success quantity.
The uplink result determining module 15 includes:
a third quantity determination unit 151, configured to use the quantity of second-stage consensus successful results in the second-stage consensus results as a second voting success quantity;
an uplink success determining unit 152, configured to upload the transaction block into a block chain if the second voting success number is greater than or equal to the first number threshold, and determine that an uplink result of the transaction block is an uplink success result;
a uplink failure determining unit 153, configured to delete the transaction block if the second voting success number is smaller than the first number threshold, and determine that the uplink result of the transaction block is an uplink failure result.
The uplink result determining module 15 includes:
a number of empty blocks counting unit 154, configured to count the number of second-stage consensus empty blocks in the second-stage consensus result;
the number of empty blocks counting unit 154 is further configured to use the sum of the number of the second-stage local empty blocks and the number of the second-stage consensus empty blocks as a second empty block number;
the uplink failure determining unit 153 is further configured to delete the transaction block if the second number of empty blocks is greater than a second number threshold, and determine that the uplink result of the transaction block is an uplink failure result.
The uplink result determining module 15 includes:
a voting result counting unit 155, configured to determine the number of second-stage voting results according to the second-stage local empty block and the second-stage consensus result;
the uplink failure determining unit 153 is further configured to delete the transaction block if the number of the second-stage voting results is smaller than the first number threshold, and determine that the uplink result of the transaction block is an uplink failure result.
Wherein, the above device 80 further comprises:
a generating node obtaining module 24, configured to obtain a block generating node of the transaction block if the uplink result of the transaction block is an uplink failure result;
a node adding module 25, configured to add the block generation node to the permission restriction node set; the permission limiting node set comprises common nodes without block generation permission;
the authority updating module 26 is configured to obtain a storage duration of the block generation node in the authority limit set, and delete the block generation node in the authority limit set if the storage duration is greater than the authority limit time, and recover the generated block authority of the block generation node.
The embodiment of the application describes a block chain consensus device, which obtains first-stage consensus results aiming at a transaction block, sent by at least two consensus nodes, in a first-stage period through a local node; verifying the transaction block, and generating a local consensus result according to the verification result; and determining the number of the voting results of the first stage according to the local consensus result and the consensus result of the first stage. When the number of the voting results of the first stage is smaller than a first number threshold, generating a local empty block of the second stage; and when the number of the first-stage voting results is greater than or equal to a first number threshold, generating a second-stage local consensus result according to the first-stage voting success result or the first-stage voting null block in the first-stage consensus result and the local consensus result. And determining the uplink result of the transaction block according to the second-stage local consensus result and the second-stage consensus results sent by the at least two consensus nodes. Through the process, the transaction block is subjected to two-stage consensus, the transaction block is directly subjected to consensus in the first stage, and the consensus results of all the consensus nodes in the first stage are subjected to consensus in the second stage, so that the safety and the reliability of the data of the transaction block are improved. Meanwhile, the two stages of consensus on the transaction blocks are limited in time, so that the consensus process on the transaction blocks can not be interrupted when the consensus result on the transaction blocks cannot be determined, the time consumed by the block chain consensus is reduced, and the efficiency of the block chain consensus is improved.
Referring to fig. 9, fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present application. As shown in fig. 9, the computer device 900 in the embodiment of the present application may include: one or more processors 901, memory 902, and input-output interface 903. The processor 901, the memory 902, and the input/output interface 903 are connected by a bus 904. The memory 902 is used for storing a computer program, the computer program comprises program instructions, and the input/output interface 903 is used for data interaction between the common nodes in the common network; the processor 901 is configured to execute the program instructions stored in the memory 902 to perform the following operations:
in a first-stage consensus period, obtaining first-stage consensus results aiming at the transaction blocks, which are sent by at least two consensus nodes;
determining the number of first-stage voting results according to the local consensus result aiming at the transaction block and the first-stage consensus result;
if the number of the voting results of the first stage is smaller than a first number threshold, generating a local empty block of the second stage; the second stage local empty block is a block with empty transaction data;
broadcasting the second-stage local empty block to the at least two consensus nodes in a second-stage consensus period to obtain second-stage consensus results sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period both belong to a consensus period for the transaction block, the first-stage consensus period being earlier than the second-stage consensus period;
and determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
In some possible embodiments, the processor 901 may be a Central Processing Unit (CPU), and the processor may also be other general processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 902 may include a read-only memory and a random access memory, and provides instructions and data to the processor 901 and the input/output interface 903. A portion of the memory 902 may also include non-volatile random access memory. For example, memory 902 may also store device type information.
In a specific implementation, the computer may execute, through each built-in functional module, the implementation manner provided in each step in fig. 4 or fig. 5, which may be specifically referred to the implementation manner provided in each step in fig. 4 or fig. 5, and is not described herein again.
The embodiment of the present application provides a computer device, including: the processor, the input/output interface, and the memory, which are used for obtaining the computer instructions in the memory through the processor and executing the steps of the method shown in fig. 4 or fig. 5, perform the block chain consensus operation. With computer instructions in the memory, the processor performs the steps of: in a first-stage period, obtaining first-stage consensus results aiming at the transaction blocks, which are sent by at least two consensus nodes; verifying the transaction block, and generating a local consensus result according to the verification result; and determining the number of the voting results of the first stage according to the local consensus result and the consensus result of the first stage. When the number of the voting results of the first stage is smaller than a first number threshold, generating a local empty block of the second stage; and when the number of the first-stage voting results is greater than or equal to a first number threshold, generating a second-stage local consensus result according to the first-stage voting success result or the first-stage voting null block in the first-stage consensus result and the local consensus result. And determining the uplink result of the transaction block according to the second-stage local consensus result and the second-stage consensus results sent by the at least two consensus nodes. Through the process, the transaction block is subjected to two-stage consensus, the transaction block is directly subjected to consensus in the first stage, and the consensus results of all the consensus nodes in the first stage are subjected to consensus in the second stage, so that the safety and the reliability of the data of the transaction block are improved. Meanwhile, the two stages of consensus on the transaction blocks are limited in time, so that the consensus process on the transaction blocks can not be interrupted when the consensus result on the transaction blocks cannot be determined, the time consumed by the block chain consensus is reduced, and the efficiency of the block chain consensus is improved.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, where the computer program includes program instructions, and when the program instructions are executed by the processor, the block chain consensus method provided in each step in fig. 4 or fig. 5 can be implemented, which specifically refers to an implementation manner provided in each step in fig. 4 or fig. 5, and is not described herein again. In addition, the beneficial effects of the same method are not described in detail. For technical details not disclosed in embodiments of the computer-readable storage medium referred to in the present application, reference is made to the description of embodiments of the method of the present application. By way of example, program instructions may be deployed to be executed on one computer device or on multiple computer devices at one site or distributed across multiple sites and interconnected by a communication network.
The computer-readable storage medium may be the block chain common identification device provided in any of the foregoing embodiments or an internal storage unit of the computer, such as a hard disk or a memory of the computer. The computer readable storage medium may also be an external storage device of the computer, such as a plug-in hard disk, a smart card (SMC), a Secure Digital (SD) card, a flash card (flash card), and the like, which are provided on the computer. Further, the computer-readable storage medium may also include both an internal storage unit and an external storage device of the computer. The computer-readable storage medium is used for storing the computer program and other programs and data required by the computer. The computer readable storage medium may also be used to temporarily store data that has been output or is to be output.
The terms "first," "second," and the like in the description and in the claims and drawings of the embodiments of the present application are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprises" and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or apparatus that comprises a list of steps or elements is not limited to the listed steps or modules, but may alternatively include other steps or modules not listed or inherent to such process, method, apparatus, product, or apparatus.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The method and the related apparatus provided by the embodiments of the present application are described with reference to the flowchart and/or the structural diagram of the method provided by the embodiments of the present application, and each flow and/or block of the flowchart and/or the structural diagram of the method, and the combination of the flow and/or block in the flowchart and/or the block diagram can be specifically implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block or blocks of the block diagram. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block or blocks of the block diagram. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block or blocks.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present application and is not to be construed as limiting the scope of the present application, so that the present application is not limited thereto, and all equivalent variations and modifications can be made to the present application.

Claims (15)

1. A method for block chain consensus, the method comprising:
in a first-stage consensus period, obtaining first-stage consensus results aiming at the transaction blocks, which are sent by at least two consensus nodes;
determining a first-stage voting result quantity according to the local consensus result aiming at the transaction block and the first-stage consensus result;
if the number of the voting results of the first stage is smaller than a first number threshold, generating a local empty block of the second stage; the second-stage local empty block is a block with empty transaction data;
broadcasting the second-stage local empty block to the at least two consensus nodes in a second-stage consensus period to obtain second-stage consensus results sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period both belong to a consensus period for the transaction block, the first-stage consensus period being earlier than the second-stage consensus period;
and determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
2. The method of claim 1, wherein the method further comprises:
if the number of the first-stage voting results is greater than or equal to the first number threshold, counting the number of first-stage voting empty blocks in the first-stage consensus result; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet a consensus condition in the at least two consensus nodes;
determining the number of first empty blocks according to the local consensus result and the number of the first-stage voting empty blocks;
and if the number of the first empty blocks is larger than a second number threshold, generating the second-stage local empty blocks.
3. The method of claim 2, wherein determining a first number of empty blocks based on the local consensus result and the first stage voted for empty blocks comprises:
determining the number of the first-stage voting empty blocks as the first empty block number if the local consensus result is a block voting success result for the transaction block;
and if the local consensus result is a first-stage local empty block, taking the sum of the number of the first-stage local empty blocks and the number of the first-stage voting empty blocks as the number of the first empty blocks.
4. The method of claim 3, wherein the method further comprises:
and if the transaction block is not acquired in the first-stage consensus period, generating the first-stage local empty block, taking the first-stage local empty block as the local consensus result, and broadcasting the local consensus result to the at least two consensus nodes.
5. The method of claim 3, wherein the method further comprises:
if the transaction block is acquired in the first-stage consensus period, verifying the transaction block;
if the transaction block is verified, generating a block voting success result aiming at the transaction block, taking the block voting success result aiming at the transaction block as the local consensus result, and broadcasting the local consensus result to the at least two consensus nodes;
and if the transaction block is not verified, generating the first-stage local empty block, taking the first-stage local empty block as the local consensus result, and broadcasting the local consensus result to the at least two consensus nodes.
6. The method of claim 1, wherein the method further comprises:
if the number of the first-stage voting results is greater than or equal to the first number threshold, counting the number of first-stage voting success results in the first-stage consensus results; the first-stage voting success result is generated by a consensus node which detects that the transaction block meets a consensus condition in the at least two consensus nodes;
determining a first voting success quantity according to the local consensus result and the quantity of the first-stage voting success results;
if the first voting success quantity is greater than or equal to the first quantity threshold value, generating a second-stage local consensus success result, broadcasting the second-stage local consensus success result to the at least two consensus nodes, and acquiring second-stage consensus results sent by the at least two consensus nodes;
and determining the uplink result of the transaction block according to the second-stage local consensus success result and the second-stage consensus result.
7. The method of claim 6, wherein determining a first number of voting successes based on the local consensus result and the number of first-stage voting successes comprises:
if the local consensus result is a block voting success result aiming at the transaction block, taking the sum of the local consensus result and the number of the first-stage voting success results as the first voting success number;
and if the local consensus result is a first-stage local empty block, determining the number of the first-stage voting success results as the first voting success number.
8. The method of claim 1, wherein the determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result comprises:
taking the number of second-stage consensus successful results in the second-stage consensus results as a second voting success number;
if the second voting success number is larger than or equal to the first number threshold, uploading the transaction block to a block chain, and determining that the uplink result of the transaction block is an uplink success result;
and if the second voting success quantity is smaller than the first quantity threshold, deleting the transaction block, and determining the uplink result of the transaction block as the uplink failure result.
9. The method of claim 1, wherein the determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result comprises:
counting the number of second-stage consensus null blocks in the second-stage consensus result;
taking the sum of the number of the second-stage local empty blocks and the number of the second-stage consensus empty blocks as a second empty block number;
and if the second empty block quantity is larger than a second quantity threshold, deleting the transaction block, and determining the uplink result of the transaction block as the uplink failure result.
10. The method of claim 1, wherein the determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result comprises:
determining the number of voting results of the second stage according to the consensus result of the local empty block of the second stage and the second stage;
and if the second-stage voting result quantity is smaller than the first quantity threshold, deleting the transaction block, and determining the uplink result of the transaction block as an uplink failure result.
11. The method of claim 1, wherein the method further comprises:
if the uplink result of the transaction block is an uplink failure result, acquiring a block generating node of the transaction block;
adding the block generation node to an authority limit node set; the permission limiting node set comprises common nodes without permission of generating the block;
and acquiring the storage duration of the block generation node in the permission limit set, and deleting the block generation node in the permission limit set and recovering the block generation permission of the block generation node if the storage duration is greater than the permission limit time.
12. An apparatus for block chain consensus, the apparatus comprising:
the consensus acquisition module is used for acquiring first-stage consensus results aiming at the transaction blocks, which are sent by at least two consensus nodes, in a first-stage consensus period;
the voting quantity determining module is used for determining the quantity of the first-stage voting results according to the local consensus result aiming at the transaction block and the first-stage consensus result;
a first empty block generation module, configured to generate a second-stage local empty block if the number of the first-stage voting results is smaller than a first number threshold; the second-stage local empty block is a block with empty transaction data;
the first consensus interaction module is used for broadcasting the second-stage local empty block to the at least two consensus nodes in a second-stage consensus period to obtain second-stage consensus results sent by the at least two consensus nodes; the first-stage consensus period and the second-stage consensus period both belong to a consensus period for the transaction block, the first-stage consensus period being earlier than the second-stage consensus period;
and the uplink result determining module is used for determining the uplink result of the transaction block according to the second-stage local empty block and the second-stage consensus result.
13. The apparatus of claim 12, wherein the apparatus further comprises:
a null block counting module, configured to count the number of first-stage voting null blocks in the first-stage consensus result if the number of first-stage voting results is greater than or equal to the first number threshold; the first-stage voting empty block is generated by a consensus node which detects that the transaction block does not meet a consensus condition in the at least two consensus nodes;
the empty block counting module is further configured to determine the number of first empty blocks according to the local consensus result and the number of the first-stage voting empty blocks;
and the second empty block generation module is used for generating the second-stage local empty block if the number of the first empty blocks is greater than a second number threshold.
14. A computer device comprising a processor, a memory, an input output interface;
the processor is connected to the memory and the input/output interface respectively, wherein the input/output interface is used for data interaction of each node in the block chain, the memory is used for storing program codes, and the processor is used for calling the program codes to execute the method according to any one of claims 1 to 11.
15. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program comprising program instructions which, when executed by a processor, perform the method according to any one of claims 1-11.
CN202010295981.2A 2020-04-15 2020-04-15 Block chain consensus method, apparatus, computer and readable storage medium Active CN111507840B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010295981.2A CN111507840B (en) 2020-04-15 2020-04-15 Block chain consensus method, apparatus, computer and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010295981.2A CN111507840B (en) 2020-04-15 2020-04-15 Block chain consensus method, apparatus, computer and readable storage medium

Publications (2)

Publication Number Publication Date
CN111507840A true CN111507840A (en) 2020-08-07
CN111507840B CN111507840B (en) 2024-03-26

Family

ID=71876134

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010295981.2A Active CN111507840B (en) 2020-04-15 2020-04-15 Block chain consensus method, apparatus, computer and readable storage medium

Country Status (1)

Country Link
CN (1) CN111507840B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112232954A (en) * 2020-10-15 2021-01-15 杭州溪塔科技有限公司 Dynamic adjustment method and device for proposal timeout threshold value and electronic equipment

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108648078A (en) * 2018-05-02 2018-10-12 杭州秘猿科技有限公司 A kind of transaction preprocess method, device and electronic equipment
WO2018223215A1 (en) * 2017-06-07 2018-12-13 Zeu Crypto Networks Inc. Scalable trading platform using central bank issued digital currency
CN109447810A (en) * 2018-11-29 2019-03-08 杭州秘猿科技有限公司 Parallel block chain common recognition method, system, electronic equipment and computer readable storage medium
CA3053208A1 (en) * 2018-12-13 2019-04-18 Alibaba Group Holding Limited Performing a change of primary node in a distributed system
CN110445778A (en) * 2019-08-01 2019-11-12 中盾云链(广州)信息科技有限公司 A kind of common recognition algorithm applied to alliance's chain
CN110493148A (en) * 2019-08-12 2019-11-22 深圳前海微众银行股份有限公司 A kind of block processes, block common recognition and block synchronous method and device
US10504179B1 (en) * 2015-12-08 2019-12-10 Fmr Llc Social aggregated fractional equity transaction partitioned acquisition apparatuses, methods and systems
CN110572429A (en) * 2019-07-30 2019-12-13 中钞信用卡产业发展有限公司杭州区块链技术研究院 block chain-based consensus method, device, equipment and storage medium
WO2020011283A2 (en) * 2019-09-05 2020-01-16 Alibaba Group Holding Limited System and method for deleting node in blockchain network
CN110765211A (en) * 2019-11-06 2020-02-07 腾讯科技(深圳)有限公司 Engineering bid inviting management method, device, terminal and storage medium based on block chain
CN110995701A (en) * 2019-12-02 2020-04-10 远光软件股份有限公司 Block chain consensus method, system, electronic equipment and storage medium

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10504179B1 (en) * 2015-12-08 2019-12-10 Fmr Llc Social aggregated fractional equity transaction partitioned acquisition apparatuses, methods and systems
WO2018223215A1 (en) * 2017-06-07 2018-12-13 Zeu Crypto Networks Inc. Scalable trading platform using central bank issued digital currency
CN108648078A (en) * 2018-05-02 2018-10-12 杭州秘猿科技有限公司 A kind of transaction preprocess method, device and electronic equipment
CN109447810A (en) * 2018-11-29 2019-03-08 杭州秘猿科技有限公司 Parallel block chain common recognition method, system, electronic equipment and computer readable storage medium
CA3053208A1 (en) * 2018-12-13 2019-04-18 Alibaba Group Holding Limited Performing a change of primary node in a distributed system
CN110572429A (en) * 2019-07-30 2019-12-13 中钞信用卡产业发展有限公司杭州区块链技术研究院 block chain-based consensus method, device, equipment and storage medium
CN110445778A (en) * 2019-08-01 2019-11-12 中盾云链(广州)信息科技有限公司 A kind of common recognition algorithm applied to alliance's chain
CN110493148A (en) * 2019-08-12 2019-11-22 深圳前海微众银行股份有限公司 A kind of block processes, block common recognition and block synchronous method and device
WO2020011283A2 (en) * 2019-09-05 2020-01-16 Alibaba Group Holding Limited System and method for deleting node in blockchain network
CN110765211A (en) * 2019-11-06 2020-02-07 腾讯科技(深圳)有限公司 Engineering bid inviting management method, device, terminal and storage medium based on block chain
CN110995701A (en) * 2019-12-02 2020-04-10 远光软件股份有限公司 Block chain consensus method, system, electronic equipment and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
程发新;程栋;赵艳萍;罗建强;: "基于共识决策的低碳供应商选择方法研究", 运筹与管理, vol. 21, no. 06, 31 December 2012 (2012-12-31) *
肖婧;张永建;许小可;: "复杂网络模糊重叠社区检测研究进展", 复杂系统与复杂性科学, vol. 14, no. 03 *
钟伟;吴娟;陈露;: "基于学习元平台的师生共读活动之社会网络分析和内容分析", 现代远距离教育, no. 01 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112232954A (en) * 2020-10-15 2021-01-15 杭州溪塔科技有限公司 Dynamic adjustment method and device for proposal timeout threshold value and electronic equipment

Also Published As

Publication number Publication date
CN111507840B (en) 2024-03-26

Similar Documents

Publication Publication Date Title
CN112446785B (en) Cross-chain transaction method, system, device, equipment and storage medium
CN111600720B (en) Data processing method, device and equipment based on block chain and readable storage medium
CN111382456B (en) Proposal message processing method, device, equipment and storage medium
CN109656778B (en) Data acquisition method and device, computer equipment and storage medium
CN111461885B (en) Consensus network management method, device, computer and readable storage medium
CN110569251A (en) Data processing method, related equipment and computer readable storage medium
CN110070445B (en) Transaction processing method and device based on blockchain system
CN112134762B (en) Testing method, device, terminal and storage medium for block chain network structure
CN111556115B (en) Block chain-based data processing method, device, equipment and storage medium
CN110570196A (en) Transaction data processing method and device, terminal equipment and storage medium
CN111464353B (en) Block link point management method, device, computer and readable storage medium
CN111061769A (en) Consensus method of block chain system and related equipment
EP3742321A1 (en) Storage of measurement datasets and distributed databases
CN111614761B (en) Block chain message transmission method, device, computer and readable storage medium
CN111209343B (en) Node data synchronization method, device, equipment and storage medium
CN111209339B (en) Block synchronization method, device, computer and storage medium
CN113326165B (en) Data processing method and device based on block chain and computer readable storage medium
CN112822239A (en) Block chain consensus method, block chain consensus device, electronic equipment and storage medium
CN110599180A (en) Block chain-based vaccine circulation management method and device
CN112671908A (en) Network management method and device, electronic equipment and readable storage medium
US20220239668A1 (en) Blockchain-based message processing method and apparatus, device, and storage medium
CN113852470B (en) Proposal broadcasting method, device, equipment and storage medium
CN111507840B (en) Block chain consensus method, apparatus, computer and readable storage medium
CN112200680B (en) Block link point management method, device, computer and readable storage medium
CN115730935A (en) Data processing method, device and equipment based on block chain and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40027390

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant