Disclosure of Invention
The embodiment of the application aims to provide a data recording method and device based on a blockchain, electronic equipment, device and electronic equipment, which can realize a data recording scheme which is never lost, objective and cannot be tampered by utilizing a decentralized database of the blockchain.
In order to achieve the above object, embodiments of the present application are implemented as follows:
in a first aspect, a data recording method based on a blockchain is provided, including:
the target block chain node responds to a uplink request of target data, and initiates multiparty consensus for the target data to other block chain nodes, wherein the target data comprises historical event data of a life process of a target user;
if the multiparty consensus aiming at the target data is successfully completed within a specified time, adding a block recorded with the target data into a local block chain by the target block chain node;
if the multiparty consensus for the target data fails to complete or the multiparty consensus for the target data is not completed within the specified time, the target block link point refuses to add the block recorded with the target data in the local block chain.
In a second aspect, there is provided a blockchain-based data recording device, comprising:
the target block chain node responds to a uplink request of target data and initiates multiparty consensus for the target data to other block chain nodes, wherein the target data comprises historical event data of a life process of a target user;
the block adding module is used for adding a block recorded with the target data into a local block chain by the target block chain node if multiparty consensus aiming at the target data is successfully completed within a set time;
and the uplink processing module refuses to add the block recorded with the target data in the local block chain by the target block link point if the multiparty consensus for the target data fails to complete or the multiparty consensus for the target data is not completed within the specified time.
In a third aspect, there is provided an electronic device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being executed by the processor:
the target block chain node responds to a uplink request of target data, and initiates multiparty consensus for the target data to other block chain nodes, wherein the target data comprises historical event data of a life process of a target user;
if the multiparty consensus aiming at the target data is successfully completed within a specified time, adding a block recorded with the target data into a local block chain by the target block chain node;
if the multiparty consensus for the target data fails to complete or the multiparty consensus for the target data is not completed within the specified time, the target block link point refuses to add the block recorded with the target data in the local block chain.
In a fourth aspect, there is provided a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
the target block chain node responds to a uplink request of target data, and initiates multiparty consensus for the target data to other block chain nodes, wherein the target data comprises historical event data of a life process of a target user;
if the multiparty consensus aiming at the target data is successfully completed within a specified time, adding a block recorded with the target data into a local block chain by the target block chain node;
if the multiparty consensus for the target data fails to complete or the multiparty consensus for the target data is not completed within the specified time, the target block link point refuses to add the block recorded with the target data in the local block chain.
The scheme of the embodiment of the application utilizes the blockchain to record the historical event data of the life progress of the target user. The decentralised blockchain is provided with a plurality of blockchain nodes, and the authenticity and objectivity of the data can be ensured by uplink the data in a multiparty consensus mode. Meanwhile, the multi-party consensus time is further limited, and if the blockchain node does not reach the consensus of the data within the specified time, the data is refused to be uplinked, so that the risk of tampering before the data is uplinked is reduced to a certain extent. In addition, once the data is uplink, more than half of the block chain nodes are destroyed to tamper, or all the block chain nodes are destroyed to delete thoroughly, which is not theoretically possible, so that the data record in the block chain can be ensured not to be tampered maliciously and never lost.
Detailed Description
In order to better understand the technical solutions in the present application, the following description will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
As mentioned above, the reliability of the records is a very important factor for data that are required for authenticity, objectivity (e.g. historical data, traffic violation data, etc.). Only by means of people and a centralized mechanism, data recording is performed, and it is difficult to ensure that the data cannot be lost or tampered maliciously. The application aims to realize a never-lost, objective and untampered data recording scheme by utilizing an decentralised database of a blockchain.
FIG. 1 is a flow chart of a blockchain-based data recording method in accordance with an embodiment of the present application. The method shown in fig. 1 may be performed by a corresponding apparatus, including:
in step S102, the target blockchain node initiates a multiparty consensus for target data to other blockchain nodes in response to a request for a uplink of the target data, wherein the target data includes historical event data of a life process of the target user.
It should be appreciated that in this step, the actual historical event data without bias can be agreed upon by the distributed blockchain nodes, resulting in a ul.
In step S104, if the multiparty consensus for the target data is completed successfully within the predetermined time, the target blockchain node adds the block in which the target data is recorded to the local blockchain.
Specifically, in this step, if the target blockchain node is an accounting node, a block in which target data is recorded is generated, and the block is added in the local blockchain, and is broadcast to other blockchain nodes. If the target blockchain node is a non-accounting node, then receiving the blocks recorded with target data broadcast by other blockchain nodes and adding the blocks in the local blockchain.
In step S106, if the multi-party consensus for the target data fails to complete or the multi-party consensus for the target data is not completed within a specified time, the target blockchain node refuses to add the block in which the target data is recorded in the local blockchain.
In order to avoid this problem, the predetermined time should not be too long, preferably 1 hour or more and 24 hours or less, in the period of multiparty consensus.
Based on the data recording method shown in fig. 1, it can be known that: the scheme of the embodiment of the application utilizes the blockchain to record the historical event data of the life progress of the target user. The decentralised blockchain is provided with a plurality of blockchain nodes, and the authenticity and objectivity of the data can be ensured by uplink the data in a multiparty consensus mode. Meanwhile, the multi-party consensus time is further limited, and if the blockchain node does not reach the consensus of the data within the specified time, the data is refused to be uplinked, so that the risk of tampering before the data is uplinked is reduced to a certain extent. In addition, once the data is uplink, more than half of the block chain nodes are destroyed to tamper, or all the block chain nodes are destroyed to delete thoroughly, which is not theoretically possible, so that the data record in the block chain can be ensured not to be tampered maliciously and never lost.
The method of the embodiment of the present application is described in detail below.
The method of the embodiment of the application realizes the recording of the data by using the decentralized, distrusted and tamper-proof distributed data storage technology of the blockchain.
The main flow of the data recording method comprises the following steps:
in step S201, a target block link of the block chain receives a request for a uplink of historical event data.
Wherein, the historical event data records the event of the life activity process. The uplink request may be initiated after an event of a human activity process occurs. In general, the current event is not known to affect the future immediately after the current event occurs, so that each party has no reason and is ready to tamper with the event, and one of the purposes of storing historical event data in the blockchain is to prevent future tampering and misreading of the current event.
In step S202, the target block link point initiates a multiparty consensus for historical event data to other block chain nodes in response to the uplink request.
In order to provide the authenticity and fairness of the consensus, the target blockchain node may be provided to initiate multiparty consensus to other blockchain nodes at the same level, such as the national history consensus through various national institutions worldwide, and the provincial history consensus through various provincial institutions nationwide.
Step S203, judging that the multiparty consensus of the historical event data is successfully completed within a specified time. If yes, step S204 is executed, otherwise step S207 is executed.
As described above, the predetermined time is preferably 1 to 24 hours, and is determined according to the nature of the event to be recorded. To ensure that an event can be truly recorded, the specified time may take the time of occurrence of the event as the starting time of the timer. It has been found in practice that the prescribed time is set to 3 hours, which is capable of satisfying the consensus requirement of most historical event data, while the motivation and preparation of tampering are difficult for each party in the 3 hours.
Step S204, the target block link point judges whether it is an accounting node, if so, step S205 is executed, otherwise, step S206 is executed.
In step S205, the target block link point generates a block in which the history event data is recorded, adds the block to the local block chain, and broadcasts the block to other block chain nodes.
Preferably, the recording address of the target data in the block uniquely corresponds to the content of the target data. For example, in this step, the target blockchain node may compile at least part of the content of the target data based on a hash algorithm (e.g., a message digest algorithm, a secure hash algorithm, etc.), to obtain the record address of the target data in the block.
It should be understood that in the above preferred embodiment, the content of the target data changes, which causes the recording address to change.
Therefore, by comparing the record addresses of the corresponding block chain nodes of the target data, whether the content of the target data is tampered or not can be effectively determined, and the accuracy of the target data is further judged. For example, when the record address of the target data recorded by the few blockchain nodes is inconsistent with the record address of the target data recorded by the plurality of blockchain nodes, it may be indicated that the target data recorded by the few blockchain nodes is tampered with (in practical applications, it is almost impossible to destroy more than half of the blockchain nodes in order to tamper with the target data).
In step S206, the target block link point receives the blocks recorded with the target data broadcast by other block link points, and adds the broadcast obtained blocks to the local block chain.
In step S207, the target blockchain node refuses the uplink request without adding the block in which the target data is recorded to the local blockchain.
The foregoing is an introduction to the methods of embodiments of the present application. It will be appreciated that suitable modifications may be made without departing from the principles set forth herein above, and such modifications are also intended to be considered within the scope of the embodiments of the present application. For example, the data recording method according to the embodiment of the present application is applicable to recording any data, and is not limited to the above-described historical event data.
In correspondence to the above method, as shown in fig. 3, an embodiment of the present application further provides a blockchain-based data recording device 300, including:
the multiparty consensus module 310, the target blockchain node initiates multiparty consensus for target data to other blockchain nodes in response to a request for a uplink of the target data, wherein the target data includes historical event data of a life process of the target user.
The block adding module 320 adds a block in which the target data is recorded to the local blockchain if the multiparty consensus for the target data is successfully completed within a predetermined time.
The uplink processing module 330 refuses to add the block in which the target data is recorded to the local block chain if the multiparty consensus for the target data fails or the multiparty consensus for the target data is not completed within the predetermined time.
Based on the data recording device shown in fig. 3, it can be seen that: the scheme of the embodiment of the application utilizes the blockchain to record the historical event data of the life progress of the target user. The decentralised blockchain is provided with a plurality of blockchain nodes, and the authenticity and objectivity of the data can be ensured by uplink the data in a multiparty consensus mode. Meanwhile, the multi-party consensus time is further limited, and if the blockchain node does not reach the consensus of the data within the specified time, the data is refused to be uplinked, so that the risk of tampering before the data is uplinked is reduced to a certain extent. In addition, once the data is uplink, more than half of the block chain nodes are destroyed to tamper, or all the block chain nodes are destroyed to delete thoroughly, which is not theoretically possible, so that the data record in the block chain can be ensured not to be tampered maliciously and never lost.
Optionally, the recording address of the target data in the block uniquely corresponds to the content of the target data, that is, the content of the target data changes, which causes the recording address to change. Obviously, based on the comparison of the record addresses of the target data, whether the content of the target data is tampered or not can be judged, and the accuracy of the target data is further determined. For example, if the record address of the target data recorded by the few blockchain nodes is inconsistent with the record address of the target data recorded by the plurality of blockchain nodes, the record address of the target data recorded by the few blockchain nodes is tampered.
Wherein, the recording address can be obtained by compiling at least part of the content of the target data based on a hash algorithm.
As an exemplary introduction, the above-described hashing algorithm includes any one of the following:
message digest algorithms and secure hash algorithms.
Optionally, if the target blockchain node is an accounting node, the blockadding module 320 generates a block in which the target data is recorded, adds the block in the local blockchain, and broadcasts the block to other blockchain nodes.
Optionally, if the target blockchain node is a non-accounting node, the blockadding module 320 receives the blocks recorded with the target data broadcast by other blockchain nodes and adds the blocks in the local blockchain.
Optionally, the target data comprises historical event data of a human activity process.
Optionally, the specified time is greater than or equal to 1 hour and less than or equal to 24 hours.
Optionally, the prescribed time starts counting when the target data is generated.
Obviously, the data recording apparatus according to the embodiment of the present application may be used as an execution subject of the data recording method shown in fig. 1, so that the data recording apparatus can implement the functions implemented by the data recording method in fig. 1 and 2. Since the principle is the same, the description is not repeated here.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Referring to fig. 4, at the hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory (non-volatile Memory), such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, network interface, and memory may be interconnected by an internal bus, which may be an ISA (Industry Standard Architecture ) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus, or EISA (Extended Industry Standard Architecture ) bus, among others. The buses may be classified as address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in FIG. 4, but not only one bus or type of bus.
And the memory is used for storing programs. In particular, the program may include program code including computer-operating instructions. The memory may include memory and non-volatile storage and provide instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs, forming the data recording device on a logic level. The processor is used for executing the programs stored in the memory and is specifically used for executing the following operations:
the target blockchain node responds to a uplink request of target data, and initiates multiparty consensus aiming at the target data to other blockchain nodes, wherein the target data comprises historical event data of a life progress of a target user.
If the multiparty consensus for the target data is completed successfully within a specified time, the target blockchain node adds a block in which the target data is recorded in a local blockchain.
If the multiparty consensus for the target data fails to complete or the multiparty consensus for the target data is not completed within the specified time, the target block link point refuses to add the block recorded with the target data in the local block chain.
Based on the electronic device shown in fig. 4, it can be known that: the scheme of the embodiment of the application utilizes the blockchain to record the historical event data of the life progress of the target user. The decentralised blockchain is provided with a plurality of blockchain nodes, and the authenticity and objectivity of the data can be ensured by uplink the data in a multiparty consensus mode. Meanwhile, the multi-party consensus time is further limited, and if the blockchain node does not reach the consensus of the data within the specified time, the data is refused to be uplinked, so that the risk of tampering before the data is uplinked is reduced to a certain extent. In addition, once the data is uplink, more than half of the block chain nodes are destroyed to tamper, or all the block chain nodes are destroyed to delete thoroughly, which is not theoretically possible, so that the data record in the block chain can be ensured not to be tampered maliciously and never lost.
The blockchain-based data recording method disclosed in the embodiment shown in fig. 1 of the present application may be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
It should be understood that the electronic device of the embodiment of the present application may implement the functions of the embodiments of the data recording apparatus shown in fig. 1 and 2, which are not described herein.
Of course, other implementations, such as a logic device or a combination of hardware and software, are not excluded from the electronic device of the present application, that is, the execution subject of the following processing flow is not limited to each logic unit, but may be hardware or a logic device.
Furthermore, embodiments of the present application provide a computer-readable storage medium storing one or more programs, the one or more programs including instructions, which when executed by a portable electronic device comprising a plurality of application programs, enable the portable electronic device to perform the method of the embodiment shown in fig. 1, and in particular to perform the method of:
the target blockchain node responds to a uplink request of target data, and initiates multiparty consensus aiming at the target data to other blockchain nodes, wherein the target data comprises historical event data of a life progress of a target user.
If the multiparty consensus for the target data is completed successfully within a specified time, the target blockchain node adds a block in which the target data is recorded in a local blockchain.
If the multiparty consensus for the target data fails to complete or the multiparty consensus for the target data is not completed within the specified time, the target block link point refuses to add the block recorded with the target data in the local block chain.
Based on the above computer readable storage medium, it is known that: the scheme of the embodiment of the application utilizes a blockchain to record data. The decentralised blockchain is provided with a plurality of blockchain nodes, and the authenticity and objectivity of the data can be ensured by uplink the data in a multiparty consensus mode. Meanwhile, the multi-party consensus time is further limited, and if the blockchain node does not reach the consensus of the data within the specified time, the data is refused to be uplinked, so that the risk of tampering before the data is uplinked is reduced to a certain extent. In addition, once the data is uplink, more than half of the block chain nodes are destroyed to tamper, or all the block chain nodes are destroyed to delete thoroughly, which is not theoretically possible, so that the data record in the block chain can be ensured not to be tampered maliciously and never lost.
It should be appreciated that the above-described instructions, when executed by a portable electronic device comprising a plurality of applications, enable the data recording apparatus described above to perform the functions of the embodiments shown in fig. 1 and 2, and are not described in detail herein.
It will be appreciated by those skilled in the art that embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the present specification may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The foregoing is merely an example of the present specification and is not intended to limit the present specification. Various modifications and alterations to this specification will become apparent to those skilled in the art. Any modifications, equivalent substitutions, improvements, or the like, which are within the spirit and principles of the present description, are intended to be included within the scope of the claims of the present description.