WO2018177190A1 - 一种区块链数据同步的方法和装置 - Google Patents

一种区块链数据同步的方法和装置 Download PDF

Info

Publication number
WO2018177190A1
WO2018177190A1 PCT/CN2018/080023 CN2018080023W WO2018177190A1 WO 2018177190 A1 WO2018177190 A1 WO 2018177190A1 CN 2018080023 W CN2018080023 W CN 2018080023W WO 2018177190 A1 WO2018177190 A1 WO 2018177190A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
blockchain
check result
synchronization
hash
Prior art date
Application number
PCT/CN2018/080023
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 WO2018177190A1 publication Critical patent/WO2018177190A1/zh

Links

Images

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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/565Conversion or adaptation of application format or content
    • H04L67/5651Reducing the amount or size of exchanged application data

Definitions

  • the present invention relates to the field of data processing technologies, and in particular, to a method and apparatus for synchronizing blockchain data.
  • Blockchain is an important concept of Bitcoin.
  • a blockchain is a string of data blocks generated by cryptography. Each block contains information about Bitcoin network transactions, which is used to verify the validity of its information. Sex and generate the next block.
  • An embodiment of the present invention provides a method and an apparatus for synchronizing blockchain data.
  • the hash check result corresponding to the blockchain data is first synchronized, and the service interaction is preferably completed, so that the amount of data is obtained. When it is large, it can improve synchronization efficiency.
  • an embodiment of the present invention provides a method for synchronizing blockchain data, where the method includes:
  • a hash algorithm is randomly selected to perform operation on the blockchain data to obtain a hash check result of the blockchain data.
  • the hash check result of the blockchain data is sent to the remaining terminals in the blockchain network, so that the remaining terminals perform data synchronization based on the hash check result of the blockchain data.
  • the hash check result of the blockchain data includes one or more of the following:
  • hash check result of the full amount of data corresponding to the blockchain data a hash check result of the new data corresponding to the blockchain data, and a single hash check result corresponding to the blockchain data.
  • the method further comprises: tagging the randomly selected hash algorithm, and transmitting the hashed algorithm of the tag to the remaining terminals in the blockchain network such that the remaining terminals are based on the tagged
  • the hash algorithm is used for data synchronization.
  • the method further includes: sending the newly added data to the remaining terminals in the blockchain network, so that the remaining terminals perform data synchronization based on the newly added data to obtain synchronized new data.
  • the method further includes: selecting the hash algorithm of the tag to perform operation on the newly added data of the synchronization, and obtaining a hash check result of the newly added data of the synchronization.
  • the method further includes: comparing a hash check result of the synchronized new data with a hash check result of any of the blockchain data, if the synchronized new data is added The hash check result is consistent with the hash check result of any of the blockchain data, and then the newly added data of the synchronization is verified to be correct.
  • an embodiment of the present invention provides a device for synchronizing blockchain data, where the device includes:
  • a determining module determining whether the size of the newly added data reaches a preset value for performing data synchronization
  • An operation module if the size of the newly added data reaches a preset value for performing data synchronization, randomly selecting a hash algorithm to perform operation on the blockchain data to obtain a hash check result of the blockchain data;
  • the sending module sends the hash check result of the blockchain data to the remaining terminals in the blockchain network, so that the remaining terminals perform data synchronization based on the hash check result of the blockchain data.
  • the hash check result of the blockchain data obtained by the operation module operation includes one or more of the following:
  • hash check result of the full amount of data corresponding to the blockchain data a hash check result of the new data corresponding to the blockchain data, and a single hash check result corresponding to the blockchain data.
  • the device further includes: a marking module, marking the randomly selected hash algorithm, and transmitting the hash algorithm marked by the marking module to the blockchain network by using the sending module
  • the remaining terminals cause the remaining terminals to perform data synchronization based on the hash algorithm marked by the tag module.
  • the sending module is further configured to: send the newly added data to the remaining terminals in the blockchain network, so that the remaining terminals perform data synchronization based on the newly added data to obtain synchronized new data.
  • the invention firstly synchronizes the hash check result corresponding to the blockchain data in the process of performing data synchronization, preferably completes the business interaction, and after the transaction is completed, when the network is idle, a large amount of newly added data is synchronized, so that the amount of data is When it is large, the synchronization efficiency can be improved, and at the same time, the user experience is improved by shortening the waiting time of the user during the data synchronization process.
  • FIG. 1 is a flowchart of a method for synchronizing blockchain data according to an embodiment of the present invention
  • FIG. 2 is a structural block diagram of an apparatus for synchronizing blockchain data according to an embodiment of the present invention.
  • the inventor has found that in the process of data synchronization, there may be a situation in which it takes a lot of time to synchronize new data due to excessive new data. Therefore, the hash check result corresponding to the blockchain data can be synchronized first, and the service interaction is preferably completed. After the transaction is completed, when the network is idle, a large amount of newly added data is synchronized, so that the synchronization efficiency can be improved when the amount of data is large. .
  • FIG. 1 is a flowchart of a method for synchronizing blockchain data according to an embodiment of the present invention. As shown in FIG. 1, a method for synchronizing blockchain data includes the following steps:
  • S101 Determine, according to the obtained blockchain data, a size of the corresponding new data.
  • the newly added data is often a tens of M high-definition image or a video-corresponding data.
  • S102 Determine whether the size of the newly added data reaches a preset value for performing data synchronization.
  • the size of the newly added data reaches a preset value for data synchronization. If the size of the newly added data is small, only a few tens of bytes can be in the blockchain.
  • the terminals of the network directly synchronize, and the time required for synchronization is in the order of seconds.
  • the method provided by the embodiment of the present invention performs data synchronization only when the size of the newly added data is greater than or equal to the preset value for performing data synchronization.
  • the hash check result of the blockchain data may be a hash check result of the full data corresponding to the blockchain data, or may be a hash check result of the new data corresponding to the blockchain data, or A single hash check result corresponding to the blockchain data.
  • S104 Send the hash check result of the blockchain data to the remaining terminals in the blockchain network, so that the remaining terminals perform data synchronization based on the hash check result of the blockchain data to obtain synchronized new data.
  • the hash check result corresponding to the blockchain data is often only a few tens of bytes, and the hash check result of the synchronous blockchain data between the terminals in the blockchain network only takes a few seconds.
  • the hash check result corresponding to the blockchain data is first synchronized, and the service interaction is preferably completed, so that when the amount of data is large, the synchronization efficiency can be improved.
  • the randomly selected hash algorithm is marked, and the marked hash algorithm is sent to the remaining terminals in the blockchain network, so that the remaining terminals perform data synchronization based on the labeled hash algorithm.
  • the embodiment of the present invention by marking the randomly selected hash algorithm, it is possible to avoid the occurrence of different hash check results due to different hash algorithms. If the hash check result is not a unique value, the accuracy of the newly added data cannot be judged based on the hash check result.
  • the hash algorithm maps binary values of arbitrary length to smaller binary values of fixed length. This small binary value is called a hash value.
  • a hash value is a unique and extremely compact numerical representation of a piece of data. If you hash a plaintext and even change only one letter of the paragraph, subsequent hashes will produce different values. It is computationally impossible to find two different inputs that are hashed to the same value, so the hash of the data can verify the integrity of the data.
  • a typical hash algorithm includes MD2, MD4, MD5, and SHA-1. The specific hash algorithm is a conventional algorithm and will not be described here.
  • the previously marked hash algorithm is selected to operate the newly added data to obtain a new synchronization. Increase the hash check result of the data.
  • the first method for verifying the newly added data of the synchronization is to compare the hash check result of the newly added data with the hash check result of the full amount of data corresponding to the blockchain data, if the newly added data is synchronized.
  • the hash check result is consistent with the hash check result of the full amount of data corresponding to the blockchain data, and the newly added data of the synchronization is verified to be correct.
  • the second method for verifying the newly added data of the synchronization is to compare the hash check result of the newly added data with the hash check result of the new data corresponding to the blockchain data, if the synchronization is newly added.
  • the hash check result of the data is consistent with the hash check result of the new data corresponding to the blockchain data, and the newly added data of the synchronization is verified to be correct.
  • the third method for verifying the newly added data of the synchronization is to compare the hash check result of the newly added data with the single hash check result corresponding to the blockchain data, and if the newly added data is synchronized, If the result of the check is consistent with the single hash check result corresponding to the blockchain data, the newly added data of the synchronization is verified to be correct.
  • the hash check result of the newly added data may be corresponding to the hash check result of the full data corresponding to the blockchain data, and the block chain data.
  • the hash check results of the newly added data are combined and compared, and will not be described here. Please refer to the foregoing.
  • the data synchronization process is newly performed on the new data corresponding to the blockchain data until the newly added data that is synchronized is verified as correct data.
  • the image file corresponding to the contract scan is uploaded to a terminal node.
  • the size of the data of the picture file corresponding to the scanned copy of the contract is 30M.
  • the inventors have found that if the existing blockchain technology is used to synchronize the new data to the remaining terminal nodes in the blockchain network, the process of synchronizing data often takes a long time. Conversely, since the hash check result corresponding to the newly added data is only a dozen bytes or tens of bytes, if the local terminal calculates the hash check result of the newly added data, it only takes milliseconds to complete. The entire process. Then, since the hash check result of the newly added data is only a few tens of bytes, it takes only a few seconds to synchronize the hash check result of the obtained new data to the remaining terminals in the blockchain network. The clock's time, thus, improves the efficiency of data synchronization.
  • the inventors considered that in the process of data synchronization, the hash check result is preferentially synchronized to quickly complete the service response.
  • the steps of the blockchain data synchronization are as follows:
  • the newly added data is: the data corresponding to the contract scan image file. Determine the size of the new data, the size of the new data is 30M.
  • the preset value for performing data synchronization is preset to be 20M. Since the size of the newly added data is 30M, the size of the newly added data is larger than the preset preset value of 20M for data synchronization. Therefore, it is judged that the size of the newly added data reaches the preset value for performing data synchronization.
  • the hash algorithm is randomly selected to operate on the blockchain data to obtain the corresponding hash check result.
  • the blockchain data is specifically the full amount of data corresponding to the blockchain data and the new data corresponding to the blockchain data.
  • the hash chain algorithm MD2 is used to hash the blockchain data, and the corresponding hash check result is obtained.
  • the hash check result corresponding to the blockchain data may be: a hash check result of the full data corresponding to the blockchain data, or may be: a hash check of the new data corresponding to the blockchain data.
  • the result is either: a single hash check result corresponding to the blockchain data.
  • the hash check result including the full amount of data corresponding to the blockchain data, the hash check result of the new data corresponding to the blockchain data, and the single hash check result corresponding to the blockchain data are sent to
  • the remaining terminals in the blockchain network cause the remaining terminals to perform data synchronization based on the hash check result described above.
  • the verification result is synchronized to complete the service response quickly. Since the hash result corresponding to the newly added data is only a dozen to several tens of bytes, the hash result of the newly added data of the local terminal operation can be completed only in milliseconds, thereby making the amount of data larger. When it is possible, the synchronization efficiency can be improved.
  • the correctness of the newly added data is determined according to the single hash check result corresponding to the blockchain data.
  • the correctness of the newly added data is determined according to the hash check result of the new data corresponding to the blockchain data and the hash check result of the full amount of data.
  • the single hash check result corresponding to the blockchain data is consistent with the hash check result of the synchronized new data, it is verified that the newly added data of the synchronization is correct.
  • the block hash data corresponds to a single hash check result
  • the hash check result of the new data corresponding to the blockchain data and the hash check result of the full data corresponding to the blockchain data, and the synchronization If the hash check results of the newly added data are inconsistent, it is verified that the newly added data of the synchronization is incorrect.
  • the marked algorithm is used to re-synchronize the newly added data until the correct synchronization is added.
  • the method for synchronizing blockchain data determines the size of the corresponding new data according to the acquired blockchain data; and determines whether the size of the newly added data reaches a pre-synchronization of data synchronization. Set the value; if the size of the newly added data reaches the preset value for data synchronization, the hash algorithm is randomly selected to perform operation on the blockchain data, and the corresponding hash check result is obtained; the hash check result is sent to the area.
  • the remaining terminals in the blockchain network cause the remaining terminals to perform data synchronization based on the hash check result.
  • the data synchronization process in the embodiment of the present invention is a hash check result corresponding to the priority synchronization blockchain data. Therefore, the technical solution provided by the present invention can improve the synchronization efficiency when the amount of data is large, and at the same time, the user experience time is improved by shortening the waiting time of the user during the data synchronization process.
  • an apparatus for synchronizing blockchain data includes: a determining module 201, a determining module 202, an arithmetic module 203, and a sending module 204.
  • the determining module determines, according to the acquired blockchain data, a size of the corresponding new data
  • the determining module determines whether the size of the newly added data reaches a preset value for performing data synchronization
  • the operation module if the size of the newly added data reaches the preset value for data synchronization, randomly selects a hash algorithm to perform operation on the blockchain data, and obtains a hash check result of the blockchain data;
  • the sending module sends the hash check result of the blockchain data to the remaining terminals in the blockchain network, so that the remaining terminals perform data synchronization based on the hash check result of the blockchain data.
  • the hash check result of the blockchain data obtained by the operation module operation includes one or more of the following: a hash check result of the full amount data corresponding to the blockchain data, and a new data corresponding to the blockchain data.
  • the hash check result and the single hash check result corresponding to the blockchain data includes one or more of the following: a hash check result of the full amount data corresponding to the blockchain data, and a new data corresponding to the blockchain data.
  • the device for synchronizing the blockchain data according to the embodiment of the present invention further includes a marking module. (Not shown in Figure 2).
  • the tagging module marks the randomly selected hashing algorithm, and sends the hashing algorithm of the tagging module tag to the remaining terminals in the blockchain network through the sending module, so that the remaining terminals perform data synchronization based on the hashing algorithm marked by the tagging module. .
  • the sending module is further configured to: send the newly added data to the remaining terminals in the blockchain network, so that the remaining terminals perform data synchronization based on the newly added data to obtain synchronized new data.
  • the operation module is further configured to: select a hash algorithm of the tag to perform operation on the newly added data, and obtain a hash check of the newly added data. result.
  • the apparatus for synchronizing the blockchain data provided by the embodiment of the present invention further includes a verification module (not shown in FIG. 2).
  • the verification module compares the hash check result of the newly added data with the hash check result of any blockchain data, if the hash check result of the newly added data is synchronized with any blockchain data If the hash check results are consistent, verify that the newly added data is correct.
  • the size of the corresponding newly added data is determined according to the acquired blockchain data; determining whether the size of the newly added data reaches a preset value for performing data synchronization; if the size of the newly added data reaches data synchronization
  • the preset value is randomly selected by a hash algorithm to perform operation on the blockchain data to obtain a corresponding hash check result; the hash check result is sent to the remaining terminals in the blockchain network, so that the remaining terminals are based on the The result of the checksum is data synchronization.
  • the data synchronization process in the embodiment of the present invention is a hash check result corresponding to the priority synchronization blockchain data. Therefore, the technical solution provided by the present invention can improve the synchronization efficiency when the amount of data is large, and at the same time, the user experience is improved by shortening the waiting time of the user during the data synchronization process.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明涉及一种区块链数据同步的方法和装置。所述方法包括:根据获取的区块链数据确定相应的新增数据的大小;判断新增数据的大小是否达到进行数据同步的预设值;如果新增数据的大小达到进行数据同步的预设值,随机选取哈希算法对区块链数据进行运算,获得相应的哈希校验结果;将区块链数据的哈希校验结果发送至区块链网络内的其余终端,使得其余终端基于该哈希校验结果进行数据同步。本发明通过在进行数据同步的过程中,先同步区块链数据对应的哈希校验结果,优选完成业务交互,在完成交易后,网络空闲时,再同步大量新增数据,使得在数据量较大时,能够提高同步效率,同时,由于缩短了数据同步过程中用户等待的时间,从而提高了用户体验度。

Description

一种区块链数据同步的方法和装置 技术领域
本发明涉及数据处理技术领域,具体而言,本发明涉及一种区块链数据同步的方法和装置。
背景技术
区块链是比特币的一个重要概念,区块链是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一次比特币网络交易的信息,用于验证其信息的有效性和生成下一个区块。
随着数据处理技术的发展,用户对区块链数据同步速度的需求越来越高。当区块链数据中的部分数据过大时,或者是,单次区块链数据添加量过大时,全网同步区块链数据将变得非常缓慢。若全网同步区块链数据缓慢时,需要消耗大量的时间,降低了数据同步的效率。同时,在区块链数据同步的过程发生了延时现象,由于延长了数据同步过程中用户等待的时间,从而降低了用户体验度。
发明内容
本发明实施例在于提供一种区块链数据同步的方法和装置,通过在进行数据同步的过程中,先同步区块链数据对应的哈希校验结果,优选完成业务交互,使得在数据量较大时,能够提高同步效率。
第一方面,本发明实施例提供了一种区块链数据同步的方法,所述方法包括:
根据获取的区块链数据确定相应的新增数据的大小;
判断所述新增数据的大小是否达到进行数据同步的预设值;
如果所述新增数据的大小达到进行数据同步的预设值,随机选取哈希算法对所述区块链数据进行运算,获得所述区块链数据的哈希校验结果;
将所述区块链数据的哈希校验结果发送至区块链网络内的其余终端,使得所述其余终端基于所述区块链数据的哈希校验结果进行数据同步。
优选的,所述区块链数据的哈希校验结果包括以下一项或多项:
所述区块链数据对应的全量数据的哈希校验结果、所述区块链数据对应的新增数据的哈希校验结果以及所述区块链数据对应的单一哈希校验结果。
优选的,所述方法还包括:对随机选取的所述哈希算法进行标记,以及将标记的所述哈希算法发送至区块链网络内的其余终端,使得所述其余终端基于标记的所述哈希算法进行数据同步。
优选的,所述方法还包括:将所述新增数据发送至区块链网络内的其余终端,使得所述其余终端基于所述新增数据进行数据同步以获得同步的新增数据。
优选的,所述方法还包括:选取标记的所述哈希算法对所述同步的新增数据进行运算,获得所述同步的新增数据的哈希校验结果。
优选的,所述方法还包括:将所述同步的新增数据的哈希校验结果与任一所述区块链数据的哈希校验结果进行比较,若所述同步的新增数据的哈希校验结果与任一所述区块链数据的哈希校验结果一致,则验证所述同步的新增数据正确。
第二方面,本发明实施例提供了一种区块链数据同步的装置,所述装置包括:
确定模块,根据获取的区块链数据确定相应的新增数据的大小;
判断模块,判断所述新增数据的大小是否达到进行数据同步的预设值;
运算模块,如果所述新增数据的大小达到进行数据同步的预设值,随机选取哈希算法对所述区块链数据进行运算,获得所述区块链数据的哈希校验结果;
发送模块,将所述区块链数据的哈希校验结果发送至区块链网络内的其余终端,使得所述其余终端基于所述区块链数据的哈希校验结果进行数据同步。
优选的,所述运算模块运算获得的所述区块链数据的哈希校验结果包括以下一项或多项:
所述区块链数据对应的全量数据的哈希校验结果、所述区块链数据对应的新增数据的哈希校验结果以及所述区块链数据对应的单一哈希校验结果。
优选的,所述装置还包括:标记模块,对随机选取的所述哈希算法进行标记,以及将所述标记模块标记的所述哈希算法通过所述发送模块发送至区块链网络内的其余终端,使得所述其余终端基于所述标记模块标记的所述哈希算法进行数据同步。
优选的,所述发送模块进一步用于:将所述新增数据发送至区块链网络内的其余终端,使得所述其余终端基于所述新增数据进行数据同步以获得同步的新增数据。
本发明通过在进行数据同步的过程中,先同步区块链数据对应的哈希校验结果,优选完成业务交互,在完成交易后,网络空闲时,再同步大量新增数据,使得在数据量较大时,能够提高同步效率,同时,由于缩短了数据同步过程中用户等待的时间,从而提高了用户体验度。
附图说明
图1是本发明实施例提供的一种区块链数据同步的方法的流程图;
图2是本发明实施例提供的一种区块链数据同步的装置的结构框图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述, 显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
为便于对本发明实施例的理解,下面将结合附图以具体实施例做进一步的解释说明。
发明人发现,在进行数据同步的过程中,可能会产生因新增数据过大而造成同步新增数据需要耗费大量时间的情况。因此,可以先同步区块链数据对应的哈希校验结果,优选完成业务交互,在完成交易后,网络空闲时,再同步大量新增数据,使得在数据量较大时,能够提高同步效率。
下面结合附图详细说明本发明的技术方案。
图1是本发明实施例提供的一种区块链数据同步的方法的流程图,如图1所示,一种区块链数据同步的方法包括如下步骤:
S101:根据获取的区块链数据确定相应的新增数据的大小。在实际应用中,新增数据往往为几十M的高清图像或者是视频对应的数据。
S102:判断新增数据的大小是否达到进行数据同步的预设值。
在实际应用中,为了提高数据同步的效率,往往需要判断新增数据的大小是否达到进行数据同步的预设值,如果新增数据的大小很小,只有几十字节,可以在区块链网络的终端直接进行同步,同步所需的时间为秒级。只有在新增数据的大小大于或者等于进行数据同步的预设值时,才采用本发明实施例提供的方法进行数据同步。
S103:如果新增数据的大小达到进行数据同步的预设值,随机选取哈希算法对区块链数据进行运算,获得区块链数据的哈希校验结果。
其中,区块链数据的哈希校验结果可以为区块链数据对应的全量数据的哈希校验结果,也可以为区块链数据对应的新增数据的哈希校验结果,或者是区块链数据对应的单一哈希校验结果。
S104:将区块链数据的哈希校验结果发送至区块链网络内的其余终端, 使得其余终端基于区块链数据的哈希校验结果进行数据同步以获得同步的新增数据。
相对于现有技术,在区块链网络内的终端之间同步大量的新增数据往往需要分钟级以上的时间。在实际应用中,区块链数据对应的哈希校验结果往往仅仅只有几十个字节,在区块链网络内的终端之间同步区块链数据的哈希校验结果仅仅需要几秒。通过在进行数据同步的过程中,先同步区块链数据对应的哈希校验结果,优选完成业务交互,使得在数据量较大时,能够提高同步效率。
此外,为了验证同步数据的准确性,对随机选取的哈希算法进行标记,以及将标记的哈希算法发送至区块链网络内的其余终端,使得其余终端基于标记的哈希算法进行数据同步。
在本发明实施例所提供的技术方案中,通过对随机选取的哈希算法进行标记,避免了由于选取的哈希算法不同,可能造成相应的哈希校验结果也不同情况的发生。如果该哈希校验结果不是唯一的数值,也就无法根据该哈希校验结果判断同步的新增数据的准确性。
哈希算法将任意长度的二进制值映射为固定长度的较小二进制值,这个小的二进制值称为哈希值。哈希值是一段数据唯一且极其紧凑的数值表示形式。如果散列一段明文而且哪怕只更改该段落的一个字母,随后的哈希都将产生不同的值。要找到散列为同一个值的两个不同的输入,在计算上是不可能的,所以数据的哈希值可以检验数据的完整性。典型的哈希算法包括MD2、MD4、MD5和SHA-1,具体的哈希算法为常规算法,在此不再赘述。
在实际应用中,在完成交易后,网络空闲时,再同步大量新增数据。具体而言,在将区块链数据的哈希校验结果发送至区块链网络内的其余终端,使得其余终端基于区块链数据的哈希校验结果进行数据同步之后,将新增数据发送至区块链网络内的其余终端,使得其余终端基于新增数据进行数据同步以获得同步的新增数据。
此外,在区块链网络内的终端获取到同步的新增数据之后,为了验证同步的新增数据的准确性,选取之前标记的哈希算法对同步的新增数据进行运算,获得同步的新增数据的哈希校验结果。
进一步地,将同步的新增数据的哈希校验结果与任一区块链数据的哈希校验结果进行比较,若同步的新增数据的哈希校验结果与任一区块链数据的哈希校验结果一致,则验证同步的新增数据正确。
第一种验证同步的新增数据正确的方法为,将同步的新增数据的哈希校验结果与区块链数据对应的全量数据的哈希校验结果进行比较,若同步的新增数据的哈希校验结果与区块链数据对应的全量数据的哈希校验结果一致,则验证同步的新增数据正确。
第二种验证同步的新增数据正确的方法为,将同步的新增数据的哈希校验结果与区块链数据对应的新增数据的哈希校验结果进行比较,若同步的新增数据的哈希校验结果与区块链数据对应的新增数据的哈希校验结果一致,则验证同步的新增数据正确。
第三种验证同步的新增数据正确的方法为,将同步的新增数据的哈希校验结果与区块链数据对应的单一哈希校验结果进行比较,若同步的新增数据的哈希校验结果与区块链数据对应的单一哈希校验结果一致,则验证同步的新增数据正确。
除了上述验证同步的新增数据正确的方法之外,也可以将同步的新增数据的哈希校验结果与区块链数据对应的全量数据的哈希校验结果、区块链数据对应的新增数据的哈希校验结果进行组合对比,在此不再赘述,请参见前述。
反之,在将同步的新增数据的哈希校验结果与任一区块链数据的哈希校验结果进行比较之后,若同步的新增数据的哈希校验结果与任一区块链数据的哈希校验结果均不一致,则验证同步的新增数据不正确。
在验证同步的新增数据不正确之后,重新对区块链数据对应的新增数据 进行数据同步过程,至到验证出得到的同步的新增数据为正确数据时为止。
在区块链网络内同步的新增数据为合同扫描件对应的图片文件的数据的一个具体应用场景中,把合同扫描件对应的图片文件上传到一个终端节点。该合同扫描件对应的图片文件的数据的大小为30M。
发明人发现,如果采用现有的区块链技术全网同步该新增数据至区块链网络内的其余终端节点,上述同步数据的过程往往需要很久。反之,由于新增数据对应的哈希校验结果仅仅只有十几个字节,或者是几十个字节,如果本地终端运算该新增数据的哈希校验结果只需要毫秒级就可以完成整个运算过程。然后,由于新增数据的哈希校验结果仅仅只有几十个字节,因此,将得到的新增数据的哈希校验结果同步至区块链网络内的其余终端也就只需要几秒钟的时间,从而,提高了数据同步的效率。
因此,发明人考虑,在进行数据同步的过程中,优先同步哈希校验结果以快速完成业务响应。
在区块链网络内同步的新增数据为合同扫描件图片文件的数据的一个具体应用场景中,区块链数据同步的步骤具体如下所述:
首先,在该应用场景下,新增数据为:合同扫描件图片文件对应的数据。确定该新增数据的大小,该新增数据的大小为30M。
进一步地,由于在该具体应用场景下,预先设置了进行数据同步的预设值为20M。由于新增数据的大小为30M,因此,新增数据的大小大于预先设置的进行数据同步的预设值20M。因此,判断出新增数据的大小达到了进行数据同步的预设值。
进一步地,在判断出新增数据的大小达到了进行数据同步的预设值之后,开始启动在区块链网络内的终端之间对该新增数据进行数据同步的过程。随机选取哈希算法对区块链数据进行运算,获得相应的哈希校验结果。
需要说明的是,区块链数据具体为区块链数据对应的全量数据以及区块链数据对应的新增数据。
在确定出随机选取的哈希算法为MD2之后,采用哈希算法MD2对区块链数据进行哈希运算,得到相应的哈希校验结果。
具体地,区块链数据对应的哈希校验结果可以为:区块链数据对应的全量数据的哈希校验结果,也可以为:区块链数据对应的新增数据的哈希校验结果,或者为:区块链数据对应的单一哈希校验结果。
进一步地,将包含区块链数据对应的全量数据的哈希校验结果、区块链数据对应的新增数据的哈希校验结果、区块链数据对应的单一哈希校验结果发送至区块链网络内的其余终端,使得其余终端基于上述哈希校验结果进行数据同步。
在该应用场景下,数据同步的过程中,先同步校验结果以快速完成业务响应。由于新增数据对应的哈希结果仅仅只有十几个到几十个字节,因此,本地终端运算该新增数据的哈希结果只需要毫秒级就可以完成,从而,使得在数据量较大时,能够提高同步效率。
在该应用场景下,在完成交易后,网络空闲时,再同步大量新增数据。获取到同步的新增数据,以及依据之前标记的哈希算法MD2对该新增数据进行运算,获得该新增数据的哈希校验结果。
依据区块链数据对应的单一哈希校验结果来判断同步的新增数据的正确性。或者是,依据区块链数据对应的新增数据的哈希校验结果和全量数据的哈希校验结果共同来判断同步的新增数据的正确性。
具体地,若区块链数据对应的单一哈希校验结果与同步的新增数据的哈希校验结果一致,则验证出:同步的新增数据正确。
若区块链数据对应的新增数据的哈希校验结果与同步的新增数据的哈希校验结果一致,则验证出:同步的新增数据正确。
若区块链数据对应的全量数据的哈希校验结果与同步的新增数据的哈希校验结果一致,则验证出:同步的新增数据正确。
若区块链数据对应的新增数据的哈希校验结果,以及区块链数据对应的 全量数据的哈希校验结果,与同步的新增数据的哈希校验结果均一致,则验证出:同步的新增数据正确。
反之,若区块链数据对应的单一哈希校验结果,区块链数据对应的新增数据的哈希校验结果,以及区块链数据对应的全量数据的哈希校验结果,与同步的新增数据的哈希校验结果均不一致,则验证出:同步的新增数据不正确。
在验证出同步的新增数据不正确之后,采用标记的算法重新对新增数据进行同步,至到得到正确的同步新增数据为止。
综上所述,本发明实施例提供的一种区块链数据同步的方法,根据获取的区块链数据确定相应的新增数据的大小;判断新增数据的大小是否达到进行数据同步的预设值;如果新增数据的大小达到进行数据同步的预设值,随机选取哈希算法对区块链数据进行运算,获得相应的哈希校验结果;将该哈希校验结果发送至区块链网络内的其余终端,使得其余终端基于该哈希校验结果进行数据同步。本发明实施例中的数据同步过程,是优先同步区块链数据对应的哈希校验结果。因此,本发明所提供的技术方案在数据量较大时,能够提高同步效率,同时,由于缩短了数据同步过程中用户等待的时间,从而提高了用户体验度。
如图2所示,本发明实施例所提供的一种区块链数据同步的装置,包括:确定模块201、判断模块202、运算模块203和发送模块204。
具体而言,确定模块,根据获取的区块链数据确定相应的新增数据的大小;
判断模块,判断新增数据的大小是否达到进行数据同步的预设值;
运算模块,如果新增数据的大小达到进行数据同步的预设值,随机选取哈希算法对区块链数据进行运算,获得区块链数据的哈希校验结果;
发送模块,将区块链数据的哈希校验结果发送至区块链网络内的其余终端,使得其余终端基于区块链数据的哈希校验结果进行数据同步。
进一步地,运算模块运算获得的区块链数据的哈希校验结果包括以下一项或多项:区块链数据对应的全量数据的哈希校验结果、区块链数据对应的新增数据的哈希校验结果以及区块链数据对应的单一哈希校验结果。
进一步地,为了提高对同步的新增数据校验的准确性,准确确定出与新增数据匹配的哈希算法,本发明实施例所提供的一种区块链数据同步的装置还包括标记模块(在图2中未标出)。
标记模块,对随机选取的哈希算法进行标记,以及将标记模块标记的哈希算法通过发送模块发送至区块链网络内的其余终端,使得其余终端基于标记模块标记的哈希算法进行数据同步。
进一步地,为了提高同步效率,同时避免对存储空间的浪费,仅同步新增数据。发送模块还用于:将新增数据发送至区块链网络内的其余终端,使得其余终端基于新增数据进行数据同步以获得同步的新增数据。
进一步地,在准确确定出与新增数据匹配的哈希算法之后,运算模块还用于:选取标记的哈希算法对同步的新增数据进行运算,获得同步的新增数据的哈希校验结果。
进一步地,为了验证同步的新增数据是否准确,本发明实施例所提供的一种区块链数据同步的装置还包括验证模块(在图2中未标出)。
验证模块,将同步的新增数据的哈希校验结果与任一区块链数据的哈希校验结果进行比较,若同步的新增数据的哈希校验结果与任一区块链数据的哈希校验结果一致,则验证同步的新增数据正确。
本发明的技术方案中,根据获取的区块链数据确定相应的新增数据的大小;判断新增数据的大小是否达到进行数据同步的预设值;如果新增数据的大小达到进行数据同步的预设值,随机选取哈希算法对区块链数据进行运算,获得相应的哈希校验结果;将该哈希校验结果发送至区块链网络内的其余终端,使得其余终端基于该哈希校验结果进行数据同步。本发明实施例中的数据同步过程,是优先同步区块链数据对应的哈希校验结果。因此,本发明所 提供的技术方案在数据量较大时,能够提高同步效率,同时,由于缩短了数据同步过程中用户等待的时间,从而提高了用户体验度。
以上所述的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (10)

  1. 一种区块链数据同步的方法,其特征在于,包括:
    根据获取的区块链数据确定相应的新增数据的大小;
    判断所述新增数据的大小是否达到进行数据同步的预设值;
    如果所述新增数据的大小达到进行数据同步的预设值,随机选取哈希算法对所述区块链数据进行运算,获得所述区块链数据的哈希校验结果;
    将所述区块链数据的哈希校验结果发送至区块链网络内的其余终端,使得所述其余终端基于所述区块链数据的哈希校验结果进行数据同步。
  2. 根据权利要求1所述的方法,其特征在于,所述区块链数据的哈希校验结果包括以下一项或多项:
    所述区块链数据对应的全量数据的哈希校验结果、所述区块链数据对应的新增数据的哈希校验结果以及所述区块链数据对应的单一哈希校验结果。
  3. 根据权利要求1所述的方法,其特征在于,所述方法还包括:对随机选取的所述哈希算法进行标记,以及将标记的所述哈希算法发送至区块链网络内的其余终端,使得所述其余终端基于标记的所述哈希算法进行数据同步。
  4. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    将所述新增数据发送至区块链网络内的其余终端,使得所述其余终端基于所述新增数据进行数据同步以获得同步的新增数据。
  5. 根据权利要求4所述的方法,其特征在于,所述方法还包括:
    选取标记的所述哈希算法对所述同步的新增数据进行运算,获得所述同步的新增数据的哈希校验结果。
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:
    将所述同步的新增数据的哈希校验结果与任一所述区块链数据的哈希校验结果进行比较,若所述同步的新增数据的哈希校验结果与任一所述区块链数据的哈希校验结果一致,则验证所述同步的新增数据正确。
  7. 一种区块链数据同步的装置,其特征在于,包括:
    确定模块,根据获取的区块链数据确定相应的新增数据的大小;
    判断模块,判断所述新增数据的大小是否达到进行数据同步的预设值;
    运算模块,如果所述新增数据的大小达到进行数据同步的预设值,随机选取哈希算法对所述区块链数据进行运算,获得所述区块链数据的哈希校验结果;
    发送模块,将所述区块链数据的哈希校验结果发送至区块链网络内的其余终端,使得所述其余终端基于所述区块链数据的哈希校验结果进行数据同步。
  8. 根据权利要求7所述的装置,其特征在于,所述运算模块运算获得的所述区块链数据的哈希校验结果包括以下一项或多项:
    所述区块链数据对应的全量数据的哈希校验结果、所述区块链数据对应的新增数据的哈希校验结果以及所述区块链数据对应的单一哈希校验结果。
  9. 根据权利要求7所述的装置,其特征在于,所述装置还包括:
    标记模块,对随机选取的所述哈希算法进行标记,以及将所述标记模块标记的所述哈希算法通过所述发送模块发送至区块链网络内的其余终端,使得所述其余终端基于所述标记模块标记的所述哈希算法进行数据同步。
  10. 根据权利要求7所述的装置,其特征在于,所述发送模块进一步用于:将所述新增数据发送至区块链网络内的其余终端,使得所述其余终端基于所述新增数据进行数据同步以获得同步的新增数据。
PCT/CN2018/080023 2017-03-28 2018-03-22 一种区块链数据同步的方法和装置 WO2018177190A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710191183.3 2017-03-28
CN201710191183.3A CN107124444B (zh) 2017-03-28 2017-03-28 一种区块链数据同步的方法和装置

Publications (1)

Publication Number Publication Date
WO2018177190A1 true WO2018177190A1 (zh) 2018-10-04

Family

ID=59717258

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/080023 WO2018177190A1 (zh) 2017-03-28 2018-03-22 一种区块链数据同步的方法和装置

Country Status (2)

Country Link
CN (1) CN107124444B (zh)
WO (1) WO2018177190A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111401672A (zh) * 2019-01-02 2020-07-10 中国移动通信有限公司研究院 一种基于区块链的合法性校验方法、设备及系统
CN113055180A (zh) * 2021-03-02 2021-06-29 知晓(北京)通信科技有限公司 一种基于区块链的数据采集系统及方法
CN113590375A (zh) * 2021-06-25 2021-11-02 北京电链科技有限公司 一种基于区块链的稳控装置信息校验方法及系统
US11436198B2 (en) * 2019-04-18 2022-09-06 Metabora Co., Ltd. Method and device for restoring blockchain network with its credibility on backup data maintained by using delayed synchronization

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107124444B (zh) * 2017-03-28 2020-08-04 丽水北斗区块链科技有限责任公司 一种区块链数据同步的方法和装置
CN108777698A (zh) * 2018-04-13 2018-11-09 深圳市元征科技股份有限公司 网页存储方法、系统及区块链节点设备
CN109410044B (zh) * 2018-08-22 2020-10-23 泰链(厦门)科技有限公司 区块链系统及其中利用非生产者节点闲置计算资源的方法
CN109460405A (zh) * 2018-09-27 2019-03-12 上海点融信息科技有限责任公司 用于区块链网络的区块生成方法、同步方法、存储介质、计算设备
CN109347935B (zh) * 2018-09-30 2021-08-03 珠海信达九州科技有限公司 一种基于区块链实现实时通讯消息同步的方法
CN110708280B (zh) * 2019-08-21 2021-02-09 北京邮电大学 一种集合多家独立单元组成的根区块链认证系统及方法
CN110602251B (zh) * 2019-09-30 2021-12-17 腾讯科技(深圳)有限公司 基于节点间数据共享的数据处理方法、设备、装置、介质
CN111241205B (zh) * 2020-04-26 2021-03-09 北京启迪区块链科技发展有限公司 基于联盟区块链底层可信数据同步方法、网络结构及服务器
CN111797169A (zh) * 2020-07-09 2020-10-20 杭州复杂美科技有限公司 数据存证方法、设备和存储介质
WO2022195643A1 (ja) * 2021-03-13 2022-09-22 株式会社クエスト ブロックチェーンシステム、記憶装置及び管理装置
CN113094437B (zh) * 2021-04-14 2023-10-03 深圳前海移联科技有限公司 一种基于Rsync的区块链状态数据同步方法及系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105162855A (zh) * 2015-08-18 2015-12-16 浪潮(北京)电子信息产业有限公司 增量数据同步方法和装置
CN105404701A (zh) * 2015-12-31 2016-03-16 浙江图讯科技股份有限公司 一种基于对等网络的异构数据库同步方法
WO2016177026A1 (zh) * 2015-05-07 2016-11-10 中兴通讯股份有限公司 一种去中心化自治组织的数据处理方法及装置
CN106506146A (zh) * 2016-10-26 2017-03-15 北京瑞卓喜投科技发展有限公司 基于区块链技术的交易信息校验方法、装置及系统
CN107124444A (zh) * 2017-03-28 2017-09-01 上海瑞麒维网络科技有限公司 一种区块链数据同步的方法和装置

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5753273B2 (ja) * 2011-10-14 2015-07-22 株式会社日立製作所 データの真正性保証方法、管理計算機及び記憶媒体
CN105956923B (zh) * 2016-04-20 2022-04-29 上海如鸽投资有限公司 资产交易系统以及资产的数字化认证和交易方法
CN106157142A (zh) * 2016-06-30 2016-11-23 惠众商务顾问(北京)有限公司 一种区块链共识及同步方法、系统和装置
CN106446705A (zh) * 2016-08-26 2017-02-22 杨鹏 一种基于区块链的数据循环写入方法及系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016177026A1 (zh) * 2015-05-07 2016-11-10 中兴通讯股份有限公司 一种去中心化自治组织的数据处理方法及装置
CN105162855A (zh) * 2015-08-18 2015-12-16 浪潮(北京)电子信息产业有限公司 增量数据同步方法和装置
CN105404701A (zh) * 2015-12-31 2016-03-16 浙江图讯科技股份有限公司 一种基于对等网络的异构数据库同步方法
CN106506146A (zh) * 2016-10-26 2017-03-15 北京瑞卓喜投科技发展有限公司 基于区块链技术的交易信息校验方法、装置及系统
CN107124444A (zh) * 2017-03-28 2017-09-01 上海瑞麒维网络科技有限公司 一种区块链数据同步的方法和装置

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111401672A (zh) * 2019-01-02 2020-07-10 中国移动通信有限公司研究院 一种基于区块链的合法性校验方法、设备及系统
CN111401672B (zh) * 2019-01-02 2023-11-28 中国移动通信有限公司研究院 一种基于区块链的合法性校验方法、设备及系统
US11436198B2 (en) * 2019-04-18 2022-09-06 Metabora Co., Ltd. Method and device for restoring blockchain network with its credibility on backup data maintained by using delayed synchronization
CN113055180A (zh) * 2021-03-02 2021-06-29 知晓(北京)通信科技有限公司 一种基于区块链的数据采集系统及方法
CN113055180B (zh) * 2021-03-02 2022-12-09 知晓(北京)通信科技有限公司 一种基于区块链的数据采集系统及方法
CN113590375A (zh) * 2021-06-25 2021-11-02 北京电链科技有限公司 一种基于区块链的稳控装置信息校验方法及系统

Also Published As

Publication number Publication date
CN107124444B (zh) 2020-08-04
CN107124444A (zh) 2017-09-01

Similar Documents

Publication Publication Date Title
WO2018177190A1 (zh) 一种区块链数据同步的方法和装置
US11669598B1 (en) Authenticating media data based on metadata encoding
US11086825B2 (en) Telemetry system for a cloud synchronization system
CN108255653B (zh) 一种产品的测试方法及其终端
US11501533B2 (en) Media authentication using distributed ledger
WO2019144761A1 (zh) 一种数据同步方法和分布式系统、设备
WO2020253083A1 (zh) 主备存储卷同步数据校验方法、装置、设备及存储介质
WO2020199713A1 (zh) 数据验证方法、系统、装置及设备
CN110597918B (zh) 一种账户管理方法、装置及计算机可读存储介质
WO2014169738A1 (zh) 主、备数据库及一致性检测、修复方法和装置、存储介质
WO2020199711A1 (zh) 数据存储方法、系统、装置及设备
CN111078672B (zh) 数据库的数据对比方法及装置
WO2023071373A1 (zh) 一种区块链共识方法、装置、设备及存储介质
CN112364049B (zh) 数据同步脚本生成方法、系统、终端及存储介质
WO2019237664A1 (zh) 纠正伴奏和干音之间的时延的方法、装置及存储介质
US10474185B2 (en) Timestamp alignment across a plurality of computing devices
WO2019057081A1 (zh) 数据存储方法、数据查询方法、计算机设备及存储介质
CN110851359A (zh) 应用程序测试方法、装置及服务器
CN104079623B (zh) 多级云存储同步控制方法及系统
US9043275B2 (en) Data synchronization using string matching
CN113888164A (zh) 区块链交易池实现方法、装置、计算机设备和存储介质
CN111339551B (zh) 数据的验证方法及相关装置、设备
CN111290998A (zh) 迁移数据的校对方法、装置、设备及存储介质
CN111756829A (zh) 账本数据同步方法、装置、设备和存储介质
CN111695098B (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: 18777536

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18777536

Country of ref document: EP

Kind code of ref document: A1