Skip to content

Commit

Permalink
modify calcDelayTime() when delayTime is greater than maxDelay
Browse files Browse the repository at this point in the history
  • Loading branch information
zongyuan committed Apr 19, 2019
1 parent 6d1c7af commit 737b275
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion consensus/datong/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,9 +845,13 @@ func (dt *DaTong) calcDelayTime(chain consensus.ChainReader, header *types.Heade
// adjust block time if illegal
if list > 0 && header.Number.Uint64() >= common.GetForkEnabledHeight(2) {
recvTime := header.Time.Int64() - parent.Time.Int64()
if recvTime < int64(maxDelay+dt.config.Period) {
maxDelaySeconds := int64(maxDelay + dt.config.Period)
if recvTime < maxDelaySeconds {
expectTime := int64(dt.config.Period + list*delayTimeModifier)
if recvTime < expectTime {
if expectTime > maxDelaySeconds {
expectTime = maxDelaySeconds
}
header.Time = big.NewInt(parent.Time.Int64() + expectTime)
minDelayTime := time.Unix(header.Time.Int64(), 0).Sub(time.Now())
if delayTime < minDelayTime {
Expand Down

0 comments on commit 737b275

Please sign in to comment.