WO2021196463A1 - 一种区块链数据的同步方法、装置及电子设备、存储介质 - Google Patents

一种区块链数据的同步方法、装置及电子设备、存储介质 Download PDF

Info

Publication number
WO2021196463A1
WO2021196463A1 PCT/CN2020/104847 CN2020104847W WO2021196463A1 WO 2021196463 A1 WO2021196463 A1 WO 2021196463A1 CN 2020104847 W CN2020104847 W CN 2020104847W WO 2021196463 A1 WO2021196463 A1 WO 2021196463A1
Authority
WO
WIPO (PCT)
Prior art keywords
tree
data
target
interval
node device
Prior art date
Application number
PCT/CN2020/104847
Other languages
English (en)
French (fr)
Inventor
李宁
薄辰龙
Original Assignee
深圳壹账通智能科技有限公司
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 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2021196463A1 publication Critical patent/WO2021196463A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • 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/2246Trees, e.g. B+trees
    • 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
    • G06F16/275Synchronous replication
    • 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
    • G06F16/278Data partitioning, e.g. horizontal or vertical partitioning
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Definitions

  • This application relates to the field of blockchain technology, and in particular to a method, device, electronic equipment, and storage medium for synchronizing blockchain data.
  • the block height has reached 8.7 million, and the full node data Over 2TB, and it is still growing rapidly.
  • For newly added node devices newly added to the blockchain network it takes months to synchronize historical blockchain data. Even with highly configured machines, it still takes several weeks. Ordinary machines cannot even catch up with the speed of data block generation. Therefore, how to speed up the synchronization of historical block data in the blockchain with newly added node devices has become an urgent problem to be solved.
  • the embodiments of the present application provide a method, device, electronic device, and storage medium for synchronizing blockchain data, which are beneficial to increase the speed of synchronizing blockchain data with newly-added node devices.
  • the first aspect of the embodiments of the present application provides a method for synchronizing blockchain data.
  • the method is applied to a newly added node device in a blockchain network.
  • the method includes: when the newly added node device joins the blockchain In the network, obtain the data tree corresponding to the blockchain data from the first connection node device, and obtain the target tree leaf node from the second connection node device based on the value of the target tree leaf node in the data tree
  • each node device in the blockchain network stores each interval data tree obtained after slicing the interval data corresponding to each block interval in the blockchain data, and
  • the data tree corresponding to the blockchain data generated based on the respective interval data trees, and each leaf node in the data master tree corresponds to each interval data tree one-to-one; based on the target interval data tree
  • the values of different target interval tree leaf nodes obtain at least one target segment data in parallel from each connected node device corresponding to the newly added node device, wherein each of the target segment data is the different target interval tree leaf node
  • the second aspect of the embodiments of the present application provides a device for synchronizing blockchain data.
  • the synchronizing device is configured in a newly-added node device in a blockchain network, and includes: a communication module for when a newly-added node device joins In the case of a blockchain network, obtain the data tree corresponding to the blockchain data from the first connection node device, and obtain the target tree from the second connection node device based on the value of the leaf node of the target tree in the data tree.
  • the target interval data tree corresponding to the tree leaf node; the communication module is further configured to obtain in parallel from each connected node device corresponding to the newly added node device based on the values of different target interval tree leaf nodes in the target interval data tree At least one target fragment data, wherein each of the target fragment data is the fragment data corresponding to each of the different target interval tree leaf nodes; a processing module is configured to integrate each of the target fragment data into the The interval data of the target block interval corresponding to the target interval data tree is obtained, the interval data of each block interval is acquired, and the interval data of each block interval is integrated to obtain the blockchain data.
  • a third aspect of the embodiments of the present application provides an electronic device, including a processor, a memory, and a communication interface.
  • the processor, the memory, and the communication interface are connected to each other.
  • a computer program the computer program includes program instructions, and the processor is configured to call the program instructions to perform the following steps: obtain the data tree corresponding to the blockchain data from the first connection node device through the communication interface, and Based on the value of the target total tree leaf node in the data total tree, obtain the target interval data tree corresponding to the target total tree leaf node from the second connecting node device through the communication interface, and each node device in the blockchain network
  • Each interval data tree obtained after slicing the interval data corresponding to each block interval in the blockchain data is stored, and the data corresponding to the blockchain data generated based on the respective interval data tree
  • each leaf node in the data total tree corresponds to each interval data tree one-to-one; through the communication interface 703, based on the value of the leaf node of the target interval tree in the target interval data tree from the
  • the fourth aspect of the embodiments of the present application provides that the embodiments of the present application provide a computer-readable storage medium, the computer-readable storage medium stores a computer program, and the computer program includes program instructions.
  • the processor executes, the processor executes the above-mentioned blockchain data synchronization method.
  • the computer-readable storage medium may be non-volatile or volatile.
  • the speed of synchronizing blockchain data with newly added node devices in the blockchain network can be improved.
  • Figure 1 is a schematic structural diagram of a blockchain provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram of the architecture of a blockchain network provided by an embodiment of the present application.
  • Fig. 3a is a schematic diagram of block chain data fragmentation processing provided by an embodiment of the present application.
  • Fig. 3b is a schematic structural diagram of an interval data tree according to an embodiment of the present application.
  • Fig. 3c is a schematic diagram of the structure of a general data tree according to an embodiment of the present application.
  • FIG. 4 is a schematic flowchart of a method for synchronizing blockchain data according to an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of another method for synchronizing blockchain data according to an embodiment of the present application.
  • Fig. 6 is a schematic structural diagram of a device for synchronizing blockchain data according to an embodiment of the present application.
  • Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
  • Block Chain is a kind of chained data structure that combines data blocks in sequence in chronological order, and cryptographically guarantees that the data is not tamperable and unforgeable distributed ledger.
  • Multiple independent distributed nodes that is, new node devices in the blockchain network
  • Blockchain technology has achieved decentralization and has become the cornerstone of credible digital asset storage, transfer and transaction.
  • FIG. 2 is a schematic diagram of the architecture of a blockchain network disclosed in an embodiment of the present application.
  • the blockchain network includes a plurality of node devices, and the blockchain network may include a newly added node device 200, and a connection node device 201 and a connection node device 202 corresponding to the newly added node device 200.
  • each node device in the blockchain network when each node device in the blockchain network detects that the current block height is an integer multiple of n (an integer greater than 0, such as 1000), it can compare the data on its own disk based on a preset sharding rule.
  • the historical blockchain data is fragmented to obtain at least one fragment corresponding to the historical blockchain data, and every n data blocks corresponds to a block interval. Further, the hash of each shard can be calculated.
  • the current block height refers to the serial number of the latest block in the blockchain maintained by the blockchain network.
  • each node device in the blockchain network can perform every n data Block, divide the historical blockchain data on the disk into slices, starting from the marker bit at the end of the last slice, one slice per 1MB, and calculate the hash of each slice.
  • the above-mentioned node device may sequentially form a 2-layer interval data tree corresponding to the block interval of the current n data blocks by the hash of each fragment, and save the interval data tree locally as an interval fragment index, which is convenient Look up.
  • the interval data tree is shown in Fig. 3b.
  • An interval data tree corresponds to an interval root hash, and the value of each leaf node in the interval data tree (hereinafter referred to as the leaf node of the interval tree) is the corresponding fragment
  • the data is hashed, and the hash obtained has a one-to-one correspondence between each leaf node of the interval tree and the fragmented data.
  • the node device can query the slice data uniquely corresponding to each interval tree leaf node through the value of each interval tree leaf node in the interval data tree.
  • the above node device can obtain the interval data tree corresponding to each block interval in the historical blockchain data. Further, the interval root hash corresponding to each interval data tree can be stored in a 2-layer MerkleTree structure to obtain the data total tree corresponding to the historical blockchain data, and the blockchain root hash corresponding to the data total tree, and save local.
  • the total data tree corresponding to the historical blockchain data is shown in FIG. 3c, and one total data tree corresponds to one blockchain root hash.
  • the value of each leaf node in the total tree of data (hereinafter referred to as the leaf node of the total tree) is the interval root hash of the corresponding interval data tree.
  • the data master tree corresponding to the blockchain data can be obtained from the first connecting node device, and based on the target tree leaf node in the data master tree The value of the target interval data tree corresponding to the leaf node of the target total tree is obtained from the second connection node device.
  • at least one target segment data may be obtained in parallel from each connection node device corresponding to the newly added node device based on the values of the leaf nodes of the different target interval tree in the target interval data tree, where each target segment data is a different target
  • the fragment data corresponding to each of the leaf nodes of the interval tree integrates each target fragment data into the interval data of the target block interval corresponding to the target interval data tree.
  • interval data of each block interval mentioned above can be obtained, and the interval data of each block interval can be integrated to obtain the blockchain data and complete the synchronization of the blockchain data. In this way, it is beneficial to increase the speed at which newly-added node devices synchronize blockchain data.
  • FIG. 4 is a schematic flowchart of a method for synchronizing blockchain data in an embodiment of the present application.
  • the method in the embodiment of the present application may be executed by a newly added node device of the blockchain network.
  • the method of the embodiment of the present application includes the following steps.
  • the data tree corresponding to the blockchain data can be obtained from the first connection node device, and based on the value of the target tree leaf node in the data tree, from the second connection
  • the node device obtains the target interval data tree corresponding to the leaf node of the target total tree.
  • first connection node device and the second connection device are any one of the connection node devices corresponding to the newly added node device.
  • the first connection node device and the second connection device may be the same or different, and the target total tree leaf node It can be one or more of the leaf nodes of each total tree included in the data total tree.
  • each node device in the blockchain network stores each interval data tree obtained after slicing the interval data corresponding to each block interval in the blockchain data, and each interval data tree based on each interval data tree
  • the generated blockchain data corresponds to the data tree, and each leaf node in the data tree corresponds to each interval data tree one-to-one.
  • the newly added node can obtain the root hash of the blockchain corresponding to the total data tree from each connected node device, and compare each connected node If the root hash of the blockchain returned by the device is the same as the preset number threshold, the same root hash of the blockchain is determined as the blockchain fingerprint data.
  • the number of connected node devices corresponding to the newly added node device is 1000, and the preset number threshold is 1000*2/3.
  • the newly added node device joins the blockchain network, it can request the blockchain from the above 1000 connected nodes Root hash, when more than 1000*2/3 of the blockchain root hashes are consistent, the blockchain root hash is used as the blockchain fingerprint data.
  • the root hash of the blockchain corresponding to the data tree obtained from the first connecting node device matches the above-mentioned blockchain fingerprint data, and if it is determined that the data tree obtained from the first connecting node device corresponds to If the root hash of the blockchain matches the fingerprint data of the blockchain, it triggers the execution of the step of obtaining the target interval data tree corresponding to the target total tree leaf node from the second connected node device based on the value of the target total tree leaf node in the data total tree .
  • the data tree can be obtained from other connected node devices until the data is obtained.
  • the root hash of the blockchain corresponding to the total tree matches the above-mentioned blockchain fingerprint data.
  • the root hash of the blockchain corresponding to the total tree of data obtained from the first connection node device can be compared with the fingerprint data of the blockchain. If the comparison shows that the two are the same, it can be determined that the two match. Otherwise, the two do not match.
  • the newly added node device may request all or part of the interval data tree (that is, the aforementioned target interval data tree) from the second connecting node device. Specifically, the newly added node device may send the interval data tree to the second connecting node.
  • An acquisition request where the interval data tree acquisition request carries the value of the leaf node of the target total tree corresponding to the target interval data tree.
  • the second connection node can search for the target interval data tree corresponding to the value of the leaf node of the target total tree, and return the target interval data tree to the newly added node device.
  • the value of the leaf node of the target total tree is the interval root hash corresponding to the target data interval data tree.
  • the second leaf node in the total data tree is the target total tree leaf node, and the value of the target leaf node is h002
  • the newly added node device can carry h002 in the interval data tree acquisition request sent to the second connecting node device. After receiving the request, the second connecting node device can search for the target interval data tree corresponding to h002, and set the target interval The data tree returns to the newly added node device.
  • each target segment data is the corresponding segment data of different target interval tree leaf nodes
  • the target interval tree leaf node is one or more of each interval tree leaf node included in the target interval data tree.
  • the newly added node device may divide each interval tree leaf node in the target interval data tree based on the indication information, and one or more interval tree leaf nodes divided into the same interval are used as the target interval tree leaf nodes.
  • the first to fifth interval tree leaf nodes can be determined as a target interval tree leaf node, and the 5th to 7th interval tree leaf nodes can be determined as Another kind of target interval tree leaf node, the 7th to 10th interval tree leaf node is determined as another target interval tree leaf node.
  • the values of leaf nodes of different target interval trees can be carried in different fragment data acquisition requests. After each connected node device receives the fragment data acquisition request, it can query the value corresponding to the value of each target interval tree leaf node. Target shard data. In this way, the newly added node device can concurrently request different fragmented data from all connected node devices, and the method of concurrently acquiring fragmented data has a fast data acquisition speed. In addition, it also reduces the synchronization pressure of node devices, and uses multi-node device synchronization instead of requesting fragmented data from a single node device.
  • a new node device needs to request a total of 1000 pieces of data from the 1001th slice to the 2000th slice, and it may request a total of 10 pieces of data from the 1001th to the 1010th slice from the connecting node device 1, and then send a request to the connected node device 1.
  • Node 2 requests 10 pieces of data from 1011th to 1020th, and so on.
  • S403 Integrate each target segment data into interval data of the target block interval corresponding to the target interval data tree.
  • S404 Obtain interval data of each block interval, and integrate the interval data of each block interval to obtain blockchain data.
  • the newly added node device can detect whether all the segment data in the target block interval has been downloaded, and if so, it can integrate all the acquired target segment data into the interval data of the target block interval. If not, you can query the missing fragment data in the target block interval and obtain the missing fragment data until all the fragment data in the target block interval have been obtained. Use the same as the interval data to obtain the target block interval In this way, the interval data of each block interval in the block chain data can be obtained, and the interval data of each block interval can be integrated to obtain the block chain data.
  • a new node device joins the blockchain network, it can be detected whether the current block height is greater than n, and if so, the execution of the above-mentioned data tree corresponding to the blockchain data obtained from the first connected node device is triggered. , And based on the value of the leaf node of the target total tree in the total data tree, the step of obtaining the target interval data tree corresponding to the leaf node of the target total tree from the second connecting node device. If not, you can use block synchronization to synchronize the blockchain data.
  • the embodiments of the present application can increase the speed at which newly-added node devices synchronize blockchain data.
  • FIG. 5 is a schematic flowchart of another method for synchronizing blockchain data in an embodiment of the present application.
  • the method in the embodiment of the present application may be executed by a newly added node device of the blockchain network.
  • the method of the embodiment of the present application includes the following steps.
  • step S501 When a new node device joins the blockchain network, the data tree corresponding to the blockchain data can be obtained from the first connection node device, and based on the value of the target tree leaf node in the data tree, from the second connection The node device obtains the target interval data tree corresponding to the leaf node of the target total tree.
  • step S501 For the specific implementation of step S501, reference may be made to the related description of step S401 in the foregoing embodiment, which will not be repeated here.
  • S502 Verify the obtained target interval data tree corresponding to the leaf node of the target total tree. If the verification is passed, then based on the value of the different target interval tree leaf node in the target interval data tree from each new node device corresponding The connected node device obtains at least one target fragment data in parallel.
  • an interval data tree corresponds to an interval root hash
  • a specific implementation manner for the newly added node device to verify the obtained target interval data tree corresponding to the leaf node of the target total tree may be: The value of each leaf node in the target interval data tree is integrated, and the string obtained by the integration process is hashed to obtain the hash corresponding to the string. Further, the hash corresponding to the character string can be compared with the interval root hash corresponding to the target interval data tree. If the hash corresponding to the character string is the same as the interval root hash corresponding to the target interval data tree, it is determined to The target interval data tree corresponding to the leaf node of the target total tree passes the verification.
  • the integration processing of the acquired values of the leaf nodes in the target interval data tree may be: sequentially concatenating the values of the leaf nodes in the target interval data tree into a character string.
  • the target interval data tree is shown in Figure 3b
  • the values of each leaf node in the target interval data tree can be spliced into a string from left to right.
  • the value of each leaf node in the total data tree is the interval root hash of the interval data tree corresponding to each leaf node. If the new node device compares the hash corresponding to the string with the target interval data tree If the corresponding interval root hash is the same, the value of the leaf node corresponding to the target interval data tree can be obtained from the total data tree, and the interval root hash corresponding to the target interval data tree can be compared with the value of the leaf node corresponding to the target interval data tree. If the comparison shows that the interval root hash corresponding to the target interval data tree is the same as the value of the leaf node corresponding to the target interval data tree, it is determined that the target interval data tree corresponding to the target total tree leaf node passes the verification.
  • the new target interval data tree can be obtained from other node devices other than the second connected node device until the obtained new target interval data tree is verified.
  • S503 Integrate each target segment data into interval data of the target block interval corresponding to the target interval data tree.
  • step S504 Obtain interval data of each block interval, and integrate the interval data of each block interval to obtain blockchain data.
  • the specific implementation manners of step S503 to step S504 can refer to the related description of step S403 to step S404 in the foregoing embodiment, which will not be repeated here.
  • the target scores corresponding to the different target interval tree leaf nodes are obtained in parallel from each connected node device corresponding to the newly added node device.
  • the specific implementation of the slice data may be: sending different slice data acquisition requests in parallel to each connected node device corresponding to the newly added node device, and each slice data acquisition request includes different target interval tree leaf nodes in the target interval data tree The value of so that each connected node device obtains the target fragment data corresponding to different target interval tree leaf nodes based on the value of the target interval tree leaf node in the fragment data acquisition request respectively received. Further, the newly added node device may receive the target fragment data corresponding to each of the different target interval tree leaf nodes returned by each connected node device.
  • the target scores corresponding to the different target interval tree leaf nodes are obtained in parallel from each connected node device corresponding to the newly added node device.
  • the specific implementation of the slice data can also be: obtain the Internet Protocol IP list from each connected node device corresponding to the newly added node device, connect each target node device corresponding to the IP list, and based on different target intervals in the target interval data tree The value of the tree leaf node exchanges fragmentation data with each target node device to obtain the target fragmentation data corresponding to each of the tree leaf nodes of different target intervals. In this way, the missing piece data can be exchanged with each target node device corresponding to the IP list, the piece data can be exchanged, and the download speed of the piece data can be accelerated.
  • the newly added node device can be based on the node position of the target interval data tree corresponding to the total tree, and each piece of data corresponds to the leaf node position of the target interval data tree, and compare its own existing pieces Data, so as to determine the missing piece of data, and then exchange the missing piece of data with each target node device corresponding to the IP list.
  • the resources of each node are effectively used, and the synchronization speed is accelerated.
  • the exchange of fragmented data can be performed in parallel with the aforementioned different target interval tree leaf node values in the target interval data tree, which are obtained from each connected node device corresponding to the newly added node device in parallel.
  • the flow of the target fragmented data corresponding to each leaf node is parallel, thereby improving the efficiency of obtaining fragmented data.
  • the obtained target interval data tree corresponding to the leaf node of the target total tree can be checked. If the check is passed, the value of the different target interval tree leaf node in the target interval data tree is added from Each connected node device corresponding to the node device obtains at least one target piece of data in parallel, which helps to improve the accuracy of the obtained target piece of data.
  • the embodiment of the present application also provides a computer storage medium, the computer storage medium stores program instructions, and when the program instructions are executed, they are used to implement the corresponding methods described in the foregoing embodiments.
  • the computer-readable storage medium may be non-volatile or volatile.
  • FIG. 6 is a schematic structural diagram of a block chain data synchronization device according to an embodiment of the present application.
  • the block chain data synchronization device according to an embodiment of the present application can be set in a newly added node of the block chain network. In the device.
  • the device includes the following structure.
  • the communication module 60 is used to obtain the data tree corresponding to the blockchain data from the first connecting node device when a new node device joins the blockchain network, and based on the value of the target tree leaf node in the data tree Acquire the target interval data tree corresponding to the leaf node of the target total tree from the second connecting node device.
  • the communication module 60 is further configured to obtain at least one target segment data in parallel from each connection node device corresponding to the newly added node device based on the values of different target interval tree leaf nodes in the target interval data tree, wherein: Each of the target fragment data is fragment data corresponding to each of the different target interval tree leaf nodes.
  • the processing module 61 is configured to integrate each of the target segment data into the interval data of the target block interval corresponding to the target interval data tree, obtain the interval data of the respective block interval, and compare the Integrate the interval data to obtain the blockchain data.
  • one said data tree corresponds to one blockchain root hash
  • said processing module 61 is further configured to obtain the blockchain root hash corresponding to said data tree from each connected node device. Hope, and compare the root hashes of the blockchains returned by the respective connected node devices; if the root hashes of the blockchains with a preset number threshold are the same, then the same blockchain root hashes It is hoped that it is the fingerprint data of the blockchain; it is determined whether the root hash of the blockchain corresponding to the total tree of the data obtained from the first connecting node device matches the fingerprint data of the blockchain, and if it matches, the execution is triggered The step of obtaining the target interval data tree corresponding to the leaf node of the target total tree from the second connecting node device based on the value of the leaf node of the target total tree in the total data tree.
  • the processing module 61 is further configured to verify the acquired target interval data tree corresponding to the leaf node of the target total tree; if the verification passes, trigger the execution of the target interval data tree The step of obtaining at least one target fragment data in parallel from each connection node device corresponding to the newly added node device with the value of the leaf node of the different target interval tree in the tree.
  • one interval data tree corresponds to an interval root hash
  • the processing module 61 is specifically configured to perform integration processing on the obtained values of each leaf node in the target interval data tree, and perform processing on the Perform hash calculation on the character string obtained by the integration process to obtain the hash corresponding to the character string; compare the hash corresponding to the character string with the interval root hash corresponding to the target interval data tree; If the hash corresponding to the character string is the same as the interval root hash corresponding to the target interval data tree, it is determined that the target interval data tree corresponding to the target total tree leaf node passes the verification.
  • the value of each leaf node in the total data tree is the interval root hash of the interval data tree corresponding to each leaf node
  • the processing module 61 is specifically configured to compare and obtain the character string If the corresponding hash is the same as the interval root hash corresponding to the target interval data tree, then the value of the leaf node corresponding to the target interval data tree is obtained from the total data tree; compared with those corresponding to the target interval data tree
  • the interval root hash and the value of the leaf node corresponding to the target interval data tree are compared, and if the interval root hash corresponding to the target interval data tree is the same as the value of the leaf node corresponding to the target interval data tree, it is determined
  • the verification of the target interval data tree corresponding to the leaf node of the target total tree is passed.
  • the processing module 61 is specifically configured to send different fragmented data acquisition requests in parallel to each connected node device corresponding to the newly added node device through the communication module 60, and each fragmented data acquisition request includes The value of the leaf node of the different target interval tree in the target interval data tree, so that each connected node device obtains the different value based on the value of the leaf node of the target interval tree in the fragmented data acquisition request respectively received The target fragment data corresponding to each of the leaf nodes of the target interval tree; receiving the target fragment data corresponding to the different target interval tree leaf nodes returned by the respective connecting node devices.
  • the processing module 61 is specifically configured to obtain an Internetwork Protocol IP list from each connected node device corresponding to the newly added node device; connect each target node device corresponding to the IP list through the communication module 60 , And exchange fragmentation data with each target node device based on the values of different target interval tree leaf nodes in the target interval data tree to obtain target fragmentation data corresponding to each of the different target interval tree leaf nodes.
  • FIG. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
  • the electronic device may be a newly-added node device in the above-mentioned blockchain network.
  • the electronic device of the embodiment of the present application includes a power supply module, etc.
  • the structure includes a processor 701, a storage device 702, and a communication interface 703.
  • the processor 701, the storage device 702, and the communication interface 703 can exchange data, and the processor 701 implements the corresponding blockchain data synchronization function.
  • the storage device 702 may include a volatile memory (volatile memory), such as a random-access memory (random-access memory). memory, RAM); the storage device 702 may also include non-volatile memory (non-volatile memory), such as flash memory (flash memory), solid-state drive (solid-state drive, SSD), etc.; the storage device 702 also A combination of the above-mentioned types of memories may be included.
  • volatile memory volatile memory
  • RAM random-access memory
  • non-volatile memory non-volatile memory
  • flash memory flash memory
  • solid-state drive solid-state drive
  • the processor 701 may be a central processing unit (CPU). In an embodiment, the processor 701 may also be a graphics processor 701 (Graphics Processing Unit, GPU). The processor 701 may also be a combination of a CPU and a GPU. In the electronic device, multiple CPUs and GPUs may be included as needed to synchronize corresponding blockchain data. In one embodiment, the storage device 702 is used to store program instructions. The processor 701 may call the program instructions to implement various methods mentioned above in the embodiments of the present application.
  • the processor 701 of the electronic device invokes the program instructions stored in the storage device 702 for when it is detected that the electronic device joins the blockchain network, through the communication interface 703 obtains the data master tree corresponding to the blockchain data from the first connection node device, and obtains the target master tree from the second connection node device through the communication interface 703 based on the value of the leaf node of the target tree in the data master tree
  • the target interval data tree corresponding to the leaf node, each node device in the blockchain network stores each interval data tree obtained after slicing the interval data corresponding to each block interval in the blockchain data ,
  • the data master tree corresponding to the blockchain data generated based on the respective interval data trees, and each leaf node in the data master tree corresponds to the respective interval data tree one-to-one; based on the communication interface 703
  • the value of the leaf node of the different target interval tree in the target interval data tree obtains at least one target fragment data in parallel from each connected node device corresponding to the newly added node device, wherein each
  • one said data tree corresponds to one blockchain root hash
  • said processing module 61 is further configured to obtain the blockchain root hash corresponding to said data tree from each connected node device. Hope, and compare the root hashes of the blockchains returned by the respective connected node devices; if the root hashes of the blockchains with a preset number threshold are the same, then the same blockchain root hashes It is hoped that it is the fingerprint data of the blockchain; it is determined whether the root hash of the blockchain corresponding to the total tree of the data obtained from the first connecting node device matches the fingerprint data of the blockchain, and if it matches, the execution is triggered The step of obtaining the target interval data tree corresponding to the leaf node of the target total tree from the second connecting node device based on the value of the leaf node of the target total tree in the total data tree.
  • the processor 701 is further configured to verify the acquired target interval data tree corresponding to the leaf node of the target total tree; if the verification is passed, trigger execution of the target interval data tree The step of obtaining at least one target fragment data in parallel from each connection node device corresponding to the newly added node device with the value of the leaf node of the different target interval tree in the tree.
  • one interval data tree corresponds to an interval root hash
  • the processor 701 is specifically configured to perform integration processing on the obtained values of each leaf node in the target interval data tree, and perform processing on the Perform a hash calculation on the character string obtained through the integration process to obtain the hash corresponding to the character string;
  • the value of each leaf node in the total data tree is the interval root hash of the interval data tree corresponding to each leaf node
  • the processor 701 is specifically configured to compare and obtain the character string If the corresponding hash is the same as the interval root hash corresponding to the target interval data tree, then the value of the leaf node corresponding to the target interval data tree is obtained from the total data tree; compared with those corresponding to the target interval data tree If the interval root hash and the value of the leaf node corresponding to the target interval data tree are compared, if the interval root hash corresponding to the target interval data tree is the same as the value of the leaf node corresponding to the target interval data tree, it is determined The verification of the target interval data tree corresponding to the leaf node of the target total tree is passed.
  • the processor 701 is specifically configured to send different fragmented data acquisition requests in parallel to each connected node device corresponding to the newly added node device through the communication interface 703, and each fragmented data acquisition request includes The value of the leaf node of the different target interval tree in the target interval data tree, so that each connected node device obtains the different value based on the value of the leaf node of the target interval tree in the fragmented data acquisition request respectively received The target fragment data corresponding to each of the leaf nodes of the target interval tree; receiving the target fragment data corresponding to the different target interval tree leaf nodes returned by the respective connecting node devices.
  • the processor 701 is specifically configured to obtain an Internetwork Protocol IP list from each connected node device corresponding to the newly added node device; connect to each target node device corresponding to the IP list through the communication interface 703 , And exchange fragmentation data with each target node device based on the values of different target interval tree leaf nodes in the target interval data tree to obtain target fragmentation data corresponding to each of the different target interval tree leaf nodes.
  • the program can be stored in a computer readable storage medium. During execution, it may include the procedures of the above-mentioned method embodiments.
  • the storage medium may be a magnetic disk, an optical disc, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请应用于区块链技术领域中,公开了一种区块链数据的同步方法、装置及电子设备、存储介质,所述方法包括:从第一连接节点设备获取区块链数据对应的数据总树,并基于数据总树中目标总树叶子节点的值,从第二连接节点设备获取目标总树叶子节点对应的目标区间数据树;基于目标区间数据树中不同的目标区间树叶子节点的值从新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,将各个目标分片数据整合为目标区间数据树对应的目标块区间的区间数据,进而获取各个块区间的区间数据,并对各个块区间的区间数据进行整合,得到区块链数据,完成区块链数据的同步。采用这样的方式,有利于提高同步区块链数据的速度。

Description

一种区块链数据的同步方法、装置及电子设备、存储介质
本申请要求于2020年3月30日提交中国专利局、申请号为202010234819.X、申请名称为“一种区块链数据的同步方法、装置及电子设备、存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及区块链技术领域,尤其涉及一种区块链数据的同步方法、装置、及电子设备、存储介质。
背景技术
发明人意识到随着区块链运行,区块高度的逐渐增大,区块链数据也会越来越大,以太坊为例,截至2019年10月,块高度达到了8700000,全节点数据超过了2TB,而且仍在快速增长。对于新加入区块链网络的新增节点设备来说,同步历史区块链数据就需要数月,即便高配置机器,仍然需要数周时间,普通机器甚至都追赶不上数据区块的生成速度。因此,如何加快新增节点设备同步区块链中历史区块数据的速度,成为一个亟待解决的问题。
技术问题
有鉴于此,本申请实施例提供了一种区块链数据的同步方法、装置及电子设备、存储介质,有利于提高新增节点设备同步区块链数据的速度。
技术解决方案
本申请实施例的第一方面提供了一种区块链数据的同步方法,所述方法应用于区块链网络中的新增节点设备,所述方法包括:当新增节点设备加入区块链网络时,从第一连接节点设备获取区块链数据对应的数据总树,并基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树,所述区块链网络中的各个节点设备均存储有对所述区块链数据中的各个块区间对应的区间数据进行分片处理后得到的各个区间数据树,以及基于所述各个区间数据树生成的所述区块链数据对应的数据总树,所述数据总树中的各个叶子节点与所述各个区间数据树一一对应;基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,其中,各个所述目标分片数据为所述不同的目标区间树叶子节点各自对应的分片数据;将各个所述目标分片数据整合为所述目标区间数据树对应的目标块区间的区间数据;获取所述各个块区间的所述区间数据,并对所述各个块区间的所述区间数据进行整合,得到所述区块链数据;其中,所述第一连接节点设备和所述第二连接节点设备均为所述各个连接节点设备中的任一个,所述目标总树叶子节点为所述数据总树包括的各个总树叶子节点中的一个或者多个,所述目标区间树叶子节点为所述目标区间数据树包括的各个区间树叶子节点中一个或者多个。
本申请实施例的第二方面提供了一种区块链数据的同步装置,所述同步装置配置于区块链网络中的新增节点设备,包括:通信模块,用于当新增节点设备加入区块链网络时,从第一连接节点设备获取区块链数据对应的数据总树,并基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树;所述通信模块,还用于基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,其中,各个所述目标分片数据为所述不同的目标区间树叶子节点各自对应的分片数据;处理模块,用于将各个所述目标分片数据整合为所述目标区间数据树对应的目标块区间的区间数据,获取所述各个块区间的所述区间数据,并对所述各个块区间的所述区间数据进行整合,得到所述区块链数据。
本申请实施例的第三方面提供了一种电子设备,包括处理器、存储器和通信接口,所述处理器、存储器和通信接口相互连接,其中,所述存储器用于存储支持终端执行上述方法的计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,执行如下步骤:通过通信接口从第一连接节点设备获取区块链数据对应的数据总树,并基于所述数据总树中目标总树叶子节点的值,通过通信接口从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树,所述区块链网络中的各个节点设备均存储有对所述区块链数据中的各个块区间对应的区间数据进行分片处理后得到的各个区间数据树,以及基于所述各个区间数据树生成的所述区块链数据对应的数据总树,所述数据总树中的各个叶子节点与所述各个区间数据树一一对应;通过通信接口703基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,其中,各个所述目标分片数据为所述不同的目标区间树叶子节点各自对应的分片数据;将各个所述目标分片数据整合为所述目标区间数据树对应的目标块区间的区间数据;获取所述各个块区间的所述区间数据,并对所述各个块区间的所述区间数据进行整合,得到所述区块链数据。
本申请实施例的第四方面提供了本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行上述区块链数据的同步方法。其中,该计算机可读存储介质可以是非易失性,也可以是易失性。
有益效果
本申请实施例中,可以提高区块链网络中新增节点设备同步区块链数据的速度。
附图说明
图1是本申请实施例提供的一种区块链的结构示意图。
图2是本申请实施例提供的一种区块链网络的架构示意图。
图3a是本申请实施例提供的一种区块链数据进行分片处理的示意图。
图3b是本申请实施例的一种区间数据树的结构示意图。
图3c是本申请实施例的一种数据总树的结构示意图。
图4是本申请实施例的一种区块链数据的同步方法的流程示意图。
图5是本申请实施例的另一种区块链数据的同步方法的流程示意图。
图6是本申请实施例的一种区块链数据的同步装置的结构示意图。
图7是本申请实施例的一种电子设备的结构示意图。
本发明的实施方式
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便理解本申请实施例。
应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。
区块链(Block Chain)是一种按照时间顺序将数据区块以顺序相连的方式组合成的一种链式数据结构,并以密码学方式保证数据不可篡改和不可伪造的分布式账本。多个独立的分布式节点(即区块链网络的新增节点设备)保存相同的记录。区块链技术实现了去中心化,成为了可信的数字资产存储、转移和交易的基石。
以图1所示的区块链的结构示意图为例,每当有新的数据需要写入区块链,这些数据会汇总到一个区块(block)中,添加在已有区块链的末端,通过共识算法保证每个节点新添加的区块是完全相同的。每个区块内记录了若干条交易记录,同时包含了前一个区块的哈希(哈希)值,所有区块就是通过这种方式保存前一个区块中的哈希,按顺序相连,组成了区块链。区块链中下一个区块的区块头中会存储前一个区块的哈希,当前一个区块中的交易数据发生变化时,本区块的哈希也会随之改变,因此通过上传至区块链网络中的交易数据难以被篡改,在区块链上进行交易实现了交易过程的公开透明,提高了交易数据的可靠性。
为了更好的理解本申请实施例公开的一种区块链数据的同步方法,下面首先对本申请实施例适用的区块链系统进行描述。
请参见图2,图2是本申请实施例公开的一种区块链网络的架构示意图。区块链网络包括多个节点设备,该区块链网络可以包括新增节点设备200,以及该新增节点设备200对应的连接节点设备201和连接节点设备202。
在一个实施例中,当区块链网络中的各个节点设备检测到当前区块高度为n(大于0的整数,例如1000)的整数倍时,可以基于预设分片规则对自身磁盘上的历史区块链数据进行分片处理,得到历史区块链数据对应的至少一个分片,每n个数据区块对应一个块区间。进一步地,可以计算各分片的哈希。其中,当前区块高度是指区块链网络维护的区块链中最新区块的序列号。
示例性地,参见图3a所示,基于预设分片规则对磁盘上的区块数据文件进行分片处理的具体实施方式可以为:区块链网络中的各个节点设备可以每隔n个数据区块,将磁盘上的历史区块链数据分片,自上次分片结束的标记位开始,每1MB一片,并计算每片的哈希。
进一步地,上述节点设备可以将各分片的哈希按顺序组成当前n个数据区块对应块区间的2层区间数据树,并将该区间数据树保存在本地,作为区间分片索引,方便查找。示例性地,该区间数据树如图3b所示,一个区间数据树对应一个区间根哈希,区间数据树中的每一个叶子节点(以下简称区间树叶子节点)的值为对对应的分片数据进行哈希计算,得到的哈希,每一个区间树叶子节点与分片数据一一对应。节点设备可以通过区间数据树中各个区间树叶子节点的值查询与各个区间树叶子节点唯一对应的分片数据。
采用与上述相似的流程,上述节点设备可以得到历史区块链数据中各个块区间对应的区间数据树。进一步地,可以将各个区间数据树对应的区间根哈希以2层MerkleTree结构存储,得到历史区块链数据对应的数据总树,以及该数据总树对应的区块链根哈希,并保存本地。
示例性地,该历史区块链数据对应的数据总树如图3c所示,一个数据总树对应一个区块链根哈希。数据总树中的每一个叶子节点(以下简称总树叶子节点)的值为对应区间数据树的区间根哈希,节点设备可以通过数据总树中各个总树树叶子节点的值查询与各个总树叶子节点唯一对应的区间数据树。
进一步地,在一个实施例中,当新增节点设备加入区块链网络时,可以从第一连接节点设备获取区块链数据对应的数据总树,并基于数据总树中目标总树叶子节点的值,从第二连接节点设备获取目标总树叶子节点对应的目标区间数据树。进一步地,可以基于目标区间数据树中不同的目标区间树叶子节点的值从新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,其中,各个目标分片数据为不同的目标区间树叶子节点各自对应的分片数据,将各个目标分片数据整合为目标区间数据树对应的目标块区间的区间数据。进而可以获取上述各个块区间的区间数据,并对各个块区间的区间数据进行整合,得到区块链数据,完成区块链数据的同步。采用这样的方式,有利于提高新增节点设备同步区块链数据的速度。
可以理解的是,本申请实施例描述的区块链网络是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域普通技术人员可知,随着系统架构的演变和新业务场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。
再请参见图4,是本申请实施例的一种区块链数据的同步方法的流程示意图,本申请实施例的所述方法可以由区块链网络的新增节点设备来执行。本申请实施例的所述方法包括如下步骤。
S401:当新增节点设备加入区块链网络时,可以从第一连接节点设备获取区块链数据对应的数据总树,并基于数据总树中目标总树叶子节点的值,从第二连接节点设备获取目标总树叶子节点对应的目标区间数据树。
其中,上述第一连接节点设备和第二连接设备均为新增节点设备对应的各个连接节点设备中的任一个,第一连接节点设备和第二连接设备可以相同或者不同,目标总树叶子节点可以为数据总树包括的各个总树叶子节点中的一个或者多个。
在一个实施例中,区块链网络中的各个节点设备均存储有对区块链数据中的各个块区间对应的区间数据进行分片处理后得到的各个区间数据树,以及基于各个区间数据树生成的区块链数据对应的数据总树,该数据总树中的各个叶子节点与各个区间数据树一一对应。其中,该区间数据树和数据总树的详细生成过程,可以参见上述实施例中对图3a~图3c的具体描述,此处不再赘述。
进一步地,在一个实施例中,由于一个数据总树对应一个区块链根哈希,新增节点可以向各个连接节点设备获取数据总树对应的区块链根哈希,并对比各个连接节点设备返回的区块链根哈希,若对比得到预设数量阈值区块链根哈希相同,则将相同的区块链根哈希确定为区块链指纹数据。
示例性地,假设新增节点设备对应的连接节点设备为1000,预设数量阈值为1000*2/3,新增节点设备加入区块链网络后,可以向上述1000个连接节点请求区块链根哈希,当有超过1000*2/3的区块链根哈希一致时,采用此区块链根哈希为区块链指纹数据。
进一步地, 可以判断从第一连接节点设备获取的数据总树对应的区块链根哈希与上述区块链指纹数据是否匹配,若判断出从第一连接节点设备获取的数据总树对应的区块链根哈希与区块链指纹数据匹配,则触发执行基于数据总树中目标总树叶子节点的值,从第二连接节点设备获取目标总树叶子节点对应的目标区间数据树的步骤。
或者,若判断出从第一连接节点设备获取的数据总树对应的区块链根哈希与区块链指纹数据不匹配,则可以从其他连接节点设备获取数据总树,直至获取到的数据总树对应的区块链根哈希与上述区块链指纹数据匹配。
其中,作为一种可行的实施方式,可以对比从第一连接节点设备获取的数据总树对应的区块链根哈希与区块链指纹数据,若对比得到两者相同,则可以确定两者匹配。反之,则两者不匹配。
在一个实施例中,新增节点设备可以向第二连接节点设备请求全部或者部分区间数据树(即上述目标区间数据树),具体地,新增节点设备可以向第二连接节点发送区间数据树获取请求,该区间数据树获取请求携带有目标区间数据树对应目标总树叶子节点的值。第二连接节点可以查找目标总树叶子节点的值对应的目标区间数据树,并将目标区间数据树返回至新增节点设备。
示例性地,目标总树叶子节点的值为目标数据区间数据树对应的区间根哈希,假设数据总树中的第二个叶子节点为目标总树叶子节点,该目标叶子节点的值是h002,新增节点设备可以将h002携带在发送至第二连接节点设备的区间数据树获取请求中,第二连接节点设备收到该请求后,可以查找h002对应的目标区间数据树,并将目标区间数据树返回至新增节点设备。
S402:基于目标区间数据树中不同的目标区间树叶子节点的值从新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据。其中,各个目标分片数据为不同的目标区间树叶子节点各自对应的分片数据,目标区间树叶子节点为目标区间数据树包括的各个区间树叶子节点中一个或者多个。
在一个实施例中,新增节点设备可以基于指示信息对目标区间数据树中的各个区间树叶子节点进行划分,划分至同一区间的一个或者多个区间树叶子节点作为目标区间树叶子节点。
例如,假设目标区间数据树中包括10个叶子节点,可以基于指示信息将第1~5个区间树叶子节点确定为一种目标区间树叶子节点,将第5~7个区间树叶子节点确定为另一种目标区间树叶子节点,将第7~10个区间树叶子节点确定为又一种目标区间树叶子节点。
进一步地,可以将不同的目标区间树叶子节点的值携带在不同的分片数据获取请求中,各个连接节点设备接收到分片数据获取请求后,可以查询各个目标区间树叶子节点的值对应的目标分片数据。采用这样的方式,新增节点设备可以向所有连接节点设备并发请求不同的分片数据,采用并发获取分片数据的方式,数据获取速度快。除此之外,还减轻了节点设备的同步压力,采用多节点设备同步,而非向单一节点设备请求分片数据。
示例性地,假设新增节点设备需要请求从第1001片到第2000片,总共1000片分片数据,它可以会向连接节点设备1请求第1001到第1010总共10片分片数据,向连接节点2请求第1011到第1020共10片分片数据,以此类推。
S403:将各个目标分片数据整合为目标区间数据树对应的目标块区间的区间数据。
S404:获取各个块区间的区间数据,并对各个块区间的区间数据进行整合,得到区块链数据。
在一个实施例中,新增节点设备可以检测目标块区间中的所有分片数据是否均已下载,若是,则可以将获取到的所有目标分片数据整合为目标块区间的区间数据。若否,则可以查询目标块区间中缺失的分片数据,并获取缺失的分片数据,直至目标块区间中的所有分片数据获取完毕。采用与获取目标块区间的区间数据相同的 方式,可以获取区块链数据中各个块区间的区间数据,并对各个块区间的区间数据进行整合,得到区块链数据。
在一个实施例中,当新增节点设备加入区块链网络时,可以检测当前区块高度是否大于n,若是,则触发执行上述从第一连接节点设备获取区块链数据对应的数据总树,并基于数据总树中目标总树叶子节点的值,从第二连接节点设备获取目标总树叶子节点对应的目标区间数据树的步骤。若否,则可以采用块同步方式同步区块链数据。
本申请实施例,可以提高新增节点设备同步区块链数据的速度。
再请参见图5,是本申请实施例的另一种区块链数据的同步方法的流程示意图,本申请实施例的所述方法可以由区块链网络的新增节点设备来执行。本申请实施例的所述方法包括如下步骤。
S501:当新增节点设备加入区块链网络时,可以从第一连接节点设备获取区块链数据对应的数据总树,并基于数据总树中目标总树叶子节点的值,从第二连接节点设备获取目标总树叶子节点对应的目标区间数据树。其中,步骤S501的具体实施方式可以参见上述实施例中步骤S401的相关描述,此处不再赘述。
S502:对获取到的目标总树叶子节点对应的目标区间数据树进行校验,若校验通过,则基于目标区间数据树中不同的目标区间树叶子节点的值从新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据。
在一个实施例中,一个区间数据树对应一个区间根哈希,新增节点设备对获取到的目标总树叶子节点对应的目标区间数据树进行校验的具体实施方式可以为:对获取到的目标区间数据树中各个叶子节点的值进行整合处理,并对整合处理得到的字符串进行哈希计算,得到字符串对应的哈希。进一步地,可以将字符串对应的哈希与目标区间数据树对应的区间根哈希进行对比,若对比得到字符串对应的哈希与目标区间数据树对应的区间根哈希相同,则确定对目标总树叶子节点对应的目标区间数据树校验通过。
其中,在一个实施例中,对获取到的目标区间数据树中各个叶子节点的值进行整合处理可以为:依次将目标区间数据树中各个叶子节点的值拼接成一个字符串。示例性地,假设目标区间数据树如图3b,可以从左至右将目标区间数据树中各个叶子节点的值(即各分片数据对应的哈希)拼接成一个字符串。
在一个实施例中,数据总树中的各个叶子节点的值为各个叶子节点各自对应的区间数据树的区间根哈希,若新增节点设备对比得到字符串对应的哈希与目标区间数据树对应的区间根哈希相同,则可以在数据总树中获取目标区间数据树对应的叶子节点的值,并对比目标区间数据树对应的区间根哈希与目标区间数据树对应的叶子节点的值,若对比得到目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值相同,则确定对目标总树叶子节点对应的目标区间数据树校验通过。
或者,若对比得到目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值不相同,则确定对目标总树叶子节点对应的目标区间数据树校验不通过。则可以向处第二连接节点设备以外的其他节点设备获取新的目标区间数据树,直至对获取到的新的目标区间数据树校验通过。
S503:将各个目标分片数据整合为目标区间数据树对应的目标块区间的区间数据。
S504:获取各个块区间的区间数据,并对各个块区间的区间数据进行整合,得到区块链数据。其中,步骤S503~步骤S504的具体实施方式可以参见上述实施例中步骤S403~步骤S404的相关描述,此处不再赘述。
在一个实施例中,基于目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取所述不同的目标区间树叶子节点各自对应的目标分片数据的具体实施方式可以为:向新增节点设备对应的各个连接节点设备并行发送不同的分片数据获取请求,每个分片数据获取请求包括目标区间数据树中不同的目标区间树叶子节点的值,以使各个连接节点设备基于各自接收到的分片数据获取请求中的目标区间树叶子节点的值获取不同的目标区间树叶子节点各自对应的目标分片数据。进一步地,新增节点设备可以接收各个连接节点设备返回的不同的目标区间树叶子节点各自对应的目标分片数据。
在一个实施例中,基于目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取所述不同的目标区间树叶子节点各自对应的目标分片数据的具体实施方式还可以为:从新增节点设备对应的各个连接节点设备获取网际互连协议IP列表,连接IP列表对应的各个目标节点设备 ,并基于目标区间数据树中不同的目标区间树叶子节点的值与各个目标节点设备交换分片数据,以获取不同的目标区间树叶子节点各自对应的目标分片数据。采用这样的方式,可以向IP列表对应的各个目标节点设备交换各自拥有缺少的分片数据,进行交换分片数据,加快分片数据的下载速度。
其中,作为一种可行的实施方式,新增节点设备可以基于目标区间数据树对应于总树的节点位置,各分片数据对应于目标区间数据树的叶子节点位置,对比自身已有的分片数据,从而确定出自身缺少的分片数据,进而与IP列表对应的各个目标节点设备交换这部分缺少的分片数据。有效利用了各节点的资源,加快了同步速度。
可以理解的是,分片数据的交换可以与上述基于目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取所述不同的目标区间树叶子节点各自对应的目标分片数据的流程并行,从而提高分片数据的获取效率。
本申请实施例中,可以对获取到的目标总树叶子节点对应的目标区间数据树进行校验,若校验通过,则基于目标区间数据树中不同的目标区间树叶子节点的值从新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,有利于提高所获取目标分片数据的准确度。
本申请实施例还提供了一种计算机存储介质,该计算机存储介质中存储有程序指令,该程序指令被执行时,用于实现上述实施例中描述的相应方法。其中,该计算机可读存储介质可以是非易失性,也可以是易失性。
再请参见图6,是本申请实施例的一种区块链数据的同步装置的结构示意图,本申请实施例的所述区块链数据的同步装置可以设置在区块链网络的新增节点设备中。
本申请实施例的所述装置的一个实现方式中,所述装置包括如下结构。
通信模块60,用于当新增节点设备加入区块链网络时,从第一连接节点设备获取区块链数据对应的数据总树,并基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树。
所述通信模块60,还用于基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,其中,各个所述目标分片数据为所述不同的目标区间树叶子节点各自对应的分片数据。
处理模块61,用于将各个所述目标分片数据整合为所述目标区间数据树对应的目标块区间的区间数据,获取所述各个块区间的所述区间数据,并对所述各个块区间的所述区间数据进行整合,得到所述区块链数据。
在一个实施例中,一个所述数据总树对应一个区块链根哈希,所述处理模块61,还用于从所述各个连接节点设备获取所述数据总树对应的区块链根哈希,并对比所述各个连接节点设备返回的所述区块链根哈希;若对比得到预设数量阈值的所述区块链根哈希相同,则将所述相同的区块链根哈希确定为区块链指纹数据;判断从所述第一连接节点设备获取的所述数据总树对应的区块链根哈希与所述区块链指纹数据是否匹配,若匹配,则触发执行所述基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树的步骤。
在一个实施例中,处理模块61,还用于对获取到的所述目标总树叶子节点对应的目标区间数据树进行校验;若校验通过,则触发执行所述基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据的步骤。
在一个实施例中,一个所述区间数据树对应一个区间根哈希,处理模块61,具体用于对获取到的所述目标区间数据树中各个叶子节点的值进行整合处理,并对所述整合处理得到的字符串进行哈希计算,得到所述字符串对应的哈希;将所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希进行对比;若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过。
在一个实施例中,所述数据总树中的各个叶子节点的值为所述各个叶子节点各自对应的区间数据树的区间根哈希,处理模块61,具体用于若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则在所述数据总树中获取所述目标区间数据树对应的叶子节点的值;对比所述目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值,若对比得到所述目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过。
在一个实施例中,处理模块61,具体用于通过通信模块60向所述新增节点设备对应的各个连接节点设备并行发送不同的分片数据获取请求,每个所述分片数据获取请求包括所述目标区间数据树中不同的目标区间树叶子节点的值,以使所述各个连接节点设备基于各自接收到的所述分片数据获取请求中的目标区间树叶子节点的值获取所述不同的目标区间树叶子节点各自对应的目标分片数据;接收所述各个连接节点设备返回的所述不同的目标区间树叶子节点各自对应的目标分片数据。
在一个实施例中,处理模块61,具体用于从所述新增节点设备对应的各个连接节点设备获取网际互连协议IP列表;通过通信模块60连接所述IP列表对应的各个目标节点设备 ,并基于所述目标区间数据树中不同的目标区间树叶子节点的值与所述各个目标节点设备交换分片数据,以获取所述不同的目标区间树叶子节点各自对应的目标分片数据。
再请参见图7,是本申请实施例的一种电子设备的结构示意图,该电子设备可以为上述区块链网络中的新增节点设备,本申请实施例的所述电子设备包括供电模块等结构,并包括处理器701、存储装置702以及通信接口703。所述处理器701、存储装置702以及通信接口703之间可以交互数据,由处理器701实现相应的区块链数据的同步功能。
所述存储装置702可以包括易失性存储器(volatile memory),例如随机存取存储器(random-access memory,RAM);存储装置702也可以包括非易失性存储器(non-volatile memory),例如快闪存储器(flash memory),固态硬盘(solid-state drive,SSD)等;所述存储装置702还可以包括上述种类的存储器的组合。
所述处理器701可以是中央处理器701(central processing unit,CPU)。在一个实施例中,所述处理器701还可以是图形处理器701(Graphics Processing Unit,GPU)。所述处理器701也可以是由CPU和GPU的组合。在所述电子设备中,可以根据需要包括多个CPU和GPU进行相应的区块链数据的同步。在一个实施例中,所述存储装置702用于存储程序指令。所述处理器701可以调用所述程序指令,实现如本申请实施例中上述涉及的各种方法。
在第一个可能的实施方式中,所述电子设备的所述处理器701,调用所述存储装置702中存储的程序指令,用于当检测到电子设备加入区块链网络时,通过通信接口703从第一连接节点设备获取区块链数据对应的数据总树,并基于所述数据总树中目标总树叶子节点的值,通过通信接口703从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树,所述区块链网络中的各个节点设备均存储有对所述区块链数据中的各个块区间对应的区间数据进行分片处理后得到的各个区间数据树,以及基于所述各个区间数据树生成的所述区块链数据对应的数据总树,所述数据总树中的各个叶子节点与所述各个区间数据树一一对应;通过通信接口703基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,其中,各个所述目标分片数据为所述不同的目标区间树叶子节点各自对应的分片数据;将各个所述目标分片数据整合为所述目标区间数据树对应的目标块区间的区间数据;获取所述各个块区间的所述区间数据,并对所述各个块区间的所述区间数据进行整合,得到所述区块链数据;其中,所述第一连接节点设备和所述第二连接节点设备均为所述各个连接节点设备中的任一个,所述目标总树叶子节点为所述数据总树包括的各个总树叶子节点中的一个或者多个,所述目标区间树叶子节点为所述目标区间数据树包括的各个区间树叶子节点中一个或者多个。
在一个实施例中,一个所述数据总树对应一个区块链根哈希,所述处理模块61,还用于从所述各个连接节点设备获取所述数据总树对应的区块链根哈希,并对比所述各个连接节点设备返回的所述区块链根哈希;若对比得到预设数量阈值的所述区块链根哈希相同,则将所述相同的区块链根哈希确定为区块链指纹数据;判断从所述第一连接节点设备获取的所述数据总树对应的区块链根哈希与所述区块链指纹数据是否匹配,若匹配,则触发执行所述基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树的步骤。
在一个实施例中,处理器701,还用于对获取到的所述目标总树叶子节点对应的目标区间数据树进行校验;若校验通过,则触发执行所述基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据的步骤。
在一个实施例中,一个所述区间数据树对应一个区间根哈希,处理器701,具体用于对获取到的所述目标区间数据树中各个叶子节点的值进行整合处理,并对所述整合处理得到的字符串进行哈希计算,得到所述字符串对应的哈希;
将所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希进行对比;若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过。
在一个实施例中,所述数据总树中的各个叶子节点的值为所述各个叶子节点各自对应的区间数据树的区间根哈希,处理器701,具体用于若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则在所述数据总树中获取所述目标区间数据树对应的叶子节点的值;对比所述目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值,若对比得到所述目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过。
在一个实施例中,处理器701,具体用于通过通信接口703向所述新增节点设备对应的各个连接节点设备并行发送不同的分片数据获取请求,每个所述分片数据获取请求包括所述目标区间数据树中不同的目标区间树叶子节点的值,以使所述各个连接节点设备基于各自接收到的所述分片数据获取请求中的目标区间树叶子节点的值获取所述不同的目标区间树叶子节点各自对应的目标分片数据;接收所述各个连接节点设备返回的所述不同的目标区间树叶子节点各自对应的目标分片数据。
在一个实施例中,处理器701,具体用于从所述新增节点设备对应的各个连接节点设备获取网际互连协议IP列表;通过通信接口703连接所述IP列表对应的各个目标节点设备 ,并基于所述目标区间数据树中不同的目标区间树叶子节点的值与所述各个目标节点设备交换分片数据,以获取所述不同的目标区间树叶子节点各自对应的目标分片数据。
可参考前述各个附图所对应的实施例中相关内容的描述。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。
以上所揭露的仅为本申请的部分实施例而已,当然不能以此来限定本申请之权利范围,本领域普通技术人员可以理解实现上述实施例的全部或部分流程,并依本申请权利要求所作的等同变化,仍属于发明所涵盖的范围。

Claims (20)

  1. 一种区块链数据的同步方法,其中,所述方法包括:
    当新增节点设备加入区块链网络时,从第一连接节点设备获取区块链数据对应的数据总树,并基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树,其中,所述区块链网络中的各个节点设备均存储有对所述区块链数据中的各个块区间对应的区间数据进行分片处理后得到的各个区间数据树,以及基于所述各个区间数据树生成的所述区块链数据对应的数据总树,所述数据总树中的各个叶子节点与所述各个区间数据树一一对应;
    基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,其中,各个所述目标分片数据为所述不同的目标区间树叶子节点各自对应的分片数据;
    将各个所述目标分片数据整合为所述目标区间数据树对应的目标块区间的区间数据;
    获取所述各个块区间的所述区间数据,并对所述各个块区间的所述区间数据进行整合,得到所述区块链数据;
    其中,所述第一连接节点设备和所述第二连接节点设备均为所述各个连接节点设备中的任一个,所述目标总树叶子节点为所述数据总树包括的各个总树叶子节点中的一个或者多个,所述目标区间树叶子节点为所述目标区间数据树包括的各个区间树叶子节点中一个或者多个。
  2. 根据权利要求1所述的方法,其中,一个所述数据总树对应一个区块链根哈希,所述基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树之前,所述方法还包括:
    从所述各个连接节点设备获取所述数据总树对应的区块链根哈希,并对比所述各个连接节点设备返回的所述区块链根哈希;
    若对比得到预设数量阈值的所述区块链根哈希相同,则将所述相同的区块链根哈希确定为区块链指纹数据;
    判断从所述第一连接节点设备获取的所述数据总树对应的区块链根哈希与所述区块链指纹数据是否匹配,若匹配,则触发执行所述基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树的步骤。
  3. 根据权利要求1或2所述的方法,其中,所述基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据之前,所述方法还包括:
    对获取到的所述目标总树叶子节点对应的目标区间数据树进行校验;
    若校验通过,则触发执行所述基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据的步骤。
  4. 根据权利要求3所述的方法,其中,一个所述区间数据树对应一个区间根哈希,所述对获取到的所述目标总树叶子节点对应的目标区间数据树进行校验,包括:
    对获取到的所述目标区间数据树中各个叶子节点的值进行整合处理,并对所述整合处理得到的字符串进行哈希计算,得到所述字符串对应的哈希;
    将所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希进行对比;
    若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过。
  5. 根据权利要求4所述的方法,其中,所述数据总树中的各个叶子节点的值为所述各个叶子节点各自对应的区间数据树的区间根哈希,所述若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过,包括:
    若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则在所述数据总树中获取所述目标区间数据树对应的叶子节点的值;
    对比所述目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值,若对比得到所述目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过。
  6. 根据权利要求1所述的方法,其中,所述基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,包括:
    向所述新增节点设备对应的各个连接节点设备并行发送不同的分片数据获取请求,每个所述分片数据获取请求包括所述目标区间数据树中不同的目标区间树叶子节点的值,以使所述各个连接节点设备基于各自接收到的所述分片数据获取请求中的目标区间树叶子节点的值获取所述不同的目标区间树叶子节点各自对应的目标分片数据;
    接收所述各个连接节点设备返回的所述不同的目标区间树叶子节点各自对应的目标分片数据。
  7. 根据权利要求1所述的方法,其中,所述基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,包括:
    从所述新增节点设备对应的各个连接节点设备获取网际互连协议IP列表;
    连接所述IP列表对应的各个目标节点设备 ,并基于所述目标区间数据树中不同的目标区间树叶子节点的值与所述各个目标节点设备交换分片数据,以获取所述不同的目标区间树叶子节点各自对应的目标分片数据。
  8. 一种区块链数据的同步装置,其中,所述同步装置配置于区块链网络中的新增节点设备,包括:
    通信模块,用于当新增节点设备加入区块链网络时,从第一连接节点设备获取区块链数据对应的数据总树,并基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树;
    所述通信模块,还用于基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,其中,各个所述目标分片数据为所述不同的目标区间树叶子节点各自对应的分片数据;
    处理模块,用于将各个所述目标分片数据整合为所述目标区间数据树对应的目标块区间的区间数据,获取所述各个块区间的所述区间数据,并对所述各个块区间的所述区间数据进行整合,得到所述区块链数据。
  9. 一种电子设备,其中,包括处理器、存储器和通信接口,所述处理器、所述存储器和所述通信接口相互连接,其中,所述存储器用于存储计算机程序指令,所述处理器被配置用于执行所述程序指令,用于当新增节点设备加入区块链网络时,从第一连接节点设备获取区块链数据对应的数据总树,并基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树,其中,所述区块链网络中的各个节点设备均存储有对所述区块链数据中的各个块区间对应的区间数据进行分片处理后得到的各个区间数据树,以及基于所述各个区间数据树生成的所述区块链数据对应的数据总树,所述数据总树中的各个叶子节点与所述各个区间数据树一一对应;基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,其中,各个所述目标分片数据为所述不同的目标区间树叶子节点各自对应的分片数据;将各个所述目标分片数据整合为所述目标区间数据树对应的目标块区间的区间数据;获取所述各个块区间的所述区间数据,并对所述各个块区间的所述区间数据进行整合,得到所述区块链数据;其中,所述第一连接节点设备和所述第二连接节点设备均为所述各个连接节点设备中的任一个,所述目标总树叶子节点为所述数据总树包括的各个总树叶子节点中的一个或者多个,所述目标区间树叶子节点为所述目标区间数据树包括的各个区间树叶子节点中一个或者多个。
  10. 根据权利要求9所述的电子设备,其中,一个所述数据总树对应一个区块链根哈希,其中,所述识别结果包括所述特征图像的大小和所述特征图像中每一个特征点的值,所述处理器,还用于从所述各个连接节点设备获取所述数据总树对应的区块链根哈希,并对比所述各个连接节点设备返回的所述区块链根哈希;若对比得到预设数量阈值的所述区块链根哈希相同,则将所述相同的区块链根哈希确定为区块链指纹数据;判断从所述第一连接节点设备获取的所述数据总树对应的区块链根哈希与所述区块链指纹数据是否匹配,若匹配,则触发执行所述基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树的步骤。
  11. 根据权利要求10所述的电子设备,其中其中,所述处理器,还具体用于对获取到的所述目标总树叶子节点对应的目标区间数据树进行校验;若校验通过,则触发执行所述基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据的步骤基于预设概率算法对所述第一特征参数和所述第二特征参数进行计算,确定所述样本图像属于所述各个图像类别的初始概率;对各个所述初始概率进行归一化处理,得到所述样本图像属于所述各个图像类别的计算概率。
  12. 根据权利要求9所述的电子设备,其中,一个所述区间数据树对应一个区间根哈希,所述处理器,具体用于对获取到的所述目标区间数据树中各个叶子节点的值进行整合处理,并对所述整合处理得到的字符串进行哈希计算,得到所述字符串对应的哈希;将所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希进行对比;若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过。
  13. 根据权利要求9所述的电子设备,其中,所述数据总树中的各个叶子节点的值为所述各个叶子节点各自对应的区间数据树的区间根哈希,其中,所述处理器,具体用于若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则在所述数据总树中获取所述目标区间数据树对应的叶子节点的值;对比所述目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值,若对比得到所述目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过将所述样本图像的可信度与第一可信度阈值进行对比;若对比得到所述样本图像的可信度大于所述第一可信度阈值,则对所述样本图像添加可信样本标签。
  14. 根据权利要求13所述的电子设备,其中,所述处理器,具体用于向所述新增节点设备对应的各个连接节点设备并行发送不同的分片数据获取请求,每个所述分片数据获取请求包括所述目标区间数据树中不同的目标区间树叶子节点的值,以使所述各个连接节点设备基于各自接收到的所述分片数据获取请求中的目标区间树叶子节点的值获取所述不同的目标区间树叶子节点各自对应的目标分片数据;接收所述各个连接节点设备返回的所述不同的目标区间树叶子节点各自对应的目标分片数据。
  15. 根据权利要求9所述的电子设备,其中,所述处理器,具体用于从所述新增节点设备对应的各个连接节点设备获取网际互连协议IP列表;连接所述IP列表对应的各个目标节点设备 ,并基于所述目标区间数据树中不同的目标区间树叶子节点的值与所述各个目标节点设备交换分片数据,以获取所述不同的目标区间树叶子节点各自对应的目标分片数据。
  16. 一种计算机可读存储介质,其中,所述计算机可读存储介质中存储有计算机程序指令,所述计算机程序指令被处理器执行时实现以下步骤:
    当新增节点设备加入区块链网络时,从第一连接节点设备获取区块链数据对应的数据总树,并基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树,其中,所述区块链网络中的各个节点设备均存储有对所述区块链数据中的各个块区间对应的区间数据进行分片处理后得到的各个区间数据树,以及基于所述各个区间数据树生成的所述区块链数据对应的数据总树,所述数据总树中的各个叶子节点与所述各个区间数据树一一对应;基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据,其中,各个所述目标分片数据为所述不同的目标区间树叶子节点各自对应的分片数据;将各个所述目标分片数据整合为所述目标区间数据树对应的目标块区间的区间数据;获取所述各个块区间的所述区间数据,并对所述各个块区间的所述区间数据进行整合,得到所述区块链数据;其中,所述第一连接节点设备和所述第二连接节点设备均为所述各个连接节点设备中的任一个,所述目标总树叶子节点为所述数据总树包括的各个总树叶子节点中的一个或者多个,所述目标区间树叶子节点为所述目标区间数据树包括的各个区间树叶子节点中一个或者多个。
  17. 根据权利要求16所述的计算机可读存储介质,其中,基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树之前,还实现以下步骤:
    从所述各个连接节点设备获取所述数据总树对应的区块链根哈希,并对比所述各个连接节点设备返回的所述区块链根哈希;
    若对比得到预设数量阈值的所述区块链根哈希相同,则将所述相同的区块链根哈希确定为区块链指纹数据;
    判断从所述第一连接节点设备获取的所述数据总树对应的区块链根哈希与所述区块链指纹数据是否匹配,若匹配,则触发执行所述基于所述数据总树中目标总树叶子节点的值,从第二连接节点设备获取所述目标总树叶子节点对应的目标区间数据树的步骤。
  18. 根据权利要求17所述的计算机可读存储介质,其中,所述基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据之前,还实现以下步骤:
    对获取到的所述目标总树叶子节点对应的目标区间数据树进行校验;
    若校验通过,则触发执行所述基于所述目标区间数据树中不同的目标区间树叶子节点的值从所述新增节点设备对应的各个连接节点设备并行获取至少一个目标分片数据的步骤。
  19. 根据权利要求16所述的计算机可读存储介质,其中,一个所述区间数据树对应一个区间根哈希,所述对获取到的所述目标总树叶子节点对应的目标区间数据树进行校验时,实现以下步骤:
    对获取到的所述目标区间数据树中各个叶子节点的值进行整合处理,并对所述整合处理得到的字符串进行哈希计算,得到所述字符串对应的哈希;
    将所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希进行对比;
    若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过。
  20. 根据权利要求16所述的计算机可读存储介质,其中,所述数据总树中的各个叶子节点的值为所述各个叶子节点各自对应的区间数据树的区间根哈希,所述若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过时,实现以下步骤:
    若对比得到所述字符串对应的哈希与所述目标区间数据树对应的区间根哈希相同,则在所述数据总树中获取所述目标区间数据树对应的叶子节点的值;
    对比所述目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值,若对比得到所述目标区间数据树对应的区间根哈希与所述目标区间数据树对应的叶子节点的值相同,则确定对所述目标总树叶子节点对应的目标区间数据树校验通过。
PCT/CN2020/104847 2020-03-30 2020-07-27 一种区块链数据的同步方法、装置及电子设备、存储介质 WO2021196463A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010234819.XA CN111432009B (zh) 2020-03-30 2020-03-30 一种区块链数据的同步方法、装置及电子设备、存储介质
CN202010234819.X 2020-03-30

Publications (1)

Publication Number Publication Date
WO2021196463A1 true WO2021196463A1 (zh) 2021-10-07

Family

ID=71549119

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/104847 WO2021196463A1 (zh) 2020-03-30 2020-07-27 一种区块链数据的同步方法、装置及电子设备、存储介质

Country Status (2)

Country Link
CN (1) CN111432009B (zh)
WO (1) WO2021196463A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111432009B (zh) * 2020-03-30 2023-04-07 深圳壹账通智能科技有限公司 一种区块链数据的同步方法、装置及电子设备、存储介质
CN112565389B (zh) * 2020-11-30 2021-09-24 网易(杭州)网络有限公司 基于区块链的消息广播方法、装置、电子设备及存储介质
CN113760937A (zh) * 2021-09-17 2021-12-07 恒生电子股份有限公司 数据的查缺方法、装置、电子设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109542979A (zh) * 2018-11-19 2019-03-29 广州矩阵信息科技有限公司 一种区块链系统快速同步及简精数据存储的方式
CN110493325A (zh) * 2019-07-31 2019-11-22 阿里巴巴集团控股有限公司 区块链状态数据同步方法及装置、电子设备
KR102053253B1 (ko) * 2019-04-23 2019-12-06 한화시스템(주) 전술환경에서 블록체인에 기반한 정보 관리 방법
CN110543448A (zh) * 2019-07-22 2019-12-06 深圳壹账通智能科技有限公司 数据同步方法、装置、设备及计算机可读存储介质
CN111432009A (zh) * 2020-03-30 2020-07-17 深圳壹账通智能科技有限公司 一种区块链数据的同步方法、装置及电子设备、存储介质

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9911007B2 (en) * 2015-02-27 2018-03-06 Guardtime IP Holdings, Ltd. Redundant fail-safe synchronization in a data authentication infrastructure
CN107018125B (zh) * 2017-02-17 2019-08-09 阿里巴巴集团控股有限公司 一种区块链系统、数据存储方法及装置
CN108600353B (zh) * 2018-04-12 2021-01-12 北京天德科技有限公司 一种区块链节点的并行块同步方法
CN109033757B (zh) * 2018-07-19 2022-04-05 湖南岳麓山数据科学与技术研究院有限公司 一种数据共享方法及系统
CN109325855B (zh) * 2018-08-16 2021-01-26 北京京东尚科信息技术有限公司 区块链网络、部署方法及存储介质
CN109218079B (zh) * 2018-08-16 2021-09-10 北京京东尚科信息技术有限公司 一种区块链网络、部署方法及存储介质
CN109522362B (zh) * 2018-10-17 2020-09-15 北京瑞卓喜投科技发展有限公司 基于区块链数据的非完全数据同步方法、系统及设备
CN109714412B (zh) * 2018-12-25 2021-08-10 深圳前海微众银行股份有限公司 区块同步方法、装置、设备及计算机可读存储介质
WO2019120320A2 (en) * 2019-03-28 2019-06-27 Alibaba Group Holding Limited System and method for parallel-processing blockchain transactions
CN110737664B (zh) * 2019-10-21 2022-11-25 深圳前海微众银行股份有限公司 一种区块链节点同步的方法及装置
CN110837505B (zh) * 2019-11-06 2022-07-19 杭州复杂美科技有限公司 状态数据存储方法、状态数据同步方法、设备和存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109542979A (zh) * 2018-11-19 2019-03-29 广州矩阵信息科技有限公司 一种区块链系统快速同步及简精数据存储的方式
KR102053253B1 (ko) * 2019-04-23 2019-12-06 한화시스템(주) 전술환경에서 블록체인에 기반한 정보 관리 방법
CN110543448A (zh) * 2019-07-22 2019-12-06 深圳壹账通智能科技有限公司 数据同步方法、装置、设备及计算机可读存储介质
CN110493325A (zh) * 2019-07-31 2019-11-22 阿里巴巴集团控股有限公司 区块链状态数据同步方法及装置、电子设备
CN111432009A (zh) * 2020-03-30 2020-07-17 深圳壹账通智能科技有限公司 一种区块链数据的同步方法、装置及电子设备、存储介质

Also Published As

Publication number Publication date
CN111432009B (zh) 2023-04-07
CN111432009A (zh) 2020-07-17

Similar Documents

Publication Publication Date Title
US20200412526A1 (en) Method and apparatus for verifying smart contracts in blockchain, and storage medium
WO2021196463A1 (zh) 一种区块链数据的同步方法、装置及电子设备、存储介质
WO2021003985A1 (zh) 区块链数据归档存储方法、装置、计算机设备和存储介质
WO2021032138A1 (zh) 一种基于区块链系统的共识方法、装置及系统
EP3693886A1 (en) Optimizations for verification of interactions system and method
CN109542979B (zh) 一种区块链系统快速同步及简精数据存储的方式
US8171238B1 (en) Identification of data stored in memory
WO2021036702A1 (zh) 一种基于区块链系统的共识方法及装置
WO2020220641A1 (zh) 基于点对点网络的数据存储方法、装置、介质及服务器
CN111949672B (zh) 一种支持物联网数据增量更新的区块链存储方法
CN108874803B (zh) 数据存储方法、装置及存储介质
WO2020143317A1 (zh) 分片文件验证方法及终端设备
US10862672B2 (en) Witness blocks in blockchain applications
US20210303633A1 (en) Shard hashing
WO2014094441A1 (zh) 病毒检测方法及设备
CN102420771B (zh) 高速网络环境中提高tcp并发连接速度的方法
EP4379556A1 (en) Blockchain-based data processing method, and device and computer-readable storage medium
CN113826355A (zh) 短交易标识符冲突检测和协调
CN110989922A (zh) 一种分布式数据存储方法及系统
WO2023029731A1 (zh) 区块链系统中状态证明及执行区块的方法及装置
CN112069169A (zh) 区块数据存储方法、装置、电子设备及可读存储介质
CN109918451A (zh) 基于区块链的数据库管理方法及系统
CN115514644B (zh) 表项一致性检查方法、电子设备及存储介质
CN103957119A (zh) 一种采用mib文件对网络设备进行管理的方法及浏览器
CN112732789A (zh) 基于区块链的可搜索加密方法和电子设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20929471

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 13/01/2023)

122 Ep: pct application non-entry in european phase

Ref document number: 20929471

Country of ref document: EP

Kind code of ref document: A1