Block chain node repairing method and device, electronic equipment and storage medium
By acquiring blockchain node information, identifying and repairing target blocks of abnormal nodes, the problem of ledger data anomalies caused by node failures was solved, improving the stability and data synchronization capabilities of the blockchain network.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- National Information Center (National E-Government Extranet Management Center)
- Filing Date
- 2025-12-02
- Publication Date
- 2026-05-01
AI Technical Summary
Node failures in blockchain networks can lead to abnormal ledger data, affecting network data synchronization and stability. In particular, existing technologies lack effective repair solutions when blocks are lost or recorded incorrectly.
By acquiring information about blockchain nodes, abnormal and normal nodes are identified, operation information is compared to identify the target block, ledger data from normal nodes is used for repair, and a fill block is generated to repair the target block of the abnormal node.
It improves the operational stability of the blockchain network, avoids data anomalies caused by node failures, and ensures the accuracy and consistency of ledger data.
Smart Images

Figure CN121967169A_ABST
Abstract
Description
Blockchain node repair methods and devices, electronic devices and storage media Technical Field
[0001] This application relates to the field of network technology, and in particular to a blockchain node repair method and apparatus, electronic device and storage medium. Background Technology
[0002] With the continuous development of the internet, blockchain technology has emerged. It is a new generation of internet database technology characterized by decentralization, tamper-proofing, and transparency. Users can log in to nodes in the blockchain network using any device with a blockchain client installed and initiate transactions to store data within the blockchain network. In the blockchain network, each participating node can generate content data related to a specific transaction, which constitutes the ledger's content data. All content data in the ledger is associated with an account. Then, through the blockchain network's competitive mechanism, the ledgers generated by each node are encrypted and encapsulated to generate new blocks conforming to the blockchain protocol, thus completing the transaction through node block production.
[0003] During operation, current blockchain networks may experience node failures due to factors such as hardware malfunctions, network outages, power outages, or malicious attacks. Node failures can lead to ledger data anomalies, affecting ledger synchronization and block generation within the blockchain network, ultimately resulting in overall network data corruption.
[0004] To ensure the stability and reliability of blockchain systems, it is necessary to design a repair scheme to address ledger data anomalies following node failures. Specifically, when blocks are lost or incorrectly recorded in the blockchain network, this scheme can safely and reliably repair blocks from damaged nodes, minimizing the impact of node failures on the blockchain network while ensuring the security of user account data. Summary of the Invention
[0005] This application provides a blockchain node repair method and apparatus, electronic device and storage medium to solve the defect in the prior art that the ledger data is incorrect after the node on the blockchain becomes abnormal.
[0006] To achieve the above objectives, this application provides a blockchain node repair method, characterized in that the method includes: acquiring node information of each node on the blockchain, wherein the node information includes node identifiers and operating states of all nodes on the blockchain; determining a first abnormal node and at least one first normal node based on the node information, wherein the first abnormal node is a node that has experienced an anomaly within a first predetermined time period before the current time, and the first normal node is a node that has not experienced an anomaly within the first predetermined time period before the current time; acquiring operation information of the first abnormal node and at least one first normal node within the first predetermined time period; determining a target block in the first abnormal node based on a comparison of the operation information of the first abnormal node and the at least one first normal node, wherein the target block is a block that needs repair processing; acquiring first repair information from the at least one first normal node based on the operation information and the information of the target block; and repairing the target block using the first repair information and the operation information.
[0007] This application embodiment also provides a blockchain node repair device, characterized in that it includes: a first acquisition module, used to acquire node information of each node on the blockchain, wherein the node information includes the node identifier and operating status of all nodes on the blockchain; a first determination module, used to determine a first abnormal node and at least one first normal node based on the node information, wherein the first abnormal node is a node that has experienced an anomaly within a first predetermined time period before the current time, and the first normal node is a node that has not experienced an anomaly within the first predetermined time period before the current time; a second acquisition module, used to acquire operation information of the first abnormal node and at least one first normal node within the first predetermined time period; a second determination module, used to determine a target block in the first abnormal node based on a comparison of the operation information of the first abnormal node and the at least one first normal node, wherein the target block is a block that needs to be repaired; a third acquisition module, used to acquire first repair information from the at least one first normal node based on the operation information and the information of the target block; and a repair module, used to repair the target block using the first repair information and the operation information.
[0008] This application also provides an electronic device, including: a memory for storing a program; and a processor for running the program stored in the memory, wherein the program executes the blockchain node repair method provided in this application.
[0009] This application also provides a computer-readable storage medium storing a computer program executable by a processor, wherein the program, when executed by the processor, implements the blockchain node repair method provided in this application.
[0010] The blockchain node repair method, apparatus, electronic device, and storage medium provided in this application embodiment obtain node information of each node on the blockchain, determine a first abnormal node and at least one first normal node based on the node information, then obtain the operation information of the first abnormal node and at least one first normal node within a first predetermined time period, and determine the target block in the first abnormal node that needs to be repaired by comparing the operation information of the first abnormal node with that of the at least one first normal node. Based on the operation information and the information of the target block, first repair information is obtained from the at least one first normal node and the target block is repaired using the first repair information and the operation information. Therefore, according to this application embodiment, nodes that have experienced anomalies within a predetermined time period can be identified as abnormal nodes based on the node operation information, and the target block with errors in the abnormal node can be identified by comparing the block operation information of normal nodes and abnormal nodes. Thus, the target block in the abnormal node is repaired based on the ledger data in the normal block, thereby enabling the timely correction and repair of erroneous blocks in the abnormal node. This avoids the problem of data anomalies caused by a node failure during data synchronization based on the consensus mechanism, improving the stability of blockchain operation.
[0011] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0012] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 is a flowchart of an embodiment of the blockchain node repair method provided in this application; Figure 2 is a structural schematic diagram of the blockchain node repair device provided in this application; Figure 3 is a structural schematic diagram of an embodiment of the electronic device provided in this application. Detailed Implementation
[0013] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0014] The solution provided in this application can be applied to any data system or server with encryption and decryption functions.
[0015] With the continuous evolution of the internet, blockchain technology has emerged as a new generation of internet database technology. It features decentralization, tamper-proofing, and transparency. Users can access network nodes through devices with blockchain clients installed, conduct transactions, and store data in the blockchain. Within this network, participating nodes generate relevant data based on transactions; this data forms a ledger and is associated with accounts. Through the blockchain's competitive mechanism, the ledgers generated by each node are encrypted and encapsulated to form new blocks, completing the transaction.
[0016] However, in the operation of a blockchain network, factors such as hardware failure, network interruption, power problems or malicious attacks may cause node failure, leading to abnormal ledger data, affecting ledger synchronization and block generation, and ultimately causing abnormal data across the entire network.
[0017] Therefore, as shown in Figure 1, which is a flowchart illustrating a blockchain node repair method according to an embodiment of this application, the method shown in Figure 1 may include: S101, obtaining node information of each node on the blockchain.
[0018] In this embodiment, a node deployed with the repair service according to this embodiment can obtain node information of each node on the blockchain in step S101. Therefore, in this embodiment, the node can also be called a repair node. Of course, in this embodiment, the repair node can be any node in the blockchain, or a dedicated repair node specifically used to repair blocks on other nodes. In step S101, the repair node can periodically send requests to other nodes to obtain node information, or it can obtain node information of each node in real time during operation. For example, in this embodiment, the node information can include the node identifiers and operating states of all currently running nodes on the blockchain. The operating state can include, for example, the current operating state and historical operating states within a predetermined time period before the current moment.
[0019] S102, determine the first abnormal node and at least one first normal node based on the node information.
[0020] In step S102, it can be determined whether there are any abnormal nodes among the currently running nodes on the blockchain based on the node information obtained in step S101. In this embodiment, an abnormal node can refer to a node that has previously experienced an anomaly, such as a node that has undergone a restart operation. Specifically, in this embodiment, since node information of each node can be obtained periodically in step S101, step S102 can also determine whether a node is abnormal based solely on abnormal operation information within a predetermined time period from the current time in the node information. For example, an abnormal node can be a node that experienced an anomaly within a first predetermined time period before the current time, and a normal node can be a node that did not experience an anomaly within the first predetermined time period before the current time, or it can be a node that has never experienced an anomaly before the current time.
[0021] S103, obtain the operation information of the first abnormal node and at least one first normal node within a first predetermined time period.
[0022] In step S103, based on the determination result in step S102, the operation information of the nodes identified as abnormal nodes within a predetermined time period can be obtained, and the operation information of the nodes identified as normal nodes can also be further obtained. In this embodiment, the number of normal nodes may be one or more. If multiple normal nodes are determined to exist, in step S103, the normal nodes closer to the abnormal nodes can be preferentially selected to obtain their operation information. This allows the operation information of normal nodes with network status or synchronization status closer to the abnormal nodes to be used for further processing of the abnormal nodes. Of course, in this embodiment, the operation information of two or more normal nodes can also be obtained together as a reference for further processing of the abnormal nodes.
[0023] S104, Based on the comparison of the operation information of the first abnormal node with at least one first normal node, determine the target block in the first abnormal node.
[0024] In step S104, a comparison can be performed based on the operation information of the abnormal node obtained in step S103 and the operation information of the normal node to determine the blocks in the abnormal node that need repair processing as target blocks. For example, in this embodiment, the operation information may include one or more of the current block height and the hash value of the last block. In step S104, the block heights of each block indicated in the operation information of the abnormal node can be compared with the block heights indicated in the operation information of the normal node. In particular, when there is an abnormal operation such as a restart in the abnormal node, it may not synchronize with other nodes in time to generate the corresponding blocks. In this case, the block height in the abnormal node will be different from the block height of the normal block due to the abnormal operation. Therefore, in step S104, the presence of faulty blocks in the abnormal node can be determined by comparing the block heights. In some cases, an abnormal node may still generate a block in response to synchronization or consensus requests from other nodes, even though it has performed abnormal operations such as restarting. However, the information recorded in this block may be incomplete or even incorrect due to the abnormal operation. Therefore, in this case, the block height indicated in the operation information of the abnormal node can be compared with the block height indicated in the operation information of the normal node. Since the abnormal node has also generated a block, its block height is the same as that of the normal block. Therefore, in step S104, the hash values of the blocks with the same height can be further compared. When the hash values are different, it can be considered that the blocks in the abnormal node, although having the same height as the blocks in the normal node, still record different data, i.e., erroneous data. Therefore, these blocks can be identified as target blocks that need to be repaired.
[0025] For example, in this embodiment of the application, the target block range in the first abnormal node can be determined first based on the current block height of the normal node. For example, the block height above the last block with the same height to the current block height can be taken as the target block range. Then, the target block information corresponding to the target block range can be queried in the ledger index file of the first abnormal node based on the target block range, and the block that matches the target block information is determined as the target block.
[0026] In this embodiment, when querying target block information in the ledger index file of abnormal nodes based on the target block range, the earliest target block to be deleted can be determined in the ledger index file based on the target block range. Then, based on the operation information of the abnormal nodes, it is determined whether the earliest target block has ever been abnormal, that is, whether the earliest blocks with different heights correspond to the abnormal operation indicated in the node information. When it is determined that the earliest target block has not been abnormal, it indicates that the operation information of the normal nodes obtained in step S103 may be incorrect. In this case, when multiple normal nodes are obtained in step S103, the block information of these normal nodes can be compared with each other to confirm whether the block information of these normal nodes is consistent, or... If, in this step, it is confirmed that the earliest target block does not correspond to any abnormal operation indicated in the node information, the information of the block of the abnormal node is compared with the block information of the corresponding blocks of other normal nodes obtained simultaneously in step S103. In this embodiment, the operation information can also be obtained again from other first normal nodes besides the first normal node from which the operation information is obtained. Then, the target block range in the abnormal node is determined as the updated target block range based on the current block height of the first normal node indicated in the obtained operation information. That is, the target block range is redefined, and then the target block information corresponding to the target block range is queried in the ledger index file of the abnormal node based on the updated target block range.
[0027] In this embodiment of the application, the target block where the anomaly occurred can also be determined based on the operation information of the abnormal node obtained in step S103, and then the block height of the target block can be calculated. When the block height is less than the target block height indicated by the target block range, it can also indicate that the operation information of the normal node obtained in step S103 may be incorrect. Therefore, operation information can be obtained from other first normal nodes besides the first normal node from which the operation information is obtained, and the target block range in the abnormal node can be determined as the updated target block range based on the current block height in the first normal node indicated in the obtained operation information. That is, the target block range is redefined, and then the target block information corresponding to the target block range is queried in the ledger index file of the abnormal node based on the updated target block range.
[0028] S105, based on the operation information and the target block information, obtain the first repair information from at least one first normal node.
[0029] In step S105, repair information can be obtained from normal nodes based on the operation information obtained in step S103 and the target block information determined in step S104. In this embodiment, the repair information can be ledger data recorded by normal nodes through block formation. For example, when it is determined in step S104 that there is erroneous data in blocks within a certain block height range, ledger data recorded in blocks corresponding to that height range can be obtained from normal nodes as repair information.
[0030] S106, Repair the target block using the first repair information and operation information.
[0031] In step S106, the repair information obtained in step S105 and the operation information obtained in step S103 can be used to repair the target blocks determined in step S104. For example, in step S106, these target blocks can be deleted from the blocks of the first abnormal node according to the information of the target blocks determined in step S104. Then, according to the information of the target blocks, such as the block height, the ledger data corresponding to the deleted target blocks can be obtained from at least one normal node. Filling blocks are generated using the corresponding ledger data based on the target block information of each deleted target block. The ledger index file of the first abnormal node is updated based on the block information of the generated filling blocks.
[0032] The blockchain node repair method provided in this application involves obtaining node information of each node on the blockchain, determining a first abnormal node and at least one first normal node based on the node information, then obtaining the operation information of the first abnormal node and at least one first normal node within a first predetermined time period. By comparing the operation information of the first abnormal node with that of the at least one first normal node, a target block requiring repair within the first abnormal node is determined. Based on the operation information and the target block information, first repair information is obtained from the at least one first normal node, and the target block is repaired using the first repair information and the operation information. Therefore, according to this application embodiment, nodes that have experienced anomalies within a predetermined time period can be identified as abnormal nodes based on their operation information. Furthermore, by comparing the operation information of normal nodes and abnormal nodes regarding blocks, a target block containing errors within the abnormal node can be identified. Thus, the ledger data in the normal block is used as repair information to repair the target block in the abnormal node. This ensures that erroneous blocks within abnormal nodes that have experienced anomalies can be corrected and repaired in a timely manner, avoiding the problem of data anomalies causing synchronization failures when blockchain nodes synchronize data based on consensus mechanisms, thereby improving the stability of blockchain operation.
[0033] Figure 2 is a schematic diagram of the structure of the blockchain node repair device provided in this application. This blockchain node repair device can be used to implement, for example, the blockchain node repair method provided in the embodiment of this application described with reference to Figure 1. The blockchain node repair device may include: a first acquisition module 21, a first determination module 22, a second acquisition module 23, a second determination module 24, a third acquisition module 25, and a repair module 26.
[0034] The first acquisition module 21 can be used to acquire node information of each node on the blockchain.
[0035] In this embodiment, the first acquisition module 21 can be set on a node on which the repair service according to this embodiment is deployed, and is used to acquire node information of each node on the blockchain. Therefore, in this embodiment, the node can also be called a repair node. Of course, in this embodiment, the repair node can be any node in the blockchain, or it can be a dedicated repair node in the blockchain used to repair blocks on other nodes. In step S101, the repair node can periodically send requests to other nodes to acquire node information, or the repair node can also acquire node information of each node in real time through the first acquisition module 21 during operation. For example, in this embodiment, the node information can include the node identifier and running status of all currently running nodes on the blockchain. The running status can include, for example, the current running status and the historical running status within a predetermined time period before the current moment. Of course, in this embodiment, the blockchain node repair device can also be independently set in a separate server in the blockchain, or all the nodes it contains can be set on the same node or can be set on different nodes.
[0036] The first determining module 22 can be used to determine a first abnormal node and at least one first normal node based on node information.
[0037] The first determining module 22 can determine whether there are any abnormal nodes among the currently running nodes on the blockchain based on the node information obtained by the first acquiring module 21. In this embodiment, an abnormal node can refer to a node that has previously experienced an anomaly, such as a node that has undergone a restart operation. Specifically, in this embodiment, since the first acquiring module 21 can periodically acquire node information of each node, the first determining module 22 can also determine whether a node is abnormal based solely on abnormal operation information within a predetermined time period from the current time in the node information. For example, an abnormal node can be a node that experienced an anomaly within a first predetermined time period before the current time, and a normal node can be a node that did not experience an anomaly within the first predetermined time period before the current time, or it can be a node that has never experienced an anomaly before the current time.
[0038] The second acquisition module 23 can be used to acquire the operation information of the first abnormal node and at least one first normal node within a first predetermined time period.
[0039] The second acquisition module 23 can acquire the operation information of nodes identified as abnormal nodes within a predetermined time period based on the determination result of the first determination module 22, and can further acquire the operation information of nodes identified as normal nodes. In this embodiment, the number of normal nodes may be one or more. If multiple normal nodes are determined to exist, the second acquisition module 23 can preferentially select normal nodes that are closer to the abnormal nodes to acquire their operation information, thereby enabling the use of the operation information of normal nodes whose network status or synchronization status is closer to the abnormal nodes to further process the abnormal nodes. Of course, in this embodiment, the operation information of two or more normal nodes can also be acquired together as a reference for further processing of the abnormal nodes.
[0040] The second determining module 24 can be used to determine the target block in the first abnormal node based on the comparison of the operation information of the first abnormal node with at least one first normal node.
[0041] The second determining module 24 can perform a comparison based on the operation information of the abnormal node and the operation information of the normal node obtained by the second obtaining module 23 to determine the blocks in the abnormal node that need repair processing as target blocks. For example, in this embodiment, the operation information may include one or more of the current block height and the hash value of the last block. The second determining module 24 can compare the block heights of each block indicated in the operation information of the abnormal node with the block heights indicated in the operation information of the normal node. In particular, when there is an abnormal operation such as a restart in the abnormal node, it may not synchronize with other nodes in time to generate the corresponding blocks. In this case, the block height in the abnormal node will be different from the block height of the normal block due to the abnormal operation. Therefore, the second determining module 24 can determine whether there are faulty blocks in the abnormal node by comparing the block heights. In some cases, an abnormal node may still generate a block in response to synchronization or consensus requests from other nodes, even though it has performed abnormal operations such as restarting. However, the information recorded in this block may be incomplete or even incorrect due to the abnormal operation. Therefore, in this case, the block height indicated in the operation information of the abnormal node can be compared with the block height indicated in the operation information of the normal node. Since the abnormal node has also generated a block, its block height is the same as that of the normal block. Therefore, the second determining module 24 can further compare the hash values of the blocks with the same height. When the hash values are different, it can be considered that the blocks in the abnormal node, although having the same height as the blocks in the normal node, still record different data, i.e., erroneous data. Therefore, these blocks can be identified as target blocks that need to be repaired.
[0042] For example, in this embodiment of the application, the target block range in the first abnormal node can be determined first based on the current block height of the normal node. For example, the block height above the last block with the same height to the current block height can be taken as the target block range. Then, the target block information corresponding to the target block range can be queried in the ledger index file of the first abnormal node based on the target block range, and the block that matches the target block information is determined as the target block.
[0043] In this embodiment, when querying target block information in the ledger index file of abnormal nodes based on the target block range, the earliest target block to be deleted can be determined in the ledger index file based on the target block range. Then, based on the operation information of the abnormal nodes, it is determined whether the earliest target block has ever been abnormal, that is, whether the earliest blocks with different heights correspond to the abnormal operation indicated in the node information. When it is determined that the earliest target block has not been abnormal, it indicates that the operation information of the normal nodes obtained by the second acquisition module 23 may be incorrect. In this case, when the second acquisition module 23 obtains multiple normal nodes, the block information of these normal nodes can be compared with each other to confirm whether the block information of these normal nodes is consistent, or... If, in this step, it is confirmed that the earliest target block does not correspond to any abnormal operation indicated in the node information, the information of the block of the abnormal node is compared with the block information of the corresponding blocks of other normal nodes simultaneously obtained by the second acquisition module 23. In this embodiment, the operation information can also be re-obtained from other first normal nodes besides the first normal node from which the operation information is obtained. Then, the target block range in the abnormal node is determined as the updated target block range based on the current block height in the first normal node indicated in the obtained operation information. That is, the target block range is re-determined, and then the target block information corresponding to the target block range is queried in the ledger index file of the abnormal node based on the updated target block range.
[0044] In this embodiment, the target block where the anomaly occurred can also be determined based on the operation information of the abnormal node obtained by the second acquisition module 23. Then, the block height of the target block is calculated. When the block height is less than the target block height indicated by the target block range, it can also indicate that the operation information of the normal node obtained by the second acquisition module 23 may be incorrect. Therefore, operation information can be obtained from other first normal nodes besides the first normal node from which the operation information is obtained. The target block range in the abnormal node is determined as the updated target block range based on the current block height of the first normal node indicated in the obtained operation information. That is, the target block range is redefined. Then, the target block information corresponding to the target block range is queried in the ledger index file of the abnormal node based on the updated target block range.
[0045] The third acquisition module 25 can be used to acquire first repair information from at least one first normal node based on operation information and target block information.
[0046] The third acquisition module 25 can obtain repair information from normal nodes based on the operation information obtained by the second acquisition module 23 and the target block information determined by the second determination module 24. In this embodiment, the repair information can be ledger data recorded in normal nodes by forming blocks. For example, when the second determination module 24 determines that there is erroneous data in blocks within a certain block height range, it can obtain the ledger data recorded in blocks corresponding to that height range from normal nodes as repair information.
[0047] Repair module 26 can use the first repair information and operation information to repair the target block.
[0048] The repair module 26 can use the repair information obtained by the third acquisition module 25 and the operation information obtained by the second acquisition module 23 to repair the target blocks determined by the second determination module 24. For example, the repair module 26 can delete these target blocks from the blocks of the first abnormal node according to the target block information determined by the second determination module 24, and then obtain the ledger data corresponding to the deleted target blocks from at least one normal node according to the target block information, such as the block height; generate filling blocks using the corresponding ledger data according to the target block information of each deleted target block; and update the ledger index file of the first abnormal node based on the block information of the generated filling blocks.
[0049] The blockchain node repair device provided in this application embodiment obtains node information of each node on the blockchain, determines a first abnormal node and at least one first normal node based on the node information, and then obtains the operation information of the first abnormal node and at least one first normal node within a first predetermined time period. By comparing the operation information of the first abnormal node with that of the at least one first normal node, the device determines the target block in the first abnormal node that needs repair. Based on the operation information and the information of the target block, it obtains first repair information from the at least one first normal node and uses the first repair information and operation information to repair the target block. Therefore, according to this application embodiment, nodes that have experienced anomalies within a predetermined time period can be identified as abnormal nodes based on the node operation information. By comparing the operation information of normal nodes and abnormal nodes on blocks, the device determines the target block in the abnormal node that contains errors. Thus, the ledger data in the normal block is used as repair information to repair the target block in the abnormal node. This allows erroneous blocks in abnormal nodes that have experienced anomalies to be corrected and repaired in a timely manner, avoiding the problem of data anomalies caused by a node failure during data synchronization based on the consensus mechanism, thereby improving the stability of blockchain operation.
[0050] The internal functions and structure of the blockchain node repair device described above in Embodiment 3 can be implemented as an electronic device. Figure 3 is a schematic diagram of the structure of an embodiment of the electronic device provided in this application. As shown in Figure 3, the electronic device includes a memory 31 and a processor 32.
[0051] Memory 31 is used to store programs. In addition to the programs described above, memory 31 can also be configured to store various other data to support operation on the electronic device. Examples of this data include instructions for any application or method used to operate on the electronic device, contact data, phonebook data, messages, pictures, videos, etc.
[0052] The memory 31 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0053] Processor 32 is not limited to a processor (CPU), but may also be a graphics processing unit (GPU), a field-programmable gate array (FPGA), an embedded neural network processor (NPU), or an artificial intelligence (AI) chip. Processor 32 is coupled to memory 31 and executes the program stored in memory 31 to perform the blockchain node repair method of Embodiment 1 described above.
[0054] Furthermore, as shown in Figure 3, the electronic device may also include other components such as a communication component 33, a power supply component 34, an audio component 35, and a display 36. Figure 3 only schematically shows some of the components and does not imply that the electronic device includes only the components shown in Figure 3.
[0055] Communication component 33 is configured to facilitate wired or wireless communication between electronic devices and other devices. The electronic devices can access wireless networks based on communication standards, such as WiFi, 3G, 4G, or 5G, or combinations thereof. In one exemplary embodiment, communication component 33 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 33 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0056] Power supply component 34 provides power to various components of the electronic device. Power supply component 34 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device.
[0057] Audio component 35 is configured to output and / or input audio signals. For example, audio component 35 includes a microphone (MIC) configured to receive external audio signals when the electronic device is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 31 or transmitted via communication component 33. In some embodiments, audio component 35 also includes a speaker for outputting audio signals.
[0058] Display 36 includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touchscreen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation.
[0059] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0060] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for repairing blockchain nodes, characterized in that, The method includes: acquiring node information of each node on the blockchain, wherein the node information includes the node identifier and operating status of all nodes on the blockchain; determining a first abnormal node and at least one first normal node based on the node information, wherein the first abnormal node is a node that has experienced an anomaly within a first predetermined time period before the current time, and the first normal node is a node that has not experienced an anomaly within the first predetermined time period before the current time; acquiring operation information of the first abnormal node and at least one first normal node within the first predetermined time period; determining a target block in the first abnormal node based on a comparison of the operation information of the first abnormal node and the at least one first normal node, wherein the target block is a block that needs to be repaired; acquiring first repair information from the at least one first normal node based on the operation information and the information of the target block; and repairing the target block using the first repair information and the operation information.
2. The blockchain node repair method according to claim 1, characterized in that, The operation information includes one or more of the node's current block height and the hash value of the last block.
3. The blockchain node repair method according to claim 2, characterized in that, The step of determining the target block in the first abnormal node based on the comparison of the operation information of the first abnormal node and the at least one first normal node includes: determining the target block range in the first abnormal node based on the current block height of the normal node; querying the ledger index file of the first abnormal node for target block information corresponding to the target block range based on the target block range; and determining the block that matches the target block information as the target block.
4. The blockchain node repair method according to claim 3, characterized in that, Repairing the target block using the first repair information and the operation information includes: deleting the target block from the blocks of the first abnormal node according to the target block information; obtaining ledger data corresponding to the deleted target block from the at least one normal node according to the target block information; generating filling blocks using the corresponding ledger data according to the target block information of each deleted target block; and updating the ledger index file of the first abnormal node based on the block information of the generated filling blocks.
5. The blockchain node repair method according to claim 3, characterized in that, The step of querying the ledger index file of the first abnormal node for target block information corresponding to the target block range includes: determining the earliest target block to be deleted in the ledger index file based on the target block range; determining whether the earliest target block has experienced an anomaly based on the operation information of the first abnormal node; when it is determined that the earliest target block has not experienced an anomaly, obtaining operation information from other first normal nodes besides the first normal node from which operation information is obtained; determining the target block range in the first abnormal node as the updated target block range based on the current block height in the first normal node indicated in the obtained operation information; and querying the ledger index file of the first abnormal node for target block information corresponding to the target block range based on the updated target block range.
6. The blockchain node repair method according to claim 3, characterized in that, The step of querying the ledger index file of the first abnormal node for target block information corresponding to the target block range based on the target block range includes: determining the target block that is abnormal based on the operation information of the first abnormal node; calculating the block height of the target block; when the block height is less than the target block height indicated by the target block range, obtaining operation information from other first normal nodes besides the first normal node from which the operation information is obtained; determining the target block range in the first abnormal node as the updated target block range based on the current block height in the first normal node indicated in the obtained operation information; and querying the ledger index file of the first abnormal node for target block information corresponding to the target block range based on the updated target block range.
7. The blockchain node repair method according to claim 2, characterized in that, The step of determining the target block in the first abnormal node based on the comparison of the operation information of the first abnormal node and the at least one first normal node includes: searching for blocks in the first abnormal node with a different block height than the corresponding blocks in the first normal node as candidate blocks based on the block height indicated by the operation information; for blocks in the first abnormal node with the same block height, obtaining the hash value of the block and comparing it with the hash value of the corresponding normal block in the first normal node with the same block height; when the comparison result indicates that the hash values are different, determining the block as the target block.
8. A blockchain node repair device, characterized in that, include: A first acquisition module is used to acquire node information of each node on the blockchain, wherein the node information includes the node identifier and operating status of all nodes on the blockchain; a first determination module is used to determine a first abnormal node and at least one first normal node based on the node information, wherein the first abnormal node is a node that has experienced an anomaly within a first predetermined time period before the current time, and the first normal node is a node that has not experienced an anomaly within the first predetermined time period before the current time; a second acquisition module is used to acquire operation information of the first abnormal node and at least one first normal node within the first predetermined time period; a second determination module is used to determine a target block in the first abnormal node based on a comparison of the operation information of the first abnormal node and the at least one first normal node, wherein the target block is a block that needs to be repaired; a third acquisition module is used to acquire first repair information from the at least one first normal node based on the operation information and the information of the target block; and a repair module is used to repair the target block using the first repair information and the operation information.
9. An electronic device, characterized in that, include: Memory, used to store programs; A processor for running the program stored in the memory, wherein the program, when running, executes the blockchain node repair method as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon that can be executed by a processor, characterized in that, When the program is executed by the processor, it implements the blockchain node repair method as described in any one of claims 1 to 7.