CN110059089B - Data synchronization method and device, storage medium and electronic equipment - Google Patents

Data synchronization method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN110059089B
CN110059089B CN201910239276.8A CN201910239276A CN110059089B CN 110059089 B CN110059089 B CN 110059089B CN 201910239276 A CN201910239276 A CN 201910239276A CN 110059089 B CN110059089 B CN 110059089B
Authority
CN
China
Prior art keywords
node
block
headers
consecutive
new
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910239276.8A
Other languages
Chinese (zh)
Other versions
CN110059089A (en
Inventor
陈敏
张跃洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Cloudminds Shanghai Robotics Co Ltd
Original Assignee
Cloudminds Shenzhen Robotics Systems Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Cloudminds Shenzhen Robotics Systems Co Ltd filed Critical Cloudminds Shenzhen Robotics Systems Co Ltd
Priority to CN201910239276.8A priority Critical patent/CN110059089B/en
Publication of CN110059089A publication Critical patent/CN110059089A/en
Application granted granted Critical
Publication of CN110059089B publication Critical patent/CN110059089B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database

Abstract

The present disclosure relates to a data synchronization method, apparatus, storage medium, and electronic device, so that a new node joining a licensed blockchain system can synchronize data from any node in the licensed blockchain. The data synchronization method is applied to a new node of block chain data to be synchronized in a block chain system, and comprises the following steps: the new node acquires a plurality of continuous block heads of a block chain locally stored by a first node from the first node in the block chain system; according to the identification of the block head, acquiring a plurality of continuous block heads with the same identification in a block chain locally stored by a second node from the second node; comparing the block header obtained from the first node with the block header obtained from the second node; and if the block head obtained from the first node is consistent with the block head obtained from the second node in comparison, synchronizing the block data corresponding to the plurality of continuous block heads from the first node to the new node.

Description

Data synchronization method and device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of block chain technologies, and in particular, to a data synchronization method, apparatus, storage medium, and electronic device.
Background
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. Among them, the license block chain is used more and more as a block chain with an authority control capability in various organizations and corporate unions. Each node in the permission block chain is divided into some basic chain authorities, such as mining authorities, access authorities and the like. The process of allowing the blockchain account or the node to be connected to the blockchain network and acquiring the blockchain data can be controlled based on the access authority, so that the data security of the allowed blockchain is ensured, and the problem of data synchronization is also brought.
For a new node joining the licensed blockchain system, the new node can initially synchronize block data only from the originating node, since only the originating node has access rights. Moreover, if the new node is a light node, since the light node only records the block header and does not record the authority information of other nodes, the new node can only synchronize data from the originating node but not from other nodes in the whole data synchronization process, which has a large pressure on the originating node and also affects the data synchronization efficiency of the new node.
Disclosure of Invention
The present disclosure provides a data synchronization method, apparatus, storage medium, and electronic device, so that a new node joining a licensed blockchain system can synchronize data from any node in the licensed blockchain.
In order to achieve the above object, in a first aspect, the present disclosure provides a data synchronization method applied to a new node of blockchain data to be synchronized in a blockchain system, the method including:
the new node acquires a plurality of continuous block headers of a block chain locally stored by a first node from the first node in the block chain system, wherein the first node is a node in the block chain system which has no access right to the new node;
acquiring a plurality of continuous block heads with the same identification in a block chain locally stored by a second node from the second node according to the identification of the block heads, wherein the second node is a node which has access authority to the new node in the block chain system;
comparing the block header obtained from the first node with the block header obtained from the second node;
and if the block head obtained from the first node is consistent with the block head obtained from the second node in comparison, synchronizing the block data corresponding to the plurality of continuous block heads from the first node to the new node.
In a second aspect, the present disclosure further provides a data synchronization apparatus, where the apparatus is applied to a new node of blockchain data to be synchronized in a blockchain system, and the apparatus includes:
a first obtaining module, configured to obtain, by the new node, multiple consecutive block headers of a block chain locally stored by a first node in the block chain system, where the first node is a node in the block chain system that has no access right to the new node;
a second obtaining module, configured to obtain, from a second node, multiple consecutive block headers having the same identifier in a block chain locally stored by the second node according to the identifier of the block header, where the second node is a node in the block chain system that has an access right to the new node;
a comparison module, configured to compare the block header obtained from the first node with the block header obtained from the second node;
and a synchronization module, configured to synchronize, from the first node, block data corresponding to the multiple consecutive block headers to the new node when the block header obtained from the first node is identical to the block header obtained from the second node in comparison.
In a third aspect, the present disclosure also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method described in the first aspect.
In a fourth aspect, the present disclosure also provides an electronic device, including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the method in the first aspect.
Through the technical scheme, the new node added into the permission blockchain system can synchronize the blockdata of the first node without access authority to the new node from the permission blockchain system. In addition, in the data synchronization process, the data validity of the first node can be verified through the second node having access authority to the new node in the permission blockchain system, so that the data security in the data synchronization process is ensured.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a flow chart illustrating a method of data synchronization according to an exemplary embodiment of the present disclosure;
FIG. 2 is a schematic diagram of a topology of nodes in a licensed blockchain system, according to an example embodiment of the present disclosure;
FIG. 3 is a block diagram illustrating a data synchronization apparatus according to an exemplary embodiment of the present disclosure;
fig. 4 is a block diagram illustrating an electronic device according to an exemplary embodiment of the present disclosure.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
First, terms related to the embodiments of the present disclosure will be described.
Allowed blockchain: a blockchain system is provided in which an account or node in the blockchain system is authorized to perform operations on the blockchain system.
And (3) access authority: whether the blockchain account or the node has the authority to access the blockchain system and synchronize data.
All nodes: nodes with all data in the blockchain system.
And (3) light node: nodes with partial data in the blockchain typically have all the blockhead information in the blockchain system, which allows limited data verification.
The starting node: the node where the account is initiated to run is typically a full node.
The target node: all nodes that have access to a certain licensed blockchain system.
And (4) new node: nodes, including light nodes and full nodes, that are ready to access a certain licensed blockchain system.
And (4) legal nodes: and the node having the access right to the new node.
And (3) illegal nodes: and the node which does not have the access right to the new node.
In the related art, for a new node joining the licensed blockchain system, since only the originating node has access right, the new node can initially synchronize block data only from the originating node, and only after the new node synchronizes to certain data, other target nodes having access right as well are found, so that data can be concurrently synchronized from other target nodes. However, if the new node is a light node, since the light node only records the block header and does not record the authority information of other nodes, the new node can only synchronize data from the originating node and cannot synchronize data from other nodes in the whole data synchronization process, which has a large pressure on the originating node and also affects the data synchronization efficiency of the new node.
In order to solve the above technical problem, an embodiment of the present disclosure provides a data synchronization method, which can be applied to a new node of blockchain data to be synchronized in a blockchain system. Referring to fig. 1, the data synchronization method may include:
in step S101, a new node obtains, from a first node in a blockchain system, a plurality of consecutive block headers of a blockchain locally stored by the first node.
Wherein the first node is a node in the blockchain system that has no access right to the new node, but it should be understood that in the embodiments of the present disclosure the new node has access right to the first node. Thus, the new node may obtain from the first node a number of consecutive chunk headers of a chunk chain stored locally by the first node.
For example, the first node may include a legitimate target node, that is, the first node is a target node having an access right to the new node, but the new node block data does not yet contain the corresponding related right information when the data is synchronized, in this case, the first node is currently a node having no access right to the new node. In another case, the first node may further include an illegal target node, that is, the first node is a target node having no access right to the new node. Step S102, according to the identification of the block head, a plurality of continuous block heads with the same identification in the block chain locally stored by the second node are obtained from the second node.
The second node is a node having an access right to the new node in the blockchain system, and it should be understood that the new node also has an access right to the second node in the embodiment of the present disclosure, that is, the second node and the new node have a bidirectional access right. For example, the second node may be an originating node in the blockchain system, or may be any target node having access right to a new node in the blockchain system, and the like, which is not limited in this disclosure.
In the block chain, each block is connected in sequence, and each block header has a corresponding sequence identifier (for example, the number of the block header), so in step S102, a plurality of corresponding consecutive block headers can be obtained from the second node according to the identifier of the block header. For example, 100 block headers numbered 1 to 100 are acquired from the first node in step S101, and accordingly, 100 block headers numbered 1 to 100 may be acquired at the second node according to the acquired number (identification) of the 100 block headers in step S102.
Step S103, comparing the block header obtained from the first node with the block header obtained from the second node.
Step S104, if the block header obtained from the first node is consistent with the block header obtained from the second node, synchronizing block data corresponding to a plurality of consecutive block headers from the first node to the new node.
If the comparison between the block head obtained from the first node and the block head obtained from the second node is consistent, it indicates that the block data corresponding to the block head obtained from the first node is consistent with the block data corresponding to the block head obtained from the second node (the data validity is verified to be passed), so that the block data corresponding to a plurality of continuous block heads can be synchronized from the first node to the new node. In another case, if the comparison between the block header obtained from the first node and the block header obtained from the second node is inconsistent, it indicates that the block data corresponding to the block header obtained from the first node is inconsistent with the block data corresponding to the block header obtained from the second node (the data validity verification fails), and then the block data corresponding to a plurality of consecutive block headers are not synchronized from the first node to the new node in view of data security.
Through the method, the new node added into the permission blockchain system can synchronize the blockchain data of the first node without access authority to the new node from the permission blockchain system. In addition, in the data synchronization process, the data validity of the first node can be verified through the second node having access authority to the new node in the permission blockchain system, so that the data security in the data synchronization process is ensured.
In order to make those skilled in the art understand the data synchronization method provided by the embodiments of the present disclosure, the following describes the above steps in detail.
In the embodiment of the present disclosure, since the first node is a node to which the new node has no access right, in step S101, the new node establishes a limited connection with the first node, that is, only data interaction required for establishing a connection is performed between the new node and the first node, and no other data interaction is performed except for data interaction required for establishing a connection, so that data security can be ensured.
After establishing the restricted connection with the first node, a plurality of consecutive block headers may be obtained from the first node. For example, the number of the chunk headers obtained from the first node may be determined according to the actual situation of the blockchain system, and the like, and the embodiment of the present disclosure does not limit this. It should be understood that, in order to ensure data security, the number of block headers obtained may be dynamically and randomly varied, such as obtaining 100 consecutive block headers from the first node for the first time, obtaining 120 consecutive block headers from the first node for the second time, obtaining 110 consecutive block headers from the first node for the third time, and so on.
In a possible manner, after the multiple consecutive block headers are obtained from the first node, validity of the multiple consecutive block headers obtained from the first node may be further verified, and correspondingly, in step S102, if the validity verification is successful, the multiple consecutive block headers having the same identifier in the block chain locally stored by the second node are obtained from the second node according to the identifier of the block header.
That is, before performing step S102, it may be verified whether a plurality of consecutive chunk headers obtained from the first node may constitute a valid chunk chain. For example, the verification manner may be a hash value check or a hash chain check, and the like, and the embodiment of the present disclosure does not limit this. If the validity verification is passed, that is, the plurality of consecutive block headers acquired from the first node may form an effective block chain, the plurality of consecutive block headers having the same identifier in the block chain locally stored in the second node may be acquired from the second node according to the identifier of the block header.
In another possible case, if the validity verification fails, the obtained multiple consecutive block headers of the first node may be discarded, the connection with the first node is disconnected, and the corresponding multiple consecutive block headers are obtained from other first nodes again to perform the data synchronization process. Or after the connection with the first node is disconnected, the first node can be added into a blacklist, and the block header is prevented from being acquired from the first node in the subsequent data synchronization process. By the mode, the safety of data synchronization is guaranteed, and the efficiency of data synchronization is improved.
After obtaining the corresponding plurality of consecutive block headers from the second node, the block header obtained from the first node may be compared with the block header obtained from the second node. In one possible approach, the hash values of the consecutive block headers obtained from the first node may be compared with the hash values of the consecutive block headers obtained from the second node, and accordingly, in step S104, if the hash values of the consecutive block headers obtained from the first node are the same as the hash values of the consecutive block headers obtained from the second node, the block data corresponding to the consecutive block headers may be synchronized from the first node to the new node.
That is to say, in the embodiment of the present disclosure, the hash values of a plurality of consecutive block headers obtained from the first node and the hash values of a plurality of consecutive block headers obtained from the second node may be determined respectively, then the obtained two hash values are compared, and if the two hash values are consistent, the block data corresponding to the plurality of consecutive block headers are synchronized to the new node from the first node.
In a possible manner, the hash value of each of a plurality of consecutive block headers obtained from the first node may be subjected to hash calculation to obtain a first hash value, and a second hash value is obtained, and then the first hash value and the second hash value are compared. And the second hash value is obtained by carrying out hash calculation according to the hash value of each block head in a plurality of continuous block heads acquired from the second node by the new node.
For example, the first hash value may be obtained by arranging hash values of the plurality of consecutive block headers in the order of the block header identification and then performing hash calculation. The second hash value may be obtained by the second node, after receiving a data request for acquiring multiple consecutive block headers sent by the new node, determining a range of the multiple consecutive block headers according to the data request, then arranging multiple consecutive blocks within the range of the block headers according to an identification sequence of the block headers, and performing hash calculation and sending the result to the new node. In this case, the new node may obtain the second hash value directly from the second node. Of course, in other possible manners, the second hash value may also be obtained by the new node performing hash calculation on the hash value of each of a plurality of consecutive block headers obtained from the second node, and the like, which is not limited in this disclosure.
By the mode, an integral hash value can be determined according to the hash value of each block head in a plurality of continuous block heads, and then the integral hash values corresponding to the first node and the second node are compared. Through the overall comparison mode, the first node can be verified quickly, and therefore the data synchronization process between the first node and the new node is achieved more efficiently.
In another possible manner, the hash value of each of a plurality of consecutive block headers may be determined, and then the hash values of each corresponding block header in the first node and the second node may be compared one by one. Specifically, the hash values corresponding to N +2 block headers in a plurality of consecutive block headers obtained from the first node are determined, the hash values corresponding to N +2 block headers having the same identifier as the N +2 block headers in the plurality of consecutive block headers obtained from the second node are determined, and then the hash values corresponding to the N +2 block headers of the first node and the N +2 block headers of the second node are compared one by one.
The N +2 block headers may include a first block header, a last block header, and N block headers between the first block header and the last block header, among a plurality of consecutive block headers obtained from the first node, where N is a positive integer.
For example, the value of N may be determined according to an actual situation of the blockchain system, which is not limited in the embodiment of the present disclosure. For example, if 100 consecutive block headers are obtained from the first node, then N should be a positive integer equal to or less than 98. In addition, it should be understood that the larger the value of N is, the more reliable the comparison result is, that is, the more the validity of the data acquired from the first node can be ensured, so that the data security in the data synchronization process can be ensured.
In the data synchronization process, the second node may be temporarily disconnected due to network environment, hardware failure, and the like, in this case, in step S101, multiple batches of block headers may be obtained from the first node, and a non-comparison flag is added to the block headers obtained in each batch, where each batch obtains multiple consecutive block headers. Correspondingly, in step S102, it may be determined that the second node is in a connectable state, and then it is determined whether there is a lot with an unmatched flag in the multiple lots of block headers obtained from the first node, and if there is a lot with an unmatched flag, a plurality of consecutive block headers with the same flag in the block chain locally stored in the second node are obtained from the second node according to the flag of the block header of the lot. Accordingly, in step S103, after comparing the block header of the batch with the unmatched mark with the corresponding block header obtained from the second node, the unmatched mark of the block header of the batch is deleted.
That is, when the second node is temporarily not connectable, the new node may first perform step S101 multiple times, obtain block headers for multiple batches, add an unmatched flag to each batch of block headers, then, when the second node is reconnected, sequentially perform steps S102-S104 according to the unmatched flag, and delete the unmatched flag of the corresponding batch of block headers after the unmatched flag is compared, so as to ensure normal data synchronization process.
For example, the unmatched mark may be one character, such as one number or letter, or may be multiple characters, such as a string of numbers or letters, and the like, which is not limited by the embodiments of the present disclosure. It should be understood that, in the embodiment of the present disclosure, the same unaligned flag may be uniformly added to the block headers acquired in the same batch, and different unaligned flags may be respectively added to the block headers acquired in different batches for distinguishing.
In another possible scenario, when the second node is permanently unconnected due to loss of account keys, damage, etc., other target nodes to which the new node has access rights may be designated as the second node. The selection of other target nodes may be determined based on the circumstances of the blockchain system, such as for a blockchain system that characterizes a federation enterprise, the other target nodes may be a target node that characterizes allies in the federation enterprise.
It should be noted that, after the new node synchronizes to a certain or latest block data, other target nodes designated for the new node may be cancelled, so that the new node may use any target node with access right in the blockchain system as the second node, thereby recovering the normal data synchronization process.
In addition, it should be understood that as the data synchronization process proceeds, the first node may become a node having an access right to the new node, for example, in a case that the first node is a legal target node, after the new node acquires the right information corresponding to the first node in the data synchronization process, the first node becomes a node having an access right to the new node. In this case, the new node may synchronize the block data from the first node by using a data synchronization method in the related art, for example, after the new node verifies the data validity of the first node by using a Merkle tree (merkel tree), a hash value or a hash chain check, the data may be synchronized from the first node, and the specific process is not described herein again.
The data synchronization method according to the embodiment of the present disclosure is described below as a complete example.
Referring to fig. 2, the licensed blockchain system includes two origination nodes a and B, three accessed destination nodes C, D and E, and new nodes G, F and H that are ready to access the licensed blockchain system. And, after the access right configuration, the new nodes G, F and H establish connection with the relevant nodes in the licensed blockchain system, respectively.
Since the originating node a has the access right of the new node G, the new node G can establish a bidirectional connection with the originating node a (illustrated by a double-arrow connection line in the figure), and the target nodes D and E do not have the access right of the new node G, so that according to the data synchronization method of the embodiment of the present disclosure, the new node G can establish a limited connection with the target nodes D and E, respectively (illustrated by a single-arrow connection line in the figure).
In the data synchronization process, the new node G verifies the data of the target nodes D and E through the originating node a, and the specific verification process is described above and is not described herein again. When the verification passes, the new node G synchronizes data from the target nodes D and E. In the same way, the new node F can verify the data of the target nodes C and E by the originating node B. When the verification passes, the new node F synchronizes data from the target nodes C and E.
For the new node H, since it is not directly connected to the originating nodes a and B, any target node in the licensed blockchain network may be first designated as the second node to perform the data synchronization process. For example, the target node D may be designated as the second node, and then the target node C is designated as the first node, and data is synchronized from the target node C to the new node by the data synchronization method according to the embodiment of the present disclosure.
It should be understood that, in order to further improve the data synchronization efficiency, the data synchronization process of the embodiments of the present disclosure may be executed concurrently, that is, the new node may request different batches of data from multiple target nodes at the same time to perform the data synchronization process. For example, referring to fig. 2, the new node G may request different batches of data from the target nodes D and E at the same time to perform the data synchronization process, for example, the new node G may request the block headers with numbers 1-100 from the target node D, and may also request the block headers with number 101-200 from the target node E to perform the data synchronization process.
Based on the same inventive concept, the present disclosure also provides a data synchronization device, which can be applied to a new node of block chain data to be synchronized in a block chain system. Referring to fig. 3, the apparatus includes:
a first obtaining module 301, configured to obtain, by the new node, multiple consecutive block headers of a block chain locally stored by a first node in the blockchain system, where the first node is a node in the blockchain system that has no access right to the new node;
a second obtaining module 302, configured to obtain, from a second node, multiple consecutive block headers having the same identifier in a block chain locally stored by the second node according to the identifier of the block header, where the second node is a node in the block chain system that has access right to the new node;
a comparing module 303, configured to compare the block header obtained from the first node with the block header obtained from the second node;
a synchronization module 304, configured to synchronize, from the first node, the block data corresponding to the multiple consecutive block headers to the new node when the block header obtained from the first node is aligned with the block header obtained from the second node.
Optionally, the comparing module 303 is configured to compare the hash values of the multiple block headers obtained from the first node with the hash values of the multiple block headers obtained from the second node;
the synchronization module 304 is configured to synchronize the tile data corresponding to the consecutive tile headers from the first node to the new node when the hash values of the tile headers obtained from the first node are the same as the hash values of the tile headers obtained from the second node.
Optionally, the alignment module 303 is configured to:
determining a first hash value according to the hash value of each block header of a plurality of continuous block headers acquired from the first node;
acquiring a second hash value, wherein the second hash value is obtained by carrying out hash calculation according to the hash value of each block head in a plurality of continuous block heads acquired from the second node by the new node;
and comparing the first hash value with the second hash value.
Optionally, the alignment module 303 is configured to:
determining hash values respectively corresponding to N +2 block headers in a plurality of block headers obtained from the first node, wherein the N +2 block headers include a first block header and a last block header in the plurality of block headers and N block headers between the first block header and the last block header, and N is a positive integer;
determining hash values respectively corresponding to N +2 block headers having the same identification as the N +2 block headers in the plurality of block headers acquired from the second node;
and comparing the hash values corresponding to the N +2 block heads of the first node with the hash values corresponding to the N +2 block heads of the second node one by one.
Optionally, the first obtaining module 301 is configured to obtain block headers from the first node in multiple batches, and add an unmatched flag to the block headers obtained in each batch, where each batch obtains multiple consecutive block headers;
the second obtaining module 302 is configured to determine that the second node is in a connectable state, determine whether a batch with the unmatched flag exists in the multiple batches of block headers obtained from the first node, and obtain, when a batch with the unmatched flag exists, multiple consecutive block headers with the same identifier in a block chain locally stored by the second node from the second node according to the identifier of the block header of the batch;
the comparing module 303 is configured to delete the unmatched marker of the block header of the batch having the unmatched marker after comparing the block header of the batch with the corresponding block header obtained from the second node.
Optionally, the apparatus 300 further comprises:
a validation module for validating a plurality of consecutive block headers obtained from the first node;
the second obtaining module 302 is configured to, when the validity verification is successful, obtain, from the second node, a plurality of consecutive block headers having the same identifier in a block chain locally stored by the second node according to the identifier of the block header.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Through any one of the data synchronization devices, the new node added into the permission blockchain system can synchronize the blockchain data of the first node without access authority to the new node from the permission blockchain system. In addition, in the data synchronization process, the data validity of the first node can be verified through the second node having access authority to the new node in the permission blockchain system, so that the data security in the data synchronization process is ensured.
Based on the same inventive concept, an embodiment of the present disclosure further provides an electronic device, including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of any of the above data synchronization methods.
In one possible approach, a block diagram of the electronic device may be as shown in fig. 4. Referring to fig. 4, the electronic device 400 may include: a processor 401 and a memory 402. The electronic device 400 may also include one or more of a multimedia component 403, an input/output (I/O) interface 404, and a communications component 405.
The processor 401 is configured to control the overall operation of the electronic device 400, so as to complete all or part of the steps in the data synchronization method. The memory 402 is used to store various types of data to support operations at the electronic device 400, such as instructions for any application or method operating on the electronic device 400, and application-related data, such as node privilege information, block data, and so forth. The Memory 402 may be implemented by any type of volatile or non-volatile Memory device or 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 Memory, flash Memory, magnetic disk or optical disk.
The multimedia components 403 may include a screen and an audio component. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 402 or transmitted through the communication component 405. The audio assembly also includes at least one speaker for outputting audio signals.
The I/O interface 404 provides an interface between the processor 401 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 405 is used for wired or wireless communication between the electronic device 400 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, which is not limited herein. The corresponding communication component 407 may therefore include: Wi-Fi module, Bluetooth module, NFC module, etc.
In an exemplary embodiment, the electronic Device 400 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above-described data synchronization method.
In another exemplary embodiment, there is also provided a computer readable storage medium comprising program instructions which, when executed by a processor, implement the steps of the data synchronization method described above. For example, the computer readable storage medium may be the memory 402 described above comprising program instructions that are executable by the processor 401 of the electronic device 400 to perform the data synchronization method described above.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that, in the foregoing embodiments, various features described in the above embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, various combinations that are possible in the present disclosure are not described again.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.

Claims (10)

1. A data synchronization method is applied to a new node of block chain data to be synchronized in a block chain system, and comprises the following steps:
the new node acquires a plurality of continuous block headers of a block chain locally stored by a first node from the first node in the block chain system, wherein the first node is a node in the block chain system which has no access right to the new node;
acquiring a plurality of continuous block heads with the same identification in a block chain locally stored by a second node from the second node according to the identification of the block heads, wherein the second node is a node which has access authority to the new node in the block chain system;
comparing the block header obtained from the first node with the block header obtained from the second node;
and if the block head obtained from the first node is consistent with the block head obtained from the second node in comparison, synchronizing the block data corresponding to the plurality of continuous block heads from the first node to the new node.
2. The method of claim 1, wherein comparing the block header obtained from the first node with the block header obtained from the second node comprises:
comparing the hash values of the plurality of consecutive block headers obtained from the first node with the hash values of the plurality of consecutive block headers obtained from the second node;
if the comparison between the block header obtained from the first node and the block header obtained from the second node is consistent, synchronizing the block data corresponding to the plurality of consecutive block headers from the first node to the new node, including:
synchronizing, from the first node, the tile data corresponding to a plurality of consecutive block headers obtained from the first node to the new node if the hash values of the plurality of consecutive block headers obtained from the first node are the same as the hash values of the plurality of consecutive block headers obtained from the second node.
3. The method of claim 2, wherein comparing the hash values of the consecutive block headers obtained from the first node with the hash values of the consecutive block headers obtained from the second node comprises:
performing hash calculation on the hash value of each block head in a plurality of continuous block heads acquired from the first node to obtain a first hash value;
acquiring a second hash value, wherein the second hash value is obtained by performing hash calculation according to the hash value of each block head in a plurality of continuous block heads acquired from the second node by the new node;
and comparing the first hash value with the second hash value.
4. The method of claim 2, wherein comparing the hash values of the consecutive block headers obtained from the first node with the hash values of the consecutive block headers obtained from the second node comprises:
determining hash values respectively corresponding to N +2 block headers in a plurality of continuous block headers acquired from a first node, wherein the N +2 block headers comprise a first block header and a last block header in the plurality of continuous block headers acquired from the first node and N block headers between the first block header and the last block header, and N is a positive integer;
determining hash values respectively corresponding to N +2 block headers with the same identification as the N +2 block headers in a plurality of continuous block headers obtained from a second node;
and comparing the hash values corresponding to the N +2 block heads of the first node with the hash values corresponding to the N +2 block heads of the second node one by one.
5. The method according to any of claims 1-4, wherein the new node obtaining from a first node in the blockchain system a plurality of consecutive blockheaders of a blockchain locally stored by the first node, comprises:
obtaining block heads from the first node in multiple batches, and adding an unmatched mark to the block heads obtained in each batch, wherein each batch obtains multiple continuous block heads;
the obtaining, from the second node, a plurality of consecutive block headers having the same identifier in a block chain locally stored by the second node according to the identifier of the block header includes:
determining that the second node is in a connectable state;
judging whether batches with the unmatched marks exist in the multi-batch block headers acquired from the first node;
if the batch with the unmatched mark exists, acquiring a plurality of continuous block heads with the same mark in a block chain locally stored by a second node from the second node according to the mark of the block head of the batch;
the comparing the block header obtained from the first node with the block header obtained from the second node comprises:
and after comparing the block head of the batch with the unmatched mark with the corresponding block head acquired from the second node, deleting the unmatched mark of the block head of the batch.
6. The method according to any one of claims 1-4, further comprising:
verifying validity of a plurality of consecutive block headers obtained from the first node;
the obtaining, from the second node, a plurality of consecutive block headers having the same identifier in a block chain locally stored by the second node according to the identifier of the block header includes:
and if the validity verification is successful, acquiring a plurality of continuous block heads with the same identification in a block chain locally stored by the second node from the second node according to the identification of the block heads.
7. A data synchronization apparatus, applied to a new node of blockchain data to be synchronized in a blockchain system, the apparatus comprising:
a first obtaining module, configured to obtain, by the new node, multiple consecutive block headers of a block chain locally stored by a first node in the block chain system, where the first node is a node in the block chain system that has no access right to the new node;
a second obtaining module, configured to obtain, from a second node, multiple consecutive block headers having the same identifier in a block chain locally stored by the second node according to the identifier of the block header, where the second node is a node in the block chain system that has an access right to the new node;
a comparison module, configured to compare the block header obtained from the first node with the block header obtained from the second node;
and a synchronization module, configured to synchronize, from the first node, block data corresponding to the multiple consecutive block headers to the new node when the block header obtained from the first node is identical to the block header obtained from the second node in comparison.
8. The apparatus of claim 7, wherein the comparing module is configured to compare the hash values of the chunk headers obtained from the first node with the hash values of the chunk headers obtained from the second node;
the synchronization module is configured to synchronize, from the first node, the tile data corresponding to the consecutive tile headers to the new node when the hash values of the tile headers obtained from the first node are the same as the hash values of the tile headers obtained from the second node.
9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
10. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 6.
CN201910239276.8A 2019-03-27 2019-03-27 Data synchronization method and device, storage medium and electronic equipment Active CN110059089B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910239276.8A CN110059089B (en) 2019-03-27 2019-03-27 Data synchronization method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910239276.8A CN110059089B (en) 2019-03-27 2019-03-27 Data synchronization method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN110059089A CN110059089A (en) 2019-07-26
CN110059089B true CN110059089B (en) 2021-01-22

Family

ID=67317433

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910239276.8A Active CN110059089B (en) 2019-03-27 2019-03-27 Data synchronization method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN110059089B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110572473B (en) * 2019-09-20 2022-10-14 腾讯科技(深圳)有限公司 Block header synchronization method, equipment and computer readable storage medium
CN111431867B (en) * 2020-03-06 2022-04-08 杭州云象网络技术有限公司 Node access method based on block chain BaaS platform
CN111444206B (en) * 2020-03-24 2021-10-15 腾讯科技(深圳)有限公司 Synchronous processing method, device, equipment and medium
CN111581289B (en) * 2020-05-08 2024-03-22 西安华域网络文化发展有限公司 Data management method, system, device and medium for double-head block chain
CN111756829A (en) * 2020-06-19 2020-10-09 深圳市蔚链科技有限公司 Account book data synchronization method, device, equipment and storage medium
CN113364847B (en) * 2021-05-31 2022-07-19 新疆大学 Data synchronization method and device of block chain nodes and storage medium

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106815330A (en) * 2016-12-29 2017-06-09 北京瑞卓喜投科技发展有限公司 The generation method and system of the block chain expanded along Spatial Dimension
CN107077674A (en) * 2016-12-29 2017-08-18 深圳前海达闼云端智能科技有限公司 Transaction verification processing method and device and node equipment
CN107079058A (en) * 2016-12-23 2017-08-18 深圳前海达闼云端智能科技有限公司 The business of block chain node performs method, device and node device
CN108615156A (en) * 2018-05-09 2018-10-02 上海魅联信息技术有限公司 A kind of data structure based on block chain
CN108984744A (en) * 2018-07-16 2018-12-11 夸克链科技(深圳)有限公司 A kind of non-master chain block self-propagation method
CN109034807A (en) * 2018-08-15 2018-12-18 杭州复杂美科技有限公司 A kind of block chain method of data synchronization
CN109088914A (en) * 2018-07-03 2018-12-25 深圳智乾区块链科技有限公司 Generation method, the block chain ecosystem and the computer readable storage medium of block
CN109165224A (en) * 2018-08-24 2019-01-08 东北大学 A kind of indexing means being directed to keyword key on block chain database
CN109213901A (en) * 2018-09-18 2019-01-15 百度在线网络技术(北京)有限公司 A kind of method of data synchronization, device, equipment and the medium of block chain
KR20190010515A (en) * 2018-11-22 2019-01-30 김경준 Management system for blockchain
CN109460405A (en) * 2018-09-27 2019-03-12 上海点融信息科技有限责任公司 For the block generation method of block chain network, synchronous method, storage medium, calculate equipment
CN109491996A (en) * 2018-09-27 2019-03-19 上海点融信息科技有限责任公司 For the block generation method of block chain network, block data access method, calculate equipment, storage medium
CN109542888A (en) * 2018-12-03 2019-03-29 百度在线网络技术(北京)有限公司 The data modification and synchronous method of block chain, device, equipment and storage medium
CN109542979A (en) * 2018-11-19 2019-03-29 广州矩阵信息科技有限公司 A kind of block catenary system Fast synchronization and the mode of simple smart data storage
CN110737664A (en) * 2019-10-21 2020-01-31 深圳前海微众银行股份有限公司 block link point synchronization method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170346639A1 (en) * 2016-05-24 2017-11-30 Business Information Exchange System Corp. Public Key Infrastructure based on the Public Certificates Ledger

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107079058A (en) * 2016-12-23 2017-08-18 深圳前海达闼云端智能科技有限公司 The business of block chain node performs method, device and node device
CN106815330A (en) * 2016-12-29 2017-06-09 北京瑞卓喜投科技发展有限公司 The generation method and system of the block chain expanded along Spatial Dimension
CN107077674A (en) * 2016-12-29 2017-08-18 深圳前海达闼云端智能科技有限公司 Transaction verification processing method and device and node equipment
CN108615156A (en) * 2018-05-09 2018-10-02 上海魅联信息技术有限公司 A kind of data structure based on block chain
CN109088914A (en) * 2018-07-03 2018-12-25 深圳智乾区块链科技有限公司 Generation method, the block chain ecosystem and the computer readable storage medium of block
CN108984744A (en) * 2018-07-16 2018-12-11 夸克链科技(深圳)有限公司 A kind of non-master chain block self-propagation method
CN109034807A (en) * 2018-08-15 2018-12-18 杭州复杂美科技有限公司 A kind of block chain method of data synchronization
CN109165224A (en) * 2018-08-24 2019-01-08 东北大学 A kind of indexing means being directed to keyword key on block chain database
CN109213901A (en) * 2018-09-18 2019-01-15 百度在线网络技术(北京)有限公司 A kind of method of data synchronization, device, equipment and the medium of block chain
CN109460405A (en) * 2018-09-27 2019-03-12 上海点融信息科技有限责任公司 For the block generation method of block chain network, synchronous method, storage medium, calculate equipment
CN109491996A (en) * 2018-09-27 2019-03-19 上海点融信息科技有限责任公司 For the block generation method of block chain network, block data access method, calculate equipment, storage medium
CN109542979A (en) * 2018-11-19 2019-03-29 广州矩阵信息科技有限公司 A kind of block catenary system Fast synchronization and the mode of simple smart data storage
KR20190010515A (en) * 2018-11-22 2019-01-30 김경준 Management system for blockchain
CN109542888A (en) * 2018-12-03 2019-03-29 百度在线网络技术(北京)有限公司 The data modification and synchronous method of block chain, device, equipment and storage medium
CN110737664A (en) * 2019-10-21 2020-01-31 深圳前海微众银行股份有限公司 block link point synchronization method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"基于区块链技术的数字资产确权交易模型研究";张婷;《福建工程学院学报》;20190225;第67-70页 *

Also Published As

Publication number Publication date
CN110059089A (en) 2019-07-26

Similar Documents

Publication Publication Date Title
CN110059089B (en) Data synchronization method and device, storage medium and electronic equipment
US11032293B2 (en) System and method for managing and securing a distributed ledger for a decentralized peer-to-peer network
WO2020093565A1 (en) Blockchain block deletion method and apparatus, and terminal device
CN110771091B (en) System and method for security of network connected devices
US11729175B2 (en) Blockchain folding
CN108696356B (en) Block chain-based digital certificate deleting method, device and system
CN109634615B (en) Issuing method, verification method and device of application installation package
CN111181945B (en) Digital identity management method and device, storage medium and electronic equipment
CN105187397A (en) WEB system page integration anti-hotlinking method and system
CN110855777A (en) Node management method and device based on block chain
US20220021518A1 (en) Data block modification
CN113841359A (en) Method and apparatus for propagating tiles in a blockchain network
CN112202612A (en) Block chain node management method, storage medium, node and block chain system
CN110620776B (en) Data transfer information transmission method and device
CN112101945B (en) Method and system for supervising block chain content
CN115943609A (en) Block propagation for poisoned transactions in block chain networks
US11921689B2 (en) Data structure storage optimisation
KR20190069234A (en) APPARATUS AND METHOD FOR PROVIDING SECURITY IN HOME IoT
CN109302442B (en) Data storage proving method and related equipment
CN111444496A (en) Application control method, device, equipment and storage medium
CN117692134A (en) Key update management system and key update management method
CN111641651A (en) Access verification method and device based on Hash chain
CN112242994B (en) Method for checking position between entities and digital content protection system
CN113868628A (en) Signature verification method and device, computer equipment and storage medium
CN113039766B (en) Optimized equivalent Simultaneous Authentication (SAE) authentication in wireless networks

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20210303

Address after: 201111 2nd floor, building 2, no.1508, Kunyang Road, Minhang District, Shanghai

Patentee after: Dalu Robot Co.,Ltd.

Address before: 518000 Room 201, building A, No. 1, Qian Wan Road, Qianhai Shenzhen Hong Kong cooperation zone, Shenzhen, Guangdong (Shenzhen Qianhai business secretary Co., Ltd.)

Patentee before: Shenzhen Qianhaida Yunyun Intelligent Technology Co.,Ltd.

TR01 Transfer of patent right
CP03 Change of name, title or address

Address after: 201111 Building 8, No. 207, Zhongqing Road, Minhang District, Shanghai

Patentee after: Dayu robot Co.,Ltd.

Address before: 201111 2nd floor, building 2, no.1508, Kunyang Road, Minhang District, Shanghai

Patentee before: Dalu Robot Co.,Ltd.

CP03 Change of name, title or address