WO2020172881A1 - Block generation method and apparatus, computer device and storage medium - Google Patents

Block generation method and apparatus, computer device and storage medium Download PDF

Info

Publication number
WO2020172881A1
WO2020172881A1 PCT/CN2019/076577 CN2019076577W WO2020172881A1 WO 2020172881 A1 WO2020172881 A1 WO 2020172881A1 CN 2019076577 W CN2019076577 W CN 2019076577W WO 2020172881 A1 WO2020172881 A1 WO 2020172881A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
network delay
average
block
time difference
Prior art date
Application number
PCT/CN2019/076577
Other languages
French (fr)
Chinese (zh)
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 云图有限公司
Priority to PCT/CN2019/076577 priority Critical patent/WO2020172881A1/en
Publication of WO2020172881A1 publication Critical patent/WO2020172881A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • H04L9/3239Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/12Transmitting and receiving encryption devices synchronised or initially set up in a particular manner
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3297Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving time stamps, e.g. generation of time stamps
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0852Delays
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic

Definitions

  • This application relates to the field of blockchain technology, in particular to a block generation method, device, computer equipment and storage medium.
  • the embodiment of the application provides a block generation method, including: a first node obtains the average network delay and the maximum network delay between the first node and the second node; the first node determines the first node and the second node according to the average network delay The average system time difference between the two nodes; the first node receives the block generated by the second node and determines the local timestamp when the block is received, where the timestamp is carried in the block; the first node is based on the average The network delay, the maximum network delay, the average system time difference, the local timestamp and the timestamp carried by the block determine whether the block is a block generated by the second node at the block generation time that meets the preset time requirement.
  • NetDelay max Max(Delay 0 : Delay N-1 );
  • NetDelay aver is the average value of network delay
  • NetDelay max is the maximum network delay
  • i 0,...,N-1
  • Delay i is the first node and calculated by the first node in the i-th execution of the information interaction operation Network delay data between the second nodes
  • Delay i (T2 i- T1 i )/2, where T2 i is the second time stamp in the i-th information interaction operation, and T1 i is the i-th information interaction operation The first timestamp in.
  • Figure 1 shows a flowchart of a block generation method in an embodiment of the present application
  • the embodiment of the present application provides a block generation method, as shown in FIG. 1, which may include the following steps:
  • Blockchain can be a chained data structure that combines data blocks in sequence in chronological order, and is a distributed ledger that cannot be tampered with or forged that is guaranteed by cryptography.
  • Distributed ledger means that transaction accounting is completed by multiple nodes distributed in different places, and each node records a complete account, so they can participate in the supervision of the legality of the transaction, and they can also jointly testify for it. Whether the block proposed by the proposer can be confirmed by other blocks depends on whether the block is reasonable. Only when the block generation time is consistent, will the block continue to be judged.
  • Step S102 The first node determines the average system time difference between the first node and the second node according to the average network delay.
  • the first node After the first node receives the block, it determines whether the block is the second node in accordance with the obtained average network delay, maximum network delay, average system time difference, local timestamp, and timestamp carried in the block.
  • calculating the average network delay based on the calculated average network delay value and the preset system allowable maximum network delay may include: determining whether the network delay average value is greater than the preset system allowable maximum network delay Delay; in the case of determining that the average network delay is greater than the preset maximum network delay allowed by the system, the preset maximum allowed network delay of the system is determined as the average network delay; after determining that the average network delay is not greater than the preset maximum allowed network delay In the case of, the average network delay is determined as the average network delay.
  • the maximum network delay allowed by the system can be set according to system parameters and actual requirements. Through the above method, the average network delay used to judge the reasonableness of the block time can be limited to a reasonable range, thereby improving the accuracy of the judgment.
  • TimeDiff aver is the average value of the system time difference
  • NetDelay is the average network delay
  • T2 i is the second timestamp when the first node in the i-th information interaction operation receives the pong message returned by the second node
  • T1 i It is the first time stamp of leaving the first node carried in the ping message sent by the first node in the i-th information exchange operation.
  • determining the average system time difference based on the average system time difference value and the maximum system time difference threshold allowed by the system may include: determining whether the average system time difference value is greater than a preset system allowable value Maximum system time difference; when it is determined that the average system time difference is greater than the preset maximum system time difference allowed by the system, the preset maximum system time difference allowed by the system is determined as the average system time difference; If the average time difference is not greater than the preset maximum system time difference allowed by the system, the average system time difference is determined as the average system time difference.
  • the maximum system time difference allowed by the system can be set according to system parameters and actual needs. Through the above method, the average system time difference used for judging the reasonableness of the block time can be limited to a reasonable range, thereby improving the accuracy of judgment.
  • Step 1 The first node and the second node undergo N information interaction operations, and each information interaction operation includes the following sub-steps:
  • Step 1.2 when the message reaches the second node, the second node calculates its own timestamp
  • Step 1.4 When the first node receives the pong message, calculate the local timestamp T2 i when the first node receives the pong message;
  • Localtime is the local timestamp
  • TimeDiff is the average system time difference
  • NetDelay max is the maximum network delay
  • timestamp is the timestamp carried in the block
  • NetDelay is the average network delay

Abstract

Disclosed are a block generation method and apparatus, a computer device and a storage medium. The method comprises: a first node acquiring average network delay and the maximum network delay between the first node and a second node (S101); the first node determining, according to the average network delay, an average system time difference between the first node and the second node (S102); the first node receiving a block generated by the second node, and determining a local timestamp when receiving the block, wherein the block carries a timestamp (S103); and the first node determining, according to the average network delay, the maximum network delay, the average system time difference, the local timestamp, and the timestamp carried in the block, whether the block is a block generated by the second node at a block time that satisfies a pre-set time requirement (S104). The solution solves the technical problem in the prior art of the accuracy rate of determination of rationality of block time being low, and achieves the technical effects of effectively improving the accuracy rate of the determination of the rationality of the block time, and improving block generation efficiency.

Description

区块生成方法、装置、计算机设备和存储介质Block generation method, device, computer equipment and storage medium 技术领域Technical field
本申请涉及区块链技术领域,特别涉及一种区块生成方法、装置、计算机设备和存储介质。This application relates to the field of blockchain technology, in particular to a block generation method, device, computer equipment and storage medium.
背景技术Background technique
随着互联网技术的不断发展,区块链技术的发展也越来越迅速。区块链技术是一种去中心化且公开透明的技术。区块链技术采用数据区块打破了目前互联网对中心服务器的依赖,网络中产生的所有数据都会被区块生成节点进行记录,并通过数据的广播和其他节点的验证,以形成新的区块并上链至区块链的尾部。待上链区块被确认后,该新的区块被永久记录于区块链中;而对于得不到确认的区块,将区块中的数据回滚。With the continuous development of Internet technology, the development of blockchain technology is becoming more and more rapid. Blockchain technology is a decentralized and open and transparent technology. Blockchain technology uses data blocks to break the current dependence of the Internet on the central server. All data generated in the network will be recorded by the block generation node, and the data will be broadcast and verified by other nodes to form a new block And chain to the end of the blockchain. After the block on the chain is confirmed, the new block is permanently recorded in the block chain; and for blocks that cannot be confirmed, the data in the block is rolled back.
在所有实现BFT(Byzantine Fault Tolerance,拜占庭容错)机制的共识算法中,在该算法中,区块能否被通过其他区块的验证取决于该区块是否是合理的,而在并行确认的BFT机制中,判断区块是否合理的依据需要根据当前时间是否是当前区块的提议人的出块周期,在时间符合的情况下,才会进一步判断区块的合理性。In all consensus algorithms that implement the BFT (Byzantine Fault Tolerance) mechanism, in this algorithm, whether a block can be verified by other blocks depends on whether the block is reasonable, and the BFT that is confirmed in parallel In the mechanism, the basis for judging whether a block is reasonable needs to be based on whether the current time is the block generation period of the proposer of the current block, and only when the time matches, the rationality of the block is further judged.
然而,大多数区块链系统本身并没有做时钟同步,即便有个别区块链系统实现了部分时钟同步简单协议,但也只能保证本节点在没有恶意修改系统时间的前提下的节点时间的准确性,无法准确判断区块时间的合理性。However, most blockchain systems themselves do not do clock synchronization. Even if some individual blockchain systems implement some simple clock synchronization protocols, they can only guarantee the node time without malicious modification of the system time. Accuracy, it is impossible to accurately judge the reasonableness of the block time.
针对上述问题,目前尚未提出有效的解决方案。In view of the above problems, no effective solutions have been proposed yet.
发明内容Summary of the invention
本申请实施例提供了一种区块生成方法、装置、计算机设备和存储介质,以解决现有技术中判断区块时间合理性的准确率低的问题。The embodiments of the present application provide a block generation method, device, computer equipment, and storage medium to solve the problem of low accuracy in judging block time rationality in the prior art.
本申请实施例提供了一种区块生成方法,包括:第一节点获取第一节点与第二节点之间的平均网络延迟和最大网络延迟;第一节点根据平均网络延迟确定第一节点和第二节点之间的平均系统时间差值;第一节点接收第二节点生成的区块,并确定接收到区块时的本地时间戳,其中,区块中携带有时间戳;第一节点根据平均网络延迟、最大网络延迟、平均系统时间差值、本地时间戳和区块所携带的时间戳确定区块是否为第二节点在满足预设时间要求的出块时间生成的区块。The embodiment of the application provides a block generation method, including: a first node obtains the average network delay and the maximum network delay between the first node and the second node; the first node determines the first node and the second node according to the average network delay The average system time difference between the two nodes; the first node receives the block generated by the second node and determines the local timestamp when the block is received, where the timestamp is carried in the block; the first node is based on the average The network delay, the maximum network delay, the average system time difference, the local timestamp and the timestamp carried by the block determine whether the block is a block generated by the second node at the block generation time that meets the preset time requirement.
在一个实施例中,第一节点获取第一节点与第二节点之间的平均网络延迟和最大网 络延迟,包括:第一节点重复执行N次如下信息交互操作,以得到N个网络延迟数据:第一节点发送ping报文给第二节点,其中,ping报文中携带有ping报文离开第一节点的第一时间戳;第一节点接收第二节点响应于ping报文返回的pong报文;第一节点计算第一节点接收到pong报文的第二时间戳;第一节点根据第一时间戳和第二时间戳计算第一节点和第二节点之间的网络延迟数据,其中,N为正整数;第一节点根据N个网络延迟数据确定第一节点和第二节点之间的平均网络延迟和最大网络延迟。In one embodiment, obtaining the average network delay and the maximum network delay between the first node and the second node by the first node includes: the first node repeatedly performs the following information exchange operations N times to obtain N network delay data: The first node sends a ping message to the second node, where the ping message carries the first timestamp of the ping message leaving the first node; the first node receives the pong message returned by the second node in response to the ping message ; The first node calculates the second timestamp of the pong message received by the first node; the first node calculates the network delay data between the first node and the second node according to the first timestamp and the second timestamp, where N It is a positive integer; the first node determines the average network delay and the maximum network delay between the first node and the second node according to N network delay data.
在一个实施例中,第一节点根据N个网络延迟数据确定第一节点和第二节点之间的平均网络延迟和最大网络延迟,包括:In an embodiment, the first node determines the average network delay and the maximum network delay between the first node and the second node according to the N network delay data, including:
按照以下公式计算网络延迟均值:Calculate the average network delay according to the following formula:
Figure PCTCN2019076577-appb-000001
Figure PCTCN2019076577-appb-000001
按照以下公式计算最大网络延迟:Calculate the maximum network delay according to the following formula:
NetDelay max=Max(Delay 0:Delay N-1); NetDelay max =Max(Delay 0 : Delay N-1 );
根据计算得到的网络延迟均值和预设的系统允许最大网络延迟,确定平均网络延迟,Determine the average network delay according to the calculated average network delay and the preset maximum network delay allowed by the system,
其中,NetDelay aver为网络延迟均值,NetDelay max为最大网络延迟,i=0,...,N-1,Delay i是第一节点在第i次执行信息交互操作中计算得到的第一节点和第二节点之间的网络延迟数据,Delay i=(T2 i-T1 i)/2,其中,T2 i是第i次信息交互操作中的第二时间戳,T1 i是第i次信息交互操作中的第一时间戳。 Among them, NetDelay aver is the average value of network delay, NetDelay max is the maximum network delay, i=0,...,N-1, Delay i is the first node and calculated by the first node in the i-th execution of the information interaction operation Network delay data between the second nodes, Delay i = (T2 i- T1 i )/2, where T2 i is the second time stamp in the i-th information interaction operation, and T1 i is the i-th information interaction operation The first timestamp in.
在一个实施例中,根据计算得到的网络延迟均值和预设的系统允许最大网络延迟,计算平均网络延迟,包括:确定网络延迟均值是否大于预设的系统允许最大网络延迟;在确定网络延迟均值大于预设的系统允许最大网络延迟的情况下,将预设的系统允许最大网络延迟确定为平均网络延迟;在确定网络延迟均值不大于预设的系统允许最大网络延迟的情况下,将网络延迟均值确定为平均网络延迟。In one embodiment, calculating the average network delay according to the calculated average network delay and the preset maximum allowable network delay of the system includes: determining whether the average network delay is greater than the preset maximum allowable network delay of the system; in determining the average network delay In the case of greater than the preset system allowable maximum network delay, the preset system allowable maximum network delay is determined as the average network delay; when the average network delay is determined not to be greater than the preset system allowable maximum network delay, the network delay The mean value is determined as the average network delay.
在一个实施例中,第一节点根据平均网络延迟确定第一节点和第二节点之间的平均系统时间差值,包括:In an embodiment, the first node to determine the average system time difference between the first node and the second node according to the average network delay includes:
按照以下公式计算系统时间差值均值:Calculate the mean value of the system time difference according to the following formula:
Figure PCTCN2019076577-appb-000002
Figure PCTCN2019076577-appb-000002
其中,TimeDiff aver为系统时间差值均值,NetDelay为平均网络延迟,T2 i是第i次信 息交互操作中的第二时间戳,T1 i是第i次信息交互操作中的第一时间戳; Among them, TimeDiff aver is the average value of the system time difference, NetDelay is the average network delay, T2 i is the second time stamp in the i-th information interaction operation, and T1 i is the first time stamp in the i-th information interaction operation;
根据系统时间差值均值和预设的系统允许最大系统时间差值,确定平均系统时间差值。Determine the average system time difference according to the average system time difference and the preset maximum system time difference allowed by the system.
在一个实施例中,根据系统时间差值均值和系统允许的最大系统时间差值阈值,确定平均系统时间差,可以包括:确定系统时间差值均值是否大于预设的系统允许最大系统时间差值;在确定系统时间差值均值大于预设的系统允许最大系统时间差值的情况下,将预设的系统允许最大系统时间差值确定为平均系统时间差值;在确定系统时间差值均值不大于预设的系统允许最大系统时间差值的情况下,将系统时间差值均值确定为平均系统时间差值。In one embodiment, determining the average system time difference based on the average system time difference value and the maximum system time difference threshold allowed by the system may include: determining whether the average system time difference value is greater than the preset maximum system time difference allowed by the system; When it is determined that the average value of the system time difference is greater than the preset maximum allowable system time difference, the preset maximum allowable system time difference is determined as the average system time difference; when it is determined that the average system time difference is not greater than When the preset system allows the maximum system time difference, the average system time difference is determined as the average system time difference.
在一个实施例中,第一节点根据平均网络延迟、最大网络延迟、平均系统时间差值、本地时间戳和区块所携带的时间戳确定区块是否为第二节点在满足预设时间要求的出块时间生成的区块,包括验证以下不等式是否成立以确定区块是否为第二节点在满足预设时间要求的出块时间生成的区块:In one embodiment, the first node determines whether the block is the second node in meeting the preset time requirements based on the average network delay, the maximum network delay, the average system time difference, the local timestamp, and the timestamp carried by the block. The block generated by the block generation time includes verifying whether the following inequality is true to determine whether the block is a block generated by the second node at the block generation time that meets the preset time requirement:
Localtime+TimeDiff+NetDelay max≥timestamp+NetDelay≥Localtime+TimeDiff, Localtime+TimeDiff+NetDelay max ≥timestamp+NetDelay≥Localtime+TimeDiff,
其中,Localtime为本地时间戳,TimeDiff为平均系统时间差值,NetDelay max为最大网络延迟,timestamp为区块中携带的时间戳,NetDelay为平均网络延迟。 Among them, Localtime is the local timestamp, TimeDiff is the average system time difference, NetDelay max is the maximum network delay, timestamp is the timestamp carried in the block, and NetDelay is the average network delay.
本申请实施例还提供了一种区块生成装置,位于第一节点中,包括:获取模块,用于获取第一节点与第二节点之间的平均网络延迟和最大网络延迟;第一确定模块,用于根据平均网络延迟确定第一节点和第二节点之间的平均系统时间差值;接收模块,用于接收第二节点生成的区块,并确定接收到区块时的本地时间戳,其中,区块中携带有时间戳;第二确定模块,用于根据平均网络延迟、最大网络延迟、平均系统时间差值、本地时间戳和区块所携带的时间戳确定区块是否为第二节点在满足预设时间要求的出块时间生成的区块。An embodiment of the present application also provides a block generation device, which is located in the first node, and includes: an acquisition module for acquiring the average network delay and the maximum network delay between the first node and the second node; and a first determination module , Used to determine the average system time difference between the first node and the second node according to the average network delay; the receiving module, used to receive the block generated by the second node, and determine the local timestamp when the block is received, Among them, the block carries a timestamp; the second determining module is used to determine whether the block is the second based on the average network delay, the maximum network delay, the average system time difference, the local timestamp and the timestamp carried by the block A block generated by a node at the block generation time that meets the preset time requirement.
本申请实施例还提供一种计算机设备,包括处理器以及用于存储处理器可执行指令的存储器,所述处理器执行所述指令时实现上述任意实施例中所述的区块生成方法的步骤。An embodiment of the present application also provides a computer device, including a processor and a memory for storing executable instructions of the processor. The processor executes the instructions to implement the steps of the block generation method described in any of the foregoing embodiments. .
本申请实施例还提供一种计算机可读存储介质,其上存储有计算机指令,所述指令被执行时实现上述任意实施例中所述的区块生成方法的步骤。The embodiments of the present application also provide a computer-readable storage medium on which computer instructions are stored, which when executed, realize the steps of the block generation method described in any of the foregoing embodiments.
在本申请实施例中,提供了一种区块生成方法,第一节点首先获取第一节点和第二 节点之间的平均网络延迟、最大网络延迟和平均系统时间差值,接收第二节点生成的区块并计算接收到该区块时的本地时间戳,再根据获得的平均网络延迟、最大网络延迟、平均系统时间差值、本地时间戳和区块所携带的时间戳确定该区块是否为第二节点在满足预设时间要求的出块时间生成的区块。上述方案中的区块生成方法,通过结合本地时间戳、区块所携带的时间戳、平均网络延迟、最大网络延迟和平均系统时间差值来综合判断接收到的区块是否为第二节点在正常出块时间生成的区块,相比于现有技术中仅基于区块所携带的时间戳来进行判断,本方案的方法可以更准确地进行判断,可以降低区块时间合理性的误判率,从而避免或减少对时间不合理的区块做出进一步验证和确认而导致的恶意分叉和系统资源浪费,进而提高区块生成效率。通过上述方案解决了现有技术中区块时间合理性判断准确率低的技术问题,达到了有效提升区块时间合理性判断的准确率以及提高区块生成效率的技术效果。In an embodiment of the present application, a block generation method is provided. The first node first obtains the average network delay, the maximum network delay, and the average system time difference between the first node and the second node, and receives the second node generated Calculate the local timestamp when the block is received, and then determine whether the block is based on the average network delay, maximum network delay, average system time difference, local timestamp, and timestamp carried by the block It is a block generated by the second node at the block generation time that meets the preset time requirement. The block generation method in the above scheme comprehensively judges whether the received block is the second node by combining the local time stamp, the time stamp carried by the block, the average network delay, the maximum network delay, and the average system time difference. Compared with the judgment based on the timestamp carried by the block in the prior art, the block generated by the normal block time can be judged more accurately by the method of this scheme, which can reduce the misjudgment of the reasonableness of the block time. Therefore, to avoid or reduce the malicious fork and waste of system resources caused by further verification and confirmation of unreasonable time blocks, thereby improving the efficiency of block generation. The above solution solves the technical problem of the low accuracy of block time rationality judgment in the prior art, and achieves the technical effect of effectively improving the accuracy of block time rationality judgment and improving the efficiency of block generation.
附图说明Description of the drawings
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,并不构成对本申请的限定。在附图中:The drawings described here are used to provide a further understanding of the application, constitute a part of the application, and do not constitute a limitation to the application. In the attached picture:
图1示出了本申请一实施例中的区块生成方法的流程图;Figure 1 shows a flowchart of a block generation method in an embodiment of the present application;
图2示出了本申请一实施例中的区块生成装置的示意图;Fig. 2 shows a schematic diagram of a block generating device in an embodiment of the present application;
图3示出了本申请一实施例中的计算机设备的示意图。Fig. 3 shows a schematic diagram of a computer device in an embodiment of the present application.
具体实施方式detailed description
下面将参考若干示例性实施方式来描述本申请的原理和精神。应当理解,给出这些实施方式仅仅是为了使本领域技术人员能够更好地理解进而实现本申请,而并非以任何方式限制本申请的范围。相反,提供这些实施方式是为了使本申请公开更加透彻和完整,并且能够将本公开的范围完整地传达给本领域的技术人员。The principle and spirit of the present application will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are only provided to enable those skilled in the art to better understand and then implement the application, but not to limit the scope of the application in any way. On the contrary, these embodiments are provided to make the disclosure of this application more thorough and complete, and to fully convey the scope of the disclosure to those skilled in the art.
本领域的技术人员知道,本申请的实施方式可以实现为一种系统、装置设备、方法或计算机程序产品。因此,本申请公开可以具体实现为以下形式,即:完全的硬件、完全的软件(包括固件、驻留软件、微代码等),或者硬件和软件结合的形式。Those skilled in the art know that the implementation manners of this application can be implemented as a system, apparatus, method, or computer program product. Therefore, the disclosure of the present application can be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
本申请实施例提供了一种区块生成方法,如图1所示,可以包括以下步骤:The embodiment of the present application provides a block generation method, as shown in FIG. 1, which may include the following steps:
步骤S101,第一节点获取第一节点与第二节点之间的平均网络延迟和最大网络延迟。Step S101, the first node obtains the average network delay and the maximum network delay between the first node and the second node.
区块链可以是按照时间顺序将数据区块以顺序相连的方式组合成的一种链式数据结 构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。分布式账本是指交易记账由分布在不同地方的多个节点共同完成,而且每一个节点都记录的是完整的账目,因此它们都可以参与监督交易合法性,同时也可以共同为其作证。提议人提议的区块能否被其他区块确认取决于该区块是否是合理的,在出块时间符合的情况下,才会继续判断区块的合理性。考虑到大多数区块链系统本身并没有做时钟同步,而且由于网络中可能存在恶意节点可能恶意调整自己节点的系统时间,并且网络中不可避免的存在网络延迟,因此,需要动态诊断节点彼此间的系统时间差值和网络延迟。其中,第二节点是生成区块的节点,第一节点是验证第二节点的区块合理性的节点。首先,第一节点获取第一节点与第二节点之间的平均网络延迟和最大网络延迟。Blockchain can be a chained data structure that combines data blocks in sequence in chronological order, and is a distributed ledger that cannot be tampered with or forged that is guaranteed by cryptography. Distributed ledger means that transaction accounting is completed by multiple nodes distributed in different places, and each node records a complete account, so they can participate in the supervision of the legality of the transaction, and they can also jointly testify for it. Whether the block proposed by the proposer can be confirmed by other blocks depends on whether the block is reasonable. Only when the block generation time is consistent, will the block continue to be judged. Considering that most blockchain systems themselves do not synchronize their clocks, and because there may be malicious nodes in the network that may maliciously adjust the system time of their own nodes, and there is inevitable network delay in the network, it is necessary to dynamically diagnose the nodes between each other System time difference and network delay. Among them, the second node is a node that generates a block, and the first node is a node that verifies the rationality of the second node's block. First, the first node obtains the average network delay and the maximum network delay between the first node and the second node.
步骤S102,第一节点根据平均网络延迟确定第一节点和第二节点之间的平均系统时间差值。Step S102: The first node determines the average system time difference between the first node and the second node according to the average network delay.
具体地,第一节点和第二节点之间的平均系统时间差值可以通过第一节点和第二节点之间的平均网络延迟来确定。其中,系统时间差值是指第一节点的系统时间与第二节点的系统时间的差值。Specifically, the average system time difference between the first node and the second node may be determined by the average network delay between the first node and the second node. The system time difference refers to the difference between the system time of the first node and the system time of the second node.
步骤S103,第一节点接收第二节点生成的区块,并确定接收到区块时的本地时间戳,其中,区块中携带有时间戳。Step S103: The first node receives the block generated by the second node, and determines the local timestamp when the block is received, where the timestamp is carried in the block.
具体地,第一节点可以接受第二节点生成的区块,并确定第一节点接收到该区块时的本地时间戳。其中,第二节点生成的区块中携带有时间戳,即第二节点生成该区块的时间戳。Specifically, the first node may accept the block generated by the second node, and determine the local timestamp when the first node receives the block. Wherein, the block generated by the second node carries a timestamp, that is, the timestamp of the block generated by the second node.
步骤S104,第一节点根据平均网络延迟、最大网络延迟、平均系统时间差值、本地时间戳和区块所携带的时间戳确定区块是否为第二节点在满足预设时间要求的出块时间生成的区块。Step S104, the first node determines whether the block is the block generation time of the second node that meets the preset time requirement according to the average network delay, the maximum network delay, the average system time difference, the local timestamp and the timestamp carried by the block. The generated block.
第一节点在接收到区块后,根据获得的平均网络延迟、最大网络延迟、平均系统时间差值、本地时间戳和区块中携带的时间戳来确定该区块是否为第二节点在满足预设时间要求的出块时间生成的区块。After the first node receives the block, it determines whether the block is the second node in accordance with the obtained average network delay, maximum network delay, average system time difference, local timestamp, and timestamp carried in the block. The block generated by the block generation time required by the preset time.
上述实施例中的区块生成方法,通过结合本地时间戳、区块所携带的时间戳、平均网络延迟、最大网络延迟和平均系统时间差值来综合判断接收到的区块是否为第二节点在正常出块时间生成的区块,相比于现有技术中仅基于区块所携带的时间戳来进行判断,本方案的方法可以更准确地进行判断,可以降低区块时间合理性的误判率,从而避免或减少对时间不合理的区块做出进一步验证和确认而导致的恶意分叉和系统资源浪费,进 而提高区块生成效率。通过上述方案解决了现有技术中区块时间合理性判断准确率低的技术问题,达到了有效提升区块时间合理性判断的准确率以及提高区块生成效率的技术效果。The block generation method in the above embodiment comprehensively judges whether the received block is the second node by combining the local time stamp, the time stamp carried by the block, the average network delay, the maximum network delay, and the average system time difference. Compared with the judgment based on the timestamp carried by the block in the prior art, the block generated during the normal block generation time can be judged more accurately by the method of this scheme, which can reduce errors in the reasonableness of the block time. Therefore, it can avoid or reduce the malicious fork and waste of system resources caused by further verification and confirmation of unreasonable time blocks, thereby improving the efficiency of block generation. The above solution solves the technical problem of the low accuracy of block time rationality judgment in the prior art, and achieves the technical effect of effectively improving the accuracy of block time rationality judgment and improving the efficiency of block generation.
为了获取第一节点和第二节点之间的平均网络延迟和最大网络延迟,可以让第一节点和第二节点进行多次信息交互操作,并记录相应的时间戳,从而获取第一节点和第二节点之间的多个网络延迟数据。因此,在本申请的一些实施例中,第一节点获取第一节点与第二节点之间的平均网络延迟和最大网络延迟,可以包括:第一节点重复执行N次如下信息交互操作,以得到N个网络延迟数据:第一节点发送ping报文给第二节点,其中,ping报文中携带有ping报文离开第一节点的第一时间戳;第一节点接收第二节点响应于ping报文返回的pong报文;第一节点计算第一节点接收到pong报文的第二时间戳;第一节点根据第一时间戳和第二时间戳计算第一节点和第二节点之间的网络延迟数据,其中,N为正整数;第一节点根据N个网络延迟数据确定第一节点和第二节点之间的平均网络延迟和最大网络延迟。In order to obtain the average network delay and the maximum network delay between the first node and the second node, the first node and the second node can perform multiple information interaction operations and record the corresponding timestamps, thereby obtaining the first node and the second node. Multiple network delay data between two nodes. Therefore, in some embodiments of the present application, obtaining the average network delay and the maximum network delay between the first node and the second node by the first node may include: the first node repeatedly performs the following information interaction operations N times to obtain N network delay data: the first node sends a ping message to the second node, where the ping message carries the first time stamp when the ping message leaves the first node; the first node receives the second node's response to the ping message The pong message returned by the text; the first node calculates the second timestamp of the pong message received by the first node; the first node calculates the network between the first node and the second node according to the first timestamp and the second timestamp Delay data, where N is a positive integer; the first node determines the average network delay and the maximum network delay between the first node and the second node according to the N network delay data.
具体地,第一节点和第二节点重复执行N次信息交互操作,其中,执行次数N可以根据实际情况预先设定。在每次信息交互操作中,第一节点发送ping报文给第二节点,其中,ping报文中携带有该ping报文离开第一节点的第一时间戳;第二节点接收到ping报文后向第一节点发送pong报文,其中,pong报文中可以携带有pong报文离开第二节点的时间戳;第一节点接收第二节点返回的pong报文并计算第一节点在接收到该pong报文时的第二时间戳;第一节点根据第一时间戳和第二时间戳计算本次信息交互操作中第一节点和第二节点之间的网络延迟数据。在进行N次信息交互操作之后,第一节点根据获得的N个网络延迟数据确定第一节点和第二节点之间的平均网络延迟和最大网络延迟。通过上述方式,可以方便准确地获取第一节点和第二节点之间的平均网络延迟和最大网络延迟。Specifically, the first node and the second node repeatedly execute information exchange operations N times, where the number of execution times N can be preset according to actual conditions. In each information exchange operation, the first node sends a ping message to the second node, where the ping message carries the first timestamp of the ping message leaving the first node; the second node receives the ping message Then send a pong message to the first node, where the pong message can carry the timestamp of the pong message leaving the second node; the first node receives the pong message returned by the second node and calculates the time when the first node received The second time stamp of the pong message; the first node calculates the network delay data between the first node and the second node in this information interaction operation according to the first time stamp and the second time stamp. After performing N information exchange operations, the first node determines the average network delay and the maximum network delay between the first node and the second node according to the obtained N network delay data. Through the above method, the average network delay and the maximum network delay between the first node and the second node can be conveniently and accurately obtained.
进一步地,在本申请的一些实施例中,第一节点根据N个网络延迟数据确定第一节点和第二节点之间的平均网络延迟和最大网络延迟,可以包括:Further, in some embodiments of the present application, the first node to determine the average network delay and the maximum network delay between the first node and the second node according to N network delay data may include:
按照以下公式计算网络延迟均值:Calculate the average network delay according to the following formula:
Figure PCTCN2019076577-appb-000003
Figure PCTCN2019076577-appb-000003
按照以下公式计算最大网络延迟:Calculate the maximum network delay according to the following formula:
NetDelay max=Max(Delay 0:Delay N-1); NetDelay max =Max(Delay 0 : Delay N-1 );
根据计算得到的网络延迟均值和预设的系统允许最大网络延迟,确定平均网络延迟。Determine the average network delay according to the calculated average network delay and the preset maximum network delay allowed by the system.
其中,NetDelay aver为网络延迟均值,NetDelay max为最大网络延迟,N为执行信息交互操作的总次数,i=0,...,N-1,Delay i是第一节点在第i次执行信息交互操作中计算得到的第一节点和第二节点之间的网络延迟数据,Delay i=(T2 i-T1 i)/2,Max(Delay 0:Delay N-1)用于确定Delay 0,Delay 1,……Delay N-1中最大的网络延迟数据,作为第一节点和第二节点之间的最大网络延迟;其中,T2 i是第i次信息交互操作中的第一节点接收到第二节点返回的pong报文时的第二时间戳,T1 i是第i次信息交互操作中的第一节点发送的ping报文中携带的离开第一节点的第一时间戳。通过上述方式,在确定网络延迟均值之后,可以根据网络延迟均值和预设的系统允许最大网络延迟来综合确定平均网络延迟,使得后续区块时间合理性的判断更为准确。 Among them, NetDelay aver is the average network delay, NetDelay max is the maximum network delay, N is the total number of times to perform information interaction operations, i=0,...,N-1, and Delay i is the i-th execution information of the first node The network delay data between the first node and the second node calculated in the interactive operation, Delay i = (T2 i- T1 i )/2, Max (Delay 0 : Delay N-1 ) is used to determine Delay 0 , Delay 1 ,...... The largest network delay data in Delay N-1 , as the largest network delay between the first node and the second node; where T2 i is the i-th information interaction operation received by the first node The second time stamp of the pong message returned by the node, and T1 i is the first time stamp of leaving the first node carried in the ping message sent by the first node in the i-th information exchange operation. Through the above method, after determining the average network delay, the average network delay can be comprehensively determined according to the average network delay and the preset maximum network delay allowed by the system, so that the judgment of the reasonableness of subsequent block time is more accurate.
进一步地,在本申请的一些实施例中,根据计算得到的网络延迟均值和预设的系统允许最大网络延迟,计算平均网络延迟,可以包括:确定网络延迟均值是否大于预设的系统允许最大网络延迟;在确定网络延迟均值大于预设的系统允许最大网络延迟的情况下,将预设的系统允许最大网络延迟确定为平均网络延迟;在确定网络延迟均值不大于预设的系统允许最大网络延迟的情况下,将网络延迟均值确定为平均网络延迟。其中,系统允许最大网络延迟可以根据系统参数以及实际需求来设定。通过上述方式,可以将用于判断区块时间合理性的平均网络延迟限制在比较合理的范围内,从而提高判断的准确性。Further, in some embodiments of the present application, calculating the average network delay based on the calculated average network delay value and the preset system allowable maximum network delay may include: determining whether the network delay average value is greater than the preset system allowable maximum network delay Delay; in the case of determining that the average network delay is greater than the preset maximum network delay allowed by the system, the preset maximum allowed network delay of the system is determined as the average network delay; after determining that the average network delay is not greater than the preset maximum allowed network delay In the case of, the average network delay is determined as the average network delay. Among them, the maximum network delay allowed by the system can be set according to system parameters and actual requirements. Through the above method, the average network delay used to judge the reasonableness of the block time can be limited to a reasonable range, thereby improving the accuracy of the judgment.
进一步地,在本申请的一些实施例中,第一节点根据平均网络延迟确定第一节点和第二节点之间的平均系统时间差值,可以包括:Further, in some embodiments of the present application, the first node determining the average system time difference between the first node and the second node according to the average network delay may include:
按照以下公式计算系统时间差值均值:Calculate the mean value of the system time difference according to the following formula:
Figure PCTCN2019076577-appb-000004
Figure PCTCN2019076577-appb-000004
根据系统时间差值均值和预设的系统允许最大系统时间差值,确定平均系统时间差值。Determine the average system time difference according to the average system time difference and the preset maximum system time difference allowed by the system.
其中,TimeDiff aver为系统时间差值均值,NetDelay为平均网络延迟,T2 i是第i次信息交互操作中的第一节点接收到第二节点返回的pong报文时的第二时间戳,T1 i是第i次信息交互操作中的第一节点发送的ping报文中携带的离开第一节点的第一时间戳。通过上述方式,在确定系统时间差值均值之后,可以根据系统时间差值均值和预设的系统 允许最大系统时间差值来综合确定平均系统时间差值,使得后续区块时间合理性的判断更为准确。 Among them, TimeDiff aver is the average value of the system time difference, NetDelay is the average network delay, T2 i is the second timestamp when the first node in the i-th information interaction operation receives the pong message returned by the second node, T1 i It is the first time stamp of leaving the first node carried in the ping message sent by the first node in the i-th information exchange operation. Through the above method, after determining the average system time difference, the average system time difference can be comprehensively determined according to the average system time difference and the preset maximum system time difference allowed by the system, so that the subsequent block time rationality judgment is more Is accurate.
进一步地,在本申请的一些实施例中,根据系统时间差值均值和系统允许的最大系统时间差值阈值,确定平均系统时间差,可以包括:确定系统时间差值均值是否大于预设的系统允许最大系统时间差值;在确定系统时间差值均值大于预设的系统允许最大系统时间差值的情况下,将预设的系统允许最大系统时间差值确定为平均系统时间差值;在确定系统时间差值均值不大于预设的系统允许最大系统时间差值的情况下,将系统时间差值均值确定为平均系统时间差值。其中,系统允许最大系统时间差值可以根据系统参数以及实际需求来设定。通过上述方式,可以将用于判断区块时间合理性的平均系统时间差值限制在比较合理的范围内,从而提高判断的准确性。Further, in some embodiments of the present application, determining the average system time difference based on the average system time difference value and the maximum system time difference threshold allowed by the system may include: determining whether the average system time difference value is greater than a preset system allowable value Maximum system time difference; when it is determined that the average system time difference is greater than the preset maximum system time difference allowed by the system, the preset maximum system time difference allowed by the system is determined as the average system time difference; If the average time difference is not greater than the preset maximum system time difference allowed by the system, the average system time difference is determined as the average system time difference. Among them, the maximum system time difference allowed by the system can be set according to system parameters and actual needs. Through the above method, the average system time difference used for judging the reasonableness of the block time can be limited to a reasonable range, thereby improving the accuracy of judgment.
进一步地,在本申请的一些实施例中,第一节点根据平均网络延迟、最大网络延迟、平均系统时间差值、本地时间戳和区块所携带的时间戳确定区块是否为第二节点在满足预设时间要求的出块时间生成的区块,可以包括:验证以下不等式是否成立以确定区块是否为第二节点在满足预设时间要求的出块时间生成的区块:Further, in some embodiments of the present application, the first node determines whether the block is the second node based on the average network delay, the maximum network delay, the average system time difference, the local timestamp, and the timestamp carried by the block. The block generated by the block generation time meeting the preset time requirement may include: verifying whether the following inequality is true to determine whether the block is a block generated by the second node at the block generation time meeting the preset time requirement:
Localtime+TimeDiff+NetDelay max≥timestamp+NetDelay≥Localtime+TimeDiff。 Localtime+TimeDiff+NetDelay max ≥timestamp+NetDelay≥Localtime+TimeDiff.
其中,Localtime为本地时间戳,TimeDiff为平均系统时间差值,NetDelay max为最大网络延迟,timestamp为区块中携带的时间戳,NetDelay为平均网络延迟。通过上述方式,在区块所携带的时间戳与平均网络延迟之和在本地时间戳与平均系统时间差值之和以及本地时间戳、平均系统时间差值和最大网络延迟之和之间的情况下,可以确定该区块为第二节点在满足预设时间要求的出块时间生成的区块。在不满足上述不等式的情况下,可以确认该区块不合理,无需进行下一步的验证。通过上述方式,可以简单而准确地判断区块时间合理性,有利于提高区块生成效率。 Among them, Localtime is the local timestamp, TimeDiff is the average system time difference, NetDelay max is the maximum network delay, timestamp is the timestamp carried in the block, and NetDelay is the average network delay. Through the above method, the situation between the sum of the time stamp carried by the block and the average network delay between the sum of the local time stamp and the average system time difference and the sum of the local time stamp, the average system time difference and the maximum network delay Next, it can be determined that the block is a block generated by the second node at the block generation time that meets the preset time requirement. If the above inequality is not satisfied, it can be confirmed that the block is unreasonable and no further verification is required. Through the above method, the reasonableness of the block time can be judged simply and accurately, which is beneficial to improve the efficiency of block generation.
下面结合一个具体实施例对上述方法进行说明,然而,值得注意的是,该具体实施例仅是为了更好地说明本申请,并不构成对本申请的不当限定。The above method will be described below in conjunction with a specific embodiment. However, it is worth noting that this specific embodiment is only for better describing the application, and does not constitute an improper limitation of the application.
在本实施例中,区块生成方法可以包括以下步骤:In this embodiment, the block generation method may include the following steps:
步骤1,第一节点与第二节点经过N次信息交互操作,每次信息交互操作包括以下子步骤:Step 1. The first node and the second node undergo N information interaction operations, and each information interaction operation includes the following sub-steps:
步骤1.1,第一节点发送ping报文给第二节点,该报文带有它离开第一节点时的时间戳T1 iStep 1.1, the first node sends a ping message to the second node with the timestamp T1 i when it leaves the first node;
步骤1.2,当报文到达第二节点时,第二节点计算自己的时间戳;Step 1.2, when the message reaches the second node, the second node calculates its own timestamp;
步骤1.3,第二节点回复一个pong消息给第一节点,将自己的时间戳写入pong消息;Step 1.3, the second node replies a pong message to the first node, and writes its own timestamp into the pong message;
步骤1.4,当第一节点接收到该pong报文时,计算第一节点接收到该pong报文时的本地时间戳T2 iStep 1.4: When the first node receives the pong message, calculate the local timestamp T2 i when the first node receives the pong message;
步骤1.5,第一节点可以根据T1 i和T2 i计算第二节点和第一节点的网络延迟数据Delay i=(T2 i-T1 i)/2;其中,i=0,...,N-1。 Step 1.5, the first node can calculate the network delay data of the second node and the first node according to T1 i and T2 i . Delay i = (T2 i- T1 i )/2; where i = 0,...,N- 1.
步骤2,第一节点根据N个网络延迟数据计算第一节点和第二节点之间的平均网络延迟和最大网络延迟,可以包括以下子步骤:Step 2. The first node calculates the average network delay and the maximum network delay between the first node and the second node according to the N network delay data, which may include the following sub-steps:
步骤2.1,按照以下公式计算网络延迟均值:Step 2.1, calculate the average network delay according to the following formula:
Figure PCTCN2019076577-appb-000005
Figure PCTCN2019076577-appb-000005
步骤2.1,根据计算得到的网络延迟均值和预设的系统允许最大网络延迟,确定平均网络延迟,如果网络延迟均值大于系统允许的最大网络延迟,则平均网络延迟为系统允许的最大网络延迟,否则平均网络延迟为所述网络延迟均值;Step 2.1: Determine the average network delay based on the calculated average network delay and the preset maximum network delay allowed by the system. If the average network delay is greater than the maximum network delay allowed by the system, the average network delay is the maximum network delay allowed by the system, otherwise The average network delay is the average value of the network delay;
步骤2.3,按照以下公式计算最大网络延迟:Step 2.3, calculate the maximum network delay according to the following formula:
NetDelay max=Max(Delay 0:Delay N-1)。 NetDelay max = Max (Delay 0 : Delay N-1 ).
步骤3,第一节点根据平均网络延迟确定第一节点和第二节点之间的平均系统时间差值,可以包括以下子步骤:Step 3. The first node determines the average system time difference between the first node and the second node according to the average network delay, which may include the following sub-steps:
步骤3.1,按照以下公式计算系统时间差值均值:Step 3.1, calculate the average system time difference according to the following formula:
Figure PCTCN2019076577-appb-000006
Figure PCTCN2019076577-appb-000006
其中,TimeDiff aver为系统时间差值均值,NetDelay为平均网络延迟,T2 i是第i次信息交互操作中的第二时间戳,T1 i是第i次信息交互操作中的第一时间戳; Among them, TimeDiff aver is the average value of the system time difference, NetDelay is the average network delay, T2 i is the second time stamp in the i-th information interaction operation, and T1 i is the first time stamp in the i-th information interaction operation;
步骤3.2,根据系统时间差值均值和预设的系统允许最大系统时间差值,确定平均系统时间差值。在系统时间差值均值大于预设的系统允许最大系统时间差值的情况下,将预设的系统允许最大系统时间差值确定为平均系统时间差值,否则将系统时间差值均值确定为所述平均系统时间差值。Step 3.2: Determine the average system time difference according to the average system time difference and the preset maximum system time difference allowed by the system. When the average system time difference is greater than the preset maximum system time difference allowed by the system, the preset maximum system time difference allowed by the system is determined as the average system time difference; otherwise, the average system time difference is determined as all The average system time difference.
步骤4,第一节点接收第二节点生成的区块,并确定第一节点接收到区块时的本地时间戳,其中,区块中携带有时间戳。Step 4. The first node receives the block generated by the second node, and determines the local timestamp when the first node receives the block, where the timestamp is carried in the block.
步骤5,第一节点根据平均网络延迟、最大网络延迟、平均系统时间差值、本地时 间戳和区块中携带的时间戳确定区块是否为第二节点在满足预设时间要求的出块时间生成的区块,可以包括以下步骤:Step 5. The first node determines whether the block is the block generation time for the second node to meet the preset time requirements based on the average network delay, maximum network delay, average system time difference, local timestamp, and timestamp carried in the block. The generated block can include the following steps:
验证以下不等式是否成立以确定区块是否为第二节点在满足预设时间要求的出块时间生成的区块:Verify whether the following inequality is true to determine whether the block is a block generated by the second node at the block generation time that meets the preset time requirement:
Localtime+TimeDiff+NetDelay max≥timestamp+NetDelay≥Localtime+TimeDiff, Localtime+TimeDiff+NetDelay max ≥timestamp+NetDelay≥Localtime+TimeDiff,
其中,Localtime为本地时间戳,TimeDiff为平均系统时间差值,NetDelay max为最大网络延迟,timestamp为区块中携带的时间戳,NetDelay为平均网络延迟。 Among them, Localtime is the local timestamp, TimeDiff is the average system time difference, NetDelay max is the maximum network delay, timestamp is the timestamp carried in the block, and NetDelay is the average network delay.
在具体实施过程中,上述方案可以根据不同区块链的应用需求,动态调整系统允许最大网络延迟、系统允许最大系统时间差值以及采样次数N等参数,从而可以适配不同的区块链并行确认区块的需求。上述方案中,通过第一节点和第二节点之间的多次信息交互操作,方便准确地获取平均网络延迟、最大网络延迟和系统时间差值,然后根据获得的这些参数以及第一节点接收到第二节点生成的区块的本地时间以及该区块携带的时间戳来综合判断该区块是否为第二节点在合理出块时间生成的区块,其中,通过这些参数生成的判断条件为简单的不等式,通过确定该不等式是否成立来判断该区块时间的合理性,操作过程简单快捷,而且判断的准确率得以有效提高,从而避免或减少对时间不合理的区块做出进一步验证和确认而导致的恶意分叉和系统资源浪费,进而提高区块生成效率。In the specific implementation process, the above scheme can dynamically adjust the parameters such as the maximum network delay allowed by the system, the maximum system time difference allowed by the system, and the number of sampling times N according to the application requirements of different blockchains, so as to adapt to different blockchains in parallel. Confirm the needs of the block. In the above scheme, through multiple information interaction operations between the first node and the second node, the average network delay, maximum network delay, and system time difference can be conveniently and accurately obtained, and then these parameters are obtained and the first node receives The local time of the block generated by the second node and the timestamp carried by the block are used to comprehensively determine whether the block is a block generated by the second node at a reasonable block generation time, where the judgment condition generated by these parameters is simple By determining whether the inequality is established, the reasonableness of the block time is judged. The operation process is simple and fast, and the accuracy of the judgment can be effectively improved, thereby avoiding or reducing further verification and confirmation of unreasonable blocks The resulting malicious forks and waste of system resources, thereby improving the efficiency of block generation.
基于同一发明构思,本申请实施例中还提供了一种区块生成装置,如下面的实施例所述。由于区块生成装置解决问题的原理与区块生成方法相似,因此区块生成装置的实施可以参见区块生成方法的实施,重复之处不再赘述。以下所使用的,术语“单元”或者“模块”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。图2是本申请实施例的区块生成装置的一种结构框图,如图2所示,包括:获取模块201、第一确定模块202、接收模块203和第二确定模块204,下面对该结构进行说明。Based on the same inventive concept, an embodiment of the present application also provides a block generation device, as described in the following embodiment. Since the problem-solving principle of the block generation device is similar to the block generation method, the implementation of the block generation device can refer to the implementation of the block generation method, and the repetition will not be repeated. As used below, the term "unit" or "module" can be a combination of software and/or hardware that implements predetermined functions. Although the devices described in the following embodiments are preferably implemented by software, hardware or a combination of software and hardware is also possible and conceived. FIG. 2 is a structural block diagram of the block generation device of the embodiment of the present application. As shown in FIG. 2, it includes: an acquiring module 201, a first determining module 202, a receiving module 203, and a second determining module 204. The structure is explained.
获取模块201用于获取第一节点与第二节点之间的平均网络延迟和最大网络延迟。The obtaining module 201 is configured to obtain the average network delay and the maximum network delay between the first node and the second node.
第一确定模块202用于根据平均网络延迟确定第一节点和第二节点之间的平均系统时间差值。The first determining module 202 is configured to determine the average system time difference between the first node and the second node according to the average network delay.
接收模块203用于接收第二节点生成的区块,并确定接收到区块时的本地时间戳,其中,区块中携带有时间戳。The receiving module 203 is configured to receive the block generated by the second node and determine the local timestamp when the block is received, where the timestamp is carried in the block.
第二确定模块204用于根据平均网络延迟、最大网络延迟、平均系统时间差值、本地时间戳和区块所携带的时间戳确定区块是否为第二节点在满足预设时间要求的出块时间生成的区块。The second determining module 204 is configured to determine whether the block is a block produced by the second node that meets the preset time requirement according to the average network delay, the maximum network delay, the average system time difference, the local timestamp, and the timestamp carried by the block. Time generated block.
在本申请的一些实施例中,获取模块具体可以用于:第一节点重复执行N次如下信息交互操作,以得到N个网络延迟数据:第一节点发送ping报文给第二节点,其中,ping报文中携带有ping报文离开第一节点的第一时间戳;第一节点接收第二节点响应于ping报文返回的pong报文;第一节点计算第一节点接收到pong报文的第二时间戳;第一节点根据第一时间戳和第二时间戳计算第一节点和第二节点之间的网络延迟数据,其中,N为正整数;第一节点根据N个网络延迟数据确定第一节点和第二节点之间的平均网络延迟和最大网络延迟。In some embodiments of the present application, the acquisition module may be specifically used to: the first node repeatedly executes the following information exchange operations N times to obtain N network delay data: the first node sends a ping message to the second node, where: The ping message carries the first time stamp when the ping message leaves the first node; the first node receives the pong message returned by the second node in response to the ping message; the first node calculates the number of times the first node receives the pong message The second timestamp; the first node calculates the network delay data between the first node and the second node according to the first timestamp and the second timestamp, where N is a positive integer; the first node determines according to N network delay data The average network delay and the maximum network delay between the first node and the second node.
在本申请的一些实施例中,第一节点根据N个网络延迟数据确定第一节点和第二节点之间的平均网络延迟和最大网络延迟,可以包括:In some embodiments of the present application, the first node determining the average network delay and the maximum network delay between the first node and the second node according to the N network delay data may include:
按照以下公式计算网络延迟均值:Calculate the average network delay according to the following formula:
Figure PCTCN2019076577-appb-000007
Figure PCTCN2019076577-appb-000007
按照以下公式计算最大网络延迟:Calculate the maximum network delay according to the following formula:
NetDelay max=Max(Delay 0:Delay N-1); NetDelay max =Max(Delay 0 : Delay N-1 );
根据计算得到的网络延迟均值和预设的系统允许最大网络延迟,确定平均网络延迟,Determine the average network delay according to the calculated average network delay and the preset maximum network delay allowed by the system,
其中,NetDelay aver为网络延迟均值,NetDelay max为最大网络延迟,i=0,...,N-1,Delay i是第一节点在第i次执行信息交互操作中计算得到的第一节点和第二节点之间的网络延迟数据,Delay i=(T2 i-T1 i)/2,其中,T2 i是第i次信息交互操作中的第二时间戳,T1 i是第i次信息交互操作中的第一时间戳。 Among them, NetDelay aver is the average value of network delay, NetDelay max is the maximum network delay, i=0,...,N-1, Delay i is the first node and calculated by the first node in the i-th execution of the information interaction operation Network delay data between the second nodes, Delay i = (T2 i- T1 i )/2, where T2 i is the second time stamp in the i-th information interaction operation, and T1 i is the i-th information interaction operation The first timestamp in.
在本申请的一些实施例中,根据计算得到的网络延迟均值和预设的系统允许最大网络延迟,计算平均网络延迟,可以包括:确定网络延迟均值是否大于预设的系统允许最大网络延迟;在确定网络延迟均值大于预设的系统允许最大网络延迟的情况下,将预设的系统允许最大网络延迟确定为平均网络延迟;在确定网络延迟均值不大于预设的系统允许最大网络延迟的情况下,将网络延迟均值确定为平均网络延迟。In some embodiments of the present application, calculating the average network delay based on the calculated average network delay value and the preset system allowable maximum network delay may include: determining whether the network delay average value is greater than the preset system allowable maximum network delay; When it is determined that the average network delay is greater than the preset maximum allowable network delay of the system, the preset maximum allowable network delay of the system is determined as the average network delay; when it is determined that the average network delay is not greater than the preset maximum allowable network delay of the system , Determine the average network delay as the average network delay.
在本申请的一些实施例中,第一确定模块具体可以用于:In some embodiments of the present application, the first determining module may be specifically used to:
按照以下公式计算系统时间差值均值:Calculate the mean value of the system time difference according to the following formula:
Figure PCTCN2019076577-appb-000008
Figure PCTCN2019076577-appb-000008
其中,TimeDiff aver为系统时间差值均值,NetDelay为平均网络延迟,T2 i是第i次信息交互操作中的第二时间戳,T1 i是第i次信息交互操作中的第一时间戳; Among them, TimeDiff aver is the average value of the system time difference, NetDelay is the average network delay, T2 i is the second time stamp in the i-th information interaction operation, and T1 i is the first time stamp in the i-th information interaction operation;
根据系统时间差值均值和预设的系统允许最大系统时间差值,确定平均系统时间差值。Determine the average system time difference according to the average system time difference and the preset maximum system time difference allowed by the system.
在本申请的一些实施例中,根据系统时间差值均值和系统允许的最大系统时间差值阈值,确定平均系统时间差,可以包括:确定系统时间差值均值是否大于预设的系统允许最大系统时间差值;在确定系统时间差值均值大于预设的系统允许最大系统时间差值的情况下,将预设的系统允许最大系统时间差值确定为平均系统时间差值;在确定系统时间差值均值不大于预设的系统允许最大系统时间差值的情况下,将系统时间差值均值确定为平均系统时间差值。In some embodiments of the present application, determining the average system time difference based on the average system time difference value and the maximum system time difference threshold allowed by the system may include: determining whether the average system time difference value is greater than the preset maximum system time allowed by the system Difference; when it is determined that the mean value of the system time difference is greater than the preset maximum system time difference allowed by the system, the preset maximum system time difference allowed by the system is determined as the average system time difference; when determining the system time difference When the average value is not greater than the preset maximum system time difference allowed by the system, the average system time difference value is determined as the average system time difference value.
在本申请的一些实施例中,第二确定模块具体可以用于:验证以下不等式是否成立以确定区块是否为第二节点在满足预设时间要求的出块时间生成的区块:In some embodiments of the present application, the second determining module may be specifically used to verify whether the following inequality is true to determine whether the block is a block generated by the second node at a block generation time that meets the preset time requirement:
Localtime+TimeDiff+NetDelay max≥timestamp+NetDelay≥Localtime+TimeDiff, Localtime+TimeDiff+NetDelay max ≥timestamp+NetDelay≥Localtime+TimeDiff,
其中,Localtime为本地时间戳,TimeDiff为平均系统时间差值,NetDelay max为最大网络延迟,timestamp为区块中携带的时间戳,NetDelay为平均网络延迟。 Among them, Localtime is the local timestamp, TimeDiff is the average system time difference, NetDelay max is the maximum network delay, timestamp is the timestamp carried in the block, and NetDelay is the average network delay.
从以上的描述中,可以看出,本申请实施例实现了如下技术效果:通过结合本地时间戳、区块所携带的时间戳、平均网络延迟、最大网络延迟和平均系统时间差值来综合判断接收到的区块是否为第二节点在正常出块时间生成的区块,相比于现有技术中仅基于区块所携带的时间戳来进行判断,本方案的方法可以更准确地进行判断,可以降低区块时间合理性的误判率,从而避免或减少对时间不合理的区块做出进一步验证和确认而导致的恶意分叉和系统资源浪费,进而提高区块生成效率。通过上述方案解决了现有技术中区块时间合理性判断准确率低的技术问题,达到了有效提升区块时间合理性判断的准确率以及提高区块生成效率的技术效果。From the above description, it can be seen that the embodiments of the present application achieve the following technical effects: comprehensively judge by combining the local time stamp, the time stamp carried by the block, the average network delay, the maximum network delay, and the average system time difference Whether the received block is a block generated by the second node during the normal block generation time, compared with the prior art only based on the time stamp carried by the block to determine, the method of this solution can make the determination more accurately , Can reduce the rate of misjudgment of block time rationality, thereby avoiding or reducing malicious forks and waste of system resources caused by further verification and confirmation of unreasonable blocks, thereby improving the efficiency of block generation. The above solution solves the technical problem of the low accuracy of block time rationality judgment in the prior art, and achieves the technical effect of effectively improving the accuracy of block time rationality judgment and improving the efficiency of block generation.
本申请实施方式还提供了一种计算机设备,具体可以参阅图3所示的基于本申请实施例提供的区块生成方法的计算机设备组成结构示意图,所述计算机设备具体可以包括输入设备31、处理器32、存储器33。其中,所述存储器33用于存储处理器可执行指令。所述处理器32执行所述指令时实现上述任意实施例中所述的区块生成方法的步骤。所述 输入设备31具体可以用于输入N、系统允许最大网络延迟和系统允许最大系统时间差值等参数。The embodiment of the present application also provides a computer device. For details, please refer to the schematic diagram of the structure of the computer device based on the block generation method provided by the embodiment of the present application shown in FIG. 3. The computer device may specifically include an input device 31 and a processing device.器32, memory 33. Wherein, the memory 33 is used to store processor executable instructions. The processor 32 implements the steps of the block generation method described in any of the foregoing embodiments when executing the instructions. The input device 31 may be specifically used to input parameters such as N, the maximum network delay allowed by the system, and the maximum system time difference allowed by the system.
在本实施方式中,所述输入设备具体可以是用户和计算机系统之间进行信息交互的主要装置之一。所述输入设备可以包括键盘、鼠标、摄像头、扫描仪、光笔、手写输入板、语音输入装置等;输入设备用于把原始数据和处理这些数的程序输入到计算机中。所述输入设备还可以获取接收其他模块、单元、设备传输过来的数据。所述处理器可以按任何适当的方式实现。例如,处理器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式等等。所述存储器具体可以是现代信息技术中用于保存信息的记忆设备。所述存储器可以包括多个层次,在数字系统中,只要能保存二进制数据的都可以是存储器;在集成电路中,一个没有实物形式的具有存储功能的电路也叫存储器,如RAM、FIFO等;在系统中,具有实物形式的存储设备也叫存储器,如内存条、TF卡等。In this embodiment, the input device may specifically be one of the main devices for information interaction between the user and the computer system. The input device may include a keyboard, a mouse, a camera, a scanner, a light pen, a handwriting input board, a voice input device, etc.; the input device is used to input raw data and programs for processing these numbers into the computer. The input device can also obtain and receive data transmitted from other modules, units, and devices. The processor can be implemented in any suitable way. For example, the processor may take the form of a microprocessor or a processor and a computer-readable medium, logic gates, switches, application specific integrated circuits ( Application Specific Integrated Circuit (ASIC), programmable logic controller and embedded microcontroller form, etc. The memory may specifically be a memory device used to store information in modern information technology. The memory can include multiple levels. In a digital system, as long as it can store binary data, it can be a memory; in an integrated circuit, a circuit with a storage function without a physical form is also called a memory, such as RAM, FIFO, etc.; In the system, storage devices in physical form are also called memory, such as memory sticks, TF cards, etc.
在本实施方式中,该计算机设备具体实现的功能和效果,可以与其它实施方式对照解释,在此不再赘述。In this embodiment, the specific functions and effects implemented by the computer device can be explained in comparison with other embodiments, and will not be repeated here.
本申请实施方式中还提供了一种基于区块生成方法的计算机存储介质,所述计算机存储介质存储有计算机程序指令,在所述计算机程序指令被执行时实现上述任意实施例中所述区块生成方法的步骤。The embodiment of the present application also provides a computer storage medium based on the block generation method, the computer storage medium stores computer program instructions, and when the computer program instructions are executed, the block described in any of the above embodiments is implemented. Steps to generate method.
在本实施方式中,上述存储介质包括但不限于随机存取存储器(Random Access Memory,RAM)、只读存储器(Read-Only Memory,ROM)、缓存(Cache)、硬盘(Hard Disk Drive,HDD)或者存储卡(Memory Card)。所述存储器可以用于存储计算机程序指令。网络通信单元可以是依照通信协议规定的标准设置的,用于进行网络连接通信的接口。In this embodiment, the above-mentioned storage medium includes but is not limited to random access memory (Random Access Memory, RAM), read-only memory (Read-Only Memory, ROM), cache (Cache), and hard disk (Hard Disk Drive, HDD) Or memory card (Memory Card). The memory can be used to store computer program instructions. The network communication unit may be an interface set up in accordance with a standard stipulated by the communication protocol and used for network connection communication.
在本实施方式中,该计算机存储介质存储的程序指令具体实现的功能和效果,可以与其它实施方式对照解释,在此不再赘述。In this embodiment, the specific functions and effects realized by the program instructions stored in the computer storage medium can be explained in comparison with other embodiments, and will not be repeated here.
显然,本领域的技术人员应该明白,上述的本申请实施例的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以 将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本申请实施例不限制于任何特定的硬件和软件结合。Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present application can be implemented by a general computing device, and they can be concentrated on a single computing device or distributed among multiple computing devices. Optionally, they can be implemented with program codes executable by a computing device, so that they can be stored in a storage device for execution by the computing device, and in some cases, can be different from here The steps shown or described are executed in the order of, or they are respectively fabricated into individual integrated circuit modules, or multiple modules or steps of them are fabricated into a single integrated circuit module to achieve. In this way, the embodiments of the present application are not limited to any specific hardware and software combination.
应该理解,以上描述是为了进行图示说明而不是为了进行限制。通过阅读上述描述,在所提供的示例之外的许多实施方式和许多应用对本领域技术人员来说都将是显而易见的。因此,本申请的范围不应该参照上述描述来确定,而是应该参照前述权利要求以及这些权利要求所拥有的等价物的全部范围来确定。It should be understood that the above description is for illustration and not for limitation. By reading the above description, many implementations and many applications beyond the examples provided will be apparent to those skilled in the art. Therefore, the scope of this application should not be determined with reference to the above description, but should be determined with reference to the foregoing claims and the full range of equivalents possessed by these claims.
以上所述仅为本申请的优选实施例而已,并不用于限制本申请,对于本领域的技术人员来说,本申请实施例可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The foregoing descriptions are only preferred embodiments of the present application, and are not intended to limit the present application. For those skilled in the art, the embodiments of the present application may have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included in the protection scope of this application.

Claims (10)

  1. 一种区块生成方法,其特征在于,包括:A block generation method, characterized in that it comprises:
    第一节点获取所述第一节点与第二节点之间的平均网络延迟和最大网络延迟;The first node obtains the average network delay and the maximum network delay between the first node and the second node;
    所述第一节点根据所述平均网络延迟确定所述第一节点和所述第二节点之间的平均系统时间差值;Determining, by the first node, an average system time difference between the first node and the second node according to the average network delay;
    所述第一节点接收所述第二节点生成的区块,并确定接收到所述区块时的本地时间戳,其中,所述区块中携带有时间戳;The first node receives the block generated by the second node, and determines a local timestamp when the block is received, where the timestamp is carried in the block;
    所述第一节点根据所述平均网络延迟、所述最大网络延迟、所述平均系统时间差值、所述本地时间戳和所述区块所携带的时间戳确定所述区块是否为所述第二节点在满足预设时间要求的出块时间生成的区块。The first node determines whether the block is the block according to the average network delay, the maximum network delay, the average system time difference, the local timestamp and the timestamp carried by the block The block generated by the second node at the block generation time that meets the preset time requirement.
  2. 根据权利要求1所述的方法,其特征在于,第一节点获取所述第一节点与第二节点之间的平均网络延迟和最大网络延迟,包括:The method according to claim 1, wherein the first node acquiring the average network delay and the maximum network delay between the first node and the second node comprises:
    所述第一节点重复执行N次如下信息交互操作,以得到N个网络延迟数据:所述第一节点发送ping报文给所述第二节点,其中,所述ping报文中携带有ping报文离开所述第一节点的第一时间戳;所述第一节点接收所述第二节点响应于所述ping报文返回的pong报文;所述第一节点计算所述第一节点接收到所述pong报文的第二时间戳;所述第一节点根据所述第一时间戳和所述第二时间戳计算所述第一节点和所述第二节点之间的网络延迟数据,其中,N为正整数;The first node repeatedly performs the following information exchange operations N times to obtain N network delay data: the first node sends a ping message to the second node, where the ping message carries a ping message The first time stamp when the message leaves the first node; the first node receives the pong message returned by the second node in response to the ping message; the first node calculates that the first node receives The second time stamp of the pong message; the first node calculates the network delay data between the first node and the second node according to the first time stamp and the second time stamp, wherein , N is a positive integer;
    所述第一节点根据所述N个网络延迟数据确定所述第一节点和所述第二节点之间的平均网络延迟和最大网络延迟。The first node determines the average network delay and the maximum network delay between the first node and the second node according to the N network delay data.
  3. 根据权利要求2所述的方法,其特征在于,所述第一节点根据所述N个网络延迟数据确定所述第一节点和所述第二节点之间的平均网络延迟和最大网络延迟,包括:The method according to claim 2, wherein the first node determines the average network delay and the maximum network delay between the first node and the second node according to the N network delay data, comprising :
    按照以下公式计算网络延迟均值:Calculate the average network delay according to the following formula:
    Figure PCTCN2019076577-appb-100001
    Figure PCTCN2019076577-appb-100001
    按照以下公式计算所述最大网络延迟:Calculate the stated maximum network delay according to the following formula:
    NetDelay max=Max(Delay 0:Delay N-1); NetDelay max =Max(Delay 0 : Delay N-1 );
    根据计算得到的所述网络延迟均值和预设的系统允许最大网络延迟,确定所述平均网络延迟,Determine the average network delay according to the calculated average network delay value and the preset maximum network delay allowed by the system,
    其中,NetDelay aver为所述网络延迟均值,NetDelay max为所述最大网络延迟, i=0,...,N-1,Delay i是所述第一节点在第i次执行所述信息交互操作中计算得到的所述第一节点和所述第二节点之间的网络延迟数据,Delay i=(T2 i-T1 i)/2,其中,T2 i是第i次信息交互操作中的所述第二时间戳,T1 i是第i次信息交互操作中的所述第一时间戳。 Wherein, NetDelay aver is the average value of the network delay, NetDelay max is the maximum network delay, i=0,...,N-1, and Delay i is the i-th time the first node performs the information interaction operation The network delay data between the first node and the second node calculated in, Delay i = (T2 i- T1 i )/2, where T2 i is the i-th information exchange operation The second time stamp, T1 i is the first time stamp in the i-th information exchange operation.
  4. 根据权利要求3所述的方法,其特征在于,根据计算得到的所述网络延迟均值和预设的系统允许最大网络延迟,计算所述平均网络延迟,包括:The method according to claim 3, wherein calculating the average network delay based on the calculated average network delay value and a preset maximum network delay allowed by the system comprises:
    确定所述网络延迟均值是否大于所述预设的系统允许最大网络延迟;Determining whether the average network delay is greater than the preset maximum network delay allowed by the system;
    在确定所述网络延迟均值大于所述预设的系统允许最大网络延迟的情况下,将所述预设的系统允许最大网络延迟确定为所述平均网络延迟;In the case where it is determined that the average value of the network delay is greater than the preset maximum network delay allowed by the system, determining the preset maximum allowed network delay of the system as the average network delay;
    在确定所述网络延迟均值不大于所述预设的系统允许最大网络延迟的情况下,将所述网络延迟均值确定为所述平均网络延迟。In a case where it is determined that the average network delay is not greater than the preset maximum network delay allowed by the system, the average network delay is determined as the average network delay.
  5. 根据权利要求4所述的方法,其特征在于,所述第一节点根据所述平均网络延迟确定所述第一节点和所述第二节点之间的平均系统时间差值,包括:The method according to claim 4, wherein the first node determining the average system time difference between the first node and the second node according to the average network delay comprises:
    按照以下公式计算所述系统时间差值均值:Calculate the mean value of the system time difference according to the following formula:
    Figure PCTCN2019076577-appb-100002
    Figure PCTCN2019076577-appb-100002
    其中,TimeDiff aver为所述系统时间差值均值,NetDelay为所述平均网络延迟,T2 i是第i次信息交互操作中的所述第二时间戳,T1 i是第i次信息交互操作中的所述第一时间戳; Wherein, TimeDiff aver is the average value of the system time difference, NetDelay is the average network delay, T2 i is the second time stamp in the i-th information interaction operation, and T1 i is the i-th information interaction operation The first time stamp;
    根据所述系统时间差值均值和所述预设的系统允许最大系统时间差值,确定所述平均系统时间差值。The average system time difference is determined according to the average system time difference value and the preset maximum system time difference value allowed by the system.
  6. 根据权利要求5所述的方法,其特征在于,根据所述系统时间差值均值和所述系统允许的最大系统时间差值阈值,确定所述平均系统时间差,包括:The method according to claim 5, wherein determining the average system time difference based on the average system time difference value and the maximum system time difference threshold allowed by the system comprises:
    确定所述系统时间差值均值是否大于所述预设的系统允许最大系统时间差值;Determining whether the average value of the system time difference is greater than the preset maximum system time difference allowed by the system;
    在确定所述系统时间差值均值大于所述预设的系统允许最大系统时间差值的情况下,将所述预设的系统允许最大系统时间差值确定为所述平均系统时间差值;In a case where it is determined that the average value of the system time difference is greater than the preset maximum system time difference allowed by the system, determining the preset maximum allowable system time difference value of the system as the average system time difference;
    在确定所述系统时间差值均值不大于所述预设的系统允许最大系统时间差值的情况下,将所述系统时间差值均值确定为所述平均系统时间差值。When it is determined that the average value of the system time difference is not greater than the preset maximum system time difference allowed by the system, the average value of the system time difference is determined as the average system time difference.
  7. 根据权利要求1至6中任一项所述的方法,其特征在于,所述第一节点根据所述 平均网络延迟、所述最大网络延迟、所述平均系统时间差值、所述本地时间戳和所述区块所携带的时间戳确定所述区块是否为所述第二节点在满足预设时间要求的出块时间生成的区块,包括:The method according to any one of claims 1 to 6, wherein the first node is based on the average network delay, the maximum network delay, the average system time difference, and the local time stamp. And the timestamp carried by the block to determine whether the block is a block generated by the second node at the block generation time that meets the preset time requirement includes:
    验证以下不等式是否成立以确定所述区块是否为所述第二节点在满足预设时间要求的出块时间生成的区块:Verify whether the following inequality is true to determine whether the block is a block generated by the second node at the block generation time that meets the preset time requirement:
    Localtime+TimeDiff+NetDelay max≥timestamp+NetDelay≥Localtime+TimeDiff,其中,Localtime为所述本地时间戳,TimeDiff为所述平均系统时间差值,NetDelay max为所述最大网络延迟,timestamp为所述区块中携带的时间戳,NetDelay为所述平均网络延迟。 Localtime+TimeDiff+NetDelay max ≥timestamp+NetDelay≥Localtime+TimeDiff, where Localtime is the local timestamp, TimeDiff is the average system time difference, NetDelay max is the maximum network delay, and timestamp is the block NetDelay is the average network delay.
  8. 一种区块生成装置,其特征在于,位于第一节点中,包括:A block generation device is characterized in that it is located in a first node and includes:
    获取模块,用于获取所述第一节点与第二节点之间的平均网络延迟和最大网络延迟;An obtaining module, configured to obtain the average network delay and the maximum network delay between the first node and the second node;
    第一确定模块,用于根据所述平均网络延迟确定所述第一节点和所述第二节点之间的平均系统时间差值;A first determining module, configured to determine the average system time difference between the first node and the second node according to the average network delay;
    接收模块,用于接收所述第二节点生成的区块,并确定接收到所述区块时的本地时间戳,其中,所述区块中携带有时间戳;A receiving module, configured to receive the block generated by the second node and determine the local timestamp when the block is received, wherein the block carries the timestamp;
    第二确定模块,用于根据所述平均网络延迟、所述最大网络延迟、所述平均系统时间差值、所述本地时间戳和所述区块所携带的时间戳确定所述区块是否为所述第二节点在满足预设时间要求的出块时间生成的区块。The second determining module is configured to determine whether the block is based on the average network delay, the maximum network delay, the average system time difference, the local timestamp and the timestamp carried by the block The block generated by the second node at the block generation time that meets the preset time requirement.
  9. 一种计算机设备,包括处理器以及用于存储处理器可执行指令的存储器,所述处理器执行所述指令时实现权利要求1至7中任一项所述方法的步骤。A computer device comprising a processor and a memory for storing executable instructions of the processor, and the processor implements the steps of the method according to any one of claims 1 to 7 when the processor executes the instructions.
  10. 一种计算机可读存储介质,其上存储有计算机指令,所述指令被执行时实现权利要求1至7中任一项所述方法的步骤。A computer-readable storage medium having computer instructions stored thereon, which, when executed, implement the steps of the method described in any one of claims 1 to 7.
PCT/CN2019/076577 2019-02-28 2019-02-28 Block generation method and apparatus, computer device and storage medium WO2020172881A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/076577 WO2020172881A1 (en) 2019-02-28 2019-02-28 Block generation method and apparatus, computer device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/076577 WO2020172881A1 (en) 2019-02-28 2019-02-28 Block generation method and apparatus, computer device and storage medium

Publications (1)

Publication Number Publication Date
WO2020172881A1 true WO2020172881A1 (en) 2020-09-03

Family

ID=72238794

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/076577 WO2020172881A1 (en) 2019-02-28 2019-02-28 Block generation method and apparatus, computer device and storage medium

Country Status (1)

Country Link
WO (1) WO2020172881A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113676783A (en) * 2021-08-18 2021-11-19 上海哔哩哔哩科技有限公司 Link node evaluation method and device
CN114567638A (en) * 2022-02-14 2022-05-31 珠海迈科智能科技股份有限公司 Method for dynamically adjusting sharing strategy according to actual network of node

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101727525B1 (en) * 2016-09-05 2017-04-17 주식회사 스케일체인 Block chain based distributed storage method and device thereof
CN107480990A (en) * 2017-08-01 2017-12-15 中国联合网络通信集团有限公司 Block chain bookkeeping methods and device
CN107688945A (en) * 2017-08-11 2018-02-13 杭州秘猿科技有限公司 A kind of efficient license chain based on delaying state common recognition
CN109034805A (en) * 2018-08-09 2018-12-18 江苏先安科技有限公司 It is a kind of to stab signature verification method suitable for the new time of block chain and built-in field
CN109327349A (en) * 2018-08-15 2019-02-12 泰链(厦门)科技有限公司 Method for limiting, medium, apparatus and system when block chain account creation

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101727525B1 (en) * 2016-09-05 2017-04-17 주식회사 스케일체인 Block chain based distributed storage method and device thereof
CN107480990A (en) * 2017-08-01 2017-12-15 中国联合网络通信集团有限公司 Block chain bookkeeping methods and device
CN107688945A (en) * 2017-08-11 2018-02-13 杭州秘猿科技有限公司 A kind of efficient license chain based on delaying state common recognition
CN109034805A (en) * 2018-08-09 2018-12-18 江苏先安科技有限公司 It is a kind of to stab signature verification method suitable for the new time of block chain and built-in field
CN109327349A (en) * 2018-08-15 2019-02-12 泰链(厦门)科技有限公司 Method for limiting, medium, apparatus and system when block chain account creation

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113676783A (en) * 2021-08-18 2021-11-19 上海哔哩哔哩科技有限公司 Link node evaluation method and device
CN114567638A (en) * 2022-02-14 2022-05-31 珠海迈科智能科技股份有限公司 Method for dynamically adjusting sharing strategy according to actual network of node
CN114567638B (en) * 2022-02-14 2023-09-01 珠海迈科智能科技股份有限公司 Method for dynamically adjusting sharing strategy according to actual network of node

Similar Documents

Publication Publication Date Title
CN109787867B (en) Block generation method and device, computer equipment and storage medium
US7865760B2 (en) Use of T4 timestamps to calculate clock offset and skew
CN107480990B (en) Block chain accounting method and device
TW201942816A (en) Inter-blockchain interaction method, device, system and electronic device
US11082203B2 (en) Method and apparatus for accelerating the blockchain for secure and high throughput applications
CN109218348B (en) Method for determining blocks in block chain and node equipment
US9756153B2 (en) Method for improving accuracy in computation of one-way transfer time for network time synchronization
JP5161363B2 (en) Clock synchronization in asynchronous distributed systems
US20020129290A1 (en) Method and system for time synchronization
WO2012109911A1 (en) Method and apparatus for monitoring network traffic
CN108509615B (en) Consensus establishing method and device based on drawing mechanism and readable storage medium
US20200396281A1 (en) System architecture and method of processing data therein
WO2019199768A1 (en) Fork-tolerant consensus protocol
WO2020172881A1 (en) Block generation method and apparatus, computer device and storage medium
CN112347184A (en) Bifurcation processing method and block link point
WO2020142907A1 (en) Method and apparatus for creating and adding block based on structured directed acyclic graph, and method and apparatus for establishing account book
EP3598247B1 (en) Network time correction method and apparatus
CN110489231B (en) Transaction information recording method, apparatus and computer readable storage medium
Mazurok et al. Empowering Fault-Tolerant Consensus Algorithm by Economic Leverages.
JP2020150359A (en) Analysis program, analysis device, and analysis method
JP7393048B2 (en) Fraud verification device, proof generation device, and fraud detection system
WO2016206272A1 (en) Inter-network-element signaling sorting method and apparatus, and network management system
WO2021196091A1 (en) Method and system for proving existence of file, and server and storage medium
JP2009116678A (en) Web server
Obleukhov et al. Simple Precision Time Protocol (SPTP)

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: 19917133

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: 19917133

Country of ref document: EP

Kind code of ref document: A1