Specific embodiment
It is described in detail below in conjunction with specific embodiment of the attached drawing to the disclosure.It should be understood that this place is retouched
The specific embodiment stated is only used for describing and explaining the disclosure, is not limited to the disclosure.
Illustrate the technical term that the embodiment of the present disclosure is related to first.
License block chain: in block catenary system account or node can to block catenary system progress operation weigh
Limit a kind of block catenary system of control.
Access authority: whether block chain account or node have the permission for accessing block catenary system and synchrodata.
Full node: the node with all data in block catenary system.
Light node: the node with partial data in block chain, it will usually possess block head all in block catenary system
Information can do limited data verification.
Original node: the node of original account operation, usually full node.
Destination node: the full node of a certain license block catenary system has been accessed.
New node: prepare the node of a certain license block catenary system of access, including light node and Quan Jiedian.
Legitimate node: there is the node of access authority to new node.
Illegal node: do not have the node of access authority to new node.
In the related art, the new node for permitting block catenary system for being added, since only original node has access
Permission, therefore the new node can only initially synchronize block data from original node, only when new node is synchronized to certain data
Afterwards, other destination nodes equally with access authority can just be found, thus could be concomitantly from the same step number of other destination nodes
According to.But if the new node is light node, due to light node recording areas build, the permission of other nodes is not recorded
Information, therefore in entire data synchronization process, which can only cannot all save from original node synchrodata from other
Point synchrodata, this is larger to the pressure of original node, and also affects the data synchronization efficiency of new node.
In order to solve the above-mentioned technical problem, the embodiment of the present disclosure provides a kind of method of data synchronization, can be applied to block
The new node of block chain data to be synchronized in catenary system.Referring to Fig.1, which may include:
Step S101, new node obtain the block chain that the first node is locally stored from the first node in block catenary system
Multiple continuous block heads.
Wherein, first node be there is no the node of access authority to new node in block catenary system, but it is to be understood that,
New node has access authority to first node in the embodiments of the present disclosure.Therefore, new node can be obtained from first node and is somebody's turn to do
The multiple continuous block heads for the block chain that first node is locally stored.
Illustratively, first node may include legal destination node, i.e., first node is to have access authority to new node
Destination node, but new node block data is also comprising corresponding relevant authority information when data are synchronous, in such cases,
The first node is the node of not access authority currently for new node.In another case, first node can also wrap
Illegal destination node is included, i.e. first node is not have the destination node of access authority to new node.Step S102, according to block
The mark of head obtains multiple continuous areas in the block chain that the second node is locally stored with like-identified from second node
Build.
Wherein, second node is the node to new node with access authority in block catenary system, and be should understand that
, new node equally has access authority to second node in the embodiment of the present disclosure, in other words, second node and new node
Between have bilateral construction permission.Illustratively, second node can be the original node in block catenary system, be also possible to block chain
There is the either objective node, etc. of access authority to new node, the embodiment of the present disclosure is not construed as limiting this in system.
In block chain, each block connects in sequence, and each block head has corresponding sequence identification (for example, area
The number of build), therefore can be obtained in step s 102 from second node corresponding multiple continuous according to the mark of block head
Block head.For example, 100 block heads that number is 1-100 are obtained from first node in step s101, correspondingly, in step
Can be according to the number (mark) of the 100 block heads got in rapid S102, obtaining number in second node is 1-100's
100 block heads.
The block head obtained from first node is compared step S103 with the block head obtained from second node.
Step S104, if the block head obtained from the first node and the block head ratio obtained from the second node
To consistent, then the corresponding block data of multiple continuous block heads is synchronized to new node from first node.
If the block head obtained from first node compares unanimously with the block head obtained from second node, illustrate from the
Consistent (the number of the corresponding block data of the block head block data corresponding with the block head obtained from second node that one node obtains
Pass through according to validation verification), so as to synchronize the corresponding block data of multiple continuous block heads to new section from first node
Point.In another case, if compared from the block head that first node obtains with the block head obtained from second node different
It causes, then illustrates the corresponding block data of the block head area corresponding with the block head obtained from second node obtained from first node
Block number is not according to inconsistent (Validation of Data passes through), then consider Information Security, then it is not synchronous from the first node
The corresponding block data of multiple continuous block heads is to new node.
By above-mentioned mode, the new node being added in license block catenary system can be right from the license block catenary system
New node does not have the synchronous block data of the first node of access authority, and the data of scheme compared to the prior art, the disclosure are same
One step process can mitigate the pressure of original node, accelerate data synchronization efficiency.Also, during data are synchronous, Ke Yitong
The data validity to new node with the second node verifying first node of access authority is crossed in the license block catenary system, from
And it ensure that the Information Security in data synchronization process.
For the method for data synchronization for making those skilled in the art more understand that the embodiment of the present disclosure provides, below to above-mentioned
Each step carries out illustrated in greater detail.
In the embodiments of the present disclosure, since first node is that new node does not have the node of access authority, in step
In S101, new node and first node foundation are limited connections, i.e., only carry out establishing connection institute between new node and first node
The data interaction needed, and without any other data interaction in addition to establishing needed for connection, it thereby may be ensured that data are pacified
Quan Xing.
After establishing limited connection with first node, multiple continuous block heads can be obtained from first node.Example
Ground, the quantity of the block head obtained from first node can be, the disclosure determining, etc. according to the actual conditions of block catenary system
Embodiment is not construed as limiting this.It should be understood that the block head quantity of acquisition can be dynamic for assuring data security
Change at random, for example obtain 100 continuous block heads from first node for the first time, obtains 120 from first node for the second time
A continuous block head obtains 110 continuous block heads, etc. from first node for the third time.
In a kind of possible mode, after getting multiple continuous block heads from first node, can also verify from
First node obtain multiple continuous block heads validity, correspondingly, if step S102 can be validation verification at
Function, then according to the mark of block head, obtaining from second node has like-identified in the block chain that the second node is locally stored
Multiple continuous block heads.
In other words, before executing step S102, the multiple continuous blocks obtained from first node can first be verified
Whether head can form effective block chain.Illustratively, the mode of verifying can be cryptographic Hash inspection or hash chain is examined, etc.
Deng the embodiment of the present disclosure is not construed as limiting this.If validity is verified, i.e., what is got from first node is multiple continuous
Block head can form effective block chain, then can obtain the second node sheet from second node according to the mark of block head
Multiple continuous block heads with like-identified in the block chain of ground storage.
In the case where alternatively possible, if validation verification does not pass through, the first segment got can be abandoned
Multiple continuous block heads of point, and the connection with the first node is disconnected, it is obtained again from other first nodes corresponding more
A continuum build carries out data synchronization process.Alternatively, disconnect with after the connection of the first node, can also by this first
Node is added in blacklist, avoids obtaining block head from the first node again in subsequent data synchronization process.In this way
Mode, not only ensure that the synchronous safety of data, but also improve the synchronous efficiency of data.
After corresponding multiple continuous block heads are got from second node, the area that can will be got from first node
Build is compared with the block head got from second node.In a kind of possible mode, it can will be obtained from first node
The cryptographic Hash of the multiple continuous block heads taken and the cryptographic Hash of the multiple continuous block heads obtained from second node are compared
It is right, correspondingly, in step S104, if can be from first node obtain multiple continuous block heads cryptographic Hash with from
The cryptographic Hash for multiple continuous block heads that second node obtains is identical, then synchronizes multiple continuous block heads pair from first node
The block data answered is to the new node.
In other words, in the embodiments of the present disclosure, the multiple continuous areas obtained from first node can be first determined respectively
The cryptographic Hash of the cryptographic Hash of build and the multiple continuous block heads obtained from second node, then by obtained above two
A cryptographic Hash is compared, if compared unanimously, synchronizes the corresponding block data of multiple continuous block heads from first node
To new node.
It, can be first to each block from multiple continuous block heads that first node obtains in a kind of possible mode
The cryptographic Hash of head carries out Hash calculation, the first cryptographic Hash is obtained, and obtain the second cryptographic Hash, then by the first cryptographic Hash and second
Cryptographic Hash is compared.Wherein, the second cryptographic Hash be according to new node from multiple continuous block heads that second node obtains
The cryptographic Hash of each block head carries out what Hash calculation obtained.
The cryptographic Hash of multiple continuous block head is arranged by the mark sequence of block head for example, the first cryptographic Hash can be
It is carried out obtained from Hash calculation after column.It is multiple in the acquisition for receiving new node transmission that second cryptographic Hash can be second node
After the request of data of continuum build, the range of multiple continuum builds is first determined according to the request of data, then by the block
Multiple continuous blocks in head range carry out Hash calculation after arranging according to the mark sequence of block head and obtain and be sent to new
Node.In this case, new node directly can obtain the second cryptographic Hash from second node.Certainly, possible at other
In mode, the second cryptographic Hash is also possible to new node to each block head from multiple continuous block heads that second node obtains
Cryptographic Hash carry out Hash calculation and get, etc., the embodiment of the present disclosure is not construed as limiting this.
By the above-mentioned means, can determine an entirety according to the cryptographic Hash of each block head in multiple continuous block heads
Then cryptographic Hash the corresponding whole cryptographic Hash of first node and second node is compared.It is whole in this way to compare
Mode, quickly first node can be verified, to more efficiently realize the data between first node and new node
Synchronizing process.
In alternatively possible mode, the Hash of each block head in multiple continuous block heads can also be determined respectively
Value, then the cryptographic Hash of corresponding block head each in first node and second node is compared one by one respectively.Specifically,
It can be and first determine the corresponding cryptographic Hash of N+2 block head from multiple continuous block heads that first node obtains, then
Determine the N+2 area from multiple continuous block heads that second node obtains with above-mentioned N+2 block head with like-identified
The corresponding cryptographic Hash of build, it is then that N+2 block head of N+2 block head of first node and second node is corresponding
Cryptographic Hash is compared one by one.
Wherein, N+2 block head may include first area from multiple continuous block heads that first node obtains
N number of block head between build, the last one block head and first block head and the last one block head, N is positive whole
Number.
Illustratively, the value of N can determine that the embodiment of the present disclosure does not limit this according to the actual conditions of block catenary system
It is fixed.For example, 100 continuous block heads are obtained from first node, then N should be less than the positive integer equal to 98.In addition,
It should be understood that the value of N is bigger, then comparison result is more credible, i.e., more can guarantee that the data obtained from first node are effective
Property, to more can guarantee the Information Security in data synchronization process.
In data synchronization process, second node can not temporarily be connected due to network environment, hardware fault etc.,
In such cases, multiple batches of in step s101 block head can be obtained from first node, and to the block that each batch obtains
Head addition does not compare label, wherein each batch obtains multiple continuous block heads.Correspondingly, step S102 can be first really
Determine second node be in can connection status, then judge from first node obtain multiple batches of block head in, if exist have not
The batch of label is compared, there is the batch for not comparing label if it exists, then according to the mark of the block head of the batch, from the second section
Point obtains multiple continuous block heads in the block chain that the second node is locally stored with like-identified.Correspondingly, step
S103, which can be, to carry out in the block head that will have the batch for not comparing label with the corresponding block head obtained from second node
After comparison, that deletes the block head of the batch does not compare label.
In other words, when second node can not temporarily connect, step S101 can be first performed a plurality of times in new node, multiple batches of
Block head is obtained, and label is not compared to the addition of every batch of block head, it, can be according to this then when second node restores to connect
Label is compared, successively executes step S102- step S104, and after comparison, that deletes respective batch block head does not compare mark
Note, to guarantee being normally carried out for data synchronization process.
Illustratively, not comparing label can be a character, such as a number or letter, be also possible to multiple characters,
For example string number or letter, etc., the embodiment of the present disclosure are not construed as limiting this.It should be understood that in the embodiment of the present disclosure,
For the block head that same batch is got, can uniformly add it is identical do not compare label, and different batches are got
Block head, the different labels that do not compare can be added respectively and distinguished.
In the case where alternatively possible, when second node can not permanently be connected due to account key loss, damage etc.
When connecing, it is possible to specify new node has other destination nodes of access authority as second node.For other destination nodes
Selection can be determined according to the actual conditions of block catenary system, for example the block catenary system of mechanism, alliance is characterized for one,
Other destination nodes can be a destination node for characterizing ally in the mechanism, alliance.
It should be noted that can cancel after new node is synchronized to certain or newest block data as new node
Other specified destination nodes, allow new node using the destination node with access authority any in block catenary system as
Second node, to restore normal data synchronization process.
In addition, it is to be understood that first node, which is likely to become, has new node with the progress of data synchronization process
The node of access authority, such as in the case where first node is legal destination node, the new node process synchronous in data
In get the corresponding authority information of the first node after, which, which then becomes, has access authority for new node
Node.In such cases, new node can synchronize block counts from the first node by method of data synchronization in the related technology
According to for example, new node can verify the first node by Merkle tree (Merkel tree), cryptographic Hash or hash chain inspection
Data validity after, from the first node synchrodata, which is not described herein again for detailed process.
Below with a complete example, the method for data synchronization of the embodiment of the present disclosure is illustrated.
It include two original node A and B in the license block catenary system referring to Fig. 2, three destination node C accessed,
D and E, and prepare to access new node G, F and H of the license block catenary system.Also, new node G, F and H match in access authority
It postpones, establishes connection with the interdependent node in the license block catenary system respectively.
The access authority for having new node G due to originating node A, new node G can establish two-way with original node A
Connection (with the signal of double-head arrow connecting line in figure), and destination node D and E do not have the access authority of new node G, therefore press this public affairs
The method of data synchronization of embodiment is opened, new node G can establish limited connection (with single arrow in figure with destination node D and E respectively
Connecting line signal).
In data synchronization process, new node G first passes through original node A and verifies to the data of destination node D and E,
Specific verification process is being described above, and which is not described herein again.After being verified, new node G from destination node D and
E synchrodata.Same mode, new node F can verify the data of destination node C and E by original node B.When
After being verified, new node F is from destination node C and E synchrodata.
The license block chain can first be specified since it does not connect with original node A and B directly for new node H
Either objective node in network is that second node carries out data synchronization process.Such as, it is possible to specify destination node D is the second section
Point, then using destination node C as first node, by the method for data synchronization of the embodiment of the present disclosure from the same step number of destination node C
According to arrive new node.
It should be understood that the synchronous process of the data of the embodiment of the present disclosure can in order to further increase data synchronization efficiency
Concurrently to execute, i.e., new node can carry out data synchronization process to the data of multiple destination nodes request different batches simultaneously.
For example, referring to Fig. 2, new node G can carry out data synchronization process from the data of destination node D and E request different batches simultaneously,
For example, new node G can request the block head that number is 1-100 to carry out above-mentioned data synchronization process from destination node D, simultaneously also
The block head that number is 101-200 can be requested to carry out above-mentioned data synchronization process from destination node E.
Based on the same inventive concept, the disclosure also provides a kind of data synchronization unit, can be applied in block catenary system
The new node of block chain data to be synchronized.Referring to Fig. 3, which includes:
First obtain module 301, for the new node from the first node in the block catenary system obtain this first
The multiple continuous block heads for the block chain that node is locally stored, wherein the first node is in the block catenary system
There is no the node of access authority to the new node;
Second obtains module 302, for the mark according to the block head, obtains second node local from second node
With multiple continuous block heads of like-identified in the block chain of storage, the second node is in the block catenary system
There is the node of access authority to the new node;
Comparison module 303, block head for will be obtained from the first node with from the area that the second node obtains
Build is compared;
Synchronization module 304, for when the block head that be obtained from the first node with from the area of second node acquisition
When build compares consistent, the corresponding block data of the multiple continuous block head is synchronized to the new section from the first node
Point.
Optionally, the cryptographic Hash of multiple block heads of the comparison module 303 for that will be obtained from the first node and
The cryptographic Hash of the multiple block heads obtained from the second node is compared;
The synchronization module 304 is used for when the cryptographic Hash of multiple block heads that obtains from the first node and from described the
When the cryptographic Hash for multiple block heads that two nodes obtain is identical, the multiple continuous block head pair is synchronized from the first node
The block data answered is to the new node.
Optionally, the comparison module 303 is used for:
According to the cryptographic Hash of each block head from multiple continuous block heads that the first node obtains, first is determined
Cryptographic Hash;
The second cryptographic Hash is obtained, second cryptographic Hash is the multiple companies obtained according to the new node from the second node
The cryptographic Hash of each block head carries out what Hash calculation obtained in continuous block head;
First cryptographic Hash is compared with second cryptographic Hash.
Optionally, the comparison module 303 is used for:
Determine the corresponding cryptographic Hash of N+2 block head from multiple block heads that the first node obtains, wherein
The N+2 block head includes first block head, the last one block head and described first in the multiple block head
N number of block head between a block head and the last one described block head, N is positive integer;
Determine the N+ from multiple block heads that the second node obtains with the N+2 block head with like-identified
The corresponding cryptographic Hash of 2 block heads;
By the corresponding cryptographic Hash one of N+2 block head of the N+2 block head and the second node of the first node
One is compared.
Optionally, described first module 301 is obtained for multiple batches of from first node acquisition block head, and to each
The block head addition that batch obtains does not compare label, wherein each batch obtains multiple continuous block heads;
It is described according to second acquisition module 302 for determine the second node be in can connection status, judge from described
In the multiple batches of block head that first node obtains, if exist with the batch for not comparing label, and there is institute when existing
When stating the batch for not comparing label, according to the mark of the block head of the batch, the second node is obtained from second node and is locally deposited
With multiple continuous block heads of like-identified in the block chain of storage;
The comparison module 303 be used for will have the block head of the batch for not comparing label with from second section
After the corresponding block head that point obtains is compared, that deletes the block head of the batch does not compare label.
Optionally, described device 300 further include:
Authentication module, for verifying the validity of the multiple continuous block heads obtained from the first node;
Described second, which obtains module 302, is used for when validation verification success, according to the mark of the block head, from
The second node obtains multiple continuous block heads in the block chain that the second node is locally stored with like-identified.
About the device in above-described embodiment, wherein modules execute the concrete mode of operation in related this method
Embodiment in be described in detail, no detailed explanation will be given here.
By any of the above-described data synchronization unit, the new node being added in license block catenary system can be from the license block
There is no the synchronous block data of first node of access authority to new node in catenary system, scheme compared to the prior art, this public affairs
The method of data synchronization opened can mitigate the pressure of original node, accelerate data synchronization efficiency.Also, in the synchronous process of data
In, it can be by having the data of the second node verifying first node of access authority in the license block catenary system to new node
Validity, to ensure that the Information Security in data synchronization process.
Based on the same inventive concept, the embodiment of the present disclosure also provides a kind of electronic equipment, comprising:
Memory is stored thereon with computer program;
Processor, for executing the computer program in the memory, to realize that any of the above-described item data is synchronous
The step of method.
In a kind of possible mode, the block diagram of the electronic equipment can be as shown in Figure 4.Referring to Fig. 4, the electronic equipment
400 may include: processor 401, memory 402.The electronic equipment 400 can also include multimedia component 403, input/defeated
One or more of (I/O) interface 404 and communication component 405 out.
Wherein, processor 401 is used to control the integrated operation of the electronic equipment 400, to complete the above-mentioned data side of synchronization
All or part of the steps in method.Memory 402 is for storing various types of data to support the behaviour in the electronic equipment 400
To make, these data for example may include the instruction of any application or method for operating on the electronic equipment 400, with
And the relevant data of application program, such as the authority information of node, block data etc..The memory 402 can be by any class
The volatibility or non-volatile memory device or their combination of type are realized, such as static random access memory (Static
Random Access Memory, abbreviation SRAM), electrically erasable programmable read-only memory (Electrically Erasable
Programmable Read-Only Memory, abbreviation EEPROM), Erasable Programmable Read Only Memory EPROM (Erasable
Programmable Read-Only Memory, abbreviation EPROM), programmable read only memory (Programmable Read-
Only Memory, abbreviation PROM), read-only memory (Read-Only Memory, abbreviation ROM), magnetic memory, flash
Device, disk or CD.
Multimedia component 403 may include screen and audio component.Wherein screen for example can be touch screen, audio component
For output and/or input audio signal.For example, audio component may include a microphone, microphone is for receiving outside
Audio signal.The received audio signal can be further stored in memory 402 or be sent by communication component 405.Sound
Frequency component further includes at least one loudspeaker, is used for output audio signal.
I/O interface 404 provides interface between processor 401 and other interface modules, other above-mentioned interface modules can be with
It is keyboard, mouse, button etc..These buttons can be virtual push button or entity button.Communication component 405 is set for the electronics
Wired or wireless communication is carried out between standby 400 and other equipment.Wireless communication, such as Wi-Fi, bluetooth, near-field communication (Near
Field Communication, abbreviation NFC), 2G, 3G, 4G, NB-IOT, eMTC or other 5G etc. or they one of
Or several combinations, it is not limited here.Therefore the corresponding communication component 407 may include: Wi-Fi module, bluetooth module,
NFC module etc..
In one exemplary embodiment, electronic equipment 400 can be by one or more application specific integrated circuit
(Application Specific Integrated Circuit, abbreviation ASIC), digital signal processor (Digital
Signal Processor, abbreviation DSP), digital signal processing appts (Digital Signal Processing Device,
Abbreviation DSPD), programmable logic device (Programmable Logic Device, abbreviation PLD), field programmable gate array
(Field Programmable Gate Array, abbreviation FPGA), controller, microcontroller, microprocessor or other electronics member
Part is realized, for executing above-mentioned method of data synchronization.
In a further exemplary embodiment, a kind of computer readable storage medium including program instruction is additionally provided, it should
The step of above-mentioned method of data synchronization is realized when program instruction is executed by processor.For example, the computer readable storage medium
It can be the above-mentioned memory 402 including program instruction, above procedure instruction can be executed by the processor 401 of electronic equipment 400
To complete above-mentioned method of data synchronization.
The preferred embodiment of the disclosure is described in detail in conjunction with attached drawing above, still, the disclosure is not limited to above-mentioned reality
The detail in mode is applied, in the range of the technology design of the disclosure, a variety of letters can be carried out to the technical solution of the disclosure
Monotropic type, these simple variants belong to the protection scope of the disclosure.
It is further to note that specific technical features described in the above specific embodiments, in not lance
In the case where shield, can be combined in any appropriate way, in order to avoid unnecessary repetition, the disclosure to it is various can
No further explanation will be given for the combination of energy.
In addition, any combination can also be carried out between a variety of different embodiments of the disclosure, as long as it is without prejudice to originally
Disclosed thought equally should be considered as disclosure disclosure of that.