CN111405027A - Block chain consensus result screening method and device, computer equipment and storage medium - Google Patents

Block chain consensus result screening method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN111405027A
CN111405027A CN202010169301.2A CN202010169301A CN111405027A CN 111405027 A CN111405027 A CN 111405027A CN 202010169301 A CN202010169301 A CN 202010169301A CN 111405027 A CN111405027 A CN 111405027A
Authority
CN
China
Prior art keywords
node
simulation result
result
hash value
service request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010169301.2A
Other languages
Chinese (zh)
Other versions
CN111405027B (en
Inventor
唐俊峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kingdee Software China Co Ltd
Original Assignee
Kingdee Software China Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kingdee Software China Co Ltd filed Critical Kingdee Software China Co Ltd
Priority to CN202010169301.2A priority Critical patent/CN111405027B/en
Publication of CN111405027A publication Critical patent/CN111405027A/en
Application granted granted Critical
Publication of CN111405027B publication Critical patent/CN111405027B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • 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/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0643Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application relates to a block chain consensus result screening method and device, computer equipment and a storage medium. The method comprises the following steps: receiving a service request; broadcasting the service request to each second node in the block chain; the second node is a node in the block chain except the first node; obtaining a hash value corresponding to a simulation result fed back by each second node; the simulation result is a result obtained by the second node executing the transaction request; and determining the number of tickets of each hash value, and determining the simulation result corresponding to the hash value with the largest number of tickets as a consensus result. By adopting the method, the efficiency of screening the block chain consensus result can be improved.

Description

Block chain consensus result screening method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of blockchain technologies, and in particular, to a method and an apparatus for screening blockchain consensus results, a computer device, and a storage medium.
Background
As the technology of blockchain advances, a blockchain consensus technology has emerged to allow individual blockchain link points to agree on the validity of a result. For a service request, the simulation results obtained by executing the intelligent contracts at different blockchain nodes are likely to be inconsistent.
In the traditional method, the simulation results of each block chain node are directly compared and voted to determine the final consensus result. However, the conventional method requires a data structure of the simulation result to be known in advance. With the increase of the complexity of the actual service, the resolution complexity of the data structure of the simulation result also increases, and the efficiency of screening the block chain consensus result is reduced.
Disclosure of Invention
In view of the above, it is desirable to provide a method, an apparatus, a computer device and a storage medium for screening a blockchain consensus result, which can improve efficiency of screening the blockchain consensus result.
A block chain consensus result screening method is applied to a first node; the first node is any node in a block chain; the method comprises the following steps:
receiving a service request;
broadcasting the service request to each second node in the block chain; the second node is a node in the block chain except the first node;
obtaining a hash value corresponding to a simulation result fed back by each second node; the simulation result is a result obtained by the second node executing the service request;
and determining the ticket number of each hash value, and determining a consensus result according to the simulation result corresponding to the hash value with the largest ticket number.
In one embodiment, the obtaining the hash value corresponding to the simulation result fed back by each second node includes:
obtaining a simulation result fed back by each second node;
extracting a hash value from the simulation result; the hash value is obtained by performing hash operation on key field information in the simulation result and is added to the simulation result.
In one embodiment, the determining the number of votes for each of the hash values comprises:
sequentially acquiring hash values in the simulation results;
every time a hash value is obtained, increasing the number of tickets corresponding to the hash value by 1;
and obtaining the ticket number of each hash value until all the hash values in the simulation result are obtained.
In one embodiment, the service request comprises a transaction request; the simulation result is a result set obtained after the second node executes an intelligent contract on the transaction request; the result set comprises a transaction identification number, an intelligent contract name and a transaction result; and the hash value corresponding to the simulation result is obtained by splicing and combining the transaction identification number, the intelligent contract name and the transaction result in sequence and performing hash operation on the combined result.
A block chain consensus result screening method is applied to a second node, and comprises the following steps:
receiving a service request broadcast by a first node in a block chain;
executing an intelligent contract on the service request to obtain a simulation result;
carrying out Hash operation on the simulation result to obtain a Hash value corresponding to the simulation result;
adding the hash value to the corresponding simulation result, and feeding the simulation result back to the first node; and the simulation result is used for indicating the first node, and determining a consensus result according to the simulation result corresponding to the hash value with the largest number of votes according to the number of votes of the hash value corresponding to the simulation result fed back by each second node.
In one embodiment, the performing a hash operation on the simulation result to obtain a hash value corresponding to the simulation result includes:
splicing and combining the key field information in the simulation result in sequence;
and carrying out Hash operation on the combined result to obtain a Hash value corresponding to the simulation result.
In one embodiment, the service request comprises a transaction request; the simulation result comprises a transaction identification number, an intelligent contract name and a transaction result;
the splicing and combining the key field information in the simulation result according to the sequence comprises:
and splicing and combining the transaction identification number, the intelligent contract name and the transaction result in the simulation result in sequence.
A block chain consensus result screening device is applied to a first node; the first node is any node in a block chain; the device comprises:
a service request receiving module, configured to receive a service request;
a broadcasting module, configured to broadcast the service request to each second node in the block chain; the second node is a node in the block chain except the first node;
the hash value acquisition module is used for acquiring hash values corresponding to the simulation results fed back by the second nodes; the simulation result is a result obtained by the second node executing the service request;
and the consensus result determining module is used for determining the ticket number of each hash value and determining a consensus result according to the simulation result corresponding to the hash value with the largest ticket number.
An apparatus for screening consensus results of block chains, the apparatus being applied to a second node, the apparatus comprising:
a service request receiving module, configured to receive a service request broadcast by a first node in a block chain;
the execution module is used for executing the intelligent contract on the service request to obtain a simulation result;
the Hash operation module is used for carrying out Hash operation on the simulation result to obtain a Hash value corresponding to the simulation result;
the simulation result feedback module is used for adding the hash value to the corresponding simulation result and feeding the simulation result back to the first node; and the simulation result is used for indicating the first node, and determining a consensus result according to the simulation result corresponding to the hash value with the largest number of votes according to the number of votes of the hash value corresponding to the simulation result fed back by each second node.
A computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method for screening blockchain consensus result according to the embodiments of the present application.
A computer-readable storage medium, having a computer program stored thereon, wherein when the computer program is executed by a processor, the processor is enabled to execute the steps of the blockchain consensus result screening method according to the embodiments of the present application.
According to the block chain consensus result screening method, the block chain consensus result screening device, the computer equipment and the storage medium, the first node receives the service request and broadcasts the service request to the second node, the second node executes the intelligent contract on the service request to obtain the simulation result, the simulation result is fed back to the first node, the first node obtains the hash value corresponding to the simulation result, and the consensus result is determined according to the simulation result corresponding to the hash value with the largest number of tickets. By acquiring the number of votes of the hash value of the simulation result, the consensus result can be determined without knowing the data structure of the simulation result in advance to vote for the simulation result, and the efficiency of screening the block chain consensus result is improved.
Drawings
FIG. 1 is a diagram illustrating an exemplary embodiment of a method for screening consensus results of blockchains;
FIG. 2 is a schematic flow chart illustrating a method for screening consensus results of blockchains according to an embodiment;
FIG. 3 is a flowchart illustrating a method for screening consensus results of blockchains according to an embodiment;
FIG. 4 is a block diagram of a method for screening consensus results of blockchain transaction requests in one embodiment;
FIG. 5 is a block diagram illustrating an exemplary embodiment of an apparatus for screening consensus results of blockchains;
FIG. 6 is a block diagram illustrating an exemplary embodiment of an apparatus for screening consensus results of blockchains;
FIG. 7 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
It should be noted that the blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block.
The blockchain system includes a plurality of nodes (computer devices in any form in an access network, such as servers and user terminals), a Peer-To-Peer (P2P, Peer To Peer) network is formed among the nodes, and the P2P Protocol is an application layer Protocol operating on top of a Transmission Control Protocol (TCP).
Block chain consensus, which is used to agree on the validity of each block chain link point for a certain result.
The block chain consensus result screening method provided by the application can be applied to the application environment shown in fig. 1. The client 102 is a terminal outside the blockchain. The first node 104 and the second node 106 are nodes in a blockchain, and may be terminals or servers. The first node 104 is any node in the blockchain, the second node 106 is a node except the first node in the blockchain, and the number of the second nodes 106 can be one or more. The client 102 communicates with the first node 104 through a network, the client 102 sends a service request to the first node 104, and the first node 104 feeds back a consensus result corresponding to the service request to the client 102. The first node 104 communicates with each second node 106 through the network, the first node 104 broadcasts a service request to each second node 106, and the second node 106 feeds back a simulation result of the service request to the first node 104.
In one embodiment, as shown in fig. 2, a block chain consensus result screening method is provided, which is described by taking the method as an example applied to the first node in fig. 1, and includes the following steps:
s202, receiving a service request.
The service request is a request which is sent by a client to any node (first node) in the block chain and is used for realizing a certain service operation.
In one embodiment, the service request may include a transaction request, a data storage request, and the like.
Specifically, the first node receives a service request sent by a client. And after receiving the service request sent by the client, the first node carries out identity authentication on the client.
S204, broadcasting the service request to each second node in the block chain; the second node is a node in the block chain other than the first node.
Wherein, the broadcasting is that the first node in the block chain forwards the service request To each second node in the form of P2P (Peer To Peer) protocol.
Specifically, a first node in the blockchain broadcasts a service request to each second node. And after receiving the service request sent by the client, the first node performs identity authentication on the client, and broadcasts the service request to each second node after the authentication is passed.
S206, obtaining hash values corresponding to the simulation results fed back by the second nodes; and the simulation result is the result obtained by the second node executing the service request.
The hash value is obtained by performing hash operation on the simulation result.
In one embodiment, the second node executes the intelligent contract on the service request to obtain a simulation result. Intelligent contracts, which are computerized agreements that can execute the terms of a contract, are implemented by code deployed on a shared ledger for execution when certain conditions are met, completing automated transactions according to actual business needs.
Specifically, the first node obtains a hash value corresponding to a simulation result obtained by executing an intelligent contract on the service request by each second node.
In one embodiment, the second node performs a hash operation on the simulation result and adds the obtained hash value to the simulation result, and the first node extracts the hash value from the simulation result fed back by the second node.
In another embodiment, the first node performs a hash operation on the simulation result fed back from the second node to obtain a hash value.
And S208, determining the ticket number of each hash value, and determining a consensus result according to the simulation result corresponding to the hash value with the largest ticket number.
The number of votes is obtained by voting on the hash values, that is, counting the number of each hash value. The consensus result is the result of the block chain consensus, i.e., the final result of the consensus achieved on the simulation results of the second nodes.
Specifically, the first node counts hash values corresponding to the simulation results of the second nodes, and determines the number of votes of each hash value, that is, the number of each hash value; and determining the simulation result corresponding to the hash value with the largest ticket number as a consensus result, namely determining the simulation result corresponding to the hash value with the largest number obtained through statistics as the consensus result. And the first node feeds back the consensus result to the client.
In the block chain consensus result screening method, a first node receives a service request and broadcasts the service request to a second node, the second node executes an intelligent contract on the service request to obtain a simulation result and feeds the simulation result back to the first node, the first node obtains a hash value corresponding to the simulation result, and the consensus result is determined according to the simulation result corresponding to the hash value with the largest number of tickets. By acquiring the number of votes of the hash value of the simulation result, the consensus result can be determined without knowing the data structure of the simulation result in advance to vote for the simulation result, and the efficiency of screening the block chain consensus result is improved.
In an embodiment, the step of obtaining the hash value corresponding to the simulation result fed back by each second node specifically includes the following steps: obtaining a simulation result fed back by each second node; extracting a hash value from the simulation result; the hash value is obtained by performing hash operation on the key field information in the simulation result and is added to the simulation result.
The key field information is an element included in the simulation result. The key field is a field having key information included in the simulation result. It is understood that the key fields may be preset. For example: when the business request is a transaction request, the key field information in the simulation result may include a transaction identification number, a smart contract name, and a transaction result. Specifically, the second node performs hash operation on key field information in the simulation result to obtain a hash value, the hash value is added to the simulation result, the first node obtains the simulation result fed back by the second node, and the hash value is extracted from the simulation result.
In one embodiment, the second node performs hash operation on the key field information in the simulation result, and performs hash operation after splicing and combining the key field information in the simulation result according to a preset sequence. It can be understood that the splicing order of the key field information in the simulation result of each second node must be consistent.
In this embodiment, the first node can conveniently compare the simulation results of the second nodes by extracting the hash value from the simulation result fed back by the second node, so as to determine the consensus result, and improve the efficiency of screening the block chain consensus result.
In one embodiment, the step of determining the number of tickets for each hash value specifically includes the following steps: sequentially acquiring hash values in each simulation result; every time one hash value is obtained, increasing the number of tickets corresponding to the hash value by 1; and obtaining the ticket number of each hash value until the hash values in all the simulation results are obtained.
Specifically, for example, if the number of the second nodes is 5, and the hash values in the simulation result of each second node are a, b, c, a, a in turn, the number of votes for each hash value is determined: the number of votes for hash a is 3, the number of votes for hash b is 1, and the number of votes for hash c is 1.
In this embodiment, the first node can conveniently compare the simulation results of the second nodes by determining the number of tickets of each hash value, so as to determine the consensus result, and improve the efficiency of screening the block chain consensus result.
In one embodiment, the service request comprises a transaction request. And the simulation result is a result set obtained after the second node executes the intelligent contract on the transaction request. The result set includes a transaction identification number, an intelligent contract name, and a transaction result. And the hash value corresponding to the simulation result is obtained by splicing and combining the transaction identification number, the intelligent contract name and the transaction result in sequence and performing hash operation on the combined result.
The transaction request is a request for executing a transaction. The transaction identification number is used for representing a transaction. And the intelligent contract name is used for representing an intelligent contract. And the transaction result is the transaction result output by executing the intelligent contract on the transaction request.
It is understood that the transaction results describe the balance of different account numbers or transaction error information. In the conventional method, the data structure of the transaction result needs to be analyzed to determine the consensus result.
Specifically, the hash value corresponding to the simulation result is obtained by splicing and combining the transaction identification number, the intelligent contract name and the transaction result in sequence, and performing hash operation on the combined result. It can be understood that the order of the transaction identification number, the intelligent contract name and the splicing of the transactions in each simulation result must be consistent.
In this embodiment, the first node receives the transaction request, and broadcasts the transaction request to the second node, the second node executes the intelligent contract on the transaction request to obtain the simulation result, and feeds back the simulation result to the first node, the first node obtains the hash value corresponding to the simulation result, and determines the simulation result corresponding to the hash value with the largest number of tickets as the consensus result. By acquiring the number of votes of the hash value of the simulation result, the consensus result of the transaction request can be determined without knowing the data structure of the simulation result in advance to vote for the simulation result, and the efficiency of screening the consensus result in the process of processing the transaction request by the blockchain is improved.
In one embodiment, as shown in fig. 3, a block chain consensus result screening method is provided, which is described by taking the method as an example for the second node in fig. 1, and includes the following steps:
s302, receiving a service request broadcast by a first node in a block chain.
The service request is a request which is sent by a client to any node (first node) in the block chain and is used for realizing a certain service operation.
In one embodiment, the service request may include a transaction request, a data storage request, and the like.
Specifically, after receiving a service request sent by a client, a first node performs identity authentication on the client, and broadcasts the service request to each second node after the authentication is passed. The second node receives the service request broadcast by the first node.
S304, executing an intelligent contract on the service request to obtain a simulation result.
The intelligent contract is a computerized agreement, can execute the terms of a certain contract, is realized by codes which are deployed on a shared account and are used for executing when a certain condition is met, and completes an automatic transaction according to actual business requirements.
In one embodiment, the simulation results may include a plurality of key field information.
And S306, carrying out Hash operation on the simulation result to obtain a Hash value corresponding to the simulation result.
Specifically, the second node may sequentially splice and combine the key field information in the simulation result, and then perform hash operation to obtain a hash value corresponding to the simulation result.
And S308, adding the hash value into the corresponding simulation result, and feeding the simulation result back to the first node. And the simulation result is used for indicating the first node, and determining the consensus result according to the simulation result corresponding to the hash value with the largest ticket number and the simulation result corresponding to the hash value with the largest ticket number, which are fed back by each second node.
Specifically, the second node adds the hash value to the corresponding simulation result, and feeds the simulation result back to the first node. And the first node determines the simulation result corresponding to the hash value with the largest ticket number as the consensus result according to the ticket number of the hash value corresponding to the simulation result. And the first node feeds back the consensus result to the client.
In the block chain consensus result screening method, a first node receives a service request and broadcasts the service request to a second node, the second node executes an intelligent contract on the service request to obtain a simulation result and feeds the simulation result back to the first node, the first node obtains a hash value corresponding to the simulation result, and the consensus result is determined according to the simulation result corresponding to the hash value with the largest number of tickets. By acquiring the number of votes of the hash value of the simulation result, the consensus result can be determined without knowing the data structure of the simulation result in advance to vote for the simulation result, and the efficiency of screening the block chain consensus result is improved.
In an embodiment, the step of performing a hash operation on the simulation result to obtain a hash value corresponding to the simulation result specifically includes the following steps: splicing and combining the key field information in the simulation result in sequence; and carrying out Hash operation on the combined result to obtain a Hash value corresponding to the simulation result.
The key field information is an element included in the simulation result. For example: when the business request is a transaction request, the key field information in the simulation result may include a transaction identification number, a smart contract name, and a transaction result.
Specifically, the second node sequentially splices and combines the key field information in the simulation result, and performs hash operation on the combined result to obtain a hash value corresponding to the simulation result. It can be understood that each second node splices and combines the key field information in the simulation result in sequence, and the splicing sequence must be consistent.
In this embodiment, the second node performs hash operation on the simulation result to obtain a hash value corresponding to the simulation result, so that the first node can conveniently compare the simulation results of the second nodes, thereby determining the consensus result and improving the efficiency of screening the block chain consensus result.
In one embodiment, the service request comprises a transaction request. The simulation result comprises a transaction identification number, an intelligent contract name and a transaction result. The method comprises the following steps of splicing and combining key field information in a simulation result in sequence: and splicing and combining the transaction identification number, the intelligent contract name and the transaction result in the simulation result in sequence.
The transaction request is a request for executing a transaction. The transaction identification number is used for representing a transaction. And the intelligent contract name is used for representing an intelligent contract. And the transaction result is the transaction result output by executing the intelligent contract on the transaction request.
Specifically, the second node splices and combines the transaction identification number, the intelligent contract name and the transaction result in the simulation result in sequence, and performs hash operation on the combined result to obtain a hash value corresponding to the simulation result. It can be understood that each second node splices and combines the transaction identification number, the intelligent contract name and the transaction result in the simulation result in sequence, and the splicing sequence must be consistent.
In this embodiment, the first node receives the transaction request, and broadcasts the transaction request to the second node, the second node executes the intelligent contract on the transaction request to obtain the simulation result, and feeds back the simulation result to the first node, the first node obtains the hash value corresponding to the simulation result, and determines the simulation result corresponding to the hash value with the largest number of tickets as the consensus result. By acquiring the number of votes of the hash value of the simulation result, the consensus result of the transaction request can be determined without knowing the data structure of the simulation result in advance to vote for the simulation result, and the efficiency of screening the consensus result in the process of processing the transaction request by the blockchain is improved.
In one embodiment, as shown in fig. 4, the block chain consensus result screening method is a flow chart of the block chain consensus result screening method when the service request is a transaction request. The blockchain in the graph includes four nodes, where: node.a is the first node and node.b, node.c and node.d are the second nodes. The Request box is a transaction (Tx) Request sent by the client, wherein the transaction identification number (TxID) is 3719302, the intelligent contract name (CC) is kst, and the Input (Input) of the transaction Request is "Jason-100 & Tom + 100" which means that the user Jason transfers 100 elements to the user Tom. Suppose that the balance of the account before Jason transfer is 300 yuan, and the balance of the account before Tom accepts transfer is 0 yuan.
The overall flow of the method in fig. 4 is such that: the first node (node.a) receives the transaction Request (Request) and broadcasts the transaction Request in the form of a P2P protocol to the second nodes (node.b, node.c and node.d). Each second node (node.b, node.c and node.d) executes an intelligent contract on the transaction request, respectively, to obtain a simulation result in the graph, wherein the output (output) represents the transaction result. The transaction results in the simulation results obtained by node.B and node.C are the same, and both Jason account balance is 200 yuan, and Tom account balance is 100 yuan. And the transaction result in the simulation result obtained by the node.D is that the Jason account balance is insufficient, and the transaction result is different from the node.B and the node.C. And the second node (node.B, node.C and node.D) respectively splices and combines the key field information transaction identification number (TxID), the intelligent contract name (CC) and the transaction result (output) in the simulation result in sequence, performs Hash operation on the combined result to obtain a Hash value (Hash), and adds the Hash value into the simulation result. It can be seen from the figure that node.b and node.c get the same hash value, while node.d gets a different hash value than node.b and node.c. Each second node (node.b, node.c and node.d) feeds back the simulation results to the first node (node.a) in the form of a P2P protocol. The first node (node.a) screens out the final consensus result (Response) according to the votes of the hash values of the second nodes (node.b, node.c and node.d). In the figure, the number of votes of the Hash value (Hash) abcd1234 is 2 tickets, and the number of votes of the Hash value (Hash) xyz98765 is 1 ticket, so that the first node (node.a) determines the simulation result corresponding to the Hash value (Hash) abcd1234 as the consensus result.
It can be understood that the transaction identification number (TxID), the intelligent contract name (CC) and the transaction result (output) of the key field information in the simulation result of the second node node.b and the second node.c in fig. 4 are completely consistent, and therefore, after the key field information is spliced and combined in sequence, the hash value obtained by performing the hash operation is also the same. The key field information in the simulation result of the second node node.d is not completely consistent with node.b and node.c, so the hash value obtained by node.d is different from node.b and node.c, i.e. changing one character arbitrarily will cause the hash value to change greatly. The first node (node.A) only needs to compare the votes of the hash values of the second nodes, and does not need to master the data structure of the simulation result of each second node, thereby avoiding the situation that the efficiency of screening the consensus result is reduced because complex services are processed in practice and the data structure is complex, and improving the efficiency of screening the block chain consensus result.
It should be understood that although the steps in the flowcharts of fig. 2 and 3 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2 and 3 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.
In one embodiment, as shown in fig. 5, there is provided a blockchain consensus result screening apparatus 500 applied to a first node; the first node is any node in the block chain; the apparatus 500 comprises: a service request receiving module 502, a broadcasting module 504, a hash value obtaining module 506 and a consensus result determining module 508, wherein:
a service request receiving module 502, configured to receive a service request.
A broadcasting module 504, configured to broadcast a service request to each second node in the block chain; the second node is a node in the block chain other than the first node.
A hash value obtaining module 506, configured to obtain hash values corresponding to simulation results fed back by the second nodes; and the simulation result is the result obtained by the second node executing the service request.
And a consensus result determining module 508, configured to determine the number of votes for each hash value, and determine a consensus result according to the simulation result corresponding to the hash value with the largest number of votes.
In one embodiment, the hash value obtaining module 506 is further configured to obtain a simulation result fed back by each second node; extracting a hash value from the simulation result; the hash value is obtained by performing hash operation on the key field information in the simulation result and is added to the simulation result.
In one embodiment, the consensus result determining module 508 is further configured to sequentially obtain hash values in the simulation results; every time one hash value is obtained, increasing the number of tickets corresponding to the hash value by 1; and obtaining the ticket number of each hash value until the hash values in all the simulation results are obtained.
In one embodiment, the service request comprises a transaction request. And the simulation result is a result set obtained after the second node executes the intelligent contract on the transaction request. The result set includes a transaction identification number, an intelligent contract name, and a transaction result. And the hash value corresponding to the simulation result is obtained by splicing and combining the transaction identification number, the intelligent contract name and the transaction result in sequence and performing hash operation on the combined result.
In one embodiment, an apparatus 600 for screening blockchain consensus results is provided, the apparatus being applied to a second node, the apparatus 600 comprising: a service request receiving module 602, an executing module 604, a hash operation module 606 and a simulation result feedback module 608, wherein:
a service request receiving module 602, configured to receive a service request broadcast by a first node in a block chain.
And the execution module 604 is configured to execute the intelligent contract on the service request to obtain a simulation result.
And the hash operation module 606 is configured to perform hash operation on the simulation result to obtain a hash value corresponding to the simulation result.
A simulation result feedback module 608, configured to add the hash value to the corresponding simulation result and feed the simulation result back to the first node; and the simulation result is used for indicating the first node, and determining the consensus result according to the simulation result corresponding to the hash value with the largest ticket number and the simulation result corresponding to the hash value with the largest ticket number, which are fed back by each second node.
In one embodiment, the hash operation module 606 is further configured to splice and combine the key field information in the simulation result in order; and carrying out Hash operation on the combined result to obtain a Hash value corresponding to the simulation result.
In one embodiment, the service request comprises a transaction request. The simulation result comprises a transaction identification number, an intelligent contract name and a transaction result. The hash operation module 606 is further configured to splice and combine the transaction identification number, the intelligent contract name, and the transaction result in the simulation result in sequence.
In the block chain consensus result screening device, a first node receives a service request and broadcasts the service request to a second node, the second node executes an intelligent contract on the service request to obtain a simulation result and feeds the simulation result back to the first node, the first node obtains a hash value corresponding to the simulation result, and the consensus result is determined according to the simulation result corresponding to the hash value with the largest number of tickets. By acquiring the number of votes of the hash value of the simulation result, the consensus result can be determined without knowing the data structure of the simulation result in advance to vote for the simulation result, and the efficiency of screening the block chain consensus result is improved.
For the specific limitation of the device for screening the result of blockchain consensus, reference may be made to the above limitation of the method for screening the result of blockchain consensus, which is not described herein again. All or part of each module in the block chain consensus result screening device can be realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 7. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used to store blockchain data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a block chain consensus screening method.
Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is further provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (11)

1. A block chain consensus result screening method is applied to a first node; the first node is any node in a block chain; the method comprises the following steps:
receiving a service request;
broadcasting the service request to each second node in the block chain; the second node is a node in the block chain except the first node;
obtaining a hash value corresponding to a simulation result fed back by each second node; the simulation result is a result obtained by the second node executing the service request;
and determining the ticket number of each hash value, and determining a consensus result according to the simulation result corresponding to the hash value with the largest ticket number.
2. The method according to claim 1, wherein the obtaining the hash value corresponding to the simulation result fed back by each second node comprises:
obtaining a simulation result fed back by each second node;
extracting a hash value from the simulation result; and the hash value is obtained by carrying out hash operation on the key field information in the simulation result and is added to the value in the simulation result.
3. The method of claim 2, wherein said determining the number of votes for each of said hash values comprises:
sequentially acquiring hash values in the simulation results;
every time a hash value is obtained, increasing the number of tickets corresponding to the hash value by 1;
and obtaining the ticket number of each hash value until all the hash values in the simulation result are obtained.
4. The method of claim 1, wherein the service request comprises a transaction request; the simulation result is a result set obtained after the second node executes an intelligent contract on the transaction request; the result set comprises a transaction identification number, an intelligent contract name and a transaction result; and the hash value corresponding to the simulation result is obtained by splicing and combining the transaction identification number, the intelligent contract name and the transaction result in sequence and performing hash operation on the combined result.
5. A method for screening block chain consensus results is applied to a second node, and the method comprises the following steps:
receiving a service request broadcast by a first node in a block chain;
executing an intelligent contract on the service request to obtain a simulation result;
carrying out Hash operation on the simulation result to obtain a Hash value corresponding to the simulation result;
adding the hash value to the corresponding simulation result, and feeding the simulation result back to the first node; and the simulation result is used for indicating the first node, and determining the simulation result corresponding to the hash value with the largest ticket number as a consensus result according to the ticket number of the hash value corresponding to the simulation result fed back by each second node.
6. The method of claim 5, wherein the performing the hash operation on the simulation result to obtain the hash value corresponding to the simulation result comprises:
splicing and combining the key field information in the simulation result in sequence;
and carrying out Hash operation on the combined result to obtain a Hash value corresponding to the simulation result.
7. The method of claim 6, wherein the service request comprises a transaction request; the simulation result comprises a transaction identification number, an intelligent contract name and a transaction result;
the splicing and combining the key field information in the simulation result according to the sequence comprises:
and splicing and combining the transaction identification number, the intelligent contract name and the transaction result in the simulation result in sequence.
8. The device for screening the block chain consensus result is characterized in that the device is applied to a first node; the first node is any node in a block chain; the device comprises:
a service request receiving module, configured to receive a service request;
a broadcasting module, configured to broadcast the service request to each second node in the block chain; the second node is a node in the block chain except the first node;
the hash value acquisition module is used for acquiring hash values corresponding to the simulation results fed back by the second nodes; the simulation result is a result obtained by the second node executing the service request;
and the consensus result determining module is used for determining the ticket number of each hash value and determining a consensus result according to the simulation result corresponding to the hash value with the largest ticket number.
9. An apparatus for screening consensus results of block chains, the apparatus being applied to a second node, the apparatus comprising:
a service request receiving module, configured to receive a service request broadcast by a first node in a block chain;
the execution module is used for executing the intelligent contract on the service request to obtain a simulation result;
the Hash operation module is used for carrying out Hash operation on the simulation result to obtain a Hash value corresponding to the simulation result;
the simulation result feedback module is used for adding the hash value to the corresponding simulation result and feeding the simulation result back to the first node; and the simulation result is used for indicating the first node, and determining a consensus result according to the simulation result corresponding to the hash value with the largest number of votes according to the number of votes of the hash value corresponding to the simulation result fed back by each second node.
10. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.
11. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202010169301.2A 2020-03-12 2020-03-12 Block chain consensus result screening method, device, computer equipment and storage medium Active CN111405027B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010169301.2A CN111405027B (en) 2020-03-12 2020-03-12 Block chain consensus result screening method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010169301.2A CN111405027B (en) 2020-03-12 2020-03-12 Block chain consensus result screening method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111405027A true CN111405027A (en) 2020-07-10
CN111405027B CN111405027B (en) 2023-06-23

Family

ID=71432365

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010169301.2A Active CN111405027B (en) 2020-03-12 2020-03-12 Block chain consensus result screening method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111405027B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112087502A (en) * 2020-08-28 2020-12-15 成都质数斯达克科技有限公司 Method, device and equipment for processing request and storage medium
CN112260905A (en) * 2020-12-23 2021-01-22 江苏荣泽信息科技股份有限公司 Consensus efficiency control system for block chain network consensus accelerator

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012142331A1 (en) * 2011-04-13 2012-10-18 Autonomy, Inc. Methods and systems for generating concept-based hash tags
WO2019019056A1 (en) * 2017-07-26 2019-01-31 杭州复杂美科技有限公司 Method for frontal machine to participate in block chain consensus
CN109447810A (en) * 2018-11-29 2019-03-08 杭州秘猿科技有限公司 Parallel block chain common recognition method, system, electronic equipment and computer readable storage medium
CN110046992A (en) * 2018-12-12 2019-07-23 阿里巴巴集团控股有限公司 A kind of transaction Hash acquisition methods and system based on block chain intelligence contract
CN110247774A (en) * 2019-06-28 2019-09-17 深圳市网心科技有限公司 A kind of the common recognition method and relevant device of block chain data
CN110708171A (en) * 2019-12-13 2020-01-17 腾讯科技(深圳)有限公司 Block chain consensus voting method, device, equipment and storage medium
CN110825755A (en) * 2019-10-30 2020-02-21 北京海益同展信息科技有限公司 Block chain consensus method, consensus node, electronic device, and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012142331A1 (en) * 2011-04-13 2012-10-18 Autonomy, Inc. Methods and systems for generating concept-based hash tags
WO2019019056A1 (en) * 2017-07-26 2019-01-31 杭州复杂美科技有限公司 Method for frontal machine to participate in block chain consensus
CN109447810A (en) * 2018-11-29 2019-03-08 杭州秘猿科技有限公司 Parallel block chain common recognition method, system, electronic equipment and computer readable storage medium
CN110046992A (en) * 2018-12-12 2019-07-23 阿里巴巴集团控股有限公司 A kind of transaction Hash acquisition methods and system based on block chain intelligence contract
CN110247774A (en) * 2019-06-28 2019-09-17 深圳市网心科技有限公司 A kind of the common recognition method and relevant device of block chain data
CN110825755A (en) * 2019-10-30 2020-02-21 北京海益同展信息科技有限公司 Block chain consensus method, consensus node, electronic device, and storage medium
CN110708171A (en) * 2019-12-13 2020-01-17 腾讯科技(深圳)有限公司 Block chain consensus voting method, device, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
董友康: "基于区块链的安全电子投票系统的设计与实现" *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112087502A (en) * 2020-08-28 2020-12-15 成都质数斯达克科技有限公司 Method, device and equipment for processing request and storage medium
CN112087502B (en) * 2020-08-28 2022-10-21 成都质数斯达克科技有限公司 Method, device and equipment for processing request and storage medium
CN112260905A (en) * 2020-12-23 2021-01-22 江苏荣泽信息科技股份有限公司 Consensus efficiency control system for block chain network consensus accelerator
CN112260905B (en) * 2020-12-23 2021-04-06 江苏荣泽信息科技股份有限公司 Consensus efficiency control system for block chain network

Also Published As

Publication number Publication date
CN111405027B (en) 2023-06-23

Similar Documents

Publication Publication Date Title
CN109242500B (en) Block chain transaction validity verification method and device and storage medium
CN109474578B (en) Message checking method, device, computer equipment and storage medium
CN111625593B (en) Block chain-based data processing method and device and computer equipment
CN111507717B (en) Data processing method, device, block node and computer readable storage medium
CN111861477A (en) Block chain-based post-transaction data processing method and device and computer equipment
CN107993053B (en) Claims data auditing method and device, computer equipment and storage medium
CN112613877B (en) Intelligent contract triggering method and device applied to block chain network and related equipment
CN111405027B (en) Block chain consensus result screening method, device, computer equipment and storage medium
CN111522874A (en) Block chain consensus method, block chain consensus device, computer equipment and storage medium
CN110599142A (en) Data storage method and device, computer equipment and storage medium
CN111488626A (en) Data processing method, device, equipment and medium based on block chain
CN110990790B (en) Data processing method and equipment
CN110598007B (en) Bill file processing method, device, medium and electronic equipment
CN110930254A (en) Data processing method, device, terminal and medium based on block chain
CN113781202A (en) Data processing method, data processing device, computer equipment and storage medium
CN109327499A (en) Management method and device, storage medium, the terminal of business interface
CN111201751B (en) Method and system for arbitrating data authenticity in blockchain
CN111524009A (en) Transaction verification method and device for blockchain system and hardware equipment
CN111510484B (en) Block chain processing method, system, device, computer equipment and storage medium
CN115510366A (en) Business message pushing method and device, computer equipment and storage medium
CN111522873B (en) Block generation method, device, computer equipment and storage medium
US20220005025A1 (en) Distributed ledger management system, distributed ledger management method, and node
CN110597466B (en) Control method and device of block chain node, storage medium and computer equipment
CN117010889A (en) Data processing method, device, equipment, medium and product
CN113434577A (en) Service data processing method, storage medium and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant