Skip to content

Commit 5b4e2b0

Browse files
gzliudanCopilot
andauthored
Update miner/worker.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 419a0df commit 5b4e2b0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

miner/worker.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,12 @@ func (w *worker) commitNewWork() {
739739
if parent.Time() >= uint64(tstamp) {
740740
tstamp = int64(parent.Time() + 1)
741741
}
742+
// Ensure we are still not mining too far in the future with the updated parent.
743+
if now := time.Now().Unix(); tstamp > now {
744+
wait := time.Duration(tstamp-now) * time.Second
745+
log.Info("Mining too far in the future", "wait", common.PrettyDuration(wait))
746+
time.Sleep(wait)
747+
}
742748
num := parent.Number()
743749
header := &types.Header{
744750
ParentHash: parent.Hash(),

0 commit comments

Comments
 (0)