Data sharing method, device, electronic device and computer readable storage medium
By introducing consensus nodes and gateway nodes into the node group to verify and agree to data modification requests, the problem of insufficient data security in traditional centralized data sharing methods is solved, and the security and consistency of data sharing is achieved.
Patent Information
- Application Number
- CN202210939508.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-05
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2042-08-05
AI Technical Summary
The traditional centralized data sharing method lacks security when data operation requests, which can easily lead to data tampering.
By introducing consensus nodes and gateway nodes into the node group, data modification requests are generated and verified, data modification is only performed if most consensus nodes agree, and corresponding information is broadcast.
Improve the security of data sharing, prevent any single consensus node from tampering with the data at will, and ensure the integrity and consistency of the data.
Smart Images

Figure CN115314515B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data sharing method, device, electronic device and computer-readable storage medium. Background Art
[0002] Data sharing is the premise for fully realizing the value of data. At present, the traditional data sharing method is usually centralized, that is, all data is stored in the same central server, and other devices can send data operation requests to the central server. When the central server approves the data operation request, other devices can store, modify or delete the data in the central server. When an attacker launches an attack on the central server through an operating device, if the central server does not detect the abnormality and allows the device to operate on its own data, the data stored in the central server can be easily tampered with, which will result in low data security in the central server. Summary of the invention
[0003] In view of this, the purpose of the present application is to provide a data sharing method, device, electronic device and computer-readable storage medium to improve the security of shared data.
[0004] In a first aspect, an embodiment of the present application provides a data sharing method, which is applied to any consensus node in a node group, and the consensus nodes in the node group share data stored in a target database, and the method includes:
[0005] Generate a first data modification request for the target database; the first data modification request includes original data before modification, target data after modification, and modification node information;
[0006] Sending the first data modification request to other consensus nodes in the node group through a gateway node in the node group;
[0007] receiving, through the gateway node, first feedback from other consensus nodes regarding the first data modification request; the types of the first feedback include agreeing to modify and prohibiting modification;
[0008] According to the types of the first feedback opinions of all other consensus nodes, it is determined whether to use the target data to modify the original data in the target database.
[0009] In combination with the first aspect, an embodiment of the present application provides a first possible implementation manner of the first aspect, wherein determining whether to use the target data to modify the original data in the target database according to the type of the first feedback opinions of all other consensus nodes includes:
[0010] Calculate, according to the type of the first feedback from each other consensus node, a first ratio of the number of the agreed modifications to the total number of all the first feedbacks;
[0011] If the first ratio is greater than a first preset ratio, the target data is used to modify the original data in the target database, and the first information is broadcast to other consensus nodes through the gateway node; the first information is used to indicate that the target data is allowed to be used to modify the original data in the target database;
[0012] If the first ratio is not greater than the first preset ratio, it is prohibited to use the target data to modify the original data in the target database, and the second information is broadcast to other consensus nodes through the gateway node; the second information is used to indicate that it is prohibited to use the target data to modify the original data in the target database.
[0013] In combination with the first possible implementation of the first aspect, the embodiment of the present application provides a second possible implementation of the first aspect, wherein each of the consensus nodes in the node group stores the target database; if the first ratio is greater than a first preset ratio, the target data is used to modify the original data in the target database, and the first information is broadcast to other consensus nodes through the gateway node, including:
[0014] If the first ratio is greater than a first preset ratio, the target data is used to modify the original data in the target database stored in itself, and the first information is broadcast to other consensus nodes through the gateway node, so that the other consensus nodes use the target data to modify the original data in the target database stored in themselves after receiving the first information.
[0015] In combination with the first aspect, the embodiment of the present application provides a third possible implementation of the first aspect, wherein each of the consensus nodes in the node group stores a form; and the method further includes:
[0016] Upon receiving a second data modification request for the target database sent by any other consensus node in the node group, the second data modification request is recorded in a form, and a second feedback opinion on the second data modification request is sent to the other consensus node; the second feedback opinion includes agreeing to the modification or prohibiting the modification.
[0017] In combination with the first aspect, an embodiment of the present application provides a fourth possible implementation of the first aspect, wherein the sending the first data modification request to other consensus nodes in the node group through the gateway node in the node group includes:
[0018] The first data modification request is sent to the gateway node so that the gateway node performs a first verification on the first data modification request, and if the first verification of the first data modification request by the gateway node passes, the first data modification request is sent to other consensus nodes in the node group; the first verification includes: determining whether the format of the first data modification request is a standard format, and / or determining whether the first data modification request contains the modification node information.
[0019] In combination with the first aspect, an embodiment of the present application provides a fifth possible implementation of the first aspect, wherein the sending the first data modification request to other consensus nodes in the node group through the gateway node in the node group includes:
[0020] Sending the first data modification request to the gateway node, so that the gateway node adds a preset key to the first data modification request, and sending the first data modification request carrying the preset key to other consensus nodes in the node group;
[0021] After receiving the first data modification request carrying the preset key, the other consensus nodes perform a second verification on the first data modification request in the following manner:
[0022] Using a preset key pre-stored in the other consensus node to match the preset key carried in the first data modification request;
[0023] If the preset key matches the preset secret key successfully, the first feedback is sent to the gateway node.
[0024] In combination with the first aspect, the embodiment of the present application provides a sixth possible implementation of the first aspect, which further includes:
[0025] Receiving, through the gateway node, a registration request sent by a node to be registered outside the node group;
[0026] The gateway node sends a third feedback regarding the registration request to the node to be registered, so that the node to be registered determines whether the registration is successful according to the type of the third feedback sent by the consensus node in the node group; the types of the third feedback include approval of registration and prohibition of registration.
[0027] In a second aspect, an embodiment of the present application further provides a data sharing device, wherein the device resides in any consensus node in a node group, and the consensus nodes in the node group share data stored in a target database, and the device includes:
[0028] A generating module, configured to generate a first data modification request for the target database; the first data modification request includes original data before modification, target data after modification, and modification node information;
[0029] A first sending module, used for sending the first data modification request to other consensus nodes in the node group through a gateway node in the node group;
[0030] A first receiving module, configured to receive, through the gateway node, first feedback from other consensus nodes regarding the first data modification request; the types of the first feedback include agreeing to modify and prohibiting modification;
[0031] A determination module is used to determine whether to use the target data to modify the original data in the target database according to the types of the first feedback opinions of all other consensus nodes.
[0032] In combination with the second aspect, an embodiment of the present application provides a first possible implementation of the second aspect, wherein the determination module, when used to determine whether to use the target data to modify the original data in the target database according to the type of the first feedback opinions of all other consensus nodes, is specifically used to:
[0033] Calculate, according to the type of the first feedback from each other consensus node, a first ratio of the number of the agreed modifications to the total number of all the first feedbacks;
[0034] If the first ratio is greater than a first preset ratio, the target data is used to modify the original data in the target database, and the first information is broadcast to other consensus nodes through the gateway node; the first information is used to indicate that the target data is allowed to be used to modify the original data in the target database;
[0035] If the first ratio is not greater than the first preset ratio, it is prohibited to use the target data to modify the original data in the target database, and the second information is broadcast to other consensus nodes through the gateway node; the second information is used to indicate that it is prohibited to use the target data to modify the original data in the target database.
[0036] In combination with the first possible implementation of the second aspect, an embodiment of the present application provides a second possible implementation of the second aspect, wherein each of the consensus nodes in the node group stores the target database; the determination module is used to modify the original data in the target database using the target data if the first ratio is greater than the first preset ratio, and broadcast the first information to other consensus nodes through the gateway node, specifically for:
[0037] If the first ratio is greater than a first preset ratio, the target data is used to modify the original data in the target database stored in itself, and the first information is broadcast to other consensus nodes through the gateway node, so that the other consensus nodes use the target data to modify the original data in the target database stored in themselves after receiving the first information.
[0038] In combination with the second aspect, the embodiment of the present application provides a third possible implementation of the second aspect, wherein each of the consensus nodes in the node group stores a form; and the device further includes:
[0039] A recording module is used to, upon receiving a second data modification request for the target database sent by any other consensus node in the node group, record the second data modification request in a form, and send a second feedback opinion on the second data modification request to the other consensus node; the second feedback opinion includes agreeing to modify or prohibiting modification.
[0040] In combination with the second aspect, an embodiment of the present application provides a fourth possible implementation of the second aspect, wherein the first sending module, when used to send the first data modification request to other consensus nodes in the node group through the gateway node in the node group, is specifically used to:
[0041] The first data modification request is sent to the gateway node so that the gateway node performs a first verification on the first data modification request, and if the first verification of the first data modification request by the gateway node passes, the first data modification request is sent to other consensus nodes in the node group; the first verification includes: determining whether the format of the first data modification request is a standard format, and / or determining whether the first data modification request contains the modification node information.
[0042] In combination with the second aspect, an embodiment of the present application provides a fifth possible implementation of the second aspect, wherein the first sending module, when used to send the first data modification request to other consensus nodes in the node group through the gateway node in the node group, is specifically used to:
[0043] Sending the first data modification request to the gateway node, so that the gateway node adds a preset key to the first data modification request, and sending the first data modification request carrying the preset key to other consensus nodes in the node group;
[0044] After receiving the first data modification request carrying the preset key, the other consensus nodes perform a second verification on the first data modification request in the following manner:
[0045] Using a preset key pre-stored in the other consensus node to match the preset key carried in the first data modification request;
[0046] If the preset key matches the preset secret key successfully, the first feedback is sent to the gateway node.
[0047] In combination with the second aspect, the embodiment of the present application provides a sixth possible implementation of the second aspect, which further includes:
[0048] A second receiving module, configured to receive, through the gateway node, a registration request sent by a node to be registered outside the node group;
[0049] The second sending module is used to send the third feedback opinion for the registration request to the node to be registered through the gateway node, so that the node to be registered determines whether the registration is successful according to the type of the third feedback opinion sent by the consensus node in the node group; the types of the third feedback opinion include approval of registration and prohibition of registration.
[0050] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the steps in any possible implementation of the first aspect above are performed.
[0051] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in any possible implementation of the first aspect described above are executed.
[0052] The embodiments of the present application provide a data sharing method, device, electronic device and computer-readable storage medium, wherein the method is applied to any consensus node in a node group, and all consensus nodes in the node group share the data stored in the target database. When any consensus node wants to modify the data in the target database, the data modification request must be approved by other consensus nodes in the node group. Only when other consensus nodes agree to make the modification can the data in the target database be modified. Compared with the centralized data sharing method, the decentralized data sharing method in this embodiment makes the data in the target database not only decided by a central node, but all consensus nodes in the node group participate in the decision. In this way, no consensus node can arbitrarily tamper with the data shared in the target database, which is conducive to improving the security of the data shared in the target database.
[0053] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0055] Figure 1 A flow chart of a data sharing method provided in an embodiment of the present application is shown;
[0056] Figure 2 A topological diagram of a node group provided in an embodiment of the present application is shown;
[0057] Figure 3 A schematic diagram of the structure of a data sharing device provided in an embodiment of the present application is shown;
[0058] Figure 4 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0059] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0060] Civil aircraft need to conduct test flights before they are officially put into operation. During the test flights, the sensors on the aircraft will record various data of the civil aircraft during the entire test flight process. Each test flight will generate a lot of test flight data, and after multiple test flights, a huge amount of test flight data will be generated. These data need to be provided to different departments, such as the aerodynamics department, the engine department, etc. These departments will process and analyze these test flight data to find possible faults or hidden dangers in civil aircraft. Since these test flight data will be circulated, used, and modified in different departments, there will be safety risks in the test flight data.
[0061] Taking into account the problem of low data security in centralized data sharing methods, based on this, the embodiments of the present application provide a data sharing method, device, electronic device and computer-readable storage medium, which are described below through embodiments.
[0062] Embodiment 1:
[0063] To facilitate understanding of this embodiment, a data sharing method disclosed in the embodiment of this application is first introduced in detail. The method is applied to any consensus node in a node group, and the consensus nodes in the node group share the data stored in the target database. Figure 1 A flow chart of a data sharing method provided in an embodiment of the present application is shown. Figure 1 As shown, the following steps are included:
[0064] S101: Generate a first data modification request for a target database; the first data modification request includes original data before modification, target data after modification, and modification node information.
[0065] In this embodiment, the data stored in the target database may be the test flight data generated when a civil aircraft is conducting a test flight. Each consensus node in the node group may be a client corresponding to each department that needs to use the test flight data, such as an aerodynamics department, an engine department, etc.
[0066] The node group includes a gateway node and multiple consensus nodes, and the consensus nodes communicate with each other through the gateway node. Figure 2 The topology diagram of the node group provided in the embodiment of the present application is shown as follows: Figure 2 As shown, four consensus nodes A, B, C, and D are taken as an example.
[0067] Assuming that consensus node A is used as the current node, consensus node A generates a first data modification request for the target database. The first data modification request includes the original data before modification, the target data after modification, and the modification node information. Exemplarily, the original data may be the data currently stored in the target database, and the target data may be the data obtained after noise reduction processing of the original data. The original data does not refer to all the data in the target database, but the data currently to be processed by consensus node A. For example, if there are 100 data stored in the target database, the original data in the first data modification request refers to one of the data.
[0068] In a possible implementation manner, the first data modification request also includes modification time and modification object; when executing step S101 to generate the first data modification request for the target database, the following steps may be specifically performed:
[0069] Generate a data packet containing the original data before modification, the target data after modification, the modification time and the modification object; call SDK (Software Development Kit) to encapsulate the data packet, and attach the modification node information of the current consensus node to obtain the initial data modification request. Next, convert the format of the initial data modification request into the first data modification request in the standard format. Among them, the modification node information is used to represent the identity information of the consensus node that modifies the original data.
[0070] S102: Send the first data modification request to other consensus nodes in the node group through the gateway node in the node group.
[0071] The first data modification request is sent to the gateway node, so that the gateway node sends the first data modification request to other consensus nodes in the node group.
[0072] In a possible implementation, when executing step S102 to send the first data modification request to other consensus nodes in the node group through the gateway node in the node group, the following steps S1021 may be specifically performed:
[0073] S1021: Send the first data modification request to the gateway node so that the gateway node performs a first verification on the first data modification request, and if the gateway node passes the first verification on the first data modification request, send the first data modification request to other consensus nodes in the node group; the first verification includes: determining whether the format of the first data modification request is a standard format, and / or determining whether the first data modification request contains modification node information.
[0074] In this embodiment, after sending the first data modification request to the gateway node, the gateway node performs a first verification on the first data modification request to determine whether the format of the first data modification request is a standard format, and / or determine whether the first data modification request contains modification node information.
[0075] Among them, when the first verification is to determine whether the format of the first data modification request is a standard format, and to determine whether the first data modification request contains modification node information, the first verification is passed if the format of the first data modification request is a standard format, and the first data modification request contains modification node information. After the gateway node passes the first verification of the first data modification request, it sends the first data modification request to other consensus nodes in the node group.
[0076] In another possible implementation, when executing step S102 to send the first data modification request to other consensus nodes in the node group through the gateway node in the node group, the following steps S1022 may be specifically performed:
[0077] S1022: Send the first data modification request to the gateway node, so that the gateway node adds a preset key to the first data modification request, and sends the first data modification request carrying the preset key to other consensus nodes in the node group;
[0078] After receiving the first data modification request carrying the preset key, the other consensus nodes perform a second verification on the first data modification request in the following manner:
[0079] Use the preset key pre-stored in other consensus nodes to match the preset key carried in the first data modification request;
[0080] If the preset key matches the preset secret key successfully, a first feedback is sent to the gateway node.
[0081] In this embodiment, after receiving the first data modification request, the gateway node adds a preset key to the first data modification request, and then sends the first data modification request carrying the preset key to other consensus nodes in the node group.
[0082] For any other consensus node, after receiving the first data modification request carrying the preset key, the pre-stored preset key is used to match the preset key. If the match is successful, it means that the first data modification request is sent by the gateway node and is safe. That is, the second verification in this embodiment is to verify the gateway node to verify whether the first data modification request is the data sent by the gateway node. Among them, each consensus node in the node group stores the same preset key.
[0083] In a possible implementation, the preset key stored in each consensus node in the node group and the preset key stored in the gateway node may be periodically updated to ensure the security of data transmission.
[0084] In another possible embodiment, when executing step S102 to send the first data modification request to other consensus nodes in the node group through the gateway node in the node group, the following steps S1023 may also be performed:
[0085] S1023: Send the first data modification request to the gateway node so that the gateway node performs a first verification on the first data modification request, and if the gateway node passes the first verification of the first data modification request, add a preset key to the first data modification request, and send the first data modification request carrying the preset key to other consensus nodes in the node group.
[0086] After receiving the first data modification request carrying the preset key, the other consensus nodes use the preset key pre-stored in the other consensus nodes to match the preset key carried in the first data modification request; if the preset key matches the preset key successfully, a first feedback opinion is sent to the gateway node.
[0087] S103: Receive first feedback from other consensus nodes regarding the first data modification request through the gateway node; the types of the first feedback include agreeing to modify and prohibiting modification.
[0088] In this embodiment, agreeing to modify means that the other consensus nodes allow the target consensus node to modify the original data in the target database. Prohibiting modification means that the other consensus nodes do not allow the target consensus node to modify the original data in the target database. The target consensus node is the consensus node that generates the first data modification request.
[0089] S104: Determine whether to use the target data to modify the original data in the target database according to the types of the first feedback opinions of all other consensus nodes.
[0090] In a possible implementation, when executing step S104, according to the types of the first feedback opinions of all other consensus nodes, determining whether to use the target data to modify the original data in the target database, the following steps S1041-S1043 may be specifically performed:
[0091] S1041: Calculate, based on the type of first feedback from each other consensus node, a first ratio of the number of agreed modifications to the total number of all first feedbacks.
[0092] After receiving feedback from all other consensus nodes, count the number of first feedback opinions that agree to be modified and the total number of all first feedback opinions. Calculate the ratio of the number of first feedback opinions that agree to be modified to the total number of first feedback opinions to get the first ratio. For example, if the total number of first feedback opinions is 100 and the number of first feedback opinions that agree to be modified is 80, then the first ratio is 80%.
[0093] S1042: If the first ratio is greater than the first preset ratio, the target data is used to modify the original data in the target database, and the first information is broadcast to other consensus nodes through the gateway node; the first information is used to indicate that the target data is allowed to be used to modify the original data in the target database.
[0094] In this embodiment, the first preset ratio is determined according to the total number of consensus nodes in the node group. Specifically, the first preset ratio needs to satisfy the formula:
[0095] N=3f+1
[0096]
[0097] Among them, N is the total number of consensus nodes, f is the number of malicious nodes that can be supported, and the first preset ratio is F is the first preset ratio.
[0098] Exemplarily, each consensus node in a node group is not necessarily a good node, and there may also be bad nodes. Therefore, when the number f of bad nodes in a node group is 3, the total number N of consensus nodes in the node group is at least 10, and the first preset ratio F is 70%.
[0099] In a possible implementation, the target database is stored in a node group, and the node group corresponds to a target database. When executing step S1042, if the first ratio is greater than the first preset ratio, the target data is used to modify the original data in the target database, and the first information is broadcast to other consensus nodes through the gateway node. Specifically, the following steps can be performed:
[0100] If the first ratio is greater than the first preset ratio, the target data is used to modify the original data in the target database within the node group, and the first information is broadcast to other consensus nodes through the gateway node to inform other consensus nodes that the modification of the original data in the target database has been completed.
[0101] In another possible embodiment, each consensus node in the node group stores a target database; when executing step S1042, if the first ratio is greater than the first preset ratio, the original data in the target database is modified using the target data, and the first information is broadcast to other consensus nodes through the gateway node, the following steps may be specifically performed:
[0102] If the first ratio is greater than the first preset ratio, the target data is used to modify the original data in the target database stored in itself, and the first information is broadcast to other consensus nodes through the gateway node, so that other consensus nodes use the target data to modify the original data in the target database stored in themselves after receiving the first information.
[0103] In this embodiment, since the same target database is stored in each consensus node, if the first ratio is greater than the first preset ratio, the target data is used to modify the original data in the target database stored in itself, and the first information is broadcast to other consensus nodes, so that after receiving the first information, other consensus nodes also use the target data to modify the original data in the target database stored in themselves, so as to ensure the consistency of data in all target databases.
[0104] In centralized data sharing, when the central server is attacked (for example, stolen), the security of all data will be affected. In this embodiment, since each consensus node stores the target database, when one consensus node is attacked, the target database is still stored in other consensus nodes, and the target database will not be affected, thereby improving data security.
[0105] S1043: If the first ratio is not greater than the first preset ratio, it is prohibited to use the target data to modify the original data in the target database, and the second information is broadcast to other consensus nodes through the gateway node; the second information is used to indicate that it is prohibited to use the target data to modify the original data in the target database.
[0106] If the first ratio is not greater than the first preset ratio, it means that more consensus nodes in the node group do not agree to use the target data to modify the original data in the target database. Therefore, it is prohibited to use the target data to modify the original data in the target database, and to broadcast the second information to other consensus nodes through the gateway node.
[0107] In a possible implementation, each consensus node in the node group stores a form; specifically, the following steps may be performed:
[0108] When a second data modification request for the target database is received from any other consensus node in the node group, the second data modification request is recorded in a form, and a second feedback opinion on the second data modification request is sent to the other consensus node; the second feedback opinion includes agreeing to the modification or prohibiting the modification.
[0109] Exemplarily, when consensus node B wants to modify the data in the target database, consensus node B generates a second data modification request and sends the second data modification request to consensus node A, consensus node C, and consensus node D. Taking consensus node A as an example, after consensus node A receives the second data modification request sent by consensus node B, it records the second data modification request in the form, determines whether to agree to the modification based on the second data modification request, and sends the third feedback opinion on whether to agree to the modification to consensus node B.
[0110] In this embodiment, after any consensus node issues a data modification request, all consensus nodes in the group will record the data modification request, so that the behavior of any consensus node is stored in all consensus nodes, achieving traceability.
[0111] In a possible implementation manner, the following steps may be performed:
[0112] S1051: Receive a registration request sent by a node to be registered outside the node group through the gateway node.
[0113] When nodes outside the node group also want to share data in the target database, they need to join the node group, so they need to register. For example, if a node E to be registered outside the node group wants to join the node group, the node E to be registered sends a registration request to all consensus nodes (such as A, B, C, D) in the node group through the gateway node, and consensus node A, consensus node B, consensus node C, and consensus node D all receive the registration request.
[0114] S1052: Send a third feedback opinion regarding the registration request to the node to be registered through the gateway node, so that the node to be registered determines whether the registration is successful according to the type of the third feedback opinion sent by the consensus node in the node group; the types of the third feedback opinion include approval of registration and prohibition of registration.
[0115] Consensus nodes A, B, C, and D determine whether to agree to allow the node E to be registered to join the node group based on the registration request, and each consensus node sends its own third feedback to the node E to be registered. The node E to be registered counts the third feedback of all consensus nodes, and calculates the second ratio of the number of approvals to the total number of third feedbacks. If the second ratio is greater than the second preset ratio, it means that the node E to be registered can be registered.
[0116] In the prior art, when a user registers, a centralized platform is usually used to decide whether the user can register. In this embodiment, a centralized platform is not required to make the decision. Instead, the decision is made by all consensus nodes in the node group, which is conducive to ensuring the security of the target database.
[0117] Embodiment 2:
[0118] Based on the same technical concept, the embodiment of the present application also provides a data sharing device. Figure 3 A schematic diagram of the structure of a data sharing device provided in an embodiment of the present application is shown. Figure 3 As shown, the device resides in any consensus node in the node group, and the consensus nodes in the node group share data stored in the target database. The device includes:
[0119] A generating module 301 is used to generate a first data modification request for the target database; the first data modification request includes original data before modification, target data after modification, and modification node information;
[0120] A first sending module 302, configured to send the first data modification request to other consensus nodes in the node group through a gateway node in the node group;
[0121] A first receiving module 303 is used to receive, through the gateway node, first feedback from other consensus nodes regarding the first data modification request; the types of the first feedback include agreeing to modify and prohibiting modification;
[0122] The determination module 304 is used to determine whether to use the target data to modify the original data in the target database according to the types of the first feedback opinions of all other consensus nodes.
[0123] Optionally, when the determination module 304 is used to determine whether to use the target data to modify the original data in the target database according to the types of the first feedback opinions of all other consensus nodes, it is specifically used to:
[0124] Calculate, according to the type of the first feedback from each other consensus node, a first ratio of the number of the agreed modifications to the total number of all the first feedbacks;
[0125] If the first ratio is greater than a first preset ratio, the target data is used to modify the original data in the target database, and the first information is broadcast to other consensus nodes through the gateway node; the first information is used to indicate that the target data is allowed to be used to modify the original data in the target database;
[0126] If the first ratio is not greater than the first preset ratio, it is prohibited to use the target data to modify the original data in the target database, and the second information is broadcast to other consensus nodes through the gateway node; the second information is used to indicate that it is prohibited to use the target data to modify the original data in the target database.
[0127] Optionally, each of the consensus nodes in the node group stores the target database; when the determination module 304 is used to modify the original data in the target database using the target data if the first ratio is greater than a first preset ratio, and broadcast the first information to other consensus nodes through the gateway node, it is specifically used to:
[0128] If the first ratio is greater than a first preset ratio, the target data is used to modify the original data in the target database stored in itself, and the first information is broadcast to other consensus nodes through the gateway node, so that the other consensus nodes use the target data to modify the original data in the target database stored in themselves after receiving the first information.
[0129] Optionally, each of the consensus nodes in the node group stores a form; and the device further includes:
[0130] A recording module is used to, upon receiving a second data modification request for the target database sent by any other consensus node in the node group, record the second data modification request in a form, and send a second feedback opinion on the second data modification request to the other consensus node; the second feedback opinion includes agreeing to modify or prohibiting modification.
[0131] Optionally, when the first sending module 302 is used to send the first data modification request to other consensus nodes in the node group through the gateway node in the node group, it is specifically used to:
[0132] The first data modification request is sent to the gateway node so that the gateway node performs a first verification on the first data modification request, and if the first verification of the first data modification request by the gateway node passes, the first data modification request is sent to other consensus nodes in the node group; the first verification includes: determining whether the format of the first data modification request is a standard format, and / or determining whether the first data modification request contains the modification node information.
[0133] Optionally, when the first sending module 302 is used to send the first data modification request to other consensus nodes in the node group through the gateway node in the node group, it is specifically used to:
[0134] Sending the first data modification request to the gateway node, so that the gateway node adds a preset key to the first data modification request, and sending the first data modification request carrying the preset key to other consensus nodes in the node group;
[0135] After receiving the first data modification request carrying the preset key, the other consensus nodes perform a second verification on the first data modification request in the following manner:
[0136] Using a preset key pre-stored in the other consensus node to match the preset key carried in the first data modification request;
[0137] If the preset key matches the preset secret key successfully, the first feedback is sent to the gateway node.
[0138] Optionally, also include:
[0139] A second receiving module, configured to receive, through the gateway node, a registration request sent by a node to be registered outside the node group;
[0140] The second sending module is used to send the third feedback opinion for the registration request to the node to be registered through the gateway node, so that the node to be registered determines whether the registration is successful according to the type of the third feedback opinion sent by the consensus node in the node group; the types of the third feedback opinion include approval of registration and prohibition of registration.
[0141] For the specific implementation method steps and principles, please refer to the description of Example 1, which will not be repeated here in detail.
[0142] Embodiment three:
[0143] Based on the same technical concept, the embodiment of the present application also provides an electronic device, Figure 4A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. Figure 4 As shown, the electronic device 400 includes: a processor 401, a memory 402 and a bus 403. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor 401 communicates with the memory 402 through the bus 403, and the processor 401 executes the machine-readable instructions to perform the method steps described in Example 1.
[0144] For the specific implementation method steps and principles, please refer to the description of Example 1, which will not be repeated here in detail.
[0145] Embodiment 4:
[0146] Based on the same technical concept, embodiment 4 of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method steps described in embodiment 1 are executed.
[0147] For the specific implementation method steps and principles, please refer to the description of Example 1, which will not be repeated here in detail.
[0148] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0149] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0150] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0151] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0152] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or in other words, the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0153] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A data sharing method, characterized in that: The method is applied to any consensus node in a node group, the consensus nodes in the node group share data stored in a target database, the node group includes a gateway node and multiple consensus nodes, the consensus nodes communicate with each other through the gateway node, and each consensus node in the node group stores the target database; the method includes: Generate a first data modification request for the target database; the first data modification request includes original data before modification, target data after modification, and modification node information; Sending the first data modification request to other consensus nodes in the node group through a gateway node in the node group; receiving, through the gateway node, first feedback from other consensus nodes regarding the first data modification request; the types of the first feedback include agreeing to modify and prohibiting modification; Determining whether to use the target data to modify the original data in the target database according to the types of the first feedback opinions of all other consensus nodes; The sending the first data modification request to other consensus nodes in the node group through the gateway node in the node group includes: The first data modification request is sent to the gateway node so that the gateway node performs a first verification on the first data modification request, and if the first verification of the first data modification request by the gateway node passes, a preset key is added to the first data modification request, and the first data modification request carrying the preset key is sent to other consensus nodes in the node group; wherein the first verification includes: determining whether the format of the first data modification request is a standard format, and / or determining whether the first data modification request contains the modification node information; After receiving the first data modification request carrying the preset key, the other consensus nodes use the preset key pre-stored in the other consensus nodes to match the preset key carried in the first data modification request to verify whether the first data modification request is the data sent by the gateway node; if the preset key matches the preset key successfully, a first feedback opinion is sent to the gateway node; The determining, according to the types of the first feedback opinions of all other consensus nodes, whether to use the target data to modify the original data in the target database includes: Calculate, according to the type of the first feedback from each other consensus node, a first ratio of the number of the agreed modifications to the total number of all the first feedbacks; If the first ratio is greater than a first preset ratio, the target data is used to modify the original data in the target database stored in itself, and the first information is broadcast to other consensus nodes through the gateway node, so that the other consensus nodes use the target data to modify the original data in the target database stored in themselves after receiving the first information.
2. The method according to claim 1, characterized in that: The method further comprises: If the first ratio is not greater than the first preset ratio, it is prohibited to use the target data to modify the original data in the target database, and the second information is broadcast to other consensus nodes through the gateway node; the second information is used to indicate that it is prohibited to use the target data to modify the original data in the target database.
3. The method according to claim 1, characterized in that: Each of the consensus nodes in the node group stores a form; the method further includes: Upon receiving a second data modification request for the target database sent by any other consensus node in the node group, the second data modification request is recorded in a form, and a second feedback opinion on the second data modification request is sent to the other consensus node; the second feedback opinion includes agreeing to the modification or prohibiting the modification.
4. The method according to claim 1, characterized in that: Also includes: Receiving, through the gateway node, a registration request sent by a node to be registered outside the node group; Sending a third feedback opinion regarding the registration request to the node to be registered through the gateway node, so that the node to be registered determines whether the registration is successful according to the type of the third feedback opinion sent by the consensus node in the node group; The types of the third feedback include approval of registration and prohibition of registration.
5. A data sharing device, characterized in that: The device resides in any consensus node in the node group, the consensus nodes in the node group share data stored in the target database, the node group includes a gateway node and multiple consensus nodes, the consensus nodes communicate with each other through the gateway node, and each consensus node in the node group stores the target database; the device includes: A generating module, configured to generate a first data modification request for the target database; the first data modification request includes original data before modification, target data after modification, and modification node information; A first sending module, used for sending the first data modification request to other consensus nodes in the node group through a gateway node in the node group; A first receiving module, configured to receive, through the gateway node, first feedback from other consensus nodes regarding the first data modification request; the types of the first feedback include agreeing to modify and prohibiting modification; A determination module, configured to determine whether to use the target data to modify the original data in the target database according to the types of the first feedback opinions of all other consensus nodes; When the first sending module is used to send the first data modification request to other consensus nodes in the node group through the gateway node in the node group, it is specifically used to: The first data modification request is sent to the gateway node so that the gateway node performs a first verification on the first data modification request, and if the first verification of the first data modification request by the gateway node passes, a preset key is added to the first data modification request, and the first data modification request carrying the preset key is sent to other consensus nodes in the node group; wherein the first verification includes: determining whether the format of the first data modification request is a standard format, and / or determining whether the first data modification request contains the modification node information; After receiving the first data modification request carrying the preset key, the other consensus nodes use the preset key pre-stored in the other consensus nodes to match the preset key carried in the first data modification request to verify whether the first data modification request is the data sent by the gateway node; if the preset key matches the preset key successfully, a first feedback opinion is sent to the gateway node; When the determination module is used to determine whether to use the target data to modify the original data in the target database according to the types of the first feedback opinions of all other consensus nodes, it is specifically used to: Calculate, according to the type of the first feedback from each other consensus node, a first ratio of the number of the agreed modifications to the total number of all the first feedbacks; If the first ratio is greater than a first preset ratio, the target data is used to modify the original data in the target database stored in itself, and the first information is broadcast to other consensus nodes through the gateway node, so that the other consensus nodes use the target data to modify the original data in the target database stored in themselves after receiving the first information.
6. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the method as claimed in any one of claims 1 to 4 are performed.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are executed.
Citation Information
Patent Citations
Server cluster file synchronization method and device, electronic equipment and storage medium
CN110572468A
Node management method, device, and equipment based on blockchain network and storage medium
CN112714196A
File storage method and device, electronic equipment and storage medium
CN112835854A