Skip to content

Commit

Permalink
miner: no need to broadcast sidechain header mined by this validator
Browse files Browse the repository at this point in the history
  • Loading branch information
qinglin89 committed Mar 24, 2023
1 parent e8d2c81 commit d35ead2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,20 +666,19 @@ func (w *worker) resultLoop() {
w.recentMinedBlocks.Add(block.NumberU64(), []common.Hash{block.ParentHash()})
}

// Broadcast the block and announce chain insertion event
w.mux.Post(core.NewMinedBlockEvent{Block: block})

// Commit block and state to database.
task.state.SetExpectedStateRoot(block.Root())
start := time.Now()
_, err := w.chain.WriteBlockAndSetHead(block, receipts, logs, task.state, true)
if err != nil {
log.Error("Failed writing block to chain", "err", err)
status, err := w.chain.WriteBlockAndSetHead(block, receipts, logs, task.state, true)
if status != core.CanonStatTy {
log.Error("Failed writing block to chain", "err", err, "status", status)
continue
}
writeBlockTimer.UpdateSince(start)
log.Info("Successfully sealed new block", "number", block.Number(), "sealhash", sealhash, "hash", hash,
"elapsed", common.PrettyDuration(time.Since(task.createdAt)))
// Broadcast the block and announce chain insertion event
w.mux.Post(core.NewMinedBlockEvent{Block: block})

// Insert the block into the set of pending ones to resultLoop for confirmations
w.unconfirmed.Insert(block.NumberU64(), block.Hash())
Expand Down

0 comments on commit d35ead2

Please sign in to comment.