Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consortium-v2: move the block timestamp calculation before IsPeriodBlock #629

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions consensus/consortium/v2/consortium.go
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,14 @@ func (c *Consortium) Prepare(chain consensus.ChainHeaderReader, header *types.He
return err
}

// Ensure the timestamp has the correct delay
parent := chain.GetHeader(header.ParentHash, number-1)
if parent == nil {
return consensus.ErrUnknownAncestor
}

header.Time = c.computeHeaderTime(header, parent, snap)

// Set the correct difficulty
header.Difficulty = CalcDifficulty(snap, coinbase)

Expand Down Expand Up @@ -926,13 +934,6 @@ func (c *Consortium) Prepare(chain consensus.ChainHeaderReader, header *types.He
// Mix digest is reserved for now, set to empty
header.MixDigest = common.Hash{}

// Ensure the timestamp has the correct delay
parent := chain.GetHeader(header.ParentHash, number-1)
if parent == nil {
return consensus.ErrUnknownAncestor
}

header.Time = c.computeHeaderTime(header, parent, snap)
return nil
}

Expand Down
Loading