Asynchronous consensus method, system, device and medium based on block chain
1. The asynchronous consensus method based on the block chain is characterized by comprising the following steps:
the requester acquires target data and sends a consensus request to the participants;
the requester acquires first parameter data and second parameter data of the target data according to the target data;
the requester packs the target data, the first parameter data and the second parameter data into a first block and adds the first block to a block chain, and broadcasts the first block in the block chain;
and the participator receives and verifies the first block, and uses the first block as a consensus data source for consensus to obtain a consensus result.
2. The asynchronous consensus method based on block chains according to claim 1, wherein obtaining the first parameter data and the second parameter data of the target data specifically comprises:
acquiring an interface parameter and a reading parameter of target data as a first data parameter;
and acquiring the hash value of the target data as a second data parameter.
3. The asynchronous block chain-based consensus method of claim 1, wherein a participant receives and authenticates a first block, comprising:
the requester packs the target data, the first parameter data and the second parameter data into a first block, and the requester signs the first block;
the participator receives the consensus request and the public key of the first block;
the participator obtains target data, first parameter data and second parameter data in the first block according to the public key;
the participator obtains target data to be verified according to the first parameter data and the second parameter data;
comparing the target data with the target data to be verified, and if the target data is consistent with the target data to be verified, the verification is passed;
if not, the participant reacquires the first block.
4. The asynchronous block chain-based consensus method according to claim 3, wherein a participant receives and verifies the first block as a consensus data source for consensus, resulting in a consensus result;
the participant receives and verifies the first block, and the number of participants passing the verification is obtained;
if the number of the verified participants is greater than or equal to 50% of the number of all the participants, the first block is a consensus result.
5. The block chain based asynchronous consensus method of claim 4,
the participant receives and verifies the first block;
if the verification is passed, generating a valid result and transmitting the valid result to the next participant;
if the verification fails, the first block is received again and verified.
6. The asynchronous consensus system based on the block chain is characterized by comprising an acquisition module, a parameter module, a first verification module, a second verification module and a consensus module;
the acquisition module is used for acquiring target data;
the parameter module is used for acquiring a first data parameter and a second data parameter according to the target data, packaging the target data, the first parameter data and the second parameter data into a first block and adding the first block, the first parameter data and the second parameter data into a block chain;
the first verification module is used for verifying the first block and acquiring target data, first parameter data and second parameter data in the verified first block;
the second verification module is used for acquiring target data to be verified according to the first parameter data and the second parameter data and verifying the target data through the target data;
the consensus module is used for obtaining a consensus result according to the second verification module.
7. The asynchronous block chain based consensus system of claim 6, further comprising a broadcast module for transmitting the first block.
8. The blockchain-based asynchronous consensus system as claimed in claim 6, wherein the first data parameter is an interface parameter and a read parameter of the target data; the second data parameter is a hash value of the target data.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the block chain based asynchronous consensus method according to any one of claims 1-5 when executing the computer program.
10. A storage medium, in which a computer program is stored, which, when being executed by a processor, carries out the steps of the block chain based asynchronous consensus method according to one of the claims 1 to 5.
Background
Block chains can be generally classified into public chains, federation chains, and private chains, depending on access rights. The public chain refers to a block chain which can be accessed by anyone according to a protocol and is in consensus; the alliance chain is a block chain of which the consensus process is controlled by a preselected node; private chain refers to a chain of blocks that are authorized in an organization and are fully controlled by the organization.
The block chain is generally divided into several large technical points such as consensus algorithm, cryptography, P2P network and the like at the technical level. Where the consensus algorithm is the most core part of the blockchain project, and there is a distribution, consensus needs to be achieved.
As a BFT consensus protocol for asynchronous networks, honeybadger bayer fault Tolerance (honeybadger BFT) does not depend on any time assumption about network environment, compared with the conventional Practical Bayer Fault Tolerance (PBFT), honeybadger BFT has higher processing efficiency and is therefore recognized by more and more organizations.
The existing block chain consensus method generally needs to be connected with most nodes in the consensus process to acquire votes. The node has larger dependence on the network body, and the data transmission efficiency of the system is difficult to improve; secondly, in the actual data sharing application process, especially in the state that data production, storage and sharing involve multiple parties, when the production result and the storage result of the data are influenced by risks such as attack, tampering and the like, the credibility of the data authenticity is poor, and even if the authority of the prover is used to force the trust of other parties to be promoted at a non-mathematical proving level, the trust result is lack of scientificity and commonality.
Disclosure of Invention
The invention aims to provide a method for calculating values of database fields and record values by multiple parties according to an agreed rule aiming at data of database record types, and realize common identification and common identification under high efficiency.
In order to achieve the above object, the present invention provides an asynchronous consensus method based on a block chain, comprising:
the requester acquires target data and sends a consensus request to the participants;
the requester acquires first parameter data and second parameter data of the target data according to the target data;
the requester packs the target data, the first parameter data and the second parameter data into a first block and adds the first block to a block chain, and broadcasts the first block in the block chain;
and the participator receives and verifies the first block, and uses the first block as a consensus data source for consensus to obtain a consensus result.
The acquiring of the first parameter data and the second parameter data of the target data specifically includes:
acquiring an interface parameter and a reading parameter of target data as a first data parameter;
and acquiring the hash value of the target data as a second data parameter.
Wherein, the participant receiving and verifying the first block specifically comprises:
the requester packs the target data, the first parameter data and the second parameter data into a first block, and the requester signs the first block;
the participator receives the consensus request and the public key of the first block;
the participator obtains target data, first parameter data and second parameter data in the first block according to the public key;
the participator obtains target data to be verified according to the first parameter data and the second parameter data;
comparing the target data with the target data to be verified, and if the target data is consistent with the target data to be verified, the verification is passed;
if not, the participant reacquires the first block.
The participator receives and verifies the first block, and uses the first block as a consensus data source for consensus to obtain a consensus result;
the participant receives and verifies the first block, and the number of participants passing the verification is obtained;
if the number of the verified participants is greater than or equal to 50% of the number of all the participants, the first block is a consensus result.
Wherein the participant receives and verifies the first block; if the verification is passed, generating a valid result and transmitting the valid result to the next participant; if the verification fails, the first block is received again and verified.
Corresponding to the method in the invention, the invention also provides an asynchronous consensus system based on the block chain, which comprises an acquisition module, a parameter module, a first verification module, a second verification module and a consensus module;
the acquisition module is used for acquiring target data;
the parameter module is used for acquiring a first data parameter and a second data parameter according to the target data, packaging the target data, the first parameter data and the second parameter data into a first block and adding the first block, the first parameter data and the second parameter data into a block chain;
the first verification module is used for verifying the first block and acquiring target data, first parameter data and second parameter data in the verified first block;
the second verification module is used for acquiring target data to be verified according to the first parameter data and the second parameter data and verifying the target data through the target data;
the consensus module is used for obtaining a consensus result according to the second verification module.
The system further comprises a broadcasting module, wherein the broadcasting module is used for transmitting the first block.
The first data parameters are interface parameters and reading parameters of the target data; the second data parameter is a hash value of the target data.
Corresponding to the method in the present invention, the present invention further provides an electronic apparatus, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the asynchronous block chain based consensus method when executing the computer program.
Corresponding to the method in the present invention, the present invention further provides a storage medium, where the computer readable storage medium stores a computer program, and the computer program, when executed by a processor, implements the steps of the asynchronous block chain based consensus method described above.
One or more technical schemes provided by the invention at least have the following technical effects or advantages: the method can quickly obtain the consensus result, has high calculation efficiency and higher reliability, and effectively improves the use efficiency.
Drawings
The accompanying drawings, which are included to provide a further understanding of the embodiments of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the principles of the invention. In the drawings:
FIG. 1 is a schematic flow diagram of an asynchronous consensus method based on blockchains;
fig. 2 is a schematic diagram of the composition of an asynchronous consensus system based on block chains.
Detailed Description
In order that the above objects, features and advantages of the present invention can be more clearly understood, a more particular description of the invention will be rendered by reference to the appended drawings. It should be noted that the embodiments of the present invention and features of the embodiments may be combined with each other without conflicting with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, however, the present invention may be practiced in other ways than those specifically described and thus the scope of the present invention is not limited by the specific embodiments disclosed below.
It will be understood by those skilled in the art that in the present disclosure, the terms "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," and the like are used in an orientation or positional relationship indicated in the drawings for ease of description and simplicity of description, and do not indicate or imply that the referenced devices or components must be constructed and operated in a particular orientation and thus are not to be considered limiting.
It is understood that the terms "a" and "an" should be interpreted as meaning that a number of one element or element is one in one embodiment, while a number of other elements is one in another embodiment, and the terms "a" and "an" should not be interpreted as limiting the number.
Referring to fig. 1, fig. 1 is a schematic flow chart of an asynchronous consensus method based on a block chain, the invention provides an asynchronous consensus method based on a block chain, the method includes:
the requester acquires target data and sends a consensus request to the participants;
the requester acquires first parameter data and second parameter data of the target data according to the target data;
the requester packs the target data, the first parameter data and the second parameter data into a first block and adds the first block to a block chain, and broadcasts the first block in the block chain;
and the participator receives and verifies the first block, and uses the first block as a consensus data source for consensus to obtain a consensus result.
Acquiring first parameter data and second parameter data of target data, specifically comprising:
acquiring an interface parameter and a reading parameter of target data as a first data parameter;
and acquiring the hash value of the target data as a second data parameter.
The participant receiving and verifying the first block specifically includes:
the requester packs the target data, the first parameter data and the second parameter data into a first block, and the requester signs the first block;
the participator receives the consensus request and the public key of the first block;
the participator obtains target data, first parameter data and second parameter data in the first block according to the public key;
the participator obtains target data to be verified according to the first parameter data and the second parameter data;
comparing the target data with the target data to be verified, and if the target data is consistent with the target data to be verified, the verification is passed;
if not, the participant reacquires the first block.
The participator receives and verifies the first block, and uses the first block as a consensus data source for consensus to obtain a consensus result;
the participant receives and verifies the first block, and the number of participants passing the verification is obtained;
if the number of the verified participants is greater than or equal to 50% of the number of all the participants, the first block is a consensus result.
The participant receives and verifies the first block;
if the verification is passed, generating a valid result and transmitting the valid result to the next participant;
if the verification fails, the first block is received again and verified.
Example two
Referring to fig. 2, fig. 2 is a schematic composition diagram of an asynchronous consensus system based on a block chain, an embodiment of the present invention provides an asynchronous consensus system based on a block chain, and based on embodiment 1, the system includes: the system comprises an acquisition module, a parameter module, a first verification module, a second verification module and a consensus module;
the acquisition module is used for acquiring target data;
the parameter module is used for acquiring a first data parameter and a second data parameter according to the target data, packaging the target data, the first parameter data and the second parameter data into a first block and adding the first block, the first parameter data and the second parameter data into a block chain;
the first verification module is used for verifying the first block and acquiring target data, first parameter data and second parameter data in the verified first block;
the second verification module is used for acquiring target data to be verified according to the first parameter data and the second parameter data and verifying the target data through the target data;
the consensus module is used for obtaining a consensus result according to the second verification module.
In addition, the system also comprises a broadcasting module, and the broadcasting module is used for transmitting the first block. The first data parameters are interface parameters and reading parameters of the target data; the second data parameter is a hash value of the target data.
In the second embodiment of the present invention, the specific manner of the second verification module is as follows: and the second verification module acquires target data to be verified according to the first parameter data and the second parameter data, then compares the target data to be verified with the target data acquired in the first block, if the target data to be verified is consistent with the target data acquired in the first block, the verification is passed, otherwise, the verification is not passed.
EXAMPLE III
The third embodiment of the present invention provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the block chain based asynchronous consensus method when executing the computer program.
The processor may be a central processing unit, or may be other general-purpose processor, a digital signal processor, an application specific integrated circuit, an off-the-shelf programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory can be used for storing the computer program and/or the module, and the processor can realize various functions of the asynchronous consensus device based on the block chain in the invention by operating or executing data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function (such as a sound playing function, an image playing function, etc.), and the like. Further, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card, a secure digital card, a flash memory card, at least one magnetic disk storage device, a flash memory device, or other volatile solid state storage device.
Example four
A fourth embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps of the asynchronous consensus method based on a block chain are implemented.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.
- 上一篇:石墨接头机器人自动装卡簧、装栓机
- 下一篇:一种文件校验方法及系统