WO2021238514A1 - 基于区块链的数据处理方法、装置、设备及可读存储介质 - Google Patents

基于区块链的数据处理方法、装置、设备及可读存储介质 Download PDF

Info

Publication number
WO2021238514A1
WO2021238514A1 PCT/CN2021/088899 CN2021088899W WO2021238514A1 WO 2021238514 A1 WO2021238514 A1 WO 2021238514A1 CN 2021088899 W CN2021088899 W CN 2021088899W WO 2021238514 A1 WO2021238514 A1 WO 2021238514A1
Authority
WO
WIPO (PCT)
Prior art keywords
consensus
accounting
node
voting information
target block
Prior art date
Application number
PCT/CN2021/088899
Other languages
English (en)
French (fr)
Inventor
刘攀
Original Assignee
腾讯科技(深圳)有限公司
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 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Priority to EP21812015.2A priority Critical patent/EP4030314A4/en
Priority to JP2022539707A priority patent/JP7325894B2/ja
Priority to KR1020227016044A priority patent/KR20220074971A/ko
Publication of WO2021238514A1 publication Critical patent/WO2021238514A1/zh
Priority to US17/730,044 priority patent/US11914579B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • 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
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems
    • G06F16/1834Distributed file systems implemented based on peer-to-peer networks, e.g. gnutella
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • 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/389Keeping log of transactions for guaranteeing non-repudiation of a transaction
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Definitions

  • This application relates to the field of computer technology, in particular to a blockchain-based data processing method, device, equipment, and readable storage medium.
  • Blockchain is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. It is mainly used to sort data in chronological order and encrypt it into a ledger so that it cannot be tampered with or forged At the same time, data can be verified, stored and updated. Blockchain can also carry out data encryption transmission, node identification and secure access, and it is an advanced distributed infrastructure.
  • the process for the transaction data to be written into the ledger can be: the consensus node obtains the transaction data, then packs the transaction data into the block, executes the consensus process on the block, and the transaction will be carried after the consensus is passed.
  • the data block is written into the ledger.
  • the processing speed of the accounting of different consensus nodes may be different, that is, there are fast or slow, then the consensus node that completes the accounting first will enter the consensus process of the next block first ; Consensus nodes with slower bookkeeping will be slow, and the stored blocks cannot keep up with the consensus nodes with faster bookkeeping.
  • the consensus process of the next block is executed, the stored block height may be inconsistent This leads to consensus failure, which affects the consensus success rate.
  • a blockchain-based data processing method executed by a first node, which is a computer device, and includes:
  • the consensus result of the target block is determined.
  • the accounting time window is activated, and the accounting processing of the target block is performed in the accounting time window. , Receiving the first accounting completion message for the target block sent by the second node within the accounting time window;
  • the accounting duration window is closed and the consensus business process of the subsequent block of the target block is entered.
  • a block chain-based data processing device includes:
  • the voting information interaction module is used to send the first consensus voting information for the target block to the second node, and receive the second consensus voting information for the target block sent by the second node;
  • the consensus result determination module is used to determine the consensus result of the target block according to the first consensus voting information and the second consensus voting information;
  • the accounting processing module is used to start the accounting time window when the consensus result is the consensus passed result, and perform accounting processing on the target block in the accounting time window;
  • the accounting completion receiving module is configured to receive the first accounting completion message for the target block sent by the second node within the accounting time window;
  • the accounting completion notification module is used to send a second accounting completion message to the second node if the accounting processing of the target block is completed within the accounting time window;
  • the window closing module is used to close the accounting time window and enter the consensus business process of the subsequent blocks of the target block if the sum of the total number of the first accounting completion message and the second accounting completion message is greater than or equal to the number threshold .
  • a computer device that includes a memory and one or more processors.
  • the memory stores computer-readable instructions.
  • the one or more processors execute the above-mentioned blockchain-based The steps of the data processing method.
  • One or more non-volatile computer-readable storage media storing computer-readable instructions on which are stored computer-readable instructions.
  • the computer-readable instructions are executed by one or more processors, one or more processing
  • the device executes the steps of the above-mentioned blockchain-based data processing method.
  • a computer program product or computer program, the computer program product or computer program includes computer readable instructions, the computer readable instructions are stored in a computer readable storage medium, the processor of the computer device reads the computer readable from the computer readable storage medium Instruction, the processor executes the computer-readable instruction, so that the computer device executes the steps of the above-mentioned blockchain-based data processing method.
  • FIG. 1 is a schematic diagram of a network architecture provided by an embodiment of the present application.
  • FIG. 2 is a schematic flowchart of a data processing method based on blockchain provided by an embodiment of the present application
  • FIG. 3 is a schematic diagram of a billing scenario provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a billing scenario provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a billing scenario provided by an embodiment of the present application.
  • Fig. 6 is a schematic diagram of a billing scenario provided by an embodiment of the present application.
  • FIG. 7 is a schematic flowchart of a blockchain-based data processing method provided by an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of a block chain-based data processing device provided by an embodiment of the present application.
  • Fig. 9 is a schematic diagram of a computer device provided by an embodiment of the present application.
  • Fig. 1 is a schematic diagram of a network architecture provided by an embodiment of the present application.
  • Blockchain is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. It is mainly used to sort data in chronological order and encrypt it into a ledger so that it cannot be tampered with or forged At the same time, data can be verified, stored and updated.
  • the blockchain is essentially a decentralized database. Each node in the database stores the same blockchain.
  • the blockchain network divides the nodes into core nodes, data nodes, and light nodes.
  • the core node is responsible for The consensus of the entire blockchain network means that the core node is the consensus node in the blockchain network.
  • the client sends the transaction data to the data node or light node, and then the transaction data is in a baton way among the data nodes or light nodes in the blockchain network.
  • the consensus node packs the transaction data into a block and performs a consensus with other consensus nodes.
  • the block carrying the transaction data is written into the ledger.
  • the system architecture may include a first node cluster 1000 and a second node cluster 100.
  • the first node cluster 1000 may include at least two first nodes
  • the second node cluster 100 may include at least two second nodes. node.
  • the first node cluster 1000 may include a first node 1000a, a first node 1000b, ..., a first node 1000c
  • the second node cluster 100 may specifically include a second node 100a, a second node 100b, ..., the second node 100c.
  • the first node 1000a, the first node 1000b,..., the first node 1000c, and the second node 100a, the second node 100b,..., the second node 100c are all core nodes (that is, consensus nodes).
  • the second node 100a, the second node 100b,..., the second node 100c may be connected to the first node 1000a, the first node 1000b,..., the first node 1000c, respectively, to facilitate the second node
  • the data can be exchanged with the first node through the network connection; the second node 100a, the second node 100b,..., the second node 100c are connected to each other so that the second node can exchange data, the first node 1000a, the first node 1000a, the second node 100c
  • One node 1000b,..., and the first node 1000c are connected to each other, so that data exchange can be performed between the first nodes. Take the first node 1000a as an example.
  • the first node 1000a After receiving the transaction data sent by the data node or light node, the first node 1000a can store the transaction data in a memory pool (such as a transaction pool) and update it for recording input The hash tree of the data; afterwards, the update timestamp is updated to the time when the transaction data is received, and different random numbers are tried to calculate the characteristic value.
  • the transaction data can be correspondingly stored to generate the area
  • the block header and the main body of the block obtain the newly generated block; subsequently, the first node 1000a can send the newly generated block to its location according to the node identification of other core nodes (ie consensus nodes) in the blockchain network.
  • each core node in the blockchain network has a corresponding node identifier, and each core node in the blockchain network can store the node identifiers of other core nodes in the blockchain network for subsequent According to the node identification of other core nodes, broadcast the generated block to other core nodes in the blockchain network, and other core nodes will reach a consensus on the newly generated block, and the newly generated block will be transferred after the consensus is passed. The block is also added to the ledger to which other core nodes belong, so that the transaction data stored on all core nodes in the blockchain network are consistent.
  • this application adds a new record The accounting duration window. After the block has passed the consensus, the core node needs to perform accounting processing on the block in the accounting duration window.
  • the specific method may be, taking the first node 1000a, the second node 100a, the second node 100b, and the second node 100c as examples, for the consensus of the target block, the first node 1000a, the second node 100a, the second node 100b, and the The second node 100c may broadcast consensus voting information to each other, where the first node 1000a, the second node 100a, and the second node 100b all agree to vote, and the second node 100c has not broadcast the consensus voting information due to network reasons.
  • the consensus voting information of 3 consensus nodes are all yes votes, and the number of yes nodes accounts for all nodes The ratio 3/4 of the quantity exceeds the ratio threshold 2/3, the consensus result of the target block can be determined as the consensus passing result, then the first node 1000a, the second node 100a, the second node 100b, and the second node 100c You can start the accounting time window and perform accounting processing on the target block in the accounting time window; in the accounting time window, if a node has completed the accounting processing task for the target block, you can proceed Broadcast to notify other nodes that they have completed the accounting processing of the target block.
  • the first node 1000a completes the accounting processing of the target block in the second second, and broadcasts the notification.
  • the first node 1000a will wait for the second node 100a and the second node 100a and the second node within the accounting time window.
  • the completion notification of the node 100b and the second node 100c are determined.
  • the second node 100a completed the accounting processing of the target block and broadcasted the notification.
  • the second node 100b completed the target block Block accounting processing and broadcast notification, then in the 3.5s, a total of 3 consensus nodes (the first node 1000a, the second node 100a, the second node 100b) have completed the accounting processing of the target block Among the four consensus nodes of the first node 1000a, the second node 100a, the second node 100b, and the second node 100c, 3 consensus nodes have completed the accounting processing task of the target block.
  • Each consensus node in 100a and the second node 100b can be determined that at 3.5s, the proportion of the number of consensus nodes that complete the accounting processing task to the total number of all consensus nodes is 3/4, which exceeds the ratio threshold 2 /3, then in the 3.5s, the first node 1000a, the second node 100a, and the second node 100b will close the accounting time window and enter the subsequent process, that is, no longer wait for the second node 100c to complete the accounting.
  • the accounting time window is added, so that the consensus nodes (such as the first node and the second node) are performed within the accounting time window Accounting
  • each consensus node can broadcast notifications after the accounting is completed.
  • the consensus nodes that perform accounting when the consensus nodes exceeding the number threshold have completed the block accounting, these consensus nodes that have completed the accounting
  • the accounting duration window will be closed, and the consensus process of the next block will be entered together. In this way, the consensus node that completes the block accounting first can wait for other consensus nodes to complete the block accounting within the accounting time window, and then enter the consensus process of the next block together.
  • the consensus node that enters the consensus process of the next block can store the same block. In this way, when the consensus of the next block is carried out, it can reduce the consensus failure of the consensus node due to the high inconsistency of the block, thereby improving the consensus success rate of the consensus business process.
  • each first node in the first node cluster 1000 and each second node in the second node cluster 100 can be cloud servers, and these cloud servers can provide cloud services, cloud databases, cloud computing, Basic cloud computing services such as cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
  • the terminal and the server can be directly or indirectly connected through wired or wireless communication, which is not limited in this application.
  • Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and network within a wide area network or a local area network to realize the calculation, storage, processing, and sharing of data.
  • Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc., based on the application of cloud computing business models. It can form a resource pool, which can be used as needed, which is flexible and convenient. Cloud computing technology will become an important support.
  • the background service of the technical network system requires a large amount of computing and storage resources, such as video websites, image websites and more portal websites.
  • each item may have its own identification mark, which needs to be transmitted to the back-end system for logical processing. Data of different levels will be processed separately, and all types of industry data need to be powerful The backing of the system can only be achieved through cloud computing.
  • the method provided in the embodiments of the present application can be executed by a computer device, and the computer device includes but is not limited to a terminal or a server.
  • the server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server.
  • the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, etc., but it is not limited to this.
  • the terminal and the server can be directly or indirectly connected through wired or wireless communication, which is not limited in this application.
  • the node in the embodiment of the present application may be a computer device.
  • FIG 2 is a schematic flowchart of a blockchain-based data processing method provided by an embodiment of the present application.
  • the method is applied to the first node as an example for description.
  • the first node is a computer device, and the computer device may be
  • the terminal can also be a server.
  • the blockchain-based data processing method includes the following steps:
  • Step S101 Send the first consensus voting information for the target block to the second node, and receive the second consensus voting information for the target block sent by the second node.
  • both the first node and the second node can be the core nodes (consensus nodes) in the blockchain network, which can be responsible for the consensus of the entire blockchain network and write the blocks carrying transaction data to the local ledger .
  • the consensus node After the consensus node receives the transaction data, it can package the transaction data into a block and make a consensus with other consensus nodes.
  • the other consensus nodes will send their own consensus voting information to each other.
  • the consensus voting information includes the consensus voting information ( (Or agree to vote) and reject consensus through voting, then the first consensus voting information and second consensus voting information here may also include agreeing to consensus through voting and rejecting consensus through voting.
  • each core node when each core node generates a new block (such as a target block) based on transaction data, it can send the newly generated block to other core nodes in the blockchain network, and Other core nodes verify the newly generated block, that is, the core node in the blockchain network will send consensus voting information for the newly generated block, and notify other core nodes of their verification results , If the verification is passed, the consensus voting information is that the newly generated block passes the consensus; if the verification fails, the consensus voting information is the rejection of the newly generated block to pass the consensus.
  • the core node that generates a new block it can be used as a block producing node, and the first node and the second node here can be used as block producing nodes.
  • the consensus voting information is in favor of the block passing Consensus.
  • Step S102 Determine the consensus result of the target block according to the first consensus voting information and the second consensus voting information.
  • the consensus result is the consensus passed result
  • start the accounting time window and perform the accounting for the target block in the accounting time window.
  • Accounting processing receiving the first accounting completion message for the target block sent by the second node within the accounting duration window.
  • determining the consensus result of the target block according to the first consensus voting information and the second consensus voting information includes:
  • the second consensus voting information determine the number of second consensus voting information that belongs to the voting information as the first target quantity; if the first consensus voting information belongs to the voting information, then according to the first consensus voting information and the first target quantity, Determine the total number of votes for approval; if the ratio of the total number of votes for approval to the total number of nodes is greater than or equal to the ratio threshold, the consensus result of the target block is determined as the consensus passing result; the total number of nodes is the total of the first node and the second node Quantity; if the ratio of the total number of votes to the total number of nodes is less than the ratio threshold, the consensus result of the target block is determined as the consensus failure result.
  • the first node may determine the consensus result of the target block according to the received second consensus voting information sent by the second node.
  • the specific determination method can be as follows: the first node can determine the number of second voting information belonging to the approval vote (that is, the approval of the target block through the consensus) in the second consensus voting information, as the first target quantity; If a node approves the consensus of the target block, the total number of votes can be determined according to the first consensus vote and the first target number; if the ratio of the total number of votes to the total number of nodes is greater than or equal to the ratio threshold , The consensus result of the target block can be determined as the consensus passed result; where the total number of nodes is the total number of the first node and the second node; if the ratio of the total number of votes to the total number of nodes is less than With this ratio threshold, the consensus result of the target block can be determined as the consensus failure result.
  • the first node and the second node are the core nodes (consensus nodes) in the blockchain network, that is to say, in the blockchain network, there are consensus nodes that exceed or reach the ratio threshold when they agree to the consensus of the target block .
  • the consensus result of the target block will be determined as the consensus passed result; in the blockchain network, the core nodes that agree to the target block’s consensus do not exceed the proportion threshold, and the consensus result of the target block will be determined as consensus failure result.
  • the ratio threshold may be in the form of numerical values such as decimals, percentages, fractions, etc., for example, the ratio thresholds are 0.67, 2/3, 80%, etc., and no examples are given here.
  • the consensus nodes include the first node a, the second node d, the second node b, and the second node c.
  • the first consensus voting information of the first node a is the approval vote
  • the second The second consensus voting information of node d is the rejection of the consensus vote
  • the second consensus voting information of the second node b is approval voting
  • the second consensus voting information of the second node c is approval voting.
  • the total number of votes for approval is 3, and the ratio of the total number of votes for approval of 3 to the total number of nodes 4 is 3/4.
  • the ratio threshold is 2/3. It can be seen that the ratio 3/4 is greater than the ratio threshold 2/3, and the first node a can determine the consensus result of the block a as the consensus passing result.
  • the method further includes:
  • the total number of votes for the consensus is determined according to the first target number.
  • the first node can determine the quantity of the second voting information belonging to the approval vote (that is, the approval of the target block through the consensus) as the first target quantity; if the first node is If the target block is rejected to pass the consensus, the total number of votes for the target block can be determined according to the first target number; if the ratio of the total number of votes for the target block to the total number of nodes is greater than or equal to the ratio threshold, the consensus of the target block can be determined The result is determined to be the consensus approval result; where the total number of nodes is the total number of the first node and the second node; if the ratio of the total number of votes for the node to the total number of the node is less than the ratio threshold, the target area can be The consensus result of the block is determined to be the consensus failure result.
  • the consensus result of the target block can be determined as the consensus pass result. Therefore, even if the first node rejects the target block to pass the consensus, as long as there are consensus nodes in the blockchain network that exceed or reach the ratio threshold and all agree to the target block to pass the consensus, the consensus result of the target block is determined to be a consensus Pass the result.
  • the accounting time window is activated, and accounting processing is performed on the target block within the accounting time window, including:
  • the first node when it is determined that the target block is the consensus approval result, can obtain the number of second consensus voting information, and obtain the number of nodes of the second node, and use the number of nodes of the second node as the second target number ; If the quantity of the second consensus voting information is less than the second target quantity, the first node can start the accounting time window, and perform accounting processing on the target block within the accounting time window.
  • the quantity of the second consensus voting information is less than the second target quantity, which means that the first node only received part of the consensus voting information of the second node, and some second nodes may be delayed due to network delays, For reasons such as slow verification speed, the consensus voting information was not sent to the first node in time, and the first node did not receive this part of the consensus voting information of the second node. In this case, the first node will start the accounting period window , And keep accounts in the accounting time window. In other words, when the consensus result of the target block is the consensus passed result, and the first node only receives part of the consensus voting information of the second node, the first node will start the accounting time window, in the accounting time window Perform accounting processing on the target block.
  • the consensus nodes include the first node a, the second node d, the second node b, and the second node c.
  • the first node a agrees to the consensus of the block b
  • the second node d In order to approve the consensus of block b, and the second node b agrees to the consensus of block b, the consensus voting information of the first node a, the second node d, and the second node b are all in favor of voting; and the second node c is because Consensus voting information has not been broadcast due to the network, then for the first node a, the first consensus voting information of the first node a is a vote of approval, and the consensus voting information of the second node d is the second consensus voting information, which is approval Voting; the consensus vote of the second node b is the second consensus voting information.
  • the blockchain network there are a total of 3 consensus nodes of the first node a, the second node d, and the second node b.
  • favor of voting although the consensus voting information of the second node c has not been received (the first node a has only received part of the consensus voting information of the second node, and the number of second consensus voting information is less than the number of nodes of the second node), but In the received consensus voting information, the ratio 3/4 of the number of nodes in favor of voting (3) to the total number of nodes in the blockchain network (4) has exceeded the ratio threshold 2/3, then the first node a The accounting time window will be activated, and accounting processing will be performed in the accounting time window.
  • the first node only receives part of the consensus voting information sent by the second node, and in these part of the second node and the first node, the proportion of votes in favor of the total number of nodes in the blockchain network exceeds If the proportion threshold is exceeded, the first node will no longer control whether the consensus voting information of the remaining second nodes is approved or not, and will directly start the accounting time window, and perform accounting processing on the target block within the accounting time window.
  • the first node and the second node When the first node and the second node perform accounting processing within the accounting time window, if a node has completed the consensus on the target block, it can broadcast the accounting completion message to notify other nodes that they have completed the target area. Block accounting processing. Then in the accounting time window, if a second node completes the accounting processing of the target block, the second node will broadcast the notification, and the first node can receive the accounting completion of the second node that completed the accounting information.
  • Step S103 If the first node completes the accounting processing of the target block within the accounting time window, then sends a second accounting complete message to the second node.
  • the number of second nodes is multiple; if the accounting processing of the target block is completed within the accounting time window, the second accounting completion message is sent to the second node, including:
  • the accounting time window receive the third consensus voting information for the target block sent by the remaining second nodes; the remaining second nodes are among multiple second nodes, except for the second node that has sent the second consensus voting information If the accounting processing of the target block is completed within the accounting time window, the number of third consensus voting information is obtained; the number of third consensus voting information is added to the number of second consensus voting information, Obtain the total number of consensus votes; detect the message sending authority of the first node according to the total number of consensus votes and the second target number; when the first node has the message sending authority, send a second accounting completion message to the second node.
  • the first node when the first node only receives part of the consensus voting information of the second node, it will enter the accounting time window. When the first node performs accounting processing on the target block in the accounting time window, it still Can continue to receive consensus voting information (third Consensus voting information). That is to say, the remaining second node may not send the consensus voting information in time due to the network or other reasons, and only receive the consensus of the remaining second node when the first node performs accounting processing in the accounting period window Voting information, the first node can determine whether it has the message sending authority to send the accounting completion message according to the third consensus voting information of the remaining second nodes.
  • consensus voting information third Consensus voting information
  • the specific method can be as follows: if the first node completes the accounting processing of the target block within the accounting time window, the first node can obtain the number of third consensus voting information, and the first node can use the third The number of consensus voting information is added to the number of second consensus voting information to obtain the total number of consensus votes. According to the total number of consensus votes and the second target number, it is determined whether the first node has the right to send messages, and the first node has the message When sending the authority, the first node sends the second accounting complete message to the second node.
  • detecting the message sending authority of the first node according to the total number of consensus votes and the second target number includes:
  • the first node has the message sending authority; if the total number of consensus votes is equal to the second target number, it is determined that the first node does not have the message sending authority.
  • the first node can determine that it has the right to send messages, and the first node can send an accounting completion message to the second node, and broadcast a notification He has completed the block accounting; on the contrary, if the total number of consensus votes is equal to the second target number of the second node, the first node can determine that it does not have the right to send messages, and the first node completes the area within the accounting time window During block accounting, the accounting completion message will not be sent to the second node, and the accounting duration window can be directly closed and entered into the consensus business process of subsequent blocks of the target block.
  • the method further includes:
  • the accounting duration window is closed, and the consensus business process of the subsequent blocks of the target block is entered.
  • the first node can determine that it does not have the right to send messages, and when the first node completes block accounting within the accounting time window, it does not The accounting completion message will be sent to the second node, the accounting duration window can be closed directly, and the consensus business process of subsequent blocks of the target block can be entered. It should be noted that if the total number of consensus votes is equal to the second target number of the second node, the first node can determine that it has received all the consensus voting information of the second node in the accounting period window, and the first node will By default, other nodes in the blockchain network have also received all consensus voting information, and other nodes can maintain a similar accounting speed.
  • the first node will cancel the message sending authority. Therefore, because it does not have the message sending authority, the consensus node can no longer give other nodes when the accounting is completed. Send the accounting completion message. This can not only reduce traffic consumption, but also increase the speed of the consensus business process entering the subsequent block. Once the accounting is completed and the full ticket is received, the completion notification is no longer sent, and the accounting duration window is directly closed to enter the subsequent block. Consensus business process.
  • the first node can also choose to send the accounting completion message to the second node when the accounting is completed. Therefore, the second node in the accounting time window that has not received all the voting information due to network problems can determine whether it can close the accounting time window according to the accounting completion message sent by the first node.
  • the first node when the first node performs accounting processing on the target block in the accounting period window, if the first node only receives part of the consensus voting information sent by the remaining second nodes in the accounting period window, or If the consensus voting information of the remaining second node is not received (the total number of consensus votes is equal to the second target number of the second node), the first node will send the accounting to the second node when the accounting of the target block is completed Complete the message and wait for the node that has not completed the accounting within the accounting time window to perform accounting; if all the remaining consensus voting information sent by the second node is received, that is to say, the first node has received it within the accounting time window
  • the consensus voting information of all the second nodes the consensus voting information of all the second nodes (the total number of consensus votes is equal to the second target number of the second node)
  • the first node can directly close the accounting when completing the accounting of the target block Time window, no longer waiting for other consensus nodes, and directly enters the process of the next block of the target block
  • the first node can determine that the status of each consensus node (such as network status, information synchronization status, etc.) is not much different, and the speed of block accounting can be basically Keep the same, even if you don't wait, you can complete the block accounting in a small time difference, and when you enter the subsequent process together, the stored blocks will also have a small difference.
  • the status of each consensus node such as network status, information synchronization status, etc.
  • Step S104 If the sum of the total number of the first accounting completion message and the second accounting completion message is greater than or equal to the number threshold, the first node closes the accounting duration window and enters the consensus business process of the subsequent block of the target block .
  • the accounting time window if there are nodes exceeding the number threshold, they have completed the accounting processing of the target block (the sum of the total number of the first accounting completion message and the second accounting completion message is greater than or Equal to the number threshold), these nodes that have completed the accounting process can close the accounting time window, that is, jump out of the accounting time window and enter the subsequent process, such as entering the consensus business process of the next block of the target block. It is understandable that in the accounting time window, the node that completed the accounting process first has not received the consensus voting information of all the remaining nodes (in the blockchain network, the node that has not successfully sent the consensus voting information before), It will broadcast to notify itself that the accounting process has been completed, and will wait for other nodes to perform accounting within the accounting time window.
  • the number threshold here can be determined according to the total number of nodes in the blockchain network and a given ratio. If the given ratio is 3/5, the number threshold here can be 3/5 of the total number of nodes. That is, when there are more than 3/5 nodes in the blockchain network that complete the accounting, the nodes that can complete the accounting can close the accounting duration window.
  • the method further includes:
  • consensus nodes in the blockchain network include consensus node A (called the first node), consensus node B, consensus node C, consensus node D, and consensus node E (consensus node B, consensus node C, and consensus node D) And the consensus node E is called the second node).
  • consensus node A is for voting
  • consensus node B is for voting
  • consensus node C is for voting
  • consensus node D is for voting
  • consensus node E does not send out voting information due to network delays.
  • consensus node A receives the voting information of consensus node B, consensus node C, and consensus node D.
  • consensus node B, consensus node C, consensus node D, and consensus node E can also determine the consensus result of block a after receiving the voting information of other consensus nodes (not receiving the voting information of consensus node E) For the consensus to pass the result, consensus node B, consensus node C, consensus node D, and consensus node E will also start the accounting time window after confirming that the consensus of block a is passed.
  • consensus node A, consensus node B, consensus node C, consensus node D, and consensus node E will all perform accounting processing on block a within the accounting time window, where the accounting time window is 10s.
  • consensus node B When entering the 2s in the accounting time window, consensus node B has completed the accounting processing of block a, then consensus node B will broadcast to notify itself that the accounting processing of block a has been completed in the 2s, because In the second second, consensus node B has not received the accounting completion message sent by other nodes, and only consensus node B has completed the accounting processing of block a, then consensus node B will wait for others within the accounting time window Node accounting is completed; in the 3s, consensus node A also completed the accounting processing of block a, consensus node A will also broadcast notifications, in the 3s, consensus node B received the accounting sent by consensus node A After the message is completed, both consensus node B and consensus node A can confirm that two nodes, namely, consensus node A and consensus node B, have completed the accounting processing of block
  • consensus node A and consensus node B both receive the accounting completion message of consensus node D in the 4s
  • consensus node A and consensus Node B and consensus node D (consensus node D has received the accounting completion message of consensus node A and consensus node B) can confirm that there are 3 nodes in the 4s: consensus node A, consensus node B, and consensus node D Block accounting is completed, and the number of nodes that completed accounting 3 is equal to the number threshold 3.
  • Consensus node C and consensus node E that have not completed block accounting can continue to perform accounting within the accounting time window, and when the block accounting is completed and it has been determined that all nodes exceeding the number threshold have completed accounting, Close the accounting time window and enter the consensus business process of the next block of block a; if there are nodes in the consensus node C and consensus node E that have not completed the accounting processing of block a within the accounting time window , If the consensus node E has not completed the block accounting within the accounting time window within 10s, the consensus node E can enter the accounting time window when the accumulated time reaches the accounting time window's time threshold (10s), Close the accounting time window and enter the consensus business process of block b.
  • the method further includes:
  • the node that completed the accounting process first will wait for other nodes to do the accounting after the broadcast notification, and the node that completed the accounting process has not received the consensus voting information sent by all the remaining nodes. , And other nodes have not completed accounting or have not received the accounting completion message of other nodes, then when the time threshold of the accounting time window is reached, the node will determine that the number of completed nodes is less than the number threshold, then the first Both the first node and the second node (including nodes that have completed accounting and nodes that have not completed accounting) can close the accounting time window when the time threshold is reached, and enter the subsequent process together.
  • the blockchain network includes a total of 5 consensus nodes: the first node A, the second node B, the second node C, the second node D, and the second node E.
  • the first node A, the second node B, the second node C, the second node D, and the second node E perform accounting processing on block a within the accounting period window, where the period threshold of the accounting period window is 10s.
  • the second node B completes the accounting in the 2s
  • the first node A completes the accounting in the 3s
  • the second node B and the first node A will wait for the second node C, the second node D, and the first node within the accounting time window.
  • the second node E keeps accounts.
  • the second node C, the second node D, and the second node E have not completed the accounting of block a, and the cumulative time of the second node B and the first node A in the accounting time window has reached 10s ( When the time threshold of the accounting time window is reached), that is, if the accumulated time is equal to the time threshold, the second node B and the first node A will close the accounting time window and enter the consensus business process of the next block of block a . And when the second node C, the second node D, and the second node E reach the time threshold of 10s, they will also close the accounting time window and enter the consensus business process of the next block of block a.
  • the blockchain network includes a total of 5 consensus nodes: the first node A, the second node B, the second node C, the second node D, and the second node E.
  • the first node A, the second node B, the second node C, and the second node E did not receive the consensus voting information of the second node D (that is, only received the consensus voting information of some consensus nodes, and the approval votes exceeded the threshold) ,
  • the first node A, the second node B, the second node C, the second node D, and the second node E will enter the accounting period window, and perform accounting processing on the block a in the accounting period window, where,
  • the duration threshold of the accounting duration window is 10s.
  • the second node B completes the accounting in the 2s after entering the accounting time window
  • the first node A completes the accounting in the 3s
  • the second node B and the first node A receive each other's accounting completion message each other
  • the second Node B and the first node A will wait for the second node C, the second node D, and the second node E within the accounting time window.
  • the second node B and the first node A receive the first The consensus voting information of the second node D, at this time, both the second node B and the first node A have received the consensus voting information sent by all the remaining nodes (the second node D) (that is, they have received all other nodes in the blockchain network).
  • the second node B and the first node A will no longer wait for the second node C, the second node D, and the second node E to keep accounts, even if the number of nodes that have completed the block accounting is 2 ( 1 second node B + 1 first node A) is less than the number threshold 3, the second node B and the first node A will still close the accounting duration window and enter the subsequent process such as the consensus of the next block of block a In the business process.
  • the second consensus voting information carries the performance parameters of the second node, and the method further includes:
  • the accounting duration window is updated according to the performance parameters of the second node to obtain the updated accounting duration window; the duration threshold corresponding to the updated accounting duration window is less than the accounting duration The duration threshold corresponding to the accounting time window; start the updated accounting time window, and perform accounting processing on the target block in the updated accounting time window; if the target block is completed in the updated accounting time window The accounting processing of the target block enters the consensus business process of the subsequent block of the target block.
  • the first node can obtain the number of voting information of the second consensus, and obtain the number of nodes of the second node, and the number of nodes of the second node As the second target quantity; if the quantity of the second consensus voting information is equal to the second target quantity, the first node can obtain the performance parameters of the second node carried in the second consensus voting information, according to the performance of the second node Parameters are used to update the accounting time window to obtain the updated accounting time window; the first node can start the updated accounting time window, and book the target block in the updated accounting time window Processing; if the first node completes the accounting processing of the target block within the updated accounting time window, it can enter the consensus business process of the subsequent blocks of the target block.
  • the second consensus voting information carries the performance parameters of the second node, and the performance parameters may include network parameters, information transmission speed, etc.
  • the quantity of second consensus voting information is equal to the second target quantity, That is to say, the first node has received the consensus voting information of all second nodes in the blockchain network.
  • the first node can consider other second nodes The network status of the consensus nodes are all good (because the second node will soon send the voting information, and all the second nodes will soon send it), then the status of each node is good.
  • the first node can reduce the duration threshold of the accounting duration window according to the performance parameters of the second node.
  • the first node and the second node can perform accounting in a very short accounting time window (such as 1s) when they are in good condition.
  • the duration threshold can also be reduced to 0, that is, when the performance parameters are good, the accounting duration window may not be activated.
  • the first node has received all the consensus voting information of the second node and the performance parameters of the second node are very good, it can be considered that the accounting speed of the first node and the second node is not much different, and there is no need to exchange each other within the accounting time window. Waiting can also make the stored blocks the same or the difference is small, and the duration threshold of the accounting time window can be reduced, so that the node can not be restricted by the time of the accounting time window, and can quickly enter the subsequent consensus business process.
  • the embodiment of this application adds an accounting time window for the consensus node. If the consensus node receives the consensus voting information of the consensus node exceeding the number threshold as a vote, the consensus node will no longer manage the unreceived consensus node. The voting result will enter the accounting time window, and block accounting will be performed in the accounting time window. If the consensus node receives all voting information in the accounting time window, the consensus node will close the accounting time window after the accounting is completed and enter the subsequent process; if the accounting time window still has not received all the voting information, Then the consensus node will wait for other consensus nodes to book after the bookkeeping is completed.
  • Consensus nodes can synchronize blocks with small differences in a short period of time through block synchronization, so that when the consensus of the next block is carried out, the consensus nodes can be reduced due to inconsistent block heights.
  • the failure of consensus can improve the success rate of consensus for the consensus business process.
  • FIG. 3 is a schematic diagram of a billing scenario provided by an embodiment of the present application.
  • consensus node A can be the block producer, and consensus node A can be the first node.
  • consensus node A will receive other consensus nodes (the consensus in Figure 3) Node B, consensus node C) voting information, consensus node B and consensus node C can both be the second node. Because each consensus node sends information at different speeds, the voting information received by consensus node A is not received at the same time.
  • the consensus node counts that among the received voting information, the passing votes have exceeded the threshold or When the threshold is reached, the consensus node can determine that the target block has passed the consensus.
  • consensus node A has received the voting information of consensus node B, but has not yet received the voting information of consensus node C, but there are three consensus nodes: consensus node A, consensus node B, and consensus node C , There have been 2 passing votes (consensus node A is the block producer, and the voting information of the block producer is approved). The number of passed votes (2) accounts for 2/3 of the total number of consensus nodes (3). This ratio has been When the expected passing ratio of 2/3 is reached, the consensus node A can determine that the target block has passed the consensus. The consensus node A will no longer manage the voting information of the consensus node C, and will directly start the accounting time window. The target block is accounted for in the duration window.
  • consensus node B can also receive the voting information of consensus node A, and consensus node B can also determine that the target block has passed the consensus, then consensus node B will also start the accounting time window, and the accounting period will be checked in the accounting time window.
  • the target block is accounted for; in the same way, consensus node C can also receive the voting information of consensus node A and consensus node B, combined with the consensus node’s own voting information, consensus node C can determine that the number of votes passed is 3 votes, then consensus node C can also determine that the target block has passed the consensus, and the consensus node C will also start the accounting time window, and perform accounting processing on the target block within the accounting time window.
  • the accounting time window is 6s in total, that is, consensus node A, consensus node B, and consensus node C need to perform accounting processing on the target block within 6s.
  • the consensus node A when the consensus node A has completed the accounting of the target block when entering the 2s of the accounting time window, the consensus node A can send the accounting completion message to the consensus node B and the consensus node C to notify I have completed the accounting task of the target block. Because the voting information of consensus node C has not been received, and at the second second of the accounting window, only consensus node A has completed accounting for the target block, consensus node A has not received consensus node B or If the accounting completion message of the consensus node C, the consensus node A will not enter the subsequent process, and will wait for the consensus node B and the consensus node C to perform accounting within the accounting time window.
  • the consensus node B when entering the 3s of the accounting time window, the consensus node B has also completed accounting for the target block, and the consensus node B can send an accounting completion message to the consensus node A and the consensus node C to notify The other party has completed the accounting task of the target block. Because in the 3s of the accounting time window, consensus node A received the accounting completion message sent by consensus node B, and consensus node B also received the accounting completion message sent by consensus node A before, then consensus node A and consensus Node B can be determined, only consensus node A and consensus node B, a total of 2 consensus nodes, have completed accounting for the target block. The number of nodes that completed accounting 2 accounts for the ratio of the total number of blockchain network nodes 3 to 2/ 3.
  • consensus node A and consensus node B will close the accounting time window and enter the subsequent process.
  • Consensus node C which has not completed accounting, will continue to book the target block within the accounting time window, because consensus node C has received all the voting information (including the voting information of consensus node A and the voting of consensus node B Information), no matter whether the consensus node C has received the accounting completion message of the consensus node A or the consensus node B, as long as the consensus node C is completing the accounting, it can close the accounting time window and enter the subsequent process.
  • the consensus node that completes block accounting first (such as consensus node A) can wait for other consensus nodes to perform block accounting until it exceeds or reaches the specified ratio (such as 2/ 3)
  • the consensus nodes that have completed the block accounting will close the accounting duration window and enter the consensus process of the next block together. Because the consensus node with fast accounting speed waits for the consensus node with slow accounting speed to perform accounting, it can make the consensus nodes that enter the consensus process of the next block store the same block, so that the next block is being processed. When the consensus is reached, it can reduce the consensus failure of consensus nodes due to inconsistent blocks, and improve the success rate of subsequent consensus.
  • the consensus node A can be the block producer, and the consensus node A can be the first node.
  • the consensus node A will receive other consensus nodes (the consensus in Figure 4) Node B, consensus node C) voting information, consensus node B and consensus node C can both be the second node. Because each consensus node sends information at different speeds, the voting information received by consensus node A is not received at the same time.
  • the consensus node counts that among the received voting information, the passing votes have exceeded the threshold or When the threshold is reached, the consensus node can determine that the target block has passed the consensus.
  • consensus node A has received the voting information of consensus node B, but has not yet received the voting information of consensus node C, but there are three consensus nodes in total: consensus node A, consensus node B, and consensus node C , There have been 2 passing votes (consensus node A is the block producer, and the voting information of the block producer is approved). The number of passed votes (2) accounts for 2/3 of the total number of consensus nodes (3). This ratio has been When the expected passing ratio of 2/3 is reached, the consensus node A can determine that the target block has passed the consensus. The consensus node A will no longer manage the voting information of the consensus node C, and will directly start the accounting time window. The target block is accounted for in the duration window.
  • consensus node B can also receive the voting information of consensus node A, and consensus node B can also determine that the target block has passed the consensus, then consensus node B will also start the accounting time window, and the accounting period will be checked in the accounting time window.
  • the target block is accounted for; in the same way, consensus node C can also receive the voting information of consensus node A and consensus node B, combined with the consensus node’s own voting information, consensus node C can determine that the number of votes passed is 3 votes, then consensus node C can also determine that the target block has passed the consensus, and the consensus node C will also start the accounting time window, and perform accounting processing on the target block within the accounting time window.
  • the consensus node A when the consensus node A has completed the accounting of the target block when entering the 2s of the accounting time window, the consensus node A can send an accounting completion message to the consensus node B and the consensus node C to notify The other party has completed the accounting task of the target block. Because at the second second of the accounting window, the voting information of consensus node C has not been received, and the accounting completion message of consensus node B or consensus node C has not been received, consensus node A can determine that there is only consensus node A When the consensus node completes the accounting of the target block, the consensus node A will not enter the subsequent process, and will wait for the consensus node B and the consensus node C to keep the accounts within the accounting time window.
  • consensus node A when entering the 2.5s of the accounting time window, consensus node A receives the voting information sent by consensus node C, then consensus node A received the 2.5s of the accounting time window The voting information of all consensus nodes in the blockchain (including consensus node B and consensus node C), consensus node A will not continue to wait for consensus node B and consensus node C to keep accounts at 2.5 hours, and will directly close the accounting
  • the time window enters into the consensus business process of the next block of the target block.
  • FIG. 5 is a schematic diagram of a billing scenario provided by an embodiment of the present application.
  • consensus node A can be the block producer, and consensus node A can be the first node.
  • consensus node A will receive other consensus nodes (the consensus in Figure 5) Node B, consensus node C) voting information, consensus node B and consensus node C can both be the second node. Because each consensus node sends information at different speeds, the voting information received by consensus node A is not received at the same time.
  • the consensus node counts that among the received voting information, the passing votes have exceeded the threshold or When the threshold is reached, the consensus node can determine that the target block has passed the consensus.
  • consensus node A has received the voting information of consensus node B, but has not yet received the voting information of consensus node C, but there are 3 consensus nodes in consensus node A, consensus node B, and consensus node C Among them, there have been 2 passing votes (consensus node A is the block producer, and the voting information of the block producer is approved), and the ratio of the passing votes (2) to the total number of consensus nodes (3) is 2/3, the ratio Has reached the expected pass ratio of 2/3, then consensus node A can determine that the target block has passed the consensus, consensus node A will no longer manage the voting information of consensus node C, and will directly start the accounting time window, in the record The target block is accounted for in the account duration window.
  • consensus node B can also receive the voting information of consensus node A, and consensus node B can also determine that the target block has passed the consensus, then consensus node B will also start the accounting time window, and the accounting period will be checked in the accounting time window.
  • the target block is accounted for; in the same way, consensus node C can also receive the voting information of consensus node A and consensus node B, combined with the consensus node’s own voting information, consensus node C can determine that the number of votes passed is 3 votes, then consensus node C can also determine that the target block has passed the consensus, and the consensus node C will also start the accounting time window, and perform accounting processing on the target block within the accounting time window.
  • consensus node B has not completed the accounting of the target block, and consensus node B will continue accounting.
  • the consensus node B completed the accounting of the target block, because in the previous 2.5s, the consensus node B received the vote of the consensus node C Information, when the consensus node B completes accounting in the 3s, although the consensus node B thinks that only one of its own nodes has completed the block accounting and has not yet reached the number threshold 2, the consensus node will still close the accounting period window. Then wait for other consensus nodes, and directly enter the subsequent process, such as entering the consensus business process of the next block of the target block.
  • consensus node C when entering the accounting time window for the second second, consensus node A completed the block accounting, and consensus node C received the accounting completion message of consensus node A in the second second. , Because the consensus node C has not completed the block accounting, the consensus node C will continue to perform the accounting for the block A. In the 3s, consensus node C receives the accounting completion message of consensus node B, and consensus node C will continue to perform block accounting. In the accounting time window, consensus node C has not completed the accounting processing of the target block. When the time threshold of 6s is reached, consensus node C will close the accounting time window and enter the next block of the target block In the consensus business process.
  • consensus node A and the consensus node B have not received the voting information sent by the consensus node C within the accounting time window. That is to say, in the 2.5s, consensus node A and consensus node B did not receive the voting information sent by consensus node C, then consensus node A will not close the accounting when it completes accounting in the second second of the accounting window.
  • the account duration window will wait for consensus node B and consensus node C to keep accounts.
  • consensus node B and consensus node C have not completed accounting. When it reaches 6s, consensus node A that has completed accounting, consensus node B and consensus node C that have not completed accounting will close the accounting time window and enter together Go to the consensus business process of the next block of the target block.
  • the consensus node that completed the block bookkeeping first will wait for the consensus node with the slow bookkeeping speed within the bookkeeping time window, and when it reaches the bookkeeping time window At the time threshold, it enters the consensus process of the next block together with the consensus node with slow billing speed, which can reduce the difference between the block stored by the consensus node with slow billing speed and the node with fast billing speed.
  • the blocks stored by each consensus node are not much different, which improves the success rate of subsequent consensus.
  • the consensus node receives the voting information of all consensus nodes in the accounting time window, the consensus node that completed the accounting first can directly close the accounting time window when completing the block accounting, and enter the consensus of the next block Process. Because other consensus nodes have successfully sent voting information, the network status of each consensus node is in a good state. It can be considered that the status of each consensus node is not much different, and the speed of block accounting can be basically the same, then When entering the consensus process of the next block, the blocks stored by each consensus node are also very small, and these consensus nodes can synchronize through the block to synchronize the slightly behind nodes to the difference area in a short time. In this way, each consensus node can keep the stored blocks consistent in a short period of time, which can improve the consensus success rate of subsequent consensus.
  • the consensus node A can be the block producer, and the consensus node A can be the first node.
  • the consensus node A will receive other consensus nodes (the consensus in Figure 6) Node B, consensus node C) voting information, consensus node B and consensus node C can both be the second node. Consensus node B and consensus node C will soon send out voting information.
  • the voting information of consensus node B is passed, and the voting information of consensus node C is also passed, because the number of votes passed is 3 and the total number of nodes in the blockchain network If the number 3 is equal, the consensus node A can determine that the consensus result of the target block is a consensus. Because the consensus node has received all the voting information in the blockchain network (the voting information of the consensus node B and the consensus node C), the consensus node A can obtain the performance of the consensus node B carried in the voting information sent by the consensus node B Parameters, and the performance parameters of consensus node C carried in the voting information sent by consensus node C.
  • consensus node A can update the accounting duration window with a duration threshold of 6s , The time threshold of the updated accounting time window obtained after the update becomes 3s.
  • Consensus node A, consensus node B, and consensus node C can enter the updated accounting time window to perform accounting processing on the target block.
  • Consensus node A , Consensus node B and consensus node C need to perform accounting processing on the target block within 3s.
  • the consensus node A when the consensus node A completes the block accounting in the first second, it can also choose not to broadcast notification, that is, when the block accounting is completed, it does not send the accounting completion message to the consensus node B and the consensus node C. Directly close the window for updating the accounting duration and enter the consensus business process of the next block.
  • the consensus node A can send the accounting completion message to the consensus node B and the consensus node C without closing the update accounting. Accounting duration window. Consensus node A can wait for consensus node B and consensus node C to perform accounting within the update accounting duration window, and close the update accounting duration until it is determined that 2/3 of the consensus nodes have completed block accounting. Window to enter the consensus business process of the next block.
  • consensus node B completes block accounting at 1.5s, and broadcasts notification, consensus node A receives the accounting completion message of consensus node B, at this time, consensus node A can determine that there are 2 consensus nodes (consensus Node A and Consensus Node B) complete block bookkeeping, the number of nodes that have completed bookkeeping (2) accounts for 2/3 of the total number of nodes in the blockchain network (3), which has reached a given ratio of 2/3, then When the consensus node A is 1.5s, it can close the window for updating the accounting duration and enter the consensus business process of the next block.
  • 2 consensus nodes consistensus Node A and Consensus Node B
  • each consensus node can update the accounting time window according to the performance parameters of other consensus nodes (reduce the time threshold of the accounting time window), and update the accounting time window.
  • Block accounting is performed in the accounting time window, and after the block accounting is completed, it enters the subsequent consensus process. Because the status of each consensus node is good and there is not much difference, the accounting speed can also be basically the same.
  • the stored blocks can also be basically the same. In this case, reduce the accounting The duration threshold of the duration window can make the consensus node not need to wait for other consensus nodes or reduce the waiting time, so that the consensus node can quickly enter the subsequent consensus business process and the stored blocks can also be basically consistent.
  • FIG. 7 is a schematic flowchart of a blockchain-based data processing method provided by an embodiment of the present application. As shown in Figure 7, the process of this solution can be:
  • step S201 the consensus node receives voting information for the target block.
  • the consensus nodes in the blockchain network need to vote for the block production before accounting for the block.
  • the consensus node receives the voting results of the consensus nodes that exceed the threshold, the voting results are passed.
  • the block is confirmed as the consensus passed.
  • the consensus node will perform block accounting.
  • step S202 the consensus node determines that the target block consensus is passed.
  • consensus nodes are voting for block generation, because the speed of each consensus node sending messages is inconsistent, the voting information of other consensus nodes received by each consensus node is not received at the same time.
  • the consensus node counts In the received voting information, when the passing votes have exceeded the threshold, the consensus node will determine that the voting block has passed the consensus.
  • step S203 the consensus node determines that the unanimous vote is received.
  • each consensus node if each consensus node is in a good state, it will soon send its own voting information, and each consensus node may have received voting information from all consensus nodes when the statistically passed votes exceed the threshold.
  • step S204 the consensus node updates the accounting time window when receiving the unanimous vote.
  • each consensus node If in the blockchain network, each consensus node is in good condition and will soon send its own voting information, each consensus node has received the voting information of all consensus nodes when the counted votes exceed the threshold. Then in the blockchain network, because each consensus node is in a good state and the accounting speed is not much different, the blocks stored between each consensus node are also not much different, and the consensus success rate in the subsequent consensus process It will also be very high. In this case, the consensus node can update the accounting time window according to the performance parameters of other consensus nodes, reduce the time threshold of the accounting time window, and obtain the updated accounting time window, and then the updated accounting Block accounting is performed in the time window.
  • Step S205 After the consensus node completes accounting, it enters the subsequent process.
  • the consensus node can enter the subsequent process, such as entering the consensus business process of the next block of the target block; if it is not within the updated accounting time period
  • the update accounting time window will jump out and enter the subsequent process.
  • step S206 the consensus node determines that a part of the votes has been received.
  • step S207 the consensus node enters the accounting duration window.
  • the accounting speed will be slow. If the consensus node with a fast accounting speed does not wait for a consensus node with a slow accounting speed, the consensus node with a slow accounting speed will The blocks stored between the consensus nodes with fast accounting speed will be very different, which will affect the consensus success rate in the subsequent consensus process. In this case, the consensus node may enter the accounting period window without updating the accounting period window, and perform block accounting in the accounting period window.
  • the accounting time window can be understood as setting a waiting time for the consensus node, so that the consensus node with a fast accounting speed can wait for the consensus node with a slow accounting speed after the accounting is completed.
  • step S208 the consensus node has not received a full ticket within the accounting time window.
  • consensus nodes when consensus nodes perform block accounting in the accounting period window, they can still continue to receive voting information from other consensus nodes. Some consensus nodes have slow sending speeds. In the accounting period window, those consensus nodes that send slow are still The voting information is not sent, or some consensus nodes that are slow to send the voting information, but there are still a small number of consensus nodes that have not yet sent the voting information. In other words, the consensus node may have not received a full vote within the accounting time window.
  • step S209 the consensus node completes accounting within the accounting time window.
  • the consensus node when the consensus node has not received the unanimous vote, when the consensus node completes the block accounting within the accounting time window, it will broadcast a notification in the accounting time window, and need to wait for other consensus nodes to book and receive Notification messages from other nodes that have completed bookkeeping until the proportion of nodes that have completed bookkeeping to the total nodes reaches or exceeds the given proportion value.
  • step S210 the consensus node jumps out of the accounting duration window.
  • consensus nodes that have completed block accounting can jump out of the accounting duration window and enter the subsequent process; and if Consensus nodes that have completed block bookkeeping have not exceeded or reached the given ratio, then consensus nodes that have completed block bookkeeping and unfinished block bookkeeping will close the bookkeeping together when the time threshold of the bookkeeping window is reached. Time window, enter the follow-up process together.
  • a given ratio such as 2/3
  • step S211 if a given proportion of consensus nodes have not completed accounting, the consensus nodes will wait forever.
  • step S212 when the time threshold of the accounting time window is reached, all nodes close the accounting time window and enter the subsequent process.
  • step S213 the consensus node receives a full ticket within the accounting time window.
  • consensus node when the consensus node performs block accounting in the accounting period window, those consensus nodes that send slowly also send voting information (that is, the voting information of all consensus nodes is received in the accounting period window) , It can be understood that the consensus node has received unanimous votes.
  • step S214 the consensus node jumps out of the accounting duration window after the accounting is completed.
  • the consensus node when the consensus node receives a full ticket in the accounting time window, it will continue to perform block accounting in the accounting time window, and directly jump out of the accounting time window after the accounting is completed, and enter the subsequent process (because in the time window If the voting information of all consensus nodes is successfully received within, the status of each consensus node is the same, and the accounting speed is not much different from the network status. Accounting can be completed in about the same time, and the storage area is stored when entering the subsequent process. The blocks are not much different, and there is no need to wait).
  • FIG. 8 is a schematic structural diagram of a blockchain-based data processing device provided by an embodiment of the present application.
  • the blockchain-based data processing device can be a computer-readable instruction (including program code) running in a computer device.
  • the blockchain-based data processing device is an application software; the device can be used to execute this application The corresponding steps in the method provided in the embodiment.
  • the data processing device 1 may include: a voting information interaction module 11, a consensus result determination module 12, an accounting processing module 13, an accounting completion receiving module 14, an accounting completion notification module 15, and a window closing module 16.
  • the voting information interaction module 11 is configured to send the first consensus voting information for the target block to the second node, and receive the second consensus voting information for the target block sent by the second node;
  • the consensus result determining module 12 is used to determine the consensus result of the target block according to the first consensus voting information and the second consensus voting information;
  • the accounting processing module 13 is used to start the accounting time window when the consensus result is the consensus passed result, and perform accounting processing on the target block in the accounting time window;
  • the accounting completion receiving module 14 is configured to receive the first accounting completion message for the target block sent by the second node within the accounting time window;
  • the accounting completion notification module 15 is configured to send a second accounting completion message to the second node if the accounting processing of the target block is completed within the accounting time window;
  • the window closing module 16 is used to close the accounting time window and enter the consensus business of the subsequent block of the target block if the sum of the total number of the first accounting completion message and the second accounting completion message is greater than or equal to the number threshold Process.
  • step S101 to step S104 in the example will not be repeated here.
  • the consensus result determining module 12 may include: a first target quantity determining unit 121, a positive vote quantity determining unit 122, a consensus passing determining unit 123, and a consensus failure determining unit 124.
  • the first target quantity determining unit 121 is configured to determine the quantity of the second consensus voting information belonging to the approval voting in the second consensus voting information, as the first target quantity;
  • the affirmative vote quantity determining unit 122 is configured to determine the total number of affirmative votes based on the first consensus vote information and the first target number if the first consensus voting information belongs to the affirmative vote. If the first consensus vote information belongs to the rejection consensus vote, Determine the total number of votes in favor of the first target number;
  • the consensus passing determination unit 123 is used to determine the consensus result of the target block as the consensus passing result if the ratio of the total number of votes to the total number of nodes is greater than or equal to the ratio threshold; the total number of nodes is the first node and the second node The total number of;
  • the consensus failure determination unit 124 is configured to determine the consensus result of the target block as the consensus failure result if the ratio of the total number of approval votes to the total number of nodes is less than the ratio threshold.
  • the affirmative vote quantity determining unit 122 the consensus passing determining unit 123, and the consensus failure determining unit 124, please refer to the description in step S102 in the embodiment corresponding to FIG. 2. Do not repeat it here.
  • the accounting processing module 13 may include: a quantity acquiring unit 131, a second target quantity determining unit 132, and an accounting processing unit 133.
  • the quantity obtaining unit 131 is configured to obtain the quantity of second consensus voting information when the consensus result is a consensus passed result
  • the second target quantity determining unit 132 is configured to obtain the node quantity of the second node as the second target quantity
  • the accounting processing unit 133 is configured to, if the quantity of the second consensus voting information is less than the second target quantity, start the accounting time window, and perform accounting processing on the target block in the accounting time window.
  • step S102 for the specific implementation of the quantity acquisition unit 131, the second target quantity determination unit 132, and the billing processing unit 133, please refer to the description of step S102 in the embodiment corresponding to FIG. 2, which will not be repeated here.
  • the data processing device 1 may include a voting information interaction module 11, a consensus result determination module 12, an accounting processing module 13, an accounting completion receiving module 14, an accounting completion notification module 15, and a window closing module 16, and It may include: a window update module 17, a window activation module 18, and a process entry module 19.
  • the window update module 17 is used to update the accounting duration window according to the performance parameters of the second node if the quantity of the second consensus voting information is equal to the second target quantity to obtain the updated accounting duration window; the updated accounting duration The duration threshold corresponding to the window is less than the duration threshold corresponding to the accounting duration window;
  • the window activation module 18 is used to activate the updated accounting time window, and perform accounting processing on the target block in the updated accounting time window;
  • the process entry module 19 is used to enter the consensus business process of subsequent blocks of the target block if the first node completes the accounting processing of the target block within the updated accounting time window.
  • window update module 17 the window activation module 18, and the process entry module 19, please refer to the description in step S104 in the embodiment corresponding to FIG. 2, which will not be repeated here.
  • the accounting completion notification module 15 may include a voting information receiving unit 151, a voting quantity obtaining unit 152, an addition processing unit 153, a permission detection unit 154, and an accounting completion sending unit 155.
  • the voting information receiving unit 151 is configured to receive the third consensus voting information for the target block sent by the remaining second nodes within the accounting time window; the remaining second nodes are among multiple second nodes, except for the second node that has already sent Nodes other than the second node of consensus voting information;
  • the voting quantity obtaining unit 152 is configured to obtain the total quantity of third consensus voting information if the accounting processing of the target block is completed within the accounting time window;
  • the addition processing unit 153 is configured to add the quantity of the third consensus voting information and the quantity of the second consensus voting information to obtain the total number of consensus votes;
  • the permission detection unit 154 is configured to detect the message sending permission of the first node according to the total number of consensus votes and the first target number;
  • the accounting completion sending unit 155 is configured to send a second accounting completion message to the second node when the first node has the message sending authority.
  • the specific implementation of the voting information receiving unit 151, the voting quantity obtaining unit 152, the addition processing unit 153, the permission detection unit 154, and the accounting completion sending unit 155 can be referred to the description of step S103 in the embodiment corresponding to FIG. 2. I will not repeat them here.
  • the authority detecting unit 154 may include: a first authority determining subunit 1541 and a second authority determining subunit 1542.
  • the first authority determining subunit 1541 is configured to determine that the first node has the message sending authority if the total number of consensus votes is less than the second target number;
  • the second authority determining subunit 1542 is configured to determine that the first node does not have the message sending authority if the total number of consensus votes is equal to the second target number.
  • step S103 for the specific implementation of the first authority determining sub-unit 1541 and the second authority determining sub-unit 1542, please refer to the description of step S103 in the embodiment corresponding to FIG. 2, which will not be repeated here.
  • the data processing device 1 may include a voting information interaction module 11, a consensus result determining module 12, an accounting processing module 13, an accounting completion receiving module 14, an accounting completion notification module 15, and a window closing module 16, window
  • the update module 17, the window activation module 18, and the process entry module 19 may also include: a consensus process entry module 20.
  • the consensus process entry module 20 is used to close the accounting time window when the first node does not have the message sending authority, and enter the consensus business process of subsequent blocks of the target block.
  • step S104 in the embodiment corresponding to FIG. 2, which will not be repeated here.
  • the data processing device 1 may include a voting information interaction module 11, a consensus result determining module 12, an accounting processing module 13, an accounting completion receiving module 14, an accounting completion notification module 15, and a window closing module 16, window
  • the update module 17, the window activation module 18, the process entry module 19, and the consensus process entry module 20 may also include: a first duration threshold acquisition module 21, a first cumulative duration statistics module 22, and a first block consensus entry module 23.
  • the first duration threshold acquisition module 21 is configured to acquire the duration threshold corresponding to the accounting duration window
  • the first accumulated time statistics module 22 is used to count the accumulated time that the first node is in the accounting time window;
  • the first block consensus entry module 23 is used to close the accounting time window if the accumulated time is equal to the time threshold, and the sum of the total number of the first accounting completion message and the second accounting completion message is less than the number threshold, The consensus business process of subsequent blocks that enter the target block.
  • the specific implementation of the first duration threshold acquisition module 21, the first cumulative duration statistics module 22, and the first block consensus entry module 23 can be found in the description of step 104 in the embodiment corresponding to FIG. 2, which will not be omitted here. Go ahead and repeat.
  • the data processing device 1 may include a voting information interaction module 11, a consensus result determining module 12, an accounting processing module 13, an accounting completion receiving module 14, an accounting completion notification module 15, and a window closing module 16, window Update module 17, window start module 18, process entry module 19, consensus process entry module 20, first duration threshold acquisition module 21, first cumulative duration statistics module 22, and first block consensus entry module 23, and may also include a second The duration threshold obtaining module 24, the second cumulative duration statistics module 25, and the second block consensus entry module 26.
  • the second duration threshold acquisition module 24 is used to acquire the duration threshold corresponding to the accounting duration window
  • the second accumulated time statistics module 25 is used to obtain the accumulated time that the first node is in the accounting time window;
  • the second block consensus entry module 26 is used to close the accounting time window and enter the target area if the accumulated time is equal to the time threshold and the first node has not completed the accounting processing of the target block within the accounting time window.
  • the consensus business process of the subsequent blocks of the block is used to close the accounting time window and enter the target area if the accumulated time is equal to the time threshold and the first node has not completed the accounting processing of the target block within the accounting time window.
  • step S104 the specific implementation of the second duration threshold acquisition module 24, the second cumulative duration statistics module 25, and the second block consensus entry module 26 can be found in the description of step S104 in the embodiment corresponding to FIG. 2, which will not be omitted here. Go ahead and repeat.
  • the consensus node when the block is booked after the consensus is reached, the consensus node is added with a billing time window, so that the consensus nodes (such as the first node and the second node) perform billing within the billing time window.
  • Each consensus node can broadcast notifications after the accounting is completed.
  • these consensus nodes that have completed the accounting will close the accounting.
  • Account time window enter the consensus process of the next block together. In this way, the consensus node that completes the block accounting first can wait for other consensus nodes to complete the block accounting within the accounting time window, and then enter the consensus process of the next block together.
  • Consensus nodes can synchronize blocks with small differences in a short period of time through block synchronization, so that when the consensus of the next block is carried out, the consensus nodes can be reduced due to inconsistent block heights. Consensus failures can improve the consensus success rate of subsequent consensus business processes.
  • FIG. 9 is a schematic diagram of a computer device provided by an embodiment of the present application.
  • the apparatus 1 in the embodiment corresponding to FIG. 8 may be applied to a computer device 1000.
  • the computer device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, and a memory 1005 , At least one communication bus 1002.
  • the communication bus 1002 is used to implement connection and communication between these components.
  • the user interface 1003 may include a display screen (Display) and a keyboard (Keyboard), and the network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
  • the memory 1005 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory.
  • the memory 1005 may also be at least one storage device located far away from the aforementioned processor 1001.
  • the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.
  • the network interface 1004 is mainly used for network communication with the service server; and the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the storage in the memory 1005
  • the device control application to achieve:
  • the consensus result of the target block is determined.
  • the accounting time window is activated, and the accounting processing of the target block is performed in the accounting time window. , Receiving the first accounting completion message for the target block sent by the second node within the accounting time window;
  • the accounting duration window is closed and the consensus business process of subsequent blocks of the target block is entered.
  • the computer device 1000 described in the embodiment of the present application can execute the description of the blockchain-based data processing method in the foregoing embodiment corresponding to FIG. 2 to FIG. 7 and may also execute the foregoing embodiment corresponding to FIG. 8
  • the description of the data processing device 1 in, will not be repeated here.
  • the description of the beneficial effects of using the same method will not be repeated.
  • the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores the aforementioned computer program executed by the video data processing computer device 1000, and
  • the computer program includes computer-readable instructions.
  • the processor executes the computer-readable instructions, it can execute the description of the blockchain-based data processing method in the previous embodiment corresponding to Figures 2 to 7. Therefore, it will not be repeated here. Go into details.
  • the description of the beneficial effects of using the same method will not be repeated.
  • technical details not disclosed in the embodiment of the computer-readable storage medium involved in this application please refer to the description of the method embodiment of this application.
  • a computer device including a memory and one or more processors, in which computer-readable instructions are stored, and the one or more processors implement the above-mentioned methods when the computer-readable instructions are executed. Steps in the embodiment.
  • one or more non-volatile computer-readable storage media storing computer-readable instructions, and the computer-readable instructions are stored by one or more processors.
  • the steps in the foregoing method embodiments are implemented during execution.
  • a computer program product or computer program includes computer-readable instructions stored in a computer-readable storage medium.
  • the processor reads the computer-readable instructions from the computer-readable storage medium, and the processor executes the computer-readable instructions so that the computer device executes the steps in the foregoing method embodiments.
  • the computer-readable storage medium may be a blockchain-based data processing device or an internal storage unit of a computer device provided in any of the foregoing embodiments, such as a hard disk or memory of a computer device.
  • the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), or a secure digital (SD) card equipped on the computer device. Flash card, etc.
  • the computer-readable storage medium may also include both an internal storage unit of the computer device and an external storage device.
  • the computer-readable storage medium is used to store the computer-readable instructions and other programs and data required by the computer device.
  • the computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
  • These computer-readable instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are generated
  • These computer-readable instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the instruction device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the schematic structural diagram.
  • These computer-readable instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, which can be executed on the computer or other programmable equipment.
  • the instructions provide steps for implementing the functions specified in a block or blocks in a flow or multiple flows and/or structures in the flowchart.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Security & Cryptography (AREA)
  • Accounting & Taxation (AREA)
  • Computing Systems (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • General Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

一种基于区块链的数据处理方法、装置、设备及可读存储介质,方法包括:向第二节点发送针对目标区块的第一共识投票信息,接收第二节点发送的第二共识投票信息;根据第一共识投票信息与第二共识投票信息确定目标区块的共识结果,若为共识通过结果,则启动记账时长窗口,在记账时长窗口内对目标区块进行记账处理,并接收第二节点发送的第一记账完成消息;若完成对目标区块的记账处理,则向第二节点发送第二记账完成消息;若第一记账完成消息与第二记账完成消息的数量之和大于数量阈值,则关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。

Description

基于区块链的数据处理方法、装置、设备及可读存储介质
本申请要求于2020年05月27日提交中国专利局,申请号为202010458171.4,申请名称为“基于区块链的数据处理方法、装置、设备及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,尤其涉及一种基于区块链的数据处理方法、装置、设备及可读存储介质。
背景技术
区块链是一种分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式,主要用于对数据按时间顺序进行整理,并加密成账本,使其不可被篡改和伪造,同时可进行数据的验证、存储和更新。区块链还可以进行数据加密传输、节点识别和安全访问,是一种先进的分布式基础架构。
在区块链网络中,对于交易数据被写入账本的流程可以为:共识节点获取交易数据,再将该交易数据打包进区块,对区块执行共识流程,待共识通过后将携带该交易数据的区块写入账本。
在共识节点将交易数据写入账本的过程中,不同的共识节点记账的处理速度可能不同,即有快有慢,那么先记账完成的共识节点就会先进入下一个区块的共识流程;而记账较慢的共识节点会因为速度慢,存储的区块跟不上记账较快的共识节点,则在执行下一个区块的共识流程时,可能会因存储的区块高度不一致而导致共识失败,从而影响共识成功率。
发明内容
一种基于区块链的数据处理方法,由第一节点执行,第一节点为计算机设备,包括:
向第二节点发送针对目标区块的第一共识投票信息,接收第二节点发送的针对目标区块的第二共识投票信息;
根据第一共识投票信息与第二共识投票信息,确定目标区块的共识结果,在共识结果为共识通过结果时,启动记账时长窗口,在记账时长窗口内对目标区块进行记账处理,在记账时长窗口内接收第二节点发送的针对目标区块的第一记账完成消息;
若在记账时长窗口内完成对目标区块的记账处理,则向第二节点发送第二记账完成消息;及
若第一记账完成消息与第二记账完成消息的总数量之和大于或等于数量阈值,则关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。
一种基于区块链的数据处理装置,包括:
投票信息交互模块,用于向第二节点发送针对目标区块的第一共识投票信息,接收第二节点发送的针对目标区块的第二共识投票信息;
共识结果确定模块,用于根据第一共识投票信息与第二共识投票信息,确定目标区块的共识结果;
记账处理模块,用于在共识结果为共识通过结果时,启动记账时长窗口,在记账时长窗口内对目标区块进行记账处理;
记账完成接收模块,用于在记账时长窗口内接收第二节点发送的针对目标区块的第一记账完成消息;
记账完成通知模块,用于若在记账时长窗口内完成对目标区块的记账处理,则向第二节点发送第二记账完成消息;及
窗口关闭模块,用于若第一记账完成消息与第二记账完成消息的总数量之和大于或等于 数量阈值,则关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。
一种计算机设备,包括存储器和一个或多个处理器,存储器存储有计算机可读指令,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行上述基于区块链的数据处理方法的步骤。
一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,其上存储有计算机可读指令,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行上述基于区块链的数据处理方法的步骤。
一种计算机程序产品或计算机程序,计算机程序产品或计算机程序包括计算机可读指令,计算机可读指令存储在计算机可读存储介质中,计算机设备的处理器从计算机可读存储介质读取计算机可读指令,处理器执行计算机可读指令,使得计算机设备执行上述基于区块链的数据处理方法的步骤。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的一种网络架构示意图;
图2是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图;
图3是本申请实施例提供的一种记账场景示意图;
图4是本申请实施例提供的一种记账场景示意图;
图5是本申请实施例提供的一种记账场景示意图;
图6是本申请实施例提供的一种记账场景示意图;
图7是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图;
图8是本申请实施例提供的一种基于区块链的数据处理装置的结构示意图;
图9是本申请实施例提供的一种计算机设备的示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
请参见图1,是本申请实施例提供的一种网络架构示意图。区块链是一种分布式数据存储、点对点传输、共识机制以及加密算法等计算机技术的新型应用模式,主要用于对数据按时间顺序进行整理,并加密成账本,使其不可被篡改和伪造,同时可进行数据的验证、存储和更新。区块链本质上是一个去中心化的数据库,该数据库中的每个节点均存储一条相同的区块链,区块链网络将节点区分为核心节点、数据节点以及轻节点,其中核心节点负责区块链全网的共识,也就是说核心节点为区块链网络中的共识节点。对于区块链网络中交易数据被写入账本的过程可以为,客户端发送交易数据至数据节点或轻节点,随后该交易数据以接力棒的方式在区块链网络中的数据节点或轻节点之间传递,直到共识节点收到该交易数据,共识节点再将该交易数据打包进区块,与其他共识节点之间进行共识,在共识通过后,将携带该交易数据的区块写入账本。如图1所示,该系统架构可以包括第一节点集群1000以及第二节点集群100,该第一节点集群1000可以包括至少两个第一节点,第二节点集群100可以包括至少两个第二节点。如图1所示,该第一节点集群1000可以包括第一节点1000a、第一节点1000b、…、第一节点1000c,该第二节点集群100具体可以包括第二节点100a、第二节点100b、…、第二节点100c。其中,该第一节点1000a、第一节点1000b、…、第一节点 1000c以及该第二节点100a、第二节点100b、…、第二节点100c,均为核心节点(即共识节点)。
如图1所示,第二节点100a、第二节点100b、…、第二节点100c可以分别与第一节点1000a、第一节点1000b、…、第一节点1000c进行网络连接,以便于第二节点可以通过该网络连接与第一节点进行数据交互;第二节点100a、第二节点100b、…、第二节点100c互相连接,以便于第二节点之间可以进行数据交互,第一节点1000a、第一节点1000b、…、第一节点1000c互相连接,以便于第一节点之间可以进行数据交互。以第一节点1000a为例,第一节点1000a在接收到由数据节点或轻节点发送的交易数据后,可以将该交易数据存储至内存池(如交易池)中,并更新其用于记录输入数据的哈希树;之后,将更新时间戳更新为接收到该交易数据的时间,并尝试不同的随机数进行特征值计算,当得到特征值时,便可将该交易数据对应存储,生成区块头和区块主体,得到新生成的区块;随后,第一节点1000a可以根据区块链网络中其他核心节点(即共识节点)的节点标识,将新生成的区块分别发送给其所在的区块链网络中的其他核心节点,由其他核心节点对新生成的区块进行校验(即进行共识),并在完成校验后将新生成的区块添加至其所属的账本中。其中,区块链网络中的每个核心节点,均具有与其对应的节点标识,而且区块链网络中的每个核心节点均可以存储有区块链网络中其他核心节点的节点标识,以便后续根据其他核心节点的节点标识,将生成的区块广播至区块链网络中的其他核心节点,其他核心节点会对该新生成的区块进行共识,并在共识通过后将该新生成的区块也添加至其他核心节点所属的账本中,这样使得区块链网络中全部核心节点上存储的交易数据均一致。
对于区块链网络中的核心节点(包括第一节点与第二节点)添加区块至所属区块链中的过程,也就是核心节点对区块进行记账的过程,本申请新增了记账时长窗口,在区块通过共识后,核心节点需要在记账时长窗口中对区块进行记账处理。具体方法可以为,以第一节点1000a、第二节点100a、第二节点100b以及第二节点100c为例,针对目标区块的共识,第一节点1000a、第二节点100a、第二节点100b以及第二节点100c可以互相广播共识投票信息,其中,第一节点1000a、第二节点100a以及第二节点100b均为赞成投票,第二节点100c因网络原因,还未将共识投票信息广播出来。因为在第一节点1000a、第二节点100a、第二节点100b以及第二节点100c共4个共识节点中,有3个共识节点的共识投票信息都为赞成票,赞成票的节点数量占全部节点数量的比例3/4超过了比例阈值2/3,则可以将该目标区块的共识结果确定为共识通过结果,则第一节点1000a、第二节点100a、第二节点100b以及第二节点100c均可以启动记账时长窗口,并在记账时长窗口内对该目标区块进行记账处理;在记账时长窗口内,若有节点完成了对目标区块的记账处理任务,则可以进行广播,以通知其他节点自己已完成了对目标区块的记账处理。若在记账时长窗口内的某个时刻,有超过2/3的节点在该记账时长窗口内都完成了对目标区块的记账处理任务,则这些完成记账处理任务的节点在确定有2/3的节点均完成记账处理任务时,可以关闭记账时长窗口,进入到后续流程,如进入该目标区块的后继区块的共识业务流程中。如,记账时长窗口为10s,第一节点1000a在第2s完成对目标区块的记账处理,进行了广播通知,第一节点1000a会在记账时长窗口内等待第二节点100a、第二节点100b以及第二节点100c的完成通知,在第2.5s时,第二节点100a完成了对目标区块的记账处理并进行广播通知,在第3.5s时,第二节点100b完成了对目标区块的记账处理并进行广播通知,则在第3.5s时,共有3个共识节点(第一节点1000a、第二节点100a、第二节点100b)都完成了对目标区块的记账处理,在第一节点1000a、第二节点100a、第二节点100b以及第二节点100c共4个共识节点中,有3个共识节点都完成了对目标区块的记账处理任务。而第一节点1000a、第二节点100a以及第二节点100b在第3.5s时,均接收到了其他完成记账处理任务的共识节点的完成通知消息,也就是说,第一节点1000a、第二节点100a以及第二节点100b中的每个共识节点均可以确定,在第3.5s时,完成记账处理任务的共识节点数量占全部共识节点的总数量的比例为3/4,超过了比例阈值2/3,则在第3.5s时,第一节点1000a、第二节点100a、第二节点100b会关闭该记账时长窗 口,进入到后续流程中,即不再等待第二节点100c完成记账。
上述基于区块链的数据处理方法,在区块通过共识,进行区块记账时,通过增设记账时长窗口,使得共识节点(如第一节点与第二节点)在记账时长窗口内进行记账,每个共识节点在记账完成后都可以进行广播通知,在进行记账的共识节点中,有超过数量阈值的共识节点均完成区块记账时,这些完成记账的共识节点才会关闭记账时长窗口,一起进入下一个区块的共识流程。这样可以使先完成区块记账的共识节点,在记账时长窗口内等待其他共识节点完成区块记账,再一起进入下一个区块的共识流程。可以看出,在记账时长窗口中,因为速度快的共识节点等待了速度较慢的共识节点进行记账,可以使得一起进入下一个区块的共识流程的共识节点存储有相同的区块,这样在进行下一个区块的共识时,可以减少共识节点因为区块高度不一致而导致共识失败的情况,从而可以提高共识业务流程的共识成功率。
可以理解的是,第一节点集群1000中的每个第一节点与第二节点集群100中的每个第二节点均可以为云服务器,这些云服务器可以提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN、以及大数据和人工智能平台等基础云计算服务。终端以及服务器可以通过有线或无线通信方式进行直接或间接地连接,本申请在此不做限制。
云技术(Cloud technology)是指在广域网或局域网内将硬件、软件、网络等系列资源统一起来,实现数据的计算、储存、处理和共享的一种托管技术。
云技术(Cloud technology)基于云计算商业模式应用的网络技术、信息技术、整合技术、管理平台技术、应用技术等的总称,可以组成资源池,按需所用,灵活便利。云计算技术将变成重要支撑。技术网络系统的后台服务需要大量的计算、存储资源,如视频网站、图片类网站和更多的门户网站。伴随着互联网行业的高度发展和应用,将来每个物品都有可能存在自己的识别标志,都需要传输到后台系统进行逻辑处理,不同程度级别的数据将会分开处理,各类行业数据皆需要强大的系统后盾支撑,只能通过云计算来实现。
可以理解的是,本申请实施例提供的方法可以由计算机设备执行,计算机设备包括但不限于终端或服务器。服务器可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是云服务器。终端可以是智能手机、平板电脑、笔记本电脑、台式计算机、智能音箱、智能手表等,但并不局限于此。终端以及服务器可以通过有线或无线通信方式进行直接或间接地连接,本申请在此不做限制。本申请实施例中的节点可以为计算机设备。
请参见图2,是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图,以该方法应用于第一节点为例进行说明,第一节点为计算机设备,计算机设备可以是终端也可以是服务器。如图2所示,基于区块链的数据处理方法包括以下步骤:
步骤S101,向第二节点发送针对目标区块的第一共识投票信息,接收第二节点发送的针对目标区块的第二共识投票信息。
具体地,第一节点与第二节点均可以为区块链网络中的核心节点(共识节点),可以负责区块链全网的共识,以及将携带交易数据的区块写入至本地账本中。共识节点在收到交易数据后,可以将该交易数据打包进区块,与其他共识节点之间进行共识,其他共识节点会互相发送自己的共识投票信息,该共识投票信息包括赞成共识通过投票(或赞成投票)与拒绝共识通过投票,则这里的第一共识投票信息与第二共识投票信息也可以包括赞成共识通过投票与拒绝共识通过投票。在区块链网络中,每个核心节点在根据交易数据生成一个新的区块(如目标区块)时,可以将该新生成的区块发送至区块链网络中的其他核心节点,由其他核心节点来对该新生成的区块进行校验,也就是说,区块链网络中的核心节点对于新生成的区块,会发送共识投票信息,向其他核心节点通知自己的校验结果,若校验通过,则共识投票信息就为赞成该新生成的区块通过共识,若校验不合格,则共识投票信息就为拒绝该新生成的区块通过共识。其中,对于生成新区块的核心节点,可以作为出块节点,则这里的第一节点与第二节点均可以作为出块节点,在节点为出块节点时,其共识投票信息是赞成区块通过 共识的。
步骤S102,根据第一共识投票信息与第二共识投票信息,确定目标区块的共识结果,在共识结果为共识通过结果时,启动记账时长窗口,在记账时长窗口内对目标区块进行记账处理,在记账时长窗口内接收第二节点发送的针对目标区块的第一记账完成消息。
在一个实施例中,根据第一共识投票信息与第二共识投票信息,确定目标区块的共识结果,包括:
在第二共识投票信息中,确定属于赞成投票的第二共识投票信息的数量,作为第一目标数量;若第一共识投票信息属于赞成投票,则根据第一共识投票信息和第一目标数量,确定赞成投票总数量;若赞成投票总数量与节点总数量的比值大于或等于比例阈值,则将目标区块的共识结果确定为共识通过结果;节点总数量为第一节点与第二节点的总数量;若赞成投票总数量与节点总数量的比值小于比例阈值,则将目标区块的共识结果确定为共识失败结果。
具体地,第一节点可以根据接收到的第二节点发送的第二共识投票信息,来确定出目标区块的共识结果。具体确定方法可以为,第一节点可以在第二共识投票信息中,确定出属于赞成投票(也就是赞成目标区块通过共识)的第二投票信息的数量,作为第一目标数量;若该第一节点是赞成该目标区块通过共识的,则可以根据该第一共识投票和第一目标数量,确定出赞成投票总数量;若该赞成投票总数量与节点总数量的比值大于或等于比例阈值,则可以将该目标区块的共识结果确定为共识通过结果;其中,该节点总数量为该第一节点与第二节点的总数量;若该赞成投票总数量与该节点总数量的比值小于该比例阈值,则可以将该目标区块的共识结果确定为共识失败结果。因为第一节点与第二节点为区块链网络中的核心节点(共识节点),也就是说,在区块链网络中,有超过或达到比例阈值的共识节点均赞成目标区块通过共识时,才会将该目标区块的共识结果确定为共识通过结果;在区块链网络中,赞成目标区块通过共识的核心节点没有超过比例阈值,将该目标区块的共识结果确定为共识失败结果。其中,该比例阈值可以为小数、百分比、分数等数值呈现形式,如,比例阈值为0.67、2/3、80%等,在此不再进行一一举例。
如,共识节点共包括第一节点a、第二节点d、第二节点b以及第二节点c,对于区块a的共识投票,第一节点a的第一共识投票信息为赞成投票,第二节点d的第二共识投票信息为拒绝共识通过投票,第二节点b的第二共识投票信息为赞成投票,第二节点c的第二共识投票信息为赞成投票。则在第一节点a、第二节点d、第二节点b以及第二节点c这4个共识节点中,有第一节点a、第二节点b以及第二节点c共3个共识节点都为赞成投票,则赞成投票总数量为3,赞成投票总数量3与节点总数量4的比值为3/4。比例阈值为2/3,可以看出,比值3/4大于了比例阈值2/3,则第一节点a可以将该区块a的共识结果确定为共识通过结果。
在一个实施例中,所述方法还包括:
若第一共识投票信息属于拒绝共识通过投票,则根据第一目标数量确定赞成投票总数量。
具体地,第一节点可以在第二共识投票信息中,确定出属于赞成投票(也就是赞成目标区块通过共识)的第二投票信息的数量,作为第一目标数量;若该第一节点是拒绝该目标区块通过共识的,则可以根据第一目标数量确定出赞成投票总数量;若该赞成投票总数量与节点总数量的比值大于或等于比例阈值,则可以将该目标区块的共识结果确定为共识通过结果;其中,该节点总数量为该第一节点与第二节点的总数量;若该赞成投票总数量与该节点总数量的比值小于该比例阈值,则可以将该目标区块的共识结果确定为共识失败结果。在区块链网络中,有超过或达到比例阈值的共识节点均赞成目标区块通过共识时,就可以将该目标区块的共识结果确定为共识通过结果。因此,即使第一节点是拒绝该目标区块通过共识的,只要区块链网络中有超过或达到比例阈值的共识节点均赞成目标区块通过共识,则该目标区块的共识结果确定为共识通过结果。
在一个实施例中,在共识结果为共识通过结果时,启动记账时长窗口,在记账时长窗口 内对目标区块进行记账处理,包括:
在共识结果为共识通过结果时,获取第二共识投票信息的数量;获取第二节点的节点数量,作为第二目标数量;若第二共识投票信息的数量小于第二目标数量,则启动记账时长窗口,在记账时长窗口内对目标区块进行记账处理。
具体地,在确定目标区块为共识通过结果时,第一节点可以获取该第二共识投票信息的数量,并获取该第二节点的节点数量,将第二节点的节点数量作为第二目标数量;若该第二共识投票信息的数量小于该第二目标数量,第一节点可以启动该记账时长窗口,在该记账时长窗口内对该目标区块进行记账处理。可以理解的是,该第二共识投票信息的数量小于该第二目标数量,也就是说第一节点只接收到了部分第二节点的共识投票信息,还有一部分的第二节点可能因为网络延迟、校验速度慢等原因,未及时发送共识投票信息到第一节点,第一节点未接收到这一部分的第二节点的共识投票信息,在这种情况下,第一节点会启动记账时长窗口,并在记账时长窗口内进行记账。也就是说,在目标区块的共识结果为共识通过结果,且该第一节点只接收到了部分第二节点的共识投票信息时,第一节点会启动记账时长窗口,在记账时长窗口内进行对目标区块的记账处理。
如,共识节点共包括第一节点a、第二节点d、第二节点b以及第二节点c,对于区块b的共识投票,第一节点a为赞成区块b通过共识,第二节点d为赞成区块b通过共识,第二节点b为赞成区块b通过共识,则第一节点a、第二节点d以及第二节点b的共识投票信息均为赞成投票;而第二节点c因为网络原因还未广播出共识投票信息,则对于第一节点a而言,第一节点a的第一共识投票信息为赞成投票,第二节点d的共识投票信息为第二共识投票信息,为赞成投票;第二节点b的共识投票为第二共识投票信息,为赞成投票,则在区块链网络中,共有第一节点a、第二节点d以及第二节点b共3个共识节点均为赞成投票,虽然还未接收到第二节点c的共识投票信息(第一节点a只接收到部分第二节点的共识投票信息,第二共识投票信息数量小于第二节点的节点数量),但在接收到的共识投票信息中,赞成投票的节点数量(3个)与区块链网络中节点总数量(4个)的比例值3/4已超过了比例阈值2/3,则第一节点a会启动记账时长窗口,并在该记账时长窗口内进行记账处理。也就是说,第一节点在只接收到部分第二节点发送的共识投票信息,且在这些部分第二节点与第一节点中,赞成投票占区块链网络中的节点总数量的比例值超过了比例阈值,则第一节点不会再管剩下的第二节点的共识投票信息是否赞成,会直接启动记账时长窗口,并在该记账时长窗口内对目标区块进行记账处理。
第一节点与第二节点在记账时长窗口内进行记账处理时,若有节点完成了对目标区块的共识,则可以广播记账完成消息,以通知其他节点自己已经完成了对目标区块的记账处理。则在记账时长窗口内,若有第二节点完成了对目标区块的记账处理,则第二节点会进行广播通知,第一节点可以接收到完成记账的第二节点的记账完成消息。
步骤S103,若第一节点在记账时长窗口内完成对目标区块的记账处理,则向第二节点发送第二记账完成消息。
在一个实施例中,第二节点的数量为多个;若在记账时长窗口内完成对目标区块的记账处理,则向第二节点发送第二记账完成消息,包括:
在记账时长窗口内,接收剩余第二节点发送的针对目标区块的第三共识投票信息;剩余第二节点为多个第二节点中,除了已发送第二共识投票信息的第二节点以外的节点;若在记账时长窗口内完成对目标区块的记账处理,则获取第三共识投票信息的数量;将第三共识投票信息的数量与第二共识投票信息的数量进行相加,得到共识投票总数量;根据共识投票总数量与第二目标数量,检测第一节点的消息发送权限;在第一节点具备所述消息发送权限时,向第二节点发送第二记账完成消息。
具体地,第一节点是在只接收到部分第二节点的共识投票信息的情况下,会进入到记账时长窗口,第一节点在记账时长窗口对目标区块进行记账处理时,仍然可以继续接收剩余第二节点(第二节点中,除已发送第二共识投票信息的第二节点以外的节点,即还未发送共识 投票信息的第二节点)发送过来的共识投票信息(第三共识投票信息)。也就是说,剩余第二节点可能因为网络或其他原因,未及时将共识投票信息发送出来,在第一节点在记账时长窗口中进行记账处理时,才接收到该剩余第二节点的共识投票信息,第一节点可以根据剩余第二节点的第三共识投票信息来确定自己是否具备发送记账完成消息的消息发送权限。具体方法可以为,若该第一节点在该记账时长窗口内完成了对目标区块的记账处理,则第一节点可以获取第三共识投票信息的数量,第一节点可以将该第三共识投票信息的数量与第二共识投票信息的数量进行相加,得到共识投票总数量,根据共识投票总数量与第二目标数量,确定第一节点是否具备消息发送权限,在第一节点具备消息发送权限时,第一节点才向第二节点发送第二记账完成消息。
在一个实施例中,根据共识投票总数量与第二目标数量,检测第一节点的消息发送权限,包括:
若共识投票总数量小于第二目标数量,则确定第一节点具备所述消息发送权限;若共识投票总数量等于第二目标数量,则确定第一节点未具备消息发送权限。
具体地,共识投票总数量小于第二节点的节点数量(第二目标数量),则第一节点可以确定自己具备消息发送权限,则第一节点可以向第二节点发送记账完成消息,广播通知自己已完成区块记账;反之若共识投票总数量等于该第二节点的第二目标数量,则第一节点可以确定自己未具备消息发送权限,则第一节点在记账时长窗口内完成区块记账时,不会发送记账完成消息至第二节点,可以直接关闭记账时长窗口,并进入到该目标区块的后继区块的共识业务流程中。
在一个实施例中,所述方法还包括:
在第一节点未具备消息发送权限时,关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。
具体地,若共识投票总数量等于该第二节点的第二目标数量,则第一节点可以确定自己未具备消息发送权限,则第一节点在记账时长窗口内完成区块记账时,不会发送记账完成消息至第二节点,可以直接关闭记账时长窗口,并进入到该目标区块的后继区块的共识业务流程中。需要说明的是,这里若共识投票总数量等于该第二节点的第二目标数量,则第一节点可以确定自己在记账时长窗口中接收到了全部第二节点的共识投票信息,第一节点会默认区块链网络中其他节点也接收到了全部的共识投票信息,其他节点可以保持相近的记账速度。则第一节点为了减少发送消息所带来的流量消耗,第一节点会取消这个消息发送权限,由此,因为未具备消息发送权限,则在记账完成时,共识节点可以不再给其他节点发送记账完成消息。从而不仅可以减少流量消耗,也可以提高进入后继区块的共识业务流程的速度,一旦记账完成且接收到了全票,就不再发送完成通知,直接关闭记账时长窗口,进入到后继区块的共识业务流程。
可以理解的是,若第一节点在记账时长窗口内,接收到了全部的投票信息,则第一节点在记账完成的情况下,也可以选择向第二节点发送记账完成消息,这样可以使得在记账时长窗口内的因为网络问题而未接收到全部投票信息的第二节点,可以根据第一节点发送的记账完成消息来确定自己是否可以关闭记账时长窗口。
可以理解的是,第一节点在记账时长窗口内对目标区块进行记账处理时,若第一节点在记账时长窗口内只接收到部分剩余第二节点发送过来的共识投票信息,或未接收到剩余第二节点的共识投票信息(共识投票总数量等于该第二节点的第二目标数量),则第一节点在完成目标区块的记账时,会向第二节点发送记账完成消息,并在记账时长窗口内等待未完成记账的节点进行记账;若接收到了全部剩余第二节点发送过来的共识投票信息,也就是说第一节点在记账时长窗口内接收到了区块链网络中,全部第二节点的共识投票信息(共识投票总数量等于该第二节点的第二目标数量),则第一节点在完成目标区块的记账时,可以直接关闭记账时长窗口,不再等待其他共识节点,直接进入到目标区块的下一个区块的流程中;这里第一节点可以不再等待其他共识节点记账的原因为:因为在记账时长窗口内,区块链网络 中第二共识节点均将投票信息成功发送过来,第一节点在记账时长窗口内接收到了全部第二节点的共识投票信息,则第一节点会认为其他共识节点的网络状态均为良好状态(因为成功接收到了全部共识投票信息),则第一节点可以确定每个共识节点的状态(如网络状态、信息同步状态等)均相差不大,进行区块记账的速度可以基本保持一致,即使不等待,也可以在相差很小的时间里分别完成区块记账,一起进入后续流程时,所存储的区块也相差很小。
步骤S104,若第一记账完成消息与第二记账完成消息的总数量之和大于或等于数量阈值,则第一节点关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。
具体地,在记账时长窗口内,若有超过数量阈值的节点,均完成了对目标区块的记账处理(第一记账完成消息与第二记账完成消息的总数量之和大于或等于数量阈值),则这些完成记账处理的节点可以关闭记账时长窗口,也就是跳出记账时长窗口,进入到后续流程,如进入目标区块的下一个区块的共识业务流程中。可以理解的是,在记账时长窗口内,先完成记账处理的节点在未接收到全部剩余节点(区块链网络中,之前未成功发送出共识投票信息的节点)的共识投票信息时,会广播通知自己已完成记账处理,并会在记账时长窗口内等待其他节点进行记账,直到有超过数量阈值的节点均完成记账处理时,这些完成记账的节点才会关闭记账时长窗口,进入到后续流程中。其中,这里的数量阈值可以根据区块链网络中的节点总数量以及给定比例值来确定,如给定比例值为3/5,则这里的数量阈值可以为节点总数量的3/5,也就是,在区块链网络中有超过或达到3/5的节点完成记账时,可以这些完成记账的节点可以关闭记账时长窗口。
在一个实施例中,所述方法还包括:
获取记账时长窗口对应的时长阈值;获取第一节点处于记账时长窗口中的累计时长;若累计时长与时长阈值相等,且第一节点在记账时长窗口内未完成对目标区块的记账处理,则关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。
如,若区块链网络中共识节点包括共识节点A(称之为第一节点)、共识节点B、共识节点C,共识节点D以及共识节点E(共识节点B、共识节点C,共识节点D以及共识节点E均称之为第二节点)。针对于区块a的出块投票,共识节点A为赞成投票、共识节点B为赞成投票、共识节点C为赞成投票、共识节点D为赞成投票,共识节点E因为网络延迟未发送出投票信息。则共识节点A接收到共识节点B、共识节点C以及共识节点D的投票信息,可以确定在区块链网络中,已有4个共识节点为赞成投票,占区块链网络节点总数量5的比例为4/5,则共识节点A可以确定区块a已通过共识,共识节点A会启动记账时长窗口。同理,共识节点B、共识节点C,共识节点D以及共识节点E也可以在接收到其他共识节点的投票信息(未接收到共识节点E的投票信息)后,确定区块a为的共识结果为共识通过结果,则共识节点B、共识节点C,共识节点D以及共识节点E也会在确定区块a共识通过后,启动记账时长窗口。则共识节点A、共识节点B、共识节点C,共识节点D以及共识节点E均会在记账时长窗口内对区块a进行记账处理,其中,该记账时长窗口为10s。在进入记账时长窗口内的第2s时,共识节点B完成了对区块a的记账处理,则共识节点B在第2s时会广播通知自己已完成对区块a的记账处理,因为在第2s时,共识节点B未接收到其他节点发送的记账完成消息,只有共识节点B一个节点完成了对区块a的记账处理,则共识节点B会在记账时长窗口内等待其他节点记账完成;在第3s时,共识节点A也完成了对区块a的记账处理,共识节点A也会广播通知,在第3s时,共识节点B接收到了共识节点A发送的记账完成消息,则共识节点B与共识节点A均可以确定已有共识节点A与共识节点B共2个节点完成了对区块a的记账处理,但还未达到数量阈值3(节点总数量5与比例阈值3/5相乘),则共识节点A与共识节点B会在记账时长窗口内一起等待其他节点记账;在记账时长窗口内的第4s时,共识节点D完成了对区块a的记账处理,共识节点D在第4s时也会进行广播通知,共识节点A与共识节点B在第4s时,都接收到了共识节点D的记账完成消息,则共识节点A、共识节点B以及共识节点D(共识节点D已接收到共识节点A与共识节点B的记账完成消息)可以确定在第4s时,已有共识节点A、共识节点B以及共识节点D共3个节点完成了区块记账,完成 记账的节点数量3等于了数量阈值3,也就是说,在共识节点A、共识节点B、共识节点C,共识节点D以及共识节点E中,已有3/5的节点完成了区块记账,则这些完成区块记账的共识节点A、共识节点B以及共识节点D可以在第4s时,关闭记账时长窗口,一起进入到区块a的下一个区块(如区块b)的共识业务流程中。而未完成区块记账的共识节点C以及共识节点E可以继续在记账时长窗口内进行记账,并在完成区块记账时且已确定有超过数量阈值的节点均完成记账时,关闭记账时长窗口,进入区块a的下一个区块的共识业务流程中;若共识节点C以及共识节点E中,有节点在记账时长窗口内一直未完成对区块a的记账处理,如共识节点E在该10s内的记账时长窗口内一直未完成区块记账,则共识节点E可以在进入记账时长窗口的累计时长到达记账时长窗口的时长阈值(10s)时,关闭该记账时长窗口,进入到区块b的共识业务流程中。也就是说,对于记账较慢的节点(如共识节点C以及共识节点E),在其他记账快的节点完成记账并关闭记账时长窗口进入后续流程后,共识节点C以及共识节点E会继续进行记账,若在记账时长窗口的时长阈值内完成记账,则可以在完成记账时关闭记账时长窗口,进入后续流程;若在记账时长窗口内的时长阈值内一直未完成,在累计时长(从进入记账时长窗口开始算)到达时长阈值时,就是累计时长与时长阈值相等时,可以关闭记账时长窗口,进入到后续流程中。
在一个实施例中,所述方法还包括:
获取记账时长窗口对应的时长阈值;统计第一节点处于记账时长窗口中的累计时长;若累计时长与时长阈值相等,且第一记账完成消息与第二记账完成消息的总数量之和,小于数量阈值,则关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。
可以理解的是,若在记账时长窗口内,先完成记账处理的节点进行广播通知后,会等待其他节点记账,完成记账处理的节点一直未接收到全部剩余节点发送的共识投票信息,且其他节点也一直未完成记账或未接收到其他节点的记账完成消息,那么在到达记账时长窗口的时长阈值时,该节点会确定记账完成的节点数量小于数量阈值,则第一节点与第二节点(包括记账完成的节点与未完成记账的节点)均可以在到达时长阈值时关闭记账时长窗口,一起进入到后续流程中。如,区块链网络中共包括第一节点A、第二节点B、第二节点C,第二节点D以及第二节点E共5个共识节点。第一节点A、第二节点B、第二节点C,第二节点D以及第二节点E在记账时长窗口内对区块a进行记账处理,其中,该记账时长窗口的时长阈值为10s。第二节点B在第2s完成记账,第一节点A在第3s完成记账,第二节点B与第一节点A会在记账时长窗口内等待第二节点C,第二节点D以及第二节点E记账。但第二节点C,第二节点D以及第二节点E一直未完成对区块a的记账,而第二节点B与第一节点A在记账时长窗口中的累计时长已到达了10s(到达记账时长窗口的时长阈值),也就是,累计时长与时长阈值相等,则第二节点B与第一节点A会关闭记账时长窗口,进入区块a的下一个区块的共识业务流程。且第二节点C,第二节点D以及第二节点E在到达时长阈值10s时,也会关闭记账时长窗口,进入区块a的下一个区块的共识业务流程。
需要说明的是,若先完成记账处理的节点,在等待其他节点进行记账时,接收到了全部剩余节点发送过来的共识投票信息,同时完成记账的节点数量未超过阈值,那么此时这些完成记账的节点也可以不再等待其他未完成的节点记账,这些完成记账的节点也可以关闭记账时长窗口,进入到下一个区块的共识业务流程中。如区块链网络中共包括第一节点A、第二节点B、第二节点C,第二节点D以及第二节点E共5个共识节点。第一节点A、第二节点B、第二节点C以及第二节点E未接收到第二节点D的共识投票信息(也就是只接收到了部分共识节点的共识投票信息,且赞成票超过阈值),则第一节点A、第二节点B、第二节点C,第二节点D以及第二节点E会进入记账时长窗口,在记账时长窗口内对区块a进行记账处理,其中,该记账时长窗口的时长阈值为10s。第二节点B在进入记账时长窗口后的第2s完成记账,第一节点A在第3s完成记账,第二节点B与第一节点A互相接收到对方的记账完成消息,第二节点B与第一节点A会在记账时长窗口内等待第二节点C,第二节点D以及第二节点E记账,在第3.5s时,第二节点B与第一节点A接收到了第二节点D的共识投票信息,则此时, 第二节点B与第一节点A均接收到了全部剩余节点(第二节点D)发送的共识投票信息(也就是接收到了区块链网络中全部其他节点的共识投票信息),则第二节点B与第一节点A不会再等待第二节点C,第二节点D以及第二节点E记账,即使已完成区块记账的节点数量2(1个第二节点B+1个第一节点A)小于数量阈值3,第二节点B与第一节点A仍然会关闭记账时长窗口,进入后续流程如区块a的下一个区块的共识业务流程中。
在一个实施例中,第二共识投票信息携带所述第二节点的性能参数,所述方法还包括:
若第二共识投票信息的数量等于第二目标数量,则根据第二节点的性能参数更新记账时长窗口,得到更新后的记账时长窗口;更新后的记账时长窗口对应的时长阈值小于记账时长窗口对应的时长阈值;启动更新后的记账时长窗口,在更新后的记账时长窗口内对目标区块进行记账处理;若在更新后的记账时长窗口内完成对目标区块的记账处理,则进入目标区块的后继区块的共识业务流程。
可以理解的是,第一节点在确定目标区块为共识通过结果时,第一节点可以获取该第二共识投票信息的数量,并获取该第二节点的节点数量,将第二节点的节点数量作为第二目标数量;若该第二共识投票信息的数量等于该第二目标数量,第一节点可以获取到第二共识投票信息中携带的第二节点的性能参数,根据该第二节点的性能参数来对记账时长窗口进行更新,得到更新后的记账时长窗口;第一节点可以启动该更新后的记账时长窗口,在该更新后的记账时长窗口内对目标区块进行记账处理;若第一节点在该更新后的记账时长窗口内完成对该目标区块的记账处理,则可以进入该目标区块的后继区块的共识业务流程。可以理解的是,该第二共识投票信息中携带了第二节点的性能参数,该性能参数可以包括网络参数、信息发送速度等,在第二共识投票信息的数量等于该第二目标数量时,也就是说第一节点接收到了区块链网络中全部第二节点的共识投票信息,在这种情况下,第一节点因为接收到了全部节点的共识投票信息,则第一节点可以认为其他第二共识节点的网络状态均良好(因为第二节点很快便将投票信息发送过来,且全部第二节点都很快发送过来),则各个节点的状态均良好。则这个时候,第一节点可以根据第二节点的性能参数来减小记账时长窗口的时长阈值,第二节点的性能参数越好(如信息发送速度很快),则减小幅度越大。这样的话,第一节点与第二节点可以在状态良好的情况下,在时长很短(如1s)的记账时长窗口内进行记账。这里也可以将时长阈值减小为0,也就是说,在性能参数很好地情况下,可以不启动记账时长窗口,第一节点在接收到全票且第二节点的性能参数优异时,可以跳过记账时长窗口,直接进行对目标区块的记账业务流程,并在完成对目标区块的记账业务时,进入到下一个区块的共识业务流程中。因为第一节点接收到全部第二节点的共识投票信息且第二节点的性能参数很好,则可以认为第一节点与第二节点的记账速度相差不大,无需在记账时长窗口内互相等待,也可以使得所存储的区块相同或差异很小,则可以减小记账时长窗口的时长阈值,使得节点可以不受记账时长窗口的时长约束,可以很快进入后续共识业务流程。
需要说明的是,记账时长窗口中的1s、2s、10s以及3.5s等数值,均是为便于理解所作出的举例说明,不具有实际参考意义。
本申请实施例通过为共识节点增设记账时长窗口,若共识节点在接收到有超出数量阈值的共识节点的共识投票信息为赞成投票时,共识节点就不会再管未接收到的共识节点的投票结果,会进入到记账时长窗口,在记账时长窗口内进行区块记账。若在记账时长窗口内共识节点接收到了全部投票信息,则共识节点会在记账完成后关闭记账时长窗口,进入后续流程;若在记账时长窗口内依然未接收到全部的投票信息,则共识节点会在记账完成后等待其他共识节点记账,直到有超过或等于比例阈值的共识节点均完成记账时,这些完成区块记账的共识节点才会关闭记账时长窗口,一起进入后续流程。由此可见,通过增加记账时长窗口为共识节点设置了一个等待时间,记账速度快的共识节点可以在记账时长窗口内等待记账速度慢的共识节点,这样可以使得进入后续流程的共识节点可以存储有相同或相差很小的区块,即共识节点的区块高度相同或差异很小。而共识节点可以通过区块同步,在很短的时间内将差异很小的区块高度同步为相同,这样在进行下一个区块的共识时,可以减少共识节点因为区 块高度不一致而带来共识失败的情况,从而可以为共识业务流程提高共识成功率。
进一步地,请参见图3,是本申请实施例提供的一种记账场景示意图。如图3所示,共识节点A可以为出块节点,共识节点A可以为第一节点,在对目标区块进行出块投票时,共识节点A会接收其他共识节点(如图3中的共识节点B、共识节点C)的投票信息,共识节点B与共识节点C均可以为第二节点。因为每个共识节点发送信息的速度不同,则共识节点A接收到的投票信息并不是在同一时刻收到的,当共识节点统计到在已接收到的投票信息中,通过票已超过了阈值或达到阈值,则共识节点可以确定目标区块已通过了共识。如图3所示,共识节点A已接收到了共识节点B的投票信息,但还未接收到共识节点C的投票信息,但在共识节点A、共识节点B以及共识节点C共3个共识节点中,已有通过票2票(共识节点A为出块节点,出块节点的投票信息为赞成通过),通过票数(2)占共识节点总数量(3)的比例为2/3,该比例已达到了预期规定的通过比值2/3,则共识节点A可以确定目标区块已通过了共识,共识节点A不会再管共识节点C的投票信息,会直接启动记账时长窗口,在记账时长窗口中对目标区块进行记账。同理,共识节点B也可以接收到共识节点A的投票信息,共识节点B也可以确定目标区块已通过了共识,则共识节点B也会启动记账时长窗口,在记账时长窗口内对目标区块进行记账;同理,共识节点C也可以接收到共识节点A与共识节点B的投票信息,结合共识节点自己的投票信息,共识节点C可以确定通过票数为3票,则共识节点C也可以确定目标区块已通过了共识,共识节点C也会启动记账时长窗口,在记账时长窗口内对目标区块进行记账处理。如图3所示,记账时长窗口共为6s,也就是说,共识节点A、共识节点B、共识节点C需要在6s内进行对目标区块的记账处理。
如图3所示,在进入记账时长窗口的第2s时,共识节点A完成了对目标区块的记账,则共识节点A可以向共识节点B以及共识节点C发送记账完成消息,通知自己已经完成了对目标区块的记账任务。因为还未接收到共识节点C的投票信息,且在记账时长窗口的第2s时,只有共识节点A一个共识节点完成了对目标区块的记账,共识节点A未接收到共识节点B或共识节点C的记账完成消息,则共识节点A不会进入后续流程,会在记账时长窗口内等待共识节点B以及共识节点C进行记账。如图3所示,在进入记账时长窗口的第3s时,共识节点B也完成了对目标区块的记账,共识节点B可以向共识节点A以及共识节点C发送记账完成消息,通知对方自己已经完成了对目标区块的记账任务。因为在记账时长窗口的第3s时,共识节点A接收到了共识节点B发送的记账完成消息,共识节点B在之前也接收到了共识节点A发送的记账完成消息,则共识节点A与共识节点B均可以确定,只有共识节点A和共识节点B共2个共识节点完成了对目标区块的记账,完成记账的节点数量2占区块链网络节点总数量3的比例为2/3,已达到规定比例2/3,则共识节点A与共识节点B会关闭记账时长窗口,进入后续流程。而未完成记账的共识节点C会继续在记账时长窗口内进行对目标区块的记账,因为共识节点C是接收到了全部投票信息(包括共识节点A的投票信息与共识节点B的投票信息),则共识节点C无论是否有接收到共识节点A或共识节点B的记账完成消息,只要共识节点C在记账完成时,就可以关闭记账时长窗口,进入后续流程中。
可以看出,通过增加记账时长窗口,可以使先完成区块记账的共识节点(如共识节点A),等待其他共识节点进行区块记账,直到有超过或达到规定比例(如2/3)的共识节点均完成区块记账时,这些完成区块记账的共识节点才会关闭记账时长窗口,一起进入到下一个区块的共识流程。因为记账速度快的共识节点等待了记账速度较慢的共识节点进行记账,可以使得一起进入下一个区块的共识流程的共识节点存储有相同的区块,这样在进行下一个区块的共识时,可以减少共识节点因为区块不一致而带来共识失败的情况,提高后续共识的成功率。
请参见图4,是本申请实施例提供的一种记账场景示意图。如图4所示,共识节点A可以为出块节点,共识节点A可以为第一节点,在对目标区块进行出块投票时,共识节点A会接收其他共识节点(如图4中的共识节点B、共识节点C)的投票信息,共识节点B与共识节点C均可以为第二节点。因为每个共识节点发送信息的速度不同,则共识节点A接收到的投票信息并不是在同一时刻收到的,当共识节点统计到在已接收到的投票信息中,通过票已超 过了阈值或达到阈值,则共识节点可以确定目标区块已通过了共识。如图4所示,共识节点A已接收到了共识节点B的投票信息,但还未接收到共识节点C的投票信息,但在共识节点A、共识节点B以及共识节点C共3个共识节点中,已有通过票2票(共识节点A为出块节点,出块节点的投票信息为赞成通过),通过票数(2)占共识节点总数量(3)的比例为2/3,该比例已达到了预期规定的通过比值2/3,则共识节点A可以确定目标区块已通过了共识,共识节点A不会再管共识节点C的投票信息,会直接启动记账时长窗口,在记账时长窗口中对目标区块进行记账。同理,共识节点B也可以接收到共识节点A的投票信息,共识节点B也可以确定目标区块已通过了共识,则共识节点B也会启动记账时长窗口,在记账时长窗口内对目标区块进行记账;同理,共识节点C也可以接收到共识节点A与共识节点B的投票信息,结合共识节点自己的投票信息,共识节点C可以确定通过票数为3票,则共识节点C也可以确定目标区块已通过了共识,共识节点C也会启动记账时长窗口,在记账时长窗口内对目标区块进行记账处理。
如图4所示,在进入记账时长窗口的第2s时,共识节点A完成了对目标区块的记账,则共识节点A可以向共识节点B、共识节点C发送记账完成消息,通知对方自己已经完成了对目标区块的记账任务。因为在记账时长窗口的第2s时,还未接收到共识节点C的投票信息,且未接收到共识节点B或共识节点C的记账完成消息,则共识节点A可以确定只有共识节点A一个共识节点完成了对目标区块的记账,则共识节点A不会进入后续流程,会在记账时长窗口内等待共识节点B以及共识节点C记账。如图4所示,在进入记账时长窗口的第2.5s时,共识节点A接收到了共识节点C发送过来的投票信息,则共识节点A在记账时长窗口内的第2.5s时,接收到了区块链中全部共识节点(包括共识节点B与共识节点C)的投票信息,则共识节点A在第2.5时不会再继续等待共识节点B以及共识节点C进行记账,会直接关闭记账时长窗口,进入到目标区块的下一个区块的共识业务流程中。
进一步地,请参见图5,是本申请实施例提供的一种记账场景示意图。如图5所示,共识节点A可以为出块节点,共识节点A可以为第一节点,在对目标区块进行出块投票时,共识节点A会接收其他共识节点(如图5中的共识节点B、共识节点C)的投票信息,共识节点B与共识节点C均可以为第二节点。因为每个共识节点发送信息的速度不同,则共识节点A接收到的投票信息并不是在同一时刻收到的,当共识节点统计到在已接收到的投票信息中,通过票已超过了阈值或达到阈值,则共识节点可以确定目标区块已通过了共识。如图5所示),共识节点A已接收到了共识节点B的投票信息,但还未接收到共识节点C的投票信息,但在共识节点A、共识节点B以及共识节点C共3个共识节点中,已有通过票2票(共识节点A为出块节点,出块节点的投票信息为赞成通过),通过票数(2)占共识节点总数量(3)的比例为2/3,该比例已达到了预期规定的通过比值2/3,则共识节点A可以确定目标区块已通过了共识,共识节点A不会再管共识节点C的投票信息,会直接启动记账时长窗口,在记账时长窗口中对目标区块进行记账。同理,共识节点B也可以接收到共识节点A的投票信息,共识节点B也可以确定目标区块已通过了共识,则共识节点B也会启动记账时长窗口,在记账时长窗口内对目标区块进行记账;同理,共识节点C也可以接收到共识节点A与共识节点B的投票信息,结合共识节点自己的投票信息,共识节点C可以确定通过票数为3票,则共识节点C也可以确定目标区块已通过了共识,共识节点C也会启动记账时长窗口,在记账时长窗口内对目标区块进行记账处理。
如图5所示,在进入记账时长窗口的第2s时,共识节点A完成了对目标区块的记账,共识节点C接收到了共识节点A的记账完成消息,但共识节点B未接收到共识节点A的记账完成消息。因为共识节点B自己还未完成对目标区块的记账,所以共识节点B会继续进行对目标区块的记账处理。如图5所示,在进入记账时长窗口的第2.5s时,共识节点B接收到了共识节点C发送的投票信息(为通过),则在进入记账时长窗口的第2.5s时,共识节点B接收到了区块链网络中全部共识节点(包括共识节点A以及共识节点C)的投票信息,此时共识节点B还未完成目标区块的记账,共识节点B会继续进行记账。如图5所示,在进入记账 时长窗口内的第3s时,共识节点B完成了对目标区块的记账,因为在之前的第2.5s时,共识节点B收到了共识节点C的投票信息,则共识节点B在第3s完成记账时,虽然共识节点B认为只有自己一个节点完成了区块记账,还未达到数量阈值2,但共识节点还是会关闭记账时长窗口,不会再等待其他共识节点,直接进入到后续流程,如进入目标区块的下一个区块的共识业务流程中。
需要说明的是,针对于共识节点C而言,在进入记账时长窗口的第2s时,共识节点A完成了区块记账,共识节点C在第2s接收到了共识节点A的记账完成消息,因为共识节点C还未完成区块记账,则共识节点C会继续进行对区块A的记账。在第3s时,共识节点C接收到了共识节点B的记账完成消息,共识节点C会继续进行区块记账。在记账时长窗口内,共识节点C一直未完成对目标区块的记账处理,则在到达时长阈值6s时,共识节点C会关闭记账时长窗口,进入到目标区块的下一个区块的共识业务流程中。
可以理解的是,在图5所对应实施例中,若在记账时长窗口内,共识节点A、共识节点B仍未接收到共识节点C发送的投票信息。也就是说,在第2.5s时,共识节点A与共识节点B未接收到共识节点C发送的投票信息,则共识节点A在进入记账时长窗口的第2s完成记账时,不会关闭记账时长窗口,会等待共识节点B、共识节点C记账。但共识节点B与共识节点C一直未完成记账,当到达6s时,完成记账的共识节点A,与未完成记账的共识节点B以及共识节点C均会关闭记账时长窗口,一起进入到目标区块的下一个区块的共识业务流程中。
结合图4以及图5,可以看出,通过为共识节点增设记账时长窗口,可以使得共识节点在记账时长窗口内进行区块记账,可以使先完成区块记账的共识节点,等待其他共识节点完成区块记账,直到超过或达到给定比例(如2/3)的共识节点均完成区块记账时,才关闭记账时长窗口,一起进入下一个区块的共识流程。而即使完成记账的共识节点一直未超过给定比例,先完成区块记账的共识节点也会在记账时长窗口内一直等待记账速度慢的共识节点,并在到达记账时长窗口的时长阈值时,同记账速度慢的共识节点一起进入下一个区块的共识流程,这样可以减小记账速度慢的共识节点所存储的区块与记账速度快的节点之间的差异,使得一起进入下一个区块时,各个共识节点所存储的区块相差不大,提高后续共识的成功率。若共识节点在记账时长窗口内接收到了全部共识节点的投票信息,则先完成记账的共识节点可以在完成区块记账时,直接关闭记账时长窗口,进入到下一个区块的共识流程。因为其他共识节点均将投票信息成功发送,则各个共识节点的网络状态均为良好状态,则可以认为每个共识节点的状态均相差不大,进行区块记账的速度可以基本保持一致,则在进入下一个区块的共识流程时,各个共识节点所存储的区块也相差很小,而这些共识节点可以通过区块同步,在很短的时间内来使得稍微落后的节点同步到差异区块,这样,各个共识节点可以在很短的时间内将存储的区块保持为一致,可以提高后续共识的共识成功率。
需要说明的是,图3、图4、以及图5中,关于记账时长窗口中的2s、3s、2.5s以及6s等数值,均是为便于理解所作出的举例说明,不具有实际参考意义。
请参见图6,是本申请实施例提供的一种记账场景示意图。如图6所示,共识节点A可以为出块节点,共识节点A可以为第一节点,在对目标区块进行出块投票时,共识节点A会接收其他共识节点(如图6中的共识节点B、共识节点C)的投票信息,共识节点B与共识节点C均可以为第二节点。共识节点B与共识节点C很快便将投票信息发送出来,其中,共识节点B的投票信息为通过,共识节点C的投票信息也为通过,因为通过票数3与区块链网络中的节点总数量3相等,则共识节点A可以确定目标区块的共识结果为通过共识。因为共识节点接收到了区块链网络中全部的投票信息(共识节点B与共识节点C的投票信息),则共识节点A可以获取共识节点B发送过来的投票信息中所携带的共识节点B的性能参数,以及共识节点C发送过来的投票信息中所携带的共识节点C的性能参数,根据共识节点C与共识节点B的性能参数,共识节点A可以对时长阈值为6s的记账时长窗口进行更新,使得更新后得到的更新记账时长窗口的时长阈值变为3s,共识节点A、共识节点B以及共识节点C可以进入该更新记账时长窗口内对目标区块进行记账处理,共识节点A、共识节点B以及共识节 点C需要在3s内对目标区块进行记账处理,若在进入更新记账时长窗口的3s内完成对目标区块的记账处理,则可以关闭更新记账时长窗口,进入下一区块的共识业务流程;若在进入更新记账时长窗口的3s内未完成对目标区块的记账处理,则在到达3s时,可以关闭更新记账时长窗口,进入下一区块的共识业务流程。如图6所示,共识节点A在进入更新记账时长窗口的1s时,完成了对目标区块的记账处理,共识节点A进行了广播通知,共识节点B与共识节点C均接收到了共识节点A的记账完成消息,共识节点A可在完成记账时,也就是在1s时,关闭更新记账时长窗口,进入下一区块的共识业务流程。当然,共识节点A在第1s完成区块记账时,也可以选择不进行广播通知,也就是说,在完成区块记账时,不向共识节点B以及共识节点C发送记账完成消息,直接关闭更新记账时长窗口,进入下一区块的共识业务流程。
可以理解的是,在该更新记账时长窗口内,共识节点A在第1s完成区块记账时,共识节点A可以向共识节点B以及共识节点C发送记账完成消息,且不关闭更新记账时长窗口,共识节点A可以在更新记账时长窗口内等待共识节点B与共识节点C进行记账,直到确定有2/3的共识节点均完成区块记账时,才关闭更新记账时长窗口,进入下一区块的共识业务流程。如,共识节点B在第1.5s时完成区块记账,进行广播通知,共识节点A接收到了共识节点B的记账完成消息,此时,共识节点A可以确定已有2个共识节点(共识节点A与共识节点B)完成区块记账,完成记账的节点数(2)占区块链网络中的总节点数(3)为2/3,已达到给定比例2/3,则共识节点A在1.5s时,可以关闭更新记账时长窗口,进入下一区块的共识业务流程。
也就是说,在出块投票时,若全部共识节点的投票信息都很快广播出来(每个共识节点网络状态均良好,很快便将投票结果广播出来),且在这些投票信息中,有超出比例阈值的共识节点均为通过票,则各个共识节点在这种情况下可以根据其他共识节点的性能参数来更新记账时长窗口(减小记账时长窗口的时长阈值),并在更新记账时长窗口内进行区块记账,并在区块记账完成后,进入后续共识流程中。因为各个共识节点的状态均良好,相差不大,则记账速度也可以基本保持一致,在进入后续共识业务时,所存储的区块也可以基本保持一致,这种情况下,减小记账时长窗口的时长阈值,可以使得共识节点不需要等待其他共识节点或减小等待时间,可以使得共识节点可以快速进入后续共识业务流程同时所存储的区块也可以基本保持一致。
进一步地,请参见图7,是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图。如图7所示,本方案的流程可以为:
步骤S201,共识节点接收针对于目标区块的投票信息。
具体的,区块链网络中的共识节点在对区块进行记账前,需要进行区块的出块投票,当共识节点接收到有超出阈值的共识节点的投票结果均为通过时,才将区块确定为共识通过,在共识通过后,共识节点才会进行区块记账。
步骤S202,共识节点确定目标区块共识通过。
具体的,共识节点在进行出块投票时,由于每个共识节点发送消息的速度不一致,所以每个共识节点接收到的其他共识节点的投票信息并不是在同一时刻收到的,当共识节点统计到在已接收到的投票信息中,通过票已超过了阈值时,共识节点就会确定该进行投票的区块已通过了共识。
步骤S203,共识节点确定接收到全票。
具体的,若每个共识节点的状态均良好,都很快将自己的投票信息发送出来,每个共识节点在统计通过票超过了阈值时,都可能已接收到全部共识节点的投票信息。
步骤S204,共识节点在接收到全票时,对记账时长窗口进行更新。
若区块链网络中,每个共识节点的状态均良好,都很快将自己的投票信息发送出来,每个共识节点在统计通过票超过了阈值时,已接收到了全部共识节点的投票信息,则该区块链网络中因为每个共识节点均为良好状态,记账速度也相差不大,则各个共识节点之间所存储 的区块也相差不大,在后续共识流程中的共识成功率也会很高。在这种情况下,共识节点可以根据其他共识节点的性能参数对记账时长窗口进行更新,减小记账时长窗口的时长阈值,得到更新后的记账时长窗口,并在更新后的记账时长窗口内进行区块记账。
步骤S205,共识节点完成记账后,进入后续流程。
具体的,在更新后的记账时长窗口内完成区块记账后,共识节点可以进入后续流程,如进入目标区块的下一个区块的共识业务流程中;若在更新记账时长内未完成区块记账,则在到达更新记账时长窗口的时长阈值时,跳出更新记账时长窗口,进入后续流程。
步骤S206,共识节点确定接收到部分票。
具体的,个别共识节点因为发送速度缓慢,则存在共识节点还未接收到全部共识节点的投票信息,就已统计到通过票超过了阈值。
步骤S207,共识节点进入记账时长窗口。
具体的,区块链网络中因为部分共识节点的状态不够好,记账速度会比较缓慢,若记账速度快的共识节点不等待记账速度慢的共识节点,则记账速度慢的共识节点与记账速度快的共识节点之间所存储的区块会相差很大,从而会影响在后续共识流程中的共识成功率。则在这种情况下,共识节点可以不对记账时长窗口进行更新,进入记账时长窗口,在记账时长窗口内进行区块记账。该记账时长窗口可以理解为是给共识节点设置了一个等待时间,使得记账速度快的共识节点在记账完成后,可以等待记账速度慢的共识节点。
步骤S208,共识节点在记账时长窗口内仍未接收到全票。
具体的,共识节点在记账时长窗口内进行区块记账时,仍然可以继续接收其他共识节点投票信息,部分共识节点因发送速度缓慢,在记账时长窗口内,那些发送慢的共识节点还未将投票信息发送过来,或部分发送慢的共识节点将投票信息发送出来,但还有小部分的共识节点仍未将投票信息发送出来。也就是说,共识节点可能在记账时长窗口内,一直未接收到全票。
步骤S209,共识节点在记账时长窗口内完成记账。
具体的,在共识节点一直未接收到全票的情况下,共识节点在记账时长窗口内完成区块记账时,会在记账时长窗口内广播通知,并需要等待其他共识节点记账,接收其他完成记账的节点的通知消息,直到完成记账的节点占总节点的比例达到或超过给定比例值。
步骤S210,共识节点跳出记账时长窗口。
具体的,在有超过或达到给定比例值(如2/3)的共识节点均完成记账时,这部分完成区块记账的共识节点可以跳出记账时长窗口,进入后续流程;而若完成区块记账的共识节点未超过或达到给定比例值,则已完成区块记账与未完成区块记账的共识节点在到达记账时长窗口的时长阈值时,会一起关闭记账时长窗口,一起进入后续流程。
步骤S211,若一直未有给定比例的共识节点完成记账,则共识节点会一直等待。
步骤S212,当到达记账时长窗口的时长阈值时,全部节点会关闭记账时长窗口,进入后续流程。
步骤S213,共识节点在记账时长窗口内接收到全票。
具体的,当共识节点在记账时长窗口内进行区块记账时,那些发送慢的共识节点也都将投票信息发送过来(也就是在记账时长窗口内收到了全部共识节点的投票信息),可以理解为共识节点接收到了全票。
步骤S214,共识节点在记账完成后,跳出记账时长窗口。
具体的,共识节点在记账时长窗口内接收到全票时,会在记账时长窗口继续进行区块记账,并在记账完成后直接跳出记账时长窗口,进入后续流程(因为在时长窗口内成功接收到了全部共识节点的投票信息,则各个共识节点的状态均差不多,记账速度与网络状态相差均不大,在差不多的时间里均可以完成记账,在进入后续流程时存储的区块也相差不大,无需进行等待)。
进一步地,请参见图8,是本申请实施例提供的一种基于区块链的数据处理装置的结构 示意图。基于区块链的数据处理装置可以是运行于计算机设备中的一个计算机可读指令(包括程序代码),例如该基于区块链的数据处理装置为一个应用软件;该装置可以用于执行本申请实施例提供的方法中的相应步骤。该数据处理装置1可以包括:投票信息交互模块11、共识结果确定模块12、记账处理模块13、记账完成接收模块14、记账完成通知模块15以及窗口关闭模块16。
投票信息交互模块11,用于向第二节点发送针对目标区块的第一共识投票信息,接收第二节点发送的针对目标区块的第二共识投票信息;
共识结果确定模块12,用于根据第一共识投票信息与第二共识投票信息,确定目标区块的共识结果;
记账处理模块13,用于在共识结果为共识通过结果时,启动记账时长窗口,在记账时长窗口内对目标区块进行记账处理;
记账完成接收模块14,用于在记账时长窗口内接收第二节点发送的针对目标区块的第一记账完成消息;
记账完成通知模块15,用于若在记账时长窗口内完成对目标区块的记账处理,则向第二节点发送第二记账完成消息;
窗口关闭模块16,用于若第一记账完成消息与第二记账完成消息的总数量之和大于或等于数量阈值,则关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。
其中,投票信息交互模块11、共识结果确定模块12、记账处理模块13、记账完成接收模块14、记账完成通知模块15以及窗口关闭模块16的具体实现方式,可以参见图2所对应实施例中步骤S101-步骤S104的描述,这里将不再进行赘述。
请参见图8,共识结果确定模块12,可以包括:第一目标数量确定单元121、赞成票数量确定单元122、共识通过确定单元123以及共识失败确定单元124。
第一目标数量确定单元121,用于在第二共识投票信息中,确定属于赞成投票的第二共识投票信息的数量,作为第一目标数量;
赞成票数量确定单元122,用于若第一共识投票信息属于赞成投票,则根据第一共识投票信息和第一目标数量,确定赞成投票总数量,若第一共识投票信息属于拒绝共识通过投票,则根据第一目标数量确定赞成投票总数量;
共识通过确定单元123,用于若赞成投票总数量与节点总数量的比值大于或等于比例阈值,则将目标区块的共识结果确定为共识通过结果;节点总数量为第一节点与第二节点的总数量;
共识失败确定单元124,用于若赞成投票总数量与节点总数量的比值小于比例阈值,则将目标区块的共识结果确定为共识失败结果。
其中,第一目标数量确定单元121、赞成票数量确定单元122、共识通过确定单元123以及共识失败确定单元124的具体实现方式,可以参见图2所对应实施例中步骤S102中的描述,这里将不再进行赘述。
请参见图8,记账处理模块13,可以包括:数量获取单元131、第二目标数量确定单元132以及记账处理单元133。
数量获取单元131,用于在共识结果为共识通过结果时,获取第二共识投票信息的数量;
第二目标数量确定单元132,用于获取第二节点的节点数量,作为第二目标数量;
记账处理单元133,用于若第二共识投票信息的数量小于第二目标数量,则启动记账时长窗口,在记账时长窗口内对目标区块进行记账处理。
其中,数量获取单元131、第二目标数量确定单元132以及记账处理单元133的具体实现方式,可以参见图2所对应实施例中步骤S102的描述,这里将不再进行赘述。
请参见图8,该数据处理装置1可以包括投票信息交互模块11、共识结果确定模块12、记账处理模块13、记账完成接收模块14、记账完成通知模块15以及窗口关闭模块16,还可以包括:窗口更新模块17、窗口启动模块18以及流程进入模块19。
窗口更新模块17,用于若第二共识投票信息的数量等于第二目标数量,则根据第二节点的性能参数更新记账时长窗口,得到更新后的记账时长窗口;更新后的记账时长窗口对应的时长阈值小于记账时长窗口对应的时长阈值;
窗口启动模块18,用于启动更新后的记账时长窗口,在更新后的记账时长窗口内对目标区块进行记账处理;
流程进入模块19,用于若第一节点在更新后的记账时长窗口内完成对目标区块的记账处理,则进入目标区块的后继区块的共识业务流程。
其中,窗口更新模块17、窗口启动模块18以及流程进入模块19的具体实现方式,可以参见图2所对应实施例中步骤S104中的描述,这里将不再进行赘述。
请参见图8,记账完成通知模块15,可以包括:投票信息接收单元151、投票数量获取单元152、相加处理单元153、权限检测单元154以及记账完成发送单元155。
投票信息接收单元151,用于在记账时长窗口内,接收剩余第二节点发送的针对目标区块的第三共识投票信息;剩余第二节点为多个第二节点中,除了已发送第二共识投票信息的第二节点以外的节点;
投票数量获取单元152,用于若在记账时长窗口内完成对目标区块的记账处理,则获取第三共识投票信息的总数量;
相加处理单元153,用于将第三共识投票信息的数量与第二共识投票信息的数量进行相加,得到共识投票总数量;
权限检测单元154,用于根据共识投票总数量与第一目标数量,检测第一节点的消息发送权限;
记账完成发送单元155,用于在第一节点具备消息发送权限时,向第二节点发送第二记账完成消息。
其中,投票信息接收单元151、投票数量获取单元152、相加处理单元153、权限检测单元154以及记账完成发送单元155的具体实现方式,可以参见图2所对应实施例中步骤S103的描述,这里将不再进行赘述。
请参见图8,权限检测单元154,可以包括:第一权限确定子单元1541以及第二权限确定子单元1542。
第一权限确定子单元1541,用于若共识投票总数量小于第二目标数量,则确定第一节点具备消息发送权限;
第二权限确定子单元1542,用于若共识投票总数量等于第二目标数量,则确定第一节点未具备消息发送权限。
其中,第一权限确定子单元1541以及第二权限确定子单元1542的具体实现方式,可以参见图2所对应实施例中步骤S103的描述,这里将不再进行赘述。
请参见图8,该数据处理装置1可以包括投票信息交互模块11、共识结果确定模块12、记账处理模块13、记账完成接收模块14、记账完成通知模块15以及窗口关闭模块16、窗口更新模块17、窗口启动模块18以及流程进入模块19,还可以包括:共识流程进入模块20。
共识流程进入模块20,用于在第一节点未具备消息发送权限时,关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。
其中,共识流程进入模块20的具体实现方式,可以参见图2所对应实施例中步骤S104的描述,这里将不再进行赘述。
请参见图8,该数据处理装置1可以包括投票信息交互模块11、共识结果确定模块12、记账处理模块13、记账完成接收模块14、记账完成通知模块15以及窗口关闭模块16、窗口更新模块17、窗口启动模块18、流程进入模块19以及共识流程进入模块20,还可以包括:第一时长阈值获取模块21、第一累计时长统计模块22以及第一区块共识进入模块23。
第一时长阈值获取模块21,用于获取记账时长窗口对应的时长阈值;
第一累计时长统计模块22,用于统计第一节点处于记账时长窗口中的累计时长;
第一区块共识进入模块23,用于若累计时长与时长阈值相等,且第一记账完成消息与第二记账完成消息的总数量之和,小于数量阈值,则关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。
其中,第一时长阈值获取模块21、第一累计时长统计模块22以及第一区块共识进入模块23的具体实现方式,可以参见图2所对应实施例中步骤104中的描述,这里将不再进行赘述。
请参见图8,该数据处理装置1可以包括投票信息交互模块11、共识结果确定模块12、记账处理模块13、记账完成接收模块14、记账完成通知模块15以及窗口关闭模块16、窗口更新模块17、窗口启动模块18、流程进入模块19、共识流程进入模块20、第一时长阈值获取模块21、第一累计时长统计模块22以及第一区块共识进入模块23,还可以包括第二时长阈值获取模块24、第二累计时长统计模块25以及第二区块共识进入模块26。
第二时长阈值获取模块24,用于获取记账时长窗口对应的时长阈值;
第二累计时长统计模块25,用于获取第一节点处于记账时长窗口中的累计时长;
第二区块共识进入模块26,用于若累计时长与时长阈值相等,且第一节点在记账时长窗口内未完成对目标区块的记账处理,则关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。
其中,第二时长阈值获取模块24、第二累计时长统计模块25以及第二区块共识进入模块26的具体实现方式,可以参见图2所对应实施例中步骤S104中的描述,这里将不再进行赘述。
本申请实施例在区块通过共识后,进行区块记账时,为共识节点增设记账时长窗口,使得共识节点(如第一节点与第二节点)在记账时长窗口内进行记账,每个共识节点在记账完成后都可以进行广播通知,在进行记账的共识节点中,有超过数量阈值的共识节点均完成区块记账时,这些完成记账的共识节点才会关闭记账时长窗口,一起进入下一个区块的共识流程。这样可以使先完成区块记账的共识节点,在记账时长窗口内等待其他共识节点完成区块记账,再一起进入下一个区块的共识流程。可以看出,在记账时长窗口中,因为速度快的共识节点等待了速度较慢的共识节点进行记账,可以使得一起进入下一个区块的共识流程的共识节点存储有相同或差异很小的区块,即各个共识节点的区块高度相同或差异很小。而共识节点可以通过区块同步,在很短的时间内将差异很小的区块高度同步为相同,这样在进行下一个区块的共识时,可以减少共识节点因为区块高度不一致而带来共识失败的情况,从而可以提高后续共识业务流程的共识成功率。
进一步地,请参见图9,是本申请实施例提供的一种计算机设备的示意图。如图9所示,图8所对应实施例中的装置1可以应用于计算机设备1000,计算机设备1000可以包括:至少一个处理器1001,例如CPU,至少一个网络接口1004,用户接口1003,存储器1005,至少一个通信总线1002。其中,通信总线1002用于实现这些组件之间的连接通信。其中,用户接口1003可以包括显示屏(Display)、键盘(Keyboard),网络接口1004可选地可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器1005可以是高速RAM存储器,也可以是非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。存储器1005可选地还可以是至少一个位于远离前述处理器1001的存储装置。如图9所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及设备控制应用程序。
在图9所示的计算机设备1000中,网络接口1004主要用于与业务服务器进行网络通信;而用户接口1003主要用于为用户提供输入的接口;而处理器1001可以用于调用存储器1005中存储的设备控制应用程序,以实现:
向第二节点发送针对目标区块的第一共识投票信息,接收第二节点发送的针对目标区块的第二共识投票信息;
根据第一共识投票信息与第二共识投票信息,确定目标区块的共识结果,在共识结果为 共识通过结果时,启动记账时长窗口,在记账时长窗口内对目标区块进行记账处理,在记账时长窗口内接收第二节点发送的针对目标区块的第一记账完成消息;
若在记账时长窗口内完成对目标区块的记账处理,则向第二节点发送第二记账完成消息;
若第一记账完成消息与第二记账完成消息的总数量之和大于数量阈值,则关闭记账时长窗口,进入目标区块的后继区块的共识业务流程。
应当理解,本申请实施例中所描述的计算机设备1000可执行前文图2到图7所对应实施例中对该基于区块链的数据处理方法的描述,也可执行前文图8所对应实施例中对该数据处理装置1的描述,在此不再赘述。另外,对采用相同方法的有益效果描述,也不再进行赘述。
此外,这里需要指出的是:本申请实施例还提供了一种计算机可读存储介质,且计算机可读存储介质中存储有前文提及的视频数据处理的计算机设备1000所执行的计算机程序,且计算机程序包括计算机可读指令,当处理器执行计算机可读指令时,能够执行前文图2到图7所对应实施例中对基于区块链的数据处理方法的描述,因此,这里将不再进行赘述。另外,对采用相同方法的有益效果描述,也不再进行赘述。对于本申请所涉及的计算机可读存储介质实施例中未披露的技术细节,请参照本申请方法实施例的描述。
在一个实施例中,还提供了一种计算机设备,包括存储器和一个或多个处理器,存储器中存储有计算机可读指令,该一个或多个处理器执行计算机可读指令时实现上述各方法实施例中的步骤。
在一个实施例中,提供了一种一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,存储有计算机可读指令,该计算机可读指令被一个或多个处理器执行时实现上述各方法实施例中的步骤。
在一个实施例中,提供了一种计算机程序产品或计算机程序,所述计算机程序产品或计算机程序包括计算机可读指令,所述计算机可读指令存储在计算机可读存储介质中,计算机设备的处理器从所述计算机可读存储介质读取所述计算机可读指令,所述处理器执行所述计算机可读指令,使得所述计算机设备执行上述各方法实施例中的步骤。
计算机可读存储介质可以是前述任一实施例提供的基于区块链的数据处理装置或者计算机设备的内部存储单元,例如计算机设备的硬盘或内存。该计算机可读存储介质也可以是该计算机设备的外部存储设备,例如该计算机设备上配备的插接式硬盘,智能存储卡(smart media card,SMC),安全数字(secure digital,SD)卡,闪存卡(flash card)等。进一步地,该计算机可读存储介质还可以既包括该计算机设备的内部存储单元也包括外部存储设备。该计算机可读存储介质用于存储该计算机可读指令以及该计算机设备所需的其他程序和数据。该计算机可读存储介质还可以用于暂时地存储已经输出或者将要输出的数据。
本申请实施例的说明书和权利要求书及附图中的术语“第一”、“第二”等是用于区别不同对象,而非用于描述特定顺序。此外,术语“包括”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、装置、产品或设备没有限定于已列出的步骤或模块,而是可选地还包括没有列出的步骤或模块,或可选地还包括对于这些过程、方法、装置、产品或设备固有的其他步骤单元。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例提供的方法及相关装置是参照本申请实施例提供的方法流程图和/或结构示意图来描述的,具体可由计算机可读指令实现方法流程图和/或结构示意图的每一流程和/ 或方框、以及流程图和/或方框图中的流程和/或方框的结合。这些计算机可读指令可提供到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或结构示意图一个方框或多个方框中指定的功能的装置。这些计算机可读指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或结构示意图一个方框或多个方框中指定的功能。这些计算机可读指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或结构示意一个方框或多个方框中指定的功能的步骤。
以上所揭露的仅为本申请较佳实施例而已,当然不能以此来限定本申请之权利范围,因此依本申请权利要求所作的等同变化,仍属本申请所涵盖的范围。

Claims (22)

  1. 一种基于区块链的数据处理方法,由第一节点执行,第一节点为计算机设备,包括:
    向第二节点发送针对目标区块的第一共识投票信息,接收所述第二节点发送的针对所述目标区块的第二共识投票信息;
    根据所述第一共识投票信息与所述第二共识投票信息,确定所述目标区块的共识结果,在所述共识结果为共识通过结果时,启动记账时长窗口,在所述记账时长窗口内对所述目标区块进行记账处理,在所述记账时长窗口内接收所述第二节点发送的针对所述目标区块的第一记账完成消息;
    若在所述记账时长窗口内完成对所述目标区块的记账处理,则向所述第二节点发送第二记账完成消息;及
    若所述第一记账完成消息与所述第二记账完成消息的总数量之和大于或等于数量阈值,则关闭所述记账时长窗口,进入所述目标区块的后继区块的共识业务流程。
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述第一共识投票信息与所述第二共识投票信息,确定所述目标区块的共识结果,包括:
    在所述第二共识投票信息中,确定属于赞成投票的第二共识投票信息的数量,作为第一目标数量;
    若所述第一共识投票信息属于赞成投票,则根据所述第一共识投票信息和所述第一目标数量,确定赞成投票总数量;
    若所述赞成投票总数量与节点总数量的比值大于或等于比例阈值,则将所述目标区块的共识结果确定为共识通过结果;所述节点总数量为所述第一节点与所述第二节点的总数量;及
    若所述赞成投票总数量与所述节点总数量的比值小于所述比例阈值,则将所述目标区块的共识结果确定为共识失败结果。
  3. 根据权利要求2所述的方法,其特征在于,所述方法还包括:
    若所述第一共识投票信息属于拒绝共识通过投票,则根据所述第一目标数量确定所述赞成投票总数量。
  4. 根据权利要求1所述的方法,其特征在于,所述在所述共识结果为共识通过结果时,启动记账时长窗口,在所述记账时长窗口内对所述目标区块进行记账处理,包括:
    在所述共识结果为共识通过结果时,获取所述第二共识投票信息的数量;
    获取所述第二节点的节点数量,作为第二目标数量;及
    若所述第二共识投票信息的数量小于所述第二目标数量,则启动所述记账时长窗口,在所述记账时长窗口内对所述目标区块进行记账处理。
  5. 根据权利要求4所述的方法,其特征在于,所述第二共识投票信息携带所述第二节点的性能参数;
    所述方法还包括:
    若所述第二共识投票信息的数量等于所述第二目标数量,则根据所述第二节点的性能参数更新所述记账时长窗口,得到更新后的记账时长窗口;所述更新后的记账时长窗口对应的时长阈值小于所述记账时长窗口对应的时长阈值;
    启动所述更新后的记账时长窗口,在所述更新后的记账时长窗口内对所述目标区块进行记账处理;及
    若在所述更新后的记账时长窗口内完成对所述目标区块的记账处理,则进入所述目标区块的后继区块的共识业务流程。
  6. 根据权利要求4所述的方法,其特征在于,所述第二节点的数量为多个;所述若在所述记账时长窗口内完成对所述目标区块的记账处理,则向所述第二节点发送第二记账完成消息,包括:
    在所述记账时长窗口内,接收剩余第二节点发送的针对所述目标区块的第三共识投票信 息;所述剩余第二节点为多个所述第二节点中,除了已发送所述第二共识投票信息的第二节点以外的节点;
    若在所述记账时长窗口内完成对所述目标区块的记账处理,则获取所述第三共识投票信息的数量;
    将所述第三共识投票信息的数量与所述第二共识投票信息的数量进行相加,得到共识投票总数量;
    根据所述共识投票总数量与所述第二目标数量,检测所述第一节点的消息发送权限;及
    在所述第一节点具备所述消息发送权限时,向所述第二节点发送第二记账完成消息。
  7. 根据权利要求6所述的方法,其特征在于,所述根据所述共识投票总数量与所述第二目标数量,检测所述第一节点的消息发送权限,包括:
    若所述共识投票总数量小于所述第二目标数量,则确定所述第一节点具备所述消息发送权限;及
    若所述共识投票总数量等于所述第二目标数量,则确定所述第一节点未具备所述消息发送权限。
  8. 根据权利要求6所述的方法,其特征在于,所述方法还包括:
    在所述第一节点未具备所述消息发送权限时,关闭所述记账时长窗口,进入所述目标区块的后继区块的共识业务流程。
  9. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    获取所述记账时长窗口对应的时长阈值;
    统计所述第一节点处于所述记账时长窗口中的累计时长;及
    若所述累计时长与所述时长阈值相等,且所述第一记账完成消息与所述第二记账完成消息的总数量之和,小于所述数量阈值,则关闭所述记账时长窗口,进入所述目标区块的后继区块的共识业务流程。
  10. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    获取所述记账时长窗口对应的时长阈值;
    获取所述第一节点处于所述记账时长窗口中的累计时长;及
    若所述累计时长与所述时长阈值相等,且所述第一节点在所述记账时长窗口内未完成对所述目标区块的记账处理,则关闭所述记账时长窗口,进入所述目标区块的后继区块的共识业务流程。
  11. 一种基于区块链的数据处理装置,其特征在于,包括:
    投票信息交互模块,用于向第二节点发送针对目标区块的第一共识投票信息,接收所述第二节点发送的针对所述目标区块的第二共识投票信息;
    共识结果确定模块,用于根据所述第一共识投票信息与所述第二共识投票信息,确定所述目标区块的共识结果;
    记账处理模块,用于在所述共识结果为共识通过结果时,启动记账时长窗口,在所述记账时长窗口内对所述目标区块进行记账处理;
    记账完成接收模块,用于在所述记账时长窗口内接收所述第二节点发送的针对所述目标区块的第一记账完成消息;
    记账完成通知模块,用于若在所述记账时长窗口内完成对所述目标区块的记账处理,则向所述第二节点发送第二记账完成消息;及
    窗口关闭模块,用于若所述第一记账完成消息与所述第二记账完成消息的总数量之和大于或等于数量阈值,则关闭所述记账时长窗口,进入所述目标区块的后继区块的共识业务流程。
  12. 根据权利要求11所述的装置,其特征在于,所述共识结果确定模块包括:
    第一目标数量确定单元,用于在所述第二共识投票信息中,确定属于赞成投票的第二共识投票信息的数量,作为第一目标数量;
    赞成票数量确定单元,用于若所述第一共识投票信息属于赞成投票,则根据所述第一共识投票信息和所述第一目标数量,确定赞成投票总数量,若所述第一共识投票信息属于拒绝共识通过投票,则根据所述第一目标数量确定赞成投票总数量;
    共识通过确定单元,用于若所述赞成投票总数量与节点总数量的比值大于或等于比例阈值,则将所述目标区块的共识结果确定为共识通过结果;所述节点总数量为所述第一节点与所述第二节点的总数量;及
    共识失败确定单元,用于若所述赞成投票总数量与所述节点总数量的比值小于所述比例阈值,则将所述目标区块的共识结果确定为共识失败结果。
  13. 根据权利要求12所述的装置,其特征在于,所述赞成票数量确定单元还用于若所述第一共识投票信息属于拒绝共识通过投票,则根据所述第一目标数量确定所述赞成投票总数量。
  14. 根据权利要求11所述的装置,其特征在于,所述记账处理模块包括:
    数量获取单元,用于在所述共识结果为共识通过结果时,获取所述第二共识投票信息的数量;
    第二目标数量确定单元,用于获取所述第二节点的节点数量,作为第二目标数量;及
    记账处理单元,用于若所述第二共识投票信息的数量小于所述第二目标数量,则启动所述记账时长窗口,在所述记账时长窗口内对所述目标区块进行记账处理。
  15. 根据权利要求14所述的装置,其特征在于,所述第二共识投票信息携带所述第二节点的性能参数,所述装置还包括:
    窗口更新模块,用于若所述第二共识投票信息的数量等于所述第二目标数量,则根据所述第二节点的性能参数更新所述记账时长窗口,得到更新后的记账时长窗口;所述更新后的记账时长窗口对应的时长阈值小于所述记账时长窗口对应的时长阈值;
    窗口启动模块,用于启动所述更新后的记账时长窗口,在所述更新后的记账时长窗口内对所述目标区块进行记账处理;及
    流程进入模块,用于若在所述更新后的记账时长窗口内完成对所述目标区块的记账处理,则进入所述目标区块的后继区块的共识业务流程。
  16. 根据权利要求14所述的装置,其特征在于,所述第二节点的数量为多个,所述记账完成通知模块包括:
    投票信息接收单元,用于在所述记账时长窗口内,接收剩余第二节点发送的针对所述目标区块的第三共识投票信息;所述剩余第二节点为多个所述第二节点中,除了已发送所述第二共识投票信息的第二节点以外的节点;
    投票数量获取单元,用于若在所述记账时长窗口内完成对所述目标区块的记账处理,则获取所述第三共识投票信息的数量;
    相加处理单元,用于将所述第三共识投票信息的数量与所述第二共识投票信息的数量进行相加,得到共识投票总数量;
    权限检测单元,用于根据所述共识投票总数量与所述第二目标数量,检测所述第一节点的消息发送权限;及
    记账完成发送单元,用于在所述第一节点具备所述消息发送权限时,向所述第二节点发送第二记账完成消息。
  17. 根据权利要求16所述的装置,其特征在于,所述权限检测单元包括:
    第一权限确定子单元,用于若所述共识投票总数量小于所述第二目标数量,则确定所述第一节点具备所述消息发送权限;及
    第二权限确定子单元,用于若所述共识投票总数量等于所述第二目标数量,则确定所述第一节点未具备所述消息发送权限。
  18. 根据权利要求16所述的装置,其特征在于,所述装置还包括:
    共识流程进入模块,用于在所述第一节点未具备所述消息发送权限时,关闭所述记账时 长窗口,进入所述目标区块的后继区块的共识业务流程。
  19. 根据权利要求11所述的装置,其特征在于,所述装置还包括:
    第一时长阈值获取模块,用于获取所述记账时长窗口对应的时长阈值;
    第一累计时长统计模块,用于统计所述第一节点处于所述记账时长窗口中的累计时长;及
    第一区块共识进入模块,用于若所述累计时长与所述时长阈值相等,且所述第一记账完成消息与所述第二记账完成消息的总数量之和,小于所述数量阈值,则关闭所述记账时长窗口,进入所述目标区块的后继区块的共识业务流程。
  20. 根据权利要求11所述的装置,其特征在于,所述装置还包括:
    第二时长阈值获取模块,用于获取所述记账时长窗口对应的时长阈值;
    第二累计时长统计模块,用于获取所述第一节点处于所述记账时长窗口中的累计时长;及
    第二区块共识进入模块,用于若所述累计时长与所述时长阈值相等,且所述第一节点在所述记账时长窗口内未完成对所述目标区块的记账处理,则关闭所述记账时长窗口,进入所述目标区块的后继区块的共识业务流程。
  21. 一种计算机设备,包括存储器和一个或多个处理器,所述存储器存储有计算机可读指令,其特征在于,所述计算机可读指令被所述一个或多个处理器执行时,使得所述一个或多个处理器实现权利要求1至10中任一项所述的方法的步骤。
  22. 一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,存储有计算机可读指令,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器实现权利要求1至10中任一项所述的方法的步骤。
PCT/CN2021/088899 2020-05-27 2021-04-22 基于区块链的数据处理方法、装置、设备及可读存储介质 WO2021238514A1 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
EP21812015.2A EP4030314A4 (en) 2020-05-27 2021-04-22 BLOCKCHAIN BASED DATA PROCESSING METHOD, APPARATUS AND DEVICE AND READABLE STORAGE MEDIA
JP2022539707A JP7325894B2 (ja) 2020-05-27 2021-04-22 ブロックチェーンに基づくデータ処理方法、装置、デバイス及びコンピュータプログラム
KR1020227016044A KR20220074971A (ko) 2020-05-27 2021-04-22 블록체인 기반 데이터 프로세싱 방법, 장치 및 디바이스, 그리고 판독가능 저장 매체
US17/730,044 US11914579B2 (en) 2020-05-27 2022-04-26 Blockchain-based data processing method and apparatus, device, and readable storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010458171.4 2020-05-27
CN202010458171.4A CN111368008B (zh) 2020-05-27 2020-05-27 基于区块链的数据处理方法、装置、设备及可读存储介质

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/730,044 Continuation US11914579B2 (en) 2020-05-27 2022-04-26 Blockchain-based data processing method and apparatus, device, and readable storage medium

Publications (1)

Publication Number Publication Date
WO2021238514A1 true WO2021238514A1 (zh) 2021-12-02

Family

ID=71207558

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/088899 WO2021238514A1 (zh) 2020-05-27 2021-04-22 基于区块链的数据处理方法、装置、设备及可读存储介质

Country Status (6)

Country Link
US (1) US11914579B2 (zh)
EP (1) EP4030314A4 (zh)
JP (1) JP7325894B2 (zh)
KR (1) KR20220074971A (zh)
CN (1) CN111368008B (zh)
WO (1) WO2021238514A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111368008B (zh) 2020-05-27 2020-08-25 腾讯科技(深圳)有限公司 基于区块链的数据处理方法、装置、设备及可读存储介质
CN112261145B (zh) * 2020-10-22 2022-07-12 中国联合网络通信集团有限公司 一种新区块链生成方法及装置
CN114638452A (zh) * 2020-12-16 2022-06-17 中兴通讯股份有限公司 区块组头的获取方法及装置,存储介质及电子装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108776929A (zh) * 2018-04-02 2018-11-09 成都云创智融科技有限公司 基于区块链数据库的账单处理方法、系统和可读存储介质
CN108848055A (zh) * 2018-05-03 2018-11-20 中国银联股份有限公司 一种区块链共识方法、记账节点及节点
CN109903155A (zh) * 2019-01-14 2019-06-18 无锡一邦网络科技有限公司 Iift区块链共识算法
US20190279107A1 (en) * 2018-03-09 2019-09-12 Lenovo (Beijing) Co., Ltd. Blockchain-based data processing method, apparatus, and electronic device thereof
CN111368008A (zh) * 2020-05-27 2020-07-03 腾讯科技(深圳)有限公司 基于区块链的数据处理方法、装置、设备及可读存储介质

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2929988A1 (en) * 2013-08-12 2015-02-19 Selventa Systems and methods for crowd-verification of biological networks
US10417217B2 (en) * 2016-08-05 2019-09-17 Chicago Mercantile Exchange Inc. Systems and methods for blockchain rule synchronization
CN107103459A (zh) * 2017-04-27 2017-08-29 电子科技大学 基于主权区块链的记账系统及方法
JP2019012415A (ja) 2017-06-30 2019-01-24 株式会社bitFlyer ネットワークにおける合意形成方法及び当該ネットワークを構成するノード
EP3457623B1 (en) * 2017-09-15 2024-03-06 Panasonic Intellectual Property Corporation of America Electronic voting system
CN109274717B (zh) * 2018-08-22 2021-08-24 泰康保险集团股份有限公司 基于区块链的共享存储方法、装置、介质及电子设备
US20200084019A1 (en) * 2018-09-07 2020-03-12 Nebulas IO Limited Blockchain Ranking Engine
CN109544310A (zh) * 2018-11-13 2019-03-29 孙晞瑜 一种基于区块链联盟链的快速共识记账方法及其系统
CN110168582A (zh) 2018-11-30 2019-08-23 阿里巴巴集团控股有限公司 使用去中心化决策更新区块链智能合约
US11042849B2 (en) * 2019-02-26 2021-06-22 Apifiny Group Inc. Adjusting transaction distribution based on predicted open transaction execution rates
KR20200132518A (ko) * 2019-05-17 2020-11-25 삼성에스디에스 주식회사 블록체인 네트워크 간에 트랜잭션 연동을 지원하는 시스템 및 그 방법
CN110535836B (zh) * 2019-08-12 2021-10-29 安徽师范大学 一种基于角色分类的信任区块链共识方法
CN110505091B (zh) * 2019-08-23 2021-09-10 昆明理工大学 一种基于pbft改进的共识方法
CN111061769B (zh) * 2019-12-24 2021-09-10 腾讯科技(深圳)有限公司 一种区块链系统的共识方法及相关设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190279107A1 (en) * 2018-03-09 2019-09-12 Lenovo (Beijing) Co., Ltd. Blockchain-based data processing method, apparatus, and electronic device thereof
CN108776929A (zh) * 2018-04-02 2018-11-09 成都云创智融科技有限公司 基于区块链数据库的账单处理方法、系统和可读存储介质
CN108848055A (zh) * 2018-05-03 2018-11-20 中国银联股份有限公司 一种区块链共识方法、记账节点及节点
CN109903155A (zh) * 2019-01-14 2019-06-18 无锡一邦网络科技有限公司 Iift区块链共识算法
CN111368008A (zh) * 2020-05-27 2020-07-03 腾讯科技(深圳)有限公司 基于区块链的数据处理方法、装置、设备及可读存储介质

Also Published As

Publication number Publication date
US11914579B2 (en) 2024-02-27
EP4030314A1 (en) 2022-07-20
CN111368008B (zh) 2020-08-25
JP2023508210A (ja) 2023-03-01
CN111368008A (zh) 2020-07-03
US20220253432A1 (en) 2022-08-11
KR20220074971A (ko) 2022-06-03
JP7325894B2 (ja) 2023-08-15
EP4030314A4 (en) 2022-12-28

Similar Documents

Publication Publication Date Title
WO2021238514A1 (zh) 基于区块链的数据处理方法、装置、设备及可读存储介质
US11403636B2 (en) Blockchain-based transaction processing method and apparatus, and electronic device
WO2021233049A1 (zh) 基于区块链的数据处理方法、装置、设备及可读存储介质
US11823178B2 (en) Optimization of high volume transaction performance on a blockchain
US11971877B2 (en) Method, apparatus, device, and storage medium for proposal message processing for blockchain
US20230315891A1 (en) Transaction data processing method and apparatus, computer device and storage medium
CN111124917B (zh) 公共测试用例的管控方法、装置、设备及存储介质
US11966400B2 (en) Common database architecture to support largescale transactions and node archival on a MaaS platform
US20220239668A1 (en) Blockchain-based message processing method and apparatus, device, and storage medium
CN111260421B (zh) 一种基于区块链的电子发票管控方法及装置
CN109886695A (zh) 不同区块链之间的信息共享方法及装置和电子设备
CN109766365A (zh) 基于redis的运行事件控制方法、装置及电子设备
CN111556115A (zh) 一种基于区块链的数据处理方法、装置、设备及存储介质
CN114282011B (zh) 知识图谱的构建方法和装置、图计算方法及装置
CN110381150B (zh) 区块链上的数据处理方法、装置、电子设备及存储介质
CN116739596A (zh) 基于区块链的交易监管方法、装置、设备、介质和产品
CN115099925A (zh) 一种基于区块链的风险评估方法、装置及设备
US12099855B2 (en) Data processing method and apparatus, computer device, and readable storage medium
Fang Research on blockchain consensus algorithm based on DWBA protocol
US20240129143A1 (en) Dividing data storage and service operations among plural blockchains
CN117195199A (zh) 一种用户信息整合方法及相关装置
CN116703505A (zh) 一种订单信息的判断方法及装置
CN117520442A (zh) 数据同步方法、装置、计算机程序产品、设备及存储介质
CN113010799A (zh) 媒体信息的获取方法、装置、电子设备及存储介质
CN117061258A (zh) 计费检测方法、装置、设备和介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21812015

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021812015

Country of ref document: EP

Effective date: 20220414

ENP Entry into the national phase

Ref document number: 20227016044

Country of ref document: KR

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2022539707

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE