CN112948179B - Data recovery method and device for block chain nodes and electronic equipment - Google Patents

Data recovery method and device for block chain nodes and electronic equipment Download PDF

Info

Publication number
CN112948179B
CN112948179B CN202110218922.XA CN202110218922A CN112948179B CN 112948179 B CN112948179 B CN 112948179B CN 202110218922 A CN202110218922 A CN 202110218922A CN 112948179 B CN112948179 B CN 112948179B
Authority
CN
China
Prior art keywords
server
node
data
target
target data
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.)
Active
Application number
CN202110218922.XA
Other languages
Chinese (zh)
Other versions
CN112948179A (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.)
Beijing Baichen Technology Co ltd
Beijing University of Posts and Telecommunications
Original Assignee
Beijing Baichen Technology Co ltd
Beijing University of Posts and Telecommunications
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 Beijing Baichen Technology Co ltd, Beijing University of Posts and Telecommunications filed Critical Beijing Baichen Technology Co ltd
Priority to CN202110218922.XA priority Critical patent/CN112948179B/en
Publication of CN112948179A publication Critical patent/CN112948179A/en
Application granted granted Critical
Publication of CN112948179B publication Critical patent/CN112948179B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Quality & Reliability (AREA)
  • Computing Systems (AREA)
  • Bioethics (AREA)
  • Data Mining & Analysis (AREA)
  • Computer And Data Communications (AREA)
  • Retry When Errors Occur (AREA)

Abstract

The embodiment of the invention provides a data recovery method and device of a block chain node and electronic equipment, which are applied to the technical field of computers and comprise the following steps: detecting whether the main server fails or not in the process of transmitting data for the target node by the main server; if yes, determining target data which are not transmitted by the main server; sending the public key of the slave server to the servers of other nodes in the block chain, and acquiring the public key of the server of each other node; for each other node, transmitting the target data for the other node using the public key of the server of the other node. The purpose of quickly recovering data transmission can be realized while ensuring the reliability of data transmission.

Description

Data recovery method and device for block chain nodes and electronic equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data recovery method and apparatus for a blockchain node, and an electronic device.
Background
With the continuous development of the block chain technology, the application field of the block chain is more and more extensive. When data transmission is performed in the chain, the data of the node can be transmitted through the server of each node.
When node data is transmitted in a chain, there are many failures that cause transmission interruption, such as a server downtime, etc., and therefore, irreversible damage to the node data is easily caused, such as: information loss, connection interruption, etc. Therefore, when the node data transmission fails, how to quickly recover the data transmission while ensuring the reliability of the data transmission is a technical problem to be solved urgently.
Disclosure of Invention
Embodiments of the present invention provide a method and an apparatus for recovering data of a block link node, and an electronic device, so as to achieve the purpose of quickly recovering data transmission while ensuring reliability of data transmission. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a data recovery method for a blockchain node, which is applied to a slave server of a target node in a blockchain, where the server of the target node further includes a master server, and the method includes:
detecting whether the main server fails or not in the process of transmitting data for the target node by the main server;
if yes, determining target data which are not transmitted by the main server;
sending the public key of the slave server to the servers of other nodes in the block chain, and acquiring the public key of the server of each other node; the public key of any server is the key information used for data encryption when the server transmits data for the node;
for each other node, transmitting the target data for the other node by using a public key of a server of the other node or a private key of the slave server; the server of the other node is configured to transmit the target data to the slave server using the public key of the slave server when the slave server transmits the target data to the other node using its own private key, and configured to transmit the target data to the slave server using the private key of the server of the other node when the slave server transmits the target data to the other node using the public key of the server of the other node.
Optionally, the sending the public key of the slave server to the server of each other node in the blockchain and obtaining the public key of the server of each other node include:
broadcasting the public key of the slave server to the servers of other nodes in the block chain so that the servers of other nodes update the locally stored node path information; wherein the node path information includes a public key of a server of each node in the block chain;
and sending a node path request to the target node, so that the target node sends locally stored node path information to the slave server after receiving the node path request.
Optionally, when transmitting the target data for the other node includes: when the target data is sent to the server of the other node, the transmitting the target data for the other node by using the public key of the server of the other node includes: encrypting the target data by using the public key of the server of the other node, and sending the encrypted target data to the server of the other node;
the server of the other node is specifically configured to decrypt the target data sent from the server by using the private key of the server of the other node to obtain decrypted target data, and send the decrypted target data to the other node, so that the other node locally stores the decrypted target data when receiving the decrypted target data.
Optionally, when transmitting the target data for the other node comprises: when the target data sent by the server of the other node is received, the transmitting the target data for the other node by using the public key of the server of the other node includes:
receiving the target data sent by the server of the other node, decrypting the received target data by using the private key of the slave server to obtain decrypted target data, and sending the decrypted target data to the target node so that the decrypted target data is locally stored when the target node receives the decrypted target data;
the server of the other node is specifically configured to encrypt the target data to be sent by using the public key of the slave server, and send the encrypted data to the slave server.
Optionally, the manner of detecting whether the main server fails includes:
sending a detection instruction to the master server to enable the master server to inquire the data transmission state of the master server according to the detection instruction, and feeding back an inquiry result carrying the data transmission state to the slave server;
when the received query result is different from a preset target result corresponding to the detection instruction, judging that the main server has a fault; and inquiring a result aiming at the detection instruction when the target result represents that the data transmission of the main server is normal.
Optionally, the detection instruction comprises one or more of the following instructions: instructions for detecting whether data sent by the servers of the respective other nodes can be received; instructions for detecting whether data can be sent to the servers of the respective other nodes; and instructions for detecting whether the data transfer has been completed.
Optionally, before the master server transmits data for the target node, the method further includes:
generating a key of the slave server for data transmission by using a preset key generation algorithm, and sending the key of the slave server to the target node, so that the target node locally stores the key of the slave server after receiving the key of the slave server;
the sending the public key of the slave server to the server of each other node in the blockchain includes: sending a public key acquisition request to the target node so that the target node acquires the public key of the slave server from a locally stored secret key and feeds the public key back to the slave server; and receiving the public key of the slave server sent by the target node, and sending the public key of the slave server to the servers of other nodes in the block chain.
In a second aspect, an embodiment of the present invention further provides a data recovery apparatus for a blockchain node, where the data recovery apparatus is applied to a slave server of a target node in a blockchain, where the server of the target node further includes a master server, and the apparatus includes:
a failure detection module, configured to detect whether the primary server fails in a process of transmitting data for the target node by the primary server;
the data determining module is used for determining target data which are not transmitted by the main server if the target data are not transmitted;
a key obtaining device, configured to send the public key of the slave server to the server of each other node in the block chain, and obtain the public key of the server of each other node; the public key of any server is the key information used for data encryption when the server transmits data for the node;
and a data transmission module, configured to transmit, for each other node, the target data for the other node by using a public key of the server of the other node, where the server of the other node is configured to transmit the target data by using the public key of the slave server in cooperation with the slave server in a process of transmitting the target data for the other node.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete mutual communication through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the data recovery method steps of any block chain node when the program stored in the memory is executed.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method for recovering data of a blockchain node is implemented as any one of the steps of the method for recovering data of a blockchain node.
The embodiment of the invention has the following beneficial effects:
the solution provided by the embodiment of the present invention is applied to a slave server of a target node in a block chain, where the server of the target node further includes a master server, including: detecting whether the main server fails or not in the process of transmitting data for the target node by the main server; if yes, determining target data which are not transmitted by the main server; sending the public key of the slave server to the servers of other nodes in the block chain, and acquiring the public key of the server of each other node; the public key of any server is the key information used for data encryption when the server transmits data for the node; for each other node, transmitting the target data for the other node using the public key of the server of the other node. Therefore, when the main server is detected to be out of order, the slave server sends the public key of the slave server to the servers of other nodes in the block chain, the public key of the server of each other node is utilized to transmit the target data aiming at the other nodes, so that the slave server can take over the main server to continue transmitting the target data, the transmission of the target data is rapidly recovered, the reliability of the target data in the transmission process can be improved by utilizing the public key of the slave server and the public keys of the servers of other nodes, and the purpose of rapidly recovering the data transmission while ensuring the reliability of the data transmission is achieved.
Of course, it is not necessary for any product or method to achieve all of the above-described advantages at the same time for practicing the invention.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other embodiments can be obtained by using the drawings without creative efforts.
FIG. 1 is a flow chart of a method for recovering data from a block link point according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of a node server according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating operations of a master server and a slave server according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of communication among storage units, which are a master server, a slave server and a target node according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating the operation of detecting whether the primary server fails according to an embodiment of the present invention;
FIG. 6 is a schematic structural diagram of a data recovery apparatus for block link points according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived from the embodiments of the present invention by those skilled in the art based on the description, are within the scope of the present invention.
In order to achieve the purpose of rapidly recovering data transmission while ensuring the reliability of data transmission, embodiments of the present invention provide a disaster recovery method and apparatus for a block chain node, and an electronic device.
It should be noted that the disaster recovery method for the block link point provided in the embodiment of the present invention is applied to a slave server of a target node in a block chain, and the server of the target node further includes a master server. Wherein, any node in the block chain may have a plurality of servers, the plurality of servers include a master server and a slave server, the master server and the slave server may have the same hardware structure and operation capability, and the functions that can be realized may be the same, such as: communicate with the nodes and transmit data for the nodes. Also, both the master server and the slave server may be connected via a network, for example: local Area Networks (LANs), Virtual Private Networks (VPNs), etc., communicate with servers of each other node in the blockchain.
The following describes a disaster recovery method for block link points according to an embodiment of the present invention with reference to the accompanying drawings.
As shown in fig. 1, a disaster recovery method for block link points according to an embodiment of the present invention may include:
s101, detecting whether a main server fails or not in the process of transmitting data by taking the main server as a target node;
the target node may be any node in the block chain, and there may be multiple storage units in the target node, which may be used to store transmission data, operation logs, and the like of the target node, for example.
It is to be understood that, in order to facilitate the transmission of data for the target node, the data may be transmitted by the master server for the target node when the master server is in a non-failure state, and, in order to ensure the transmission of the data, whether the master server fails or not may be detected by the slave server during the transmission of the data by the master server for the target node.
Various ways of transmitting data for the target node by the master server may exist, for example: the method I comprises the following steps: sending data to the servers of each other node in the block chain for the target node; the second method comprises the following steps: and receiving data sent by the server of each other node in the block chain, and feeding the data back to the target node. The server of any other node may be a server currently transmitting data for the other node, and if the master server of the other node fails, the server of the other node may be the master server of the other node, and if the master server of the other node fails, the server of the other node may be a slave server of the other node.
For clarity of the solution, the following description is directed to an interaction process between a master server of a target node and servers of various other nodes when a mode for transmitting data for the target node is a mode two.
Illustratively, assume that a node in a blockchain includes: the target node, the node 1 and the node 2, and the corresponding interaction process may include: the server of the node 1 and the server of the node 2 respectively encrypt data to be transmitted by using a public key of a main server of the target node and transmit the encrypted data to the main server of the target node; and the main server of the target node receives the encrypted data transmitted by the server of the node 1 and the server of the node 2 respectively, decrypts and verifies the received encrypted data by using the own private key of the main server, and sends the decrypted data to the target node after the verification is passed so that the decrypted target data is locally stored when the target node receives the decrypted target data.
In order to ensure the reliability of data transmission, each node in the block chain may encrypt data to be transmitted before data transmission. In the embodiment of the present invention, an implementation manner of encrypting data to be transmitted by using a public key of a master server of a target node is not specifically limited, for example: a hash algorithm or the like may be employed. Accordingly, decrypting and verifying the received encrypted data may then include: hash operation, computing a root of a mekerr tree, updating a timestamp, and the like. For clarity of the scheme, the following description is made with reference to another embodiment for a key generation process of a server of each node.
It is understood that the master server of the target node may feed back the data transmission process to the target node, so that the target node locally generates a log for the data transmission process, and stores the log in any storage unit of the target node.
In the process of transmitting data for a target node by a primary server, there may be a plurality of ways to detect whether the primary server fails, and for example, in an implementation manner, the way to detect whether the primary server fails may include: sending a detection instruction to a master server so that the master server inquires the data transmission state of the master server according to the detection instruction, and feeding back an inquiry result carrying the data transmission state to a slave server;
when the received query result is different from a preset target result corresponding to the detection instruction, judging that the main server has a fault; and the target result is a query result aiming at the detection instruction when the data transmission of the main server is normal.
Wherein, the detection instruction may include one or more of the following instructions: the computer-readable medium includes instructions for detecting whether data transmitted by the server of each of the other nodes can be received, instructions for detecting whether data can be transmitted to the server of each of the other nodes, and instructions for detecting whether data transmission has been completed. In addition, in order to detect whether the main server executes the relevant program according to the contract commonly negotiated with other nodes, the detection instruction may further include an instruction for detecting whether the main server executes the contract.
In a specific application, detecting whether data transmitted by the server of each other node can be received may include detecting whether broadcast data sent by the server of each other node can be received, for example: public keys of the respective other node servers, etc., and consensus information such as: data to be written to the block, etc. In addition, in order to facilitate obtaining a situation that the main server currently executes the detection instruction, a watchdog for monitoring system or program operation may be added to the main server, and the main server may obtain an execution situation of the detection instruction by looking up information of the watchdog. Detecting whether the data transmission is completed may include: whether the main server has sent data to the servers of other nodes or not is detected, whether the received data are stored locally or not is detected, and whether missing data exist or not is detected.
It will be appreciated that, considering that the master server may fail at any time during data transmission, in order to detect the failure of the master server in time, the slave server may periodically send a detection instruction to the master server, for example: send a test command every 2 minutes, or send a test command every 5 minutes, and so on. In order to recover data, the slave server may detect whether the master server has failed, and the master server may detect whether the slave server has failed at regular time. Moreover, the manner of the master server detecting whether the slave server fails may be the same as the manner of the slave server detecting whether the master server fails, which is not described herein again.
In addition, considering that there may be a plurality of types of failure types of the server, if the slave server does not receive the query result fed back by the master server within a predetermined time after the detection instruction is issued, or if the program does not respond after the master server receives the detection instruction, it may be determined that the master server has failed.
It can be understood that, in order to reduce the content occupation of the primary server and reduce the load of the primary server, the primary server may call the locally stored log when querying the data transmission state of the primary server, and obtain the data transmission state of the primary server by querying the record of the log.
In order to ensure the accuracy of the query result, when the query result is different from the preset target result, the slave server may send the detection instruction to the master server again before determining that the master server fails, so that the master server queries the data transmission state of the slave server again according to the detection instruction, and feeds back the query result carrying the data transmission state to the slave server again. And when the query result received again from the slave server is different from the preset target result, judging that the main server fails, and if the query result received again is the same as the preset target result, judging that the main server does not fail.
In addition, in order to ensure data transmission, the master server can detect whether the slave server fails or not while the slave server detects whether the master server fails or not; in the process of the slave server taking over the transmission of the target data by the master server, and after the master server removes the fault, the master server may send a detection instruction to the slave server at regular time to detect whether the slave server fails, and the process of the master server detecting whether the slave server fails is similar to the process of the slave server detecting whether the master server fails, which is not described herein again.
S102, if yes, determining target data which is not transmitted by the main server;
in order to facilitate rapid recovery of data transmission when the master server fails, the slave server may determine that the master server does not complete transmission of the target data when it is determined that the master server fails. Various implementations of determining the target data that the primary server does not complete transmission may exist, and for example, in one implementation, determining the target data that the primary server does not complete transmission may include: and acquiring a log of the main server, and determining target data which is not transmitted by the main server in the acquired log.
It is understood that, in order to prevent data loss or damage, the primary server may be controlled to enter a shutdown state when a failure of the primary server is detected.
S103, sending the public key of the slave server to the servers of other nodes in the block chain, and acquiring the public key of the servers of other nodes;
the public key of any server is the key information used for data encryption when the server transmits data for the node.
In consideration of reliability of data transmission, when the master server performs data transmission with the servers of the other nodes, the master server may encrypt the data by using the public key of the corresponding server, and then, when the master server fails, in order to quickly recover the data transmission, the slave server may send its own public key to the servers of the other nodes and obtain the public key of the servers of the other nodes.
The key of each server, i.e. the public key and the private key, may be generated by the server, or may be generated by a management server in the block chain, where the management server may be a newly added server for generating a key for each node server in the block chain, or may be any one of the node servers in the block chain. Then, for example, in one implementation, for each server, when the key of the server is generated by the server, the manner of generating the key of the server may include: and generating a key for data transmission of the server by using a preset key generation algorithm. The preset key generation algorithm may be any algorithm capable of generating a key, for example: RSA encryption algorithm, etc.
It is to be understood that each server may locally store the key after generating the key, and send the public key to the servers of the other nodes in the blockchain through the network, and each server may locally store the received public key after receiving the public key sent by the servers of the other nodes. In addition, each server may locally generate node path information for storing the public key of each node server in order to conveniently store and manage the public key, and accordingly, the node path information may include the public key of each node server in the blockchain.
In addition, in order to prevent the server from being down and being unable to acquire the node path information stored in the server, that is, unable to acquire the public key of the server of each node, each server may send the node path information to the node corresponding to the server after generating or updating the node path information, so that the node corresponding to the server stores the node path information in any local storage unit.
For example, in one implementation, sending the public key of the slave server to the servers of the other nodes in the blockchain, and obtaining the public key of the servers of the other nodes may include: broadcasting the public key of the slave server to the servers of other nodes in the block chain so that the servers of other nodes update the locally stored node path information; and sending a node path request to a target node, so that the target node sends locally stored node path information to the slave server after receiving the node path request, wherein the node path information comprises a public key of the server of each node in the block chain.
For example, in another implementation, sending the public key of the slave server to the servers of the other nodes in the blockchain, and obtaining the public key of the servers of the other nodes may include:
broadcasting the public key of the slave server to the servers of other nodes in the block chain so that the servers of other nodes update the locally stored node path information and send the public key of the slave server after updating; wherein the node path information includes a public key of a server of each node in the block chain; and receiving the public key of the server of each other node.
And S104, aiming at each other node, transmitting the target data aiming at the other node by using the public key of the server of the other node or the private key of the slave server.
The server of the other node is configured to transmit the target data to the slave server using the public key of the slave server when the slave server transmits the target data to the other node using its own private key, and configured to transmit the target data to the slave server using the private key of the server of the other node when the slave server transmits the target data to the other node using the public key of the server of the other node.
It will be appreciated that there are many ways in which a server may transmit data, for example, to send data to other servers, or receive data sent by other servers. Accordingly, there may be a variety of ways to transmit the target data for the other node, such as: transmitting the target data for the other node may include transmitting the target data to a server of the other node or receiving the target data transmitted by the server of the other node. Illustratively, when transmitting the target data for the other node includes: when the target data is sent to the server of the other node, in an implementation manner, transmitting the target data for the other node by using a public key of the server of the other node may include: and encrypting the target data by using the public key of the server of the other node, and sending the encrypted target data to the server of the other node.
Illustratively, when transmitting the target data for the other node includes: when target data sent by a server of another node is received, in one implementation manner, transmitting the target data for the other node by using a private key of the slave server may include: when receiving the encrypted target data sent by the server of another node, the slave server decrypts the received target data by using its own private key to obtain the decrypted target data.
The server of the other node is specifically configured to decrypt, by using the private key of the server of the other node, the target data sent from the server to obtain decrypted target data, and locally store the decrypted target data.
Illustratively, in one implementation, when transmitting the target data for the other node includes: when receiving the target data sent by the server of the other node, the transmitting the target data for the other node by using the public key of the server of the other node may include:
receiving the target data sent by the servers of the other nodes, decrypting the received target data by using the private key of the slave server to obtain decrypted target data, and sending the decrypted target data to the target node so that the decrypted target data is locally stored when the target node receives the decrypted target data;
the server of the other node is specifically configured to encrypt target data to be sent by using the public key of the slave server, and send the encrypted data to the slave server.
In addition, considering that the storage unit of each node may store node path information, in a specific application, the server of the other node may be further specifically configured to execute the target task in cooperation with the slave server by using the public key of the slave server in the locally stored node path information in the process of transmitting the target data for the other node.
In this embodiment, when it is detected that the master server fails, the slave server sends its own public key to the servers of each other node in the block chain, and transmits the target data for each other node by using the public key of the server of each other node, so that the slave server can take over the master server to continue transmitting the target data, thereby quickly recovering the transmission of the target data.
Optionally, in the embodiment of the present invention, before the master server transmits data for the target node, the method may further include:
generating a key of the slave server for data transmission by using a preset key generation algorithm, and sending the key of the slave server to a target node, so that the target node locally stores the key of the slave server after receiving the key of the slave server;
sending the public key of the slave server to the servers of the respective other nodes in the blockchain may include:
sending a public key acquisition request to the target node so that the target node acquires the public key of the slave server from the locally stored secret key and feeds the public key back to the slave server; and receiving the public key of the slave server sent by the target node, and sending the public key of the slave server to the servers of the other nodes in the block chain.
It can be understood that, in order to improve reliability of data transmission, before the master server transmits data for the target node, a key for data transmission may be generated for the slave server, and a key generation process of the slave server may refer to step S103 in the foregoing embodiment, which is not described herein again. In addition, after generating the key for the slave server, the slave server may send its own key to the target node, so that the target node stores the key of the slave server locally after receiving the key of the slave server.
In this embodiment, when it is detected that the master server fails, the slave server sends its own public key to the servers of each other node in the block chain, and transmits the target data for each other node by using the public key of the server of each other node, so that the slave server can take over the master server to continue transmitting the target data, thereby quickly recovering the transmission of the target data.
For clarity, the structure of the server of the node in the embodiment of the present invention is described below with reference to fig. 2.
As shown in fig. 2, the server of the node may include one or more Central Processing Units (CPUs) 210, a memory 220, a network interface 230, and a data input/output interface 240, wherein the central processing unit 210 may satisfy one or more threads, the memory 220 may exist in plurality, and the memory 220 is used for storing an operating system, and the operating system 220 is used for controlling input and output of data and program execution. Further, there may be multiple execution modules within memory 220, such as: the specific functions of each module are referred to the following embodiments of the data recovery device of the blockchain node. The network interface 230 is used for transmitting data to the node, completing data transmission between the node and the server, and can also be used for information synchronization with other servers. The output interface 240 is used for communicating the data processing result with the node, and can output and store the operation information to the log stored in the node. In addition, the central processing unit 210, the memory 220, the network interface 230, and the data input/output interface 240 are connected via a main line.
The following describes the workflow of the master server and the slave server of the target node with reference to fig. 3 and 4. Fig. 3 is a flowchart of the operation of the master server and the slave server when receiving data for the target node, and fig. 4 is a schematic diagram of communication between the master server and the slave server and each storage unit of the target node.
As shown in fig. 3 to 4, the workflow of the master server and the slave server of the target node in receiving data for the target node may include the following steps:
s301, the main server receives data sent by the servers of other nodes; the slave server detects whether the master server fails in the receiving process;
s302, the main server decrypts and verifies the received data to obtain decrypted data, and sends the operation record to the target node so that the target node generates a corresponding log table and stores the log table locally; synchronizing the operation record of the master server by the slave server;
when decrypting received data, the main server can send a node path request to the target node, so that the target node feeds back node path information to the main server after receiving the node path request; the main server decrypts and verifies the received data by using the received node path information.
And S303, the main server sends the decrypted data to the target node, so that the target node stores the decrypted data to a storage unit for storing the block data after receiving the decrypted data.
A specific process for detecting whether the primary server fails is described below with reference to a specific example. As shown in fig. 5, detecting whether the primary server fails may include the following steps:
s501, the slave server sends a detection instruction to the master server at regular time;
s502, judging whether the main server is in a detected stage;
s503, if yes, waiting for a preset time, and returning to the step S501;
s504, if not, the inquiry result which is sent by the main server and carries the detection instruction is delayed to wait for receiving;
s505, judging whether the received query result is the same as a preset target result corresponding to the detection instruction or not;
s506, if yes, ending;
and S507, if not, judging that the main server fails.
It will be appreciated that in the transmission of data for a target node, the operating states of the master and slave servers are changed in the event of a failure of the master server. The transition of different operating states of the master server and the slave server is described below with reference to specific examples.
The master and slave servers may have the following states: firstly, the master server and the slave server work normally; the master server is damaged, and the slave server is normal; the slave server is damaged, and the master server is normal; fourthly, both the master server and the slave server are in failure, and the system is interrupted. Then, the transition of the operating states of the master server and the slave server may include:
the first step and the second step: and after the main server fails, reporting error information to the target node, cutting off data input and output, and stopping working. And the slave server sends an error alarm, synchronizes the information of the master server and sends the public key of the slave server to the other nodes so that the servers of the other nodes complete corresponding updating. Finally, the slave server works in place of the master server, performing on-chain data processing and storage tasks on behalf of the current node, such as contracts, participation in consensus and write blocks.
(ii) c: and after the slave server fails, the master server reports error information to the target node, the slave server stops working, and a synchronous network between the slave server and the master server is cut off.
Secondly, the steps of (1): and starting the main server and finishing initialization of the main server, namely generating a key for the main server, broadcasting a public key of the main server to servers of other nodes, and the like, wherein the main server sends public key information to the target node and the servers of other nodes so as to finish corresponding updating of the servers of other nodes. And completing the fault switching, and synchronizing data from the server.
③ to: and starting the slave server, finishing the initialization of the slave server and synchronizing the information of the master server.
Fourthly, the step of: and starting the master server and the slave server and reinitializing the target node.
(iii) -iv/c-iv: and after the master server and the slave server both have faults, the master server and the slave server store the data of the current storage, cut off all data input and output and close the communication between the fault node and other nodes on the chain. And an alarm is issued.
With respect to the above method embodiment, as shown in fig. 6, an embodiment of the present invention provides a data recovery apparatus for a blockchain node, where the data recovery apparatus is applied to a slave server of a target node in a blockchain, where the server of the target node further includes a master server, and the apparatus includes:
a failure detection module 610, configured to detect whether the primary server fails in a process of transmitting data for the target node by the primary server;
a data determining module 620, configured to determine, if yes, target data that is not completely transmitted by the primary server;
a key obtaining module 630, configured to send the public key of the slave server to the servers of the other nodes in the block chain, and obtain the public key of the server of each other node; the public key of any server is the key information used for data encryption when the server transmits data for the node;
a data transmission module 640, configured to transmit, for each other node, the target data for the other node by using a public key of a server of the other node or a private key of the slave server; the server of the other node is configured to transmit the target data to the slave server using the public key of the slave server when the slave server transmits the target data to the other node using the private key of the slave server, and to transmit the target data to the slave server using the private key of the server of the other node when the slave server transmits the target data to the other node using the public key of the server of the other node.
Optionally, the key obtaining module 630 includes:
the key receiving submodule is used for broadcasting the public key of the slave server to the servers of other nodes in the block chain so that the servers of other nodes update the locally stored node path information; wherein the node path information includes a public key of a server of each node in the block chain; and sending a node path request to the target node, so that the target node sends locally stored node path information to the slave server after receiving the node path request.
Optionally, the data transmission module 640 includes: a first transmission submodule, configured to, when transmitting the target data for the other node, include: when the target data is sent to the server of the other node, the public key of the server of the other node is used for encrypting the target data, and the encrypted target data is sent to the server of the other node;
the server of the other node is specifically configured to decrypt the target data sent from the server by using the private key of the server of the other node to obtain decrypted target data, and send the decrypted target data to the other node, so that the other node locally stores the decrypted target data when receiving the decrypted target data.
Optionally, the data transmission module 640 includes: a second transmission submodule, configured to, when transmitting the target data for the other node, include: when the target data sent by the server of the other node is received, the received target data is decrypted by using a private key of the slave server to obtain decrypted target data, and the decrypted target data is sent to the target node, so that the decrypted target data is locally stored when the decrypted target data is received by the target node;
the server of the other node is specifically configured to encrypt the target data to be sent by using the public key of the slave server, and send the encrypted data to the slave server.
Optionally, the fault detection module 610 is specifically configured to send a detection instruction to the master server, so that the master server queries a data transmission state of the master server according to the detection instruction, and feeds back a query result carrying the data transmission state to the slave server;
when the received query result is different from a preset target result corresponding to the detection instruction, judging that the main server has a fault; and inquiring a result aiming at the detection instruction when the target result represents that the data transmission of the main server is normal.
Optionally, the detection instruction includes one or more of the following instructions: instructions for detecting whether data sent by the servers of the respective other nodes can be received; instructions for detecting whether data can be sent to the servers of the respective other nodes; and instructions for detecting whether the data transfer has been completed.
Optionally, the apparatus further comprises: a key generation module, configured to generate, by using a preset key generation algorithm, a key of the slave server for data transmission before the master server transmits data for the target node, and send the key of the slave server to the target node, so that the target node locally stores the key of the slave server after receiving the key of the slave server;
the key obtaining module 630 is specifically configured to send a public key obtaining request to the target node, so that the target node obtains the public key of the slave server from a locally stored key and feeds the public key back to the slave server; and receiving the public key of the slave server sent by the target node, and sending the public key of the slave server to the servers of other nodes in the block chain.
An embodiment of the present invention further provides an electronic device, as shown in fig. 7, including a processor 701, a communication interface 702, a memory 703 and a communication bus 704, where the processor 701, the communication interface 702, and the memory 703 complete mutual communication through the communication bus 704,
a memory 703 for storing a computer program;
the processor 701 is configured to implement the steps of the data recovery method for any blockchain node when executing the program stored in the memory 703.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
In another embodiment provided by the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the data recovery method of any one of the above blockchain nodes.
In a further embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the method for data recovery of any of the above-described embodiments of blockchain nodes.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to be performed in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for embodiments such as the apparatus, the electronic device, and the storage medium, since they are substantially similar to the method embodiments, the description is relatively simple, and reference may be made to the partial description of the method embodiments for relevant points.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (8)

1. A data recovery method for a blockchain node, the method being applied to a slave server of a target node in a blockchain, the server of the target node further including a master server, the method comprising:
detecting whether the main server fails or not in the process of transmitting data for the target node by the main server;
if yes, determining target data which are not transmitted by the main server;
sending the public key of the slave server to the servers of other nodes in the block chain, and acquiring the public key of the server of each other node; the public key of any server is the key information used for data encryption when the server transmits data for the node;
for each other node, transmitting the target data for the other node by using the public key of the server of the other node or the private key of the slave server; when the slave server transmits the target data aiming at the other node by using the private key of the slave server, the server of the other node is used for matching the public key of the slave server to transmit the target data, and when the slave server transmits the target data aiming at the other node by using the public key of the server of the other node, the server of the other node is used for matching the private key of the server of the other node to transmit the target data;
the transmitting the target data for the other node by using the public key of the server of the other node or the private key of the slave server includes: encrypting the target data by using the public key of the server of the other node, and sending the encrypted target data to the server of the other node;
the server of the other node is specifically configured to decrypt the target data sent from the server by using a private key of the server of the other node to obtain decrypted target data, and send the decrypted target data to the other node, so that the other node locally stores the decrypted target data when receiving the decrypted target data;
the transmitting the target data for the other node by using the public key of the server of the other node or the private key of the slave server includes: receiving the target data sent by the server of the other node, decrypting the received target data by using the private key of the slave server to obtain decrypted target data, and sending the decrypted target data to the target node so that the decrypted target data is locally stored when the target node receives the decrypted target data;
the server of the other node is specifically configured to encrypt the target data to be sent by using the public key of the slave server, and send the encrypted data to the slave server.
2. The method according to claim 1, wherein the sending the public key of the slave server to the server of each other node in the blockchain and obtaining the public key of the server of each other node comprises:
broadcasting the public key of the slave server to the servers of other nodes in the block chain so that the servers of other nodes update the locally stored node path information; wherein the node path information includes a public key of a server of each node in the block chain;
and sending a node path request to the target node, so that the target node sends locally stored node path information to the slave server after receiving the node path request.
3. The method of claim 1 or 2, wherein the detecting whether the primary server fails comprises:
sending a detection instruction to the master server to enable the master server to inquire the data transmission state of the master server according to the detection instruction, and feeding back an inquiry result carrying the data transmission state to the slave server;
when the received query result is different from a preset target result corresponding to the detection instruction, judging that the main server has a fault; and inquiring a result aiming at the detection instruction when the target result represents that the data transmission of the main server is normal.
4. The method of claim 3, wherein the detection instructions comprise one or more of the following instructions: instructions for detecting whether data sent by the servers of the respective other nodes can be received; instructions for detecting whether data can be sent to the servers of the respective other nodes; and instructions for detecting whether the data transfer has been completed.
5. The method of claim 1 or 2, wherein before the master server transmits data for the target node, the method further comprises:
generating a key of the slave server for data transmission by using a preset key generation algorithm, and sending the key of the slave server to the target node, so that the target node locally stores the key of the slave server after receiving the key of the slave server;
the sending the public key of the slave server to the server of each other node in the blockchain includes: sending a public key acquisition request to the target node so that the target node acquires the public key of the slave server from a locally stored secret key and feeds the public key back to the slave server; and receiving the public key of the slave server sent by the target node, and sending the public key of the slave server to the servers of other nodes in the block chain.
6. An apparatus for data recovery of a blockchain node, the apparatus being applied to a slave server of a target node in a blockchain, the server of the target node further comprising a master server, the apparatus comprising:
the fault detection module is used for detecting whether the main server fails or not in the process that the main server transmits data for the target node;
the data determining module is used for determining target data which are not transmitted by the main server if the target data are not transmitted;
a key obtaining device, configured to send the public key of the slave server to the server of each other node in the block chain, and obtain the public key of the server of each other node; the public key of any server is the key information used for data encryption when the server transmits data for the node;
a data transmission module, configured to transmit, for each other node, the target data for the other node by using a public key of a server of the other node or a private key of the slave server, where the server of the other node is configured to cooperate with the slave server to transmit the target data by using the public key of the slave server when the slave server transmits the target data for the other node by using its own private key, and is configured to cooperate with the slave server to transmit the target data by using the private key of the server of the other node when the slave server transmits the target data for the other node by using the public key of the server of the other node;
the data transmission module is specifically configured to encrypt the target data by using the public key of the server of the other node, and send the encrypted target data to the server of the other node;
the server of the other node is specifically configured to decrypt the target data sent from the server by using a private key of the server of the other node to obtain decrypted target data, and send the decrypted target data to the other node, so that the other node locally stores the decrypted target data when receiving the decrypted target data;
the data transmission module is specifically configured to receive the target data sent by the server of the other node, decrypt the received target data by using the private key of the slave server to obtain decrypted target data, and send the decrypted target data to the target node, so that when the target node receives the decrypted target data, the decrypted target data is locally stored;
the server of the other node is specifically configured to encrypt the target data to be sent by using the public key of the slave server, and send the encrypted data to the slave server.
7. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 5 when executing a program stored in the memory.
8. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-5.
CN202110218922.XA 2021-02-26 2021-02-26 Data recovery method and device for block chain nodes and electronic equipment Active CN112948179B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110218922.XA CN112948179B (en) 2021-02-26 2021-02-26 Data recovery method and device for block chain nodes and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110218922.XA CN112948179B (en) 2021-02-26 2021-02-26 Data recovery method and device for block chain nodes and electronic equipment

Publications (2)

Publication Number Publication Date
CN112948179A CN112948179A (en) 2021-06-11
CN112948179B true CN112948179B (en) 2022-07-22

Family

ID=76246547

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110218922.XA Active CN112948179B (en) 2021-02-26 2021-02-26 Data recovery method and device for block chain nodes and electronic equipment

Country Status (1)

Country Link
CN (1) CN112948179B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA3041168A1 (en) * 2018-11-07 2019-04-18 Alibaba Group Holding Limited Regulating blockchain confidential transactions
CN110019235A (en) * 2017-12-29 2019-07-16 百度在线网络技术(北京)有限公司 Data storage, restoration methods, device, equipment and medium based on block chain

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10671315B2 (en) * 2018-08-17 2020-06-02 Bank Of America Corporation Blockchain architecture for selective data restore and migration

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110019235A (en) * 2017-12-29 2019-07-16 百度在线网络技术(北京)有限公司 Data storage, restoration methods, device, equipment and medium based on block chain
CA3041168A1 (en) * 2018-11-07 2019-04-18 Alibaba Group Holding Limited Regulating blockchain confidential transactions

Also Published As

Publication number Publication date
CN112948179A (en) 2021-06-11

Similar Documents

Publication Publication Date Title
JP5075736B2 (en) System failure recovery method and system for virtual server
CN109522363B (en) Cloud platform synchronization method, system, equipment and storage medium based on block chain
US11231885B2 (en) Hierarchical authority store for cross-zone replicated block storage devices
EP3285168A1 (en) Disaster tolerance method and apparatus in active-active cluster system
WO2020063197A1 (en) Database switching method and system, and electronic device and computer-readable medium
US9052833B2 (en) Protection of former primary volumes in a synchronous replication relationship
CN105159795A (en) Data synchronization method, apparatus and system
US9455827B2 (en) Communication apparatus, computer program product, and communication system
CN109508295B (en) Block chain consensus algorithm testing method and device, calculating device and storage medium
EP3031172B1 (en) Managing data feeds
CN108418859B (en) Method and device for writing data
CN112835885B (en) Processing method, device and system for distributed form storage
US20180225183A1 (en) SMB Service Fault Processing Method and Storage Device
CN112261114A (en) Data backup system and method
WO2018157605A1 (en) Message transmission method and device in cluster file system
KR101024249B1 (en) Real-time data replication system
CN113190620B (en) Method, device, equipment and storage medium for synchronizing data between Redis clusters
US20210089211A1 (en) Cross-zone replicated block storage devices
CN112948179B (en) Data recovery method and device for block chain nodes and electronic equipment
CN116724297A (en) Fault processing method, device and system
KR102665749B1 (en) Method and apparatus for ensuring continued device operational reliability in cloud-degraded mode
JPH02266429A (en) Console control system for information processing system
CN116795601A (en) Dual-computer hot backup method, system, device, computer equipment and storage medium
CN110879760B (en) Unified storage system and method and electronic equipment
WO2020042150A1 (en) Blockchain system, information sharing method and related device

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