Skip to content

Commit 059a1e9

Browse files
committed
miner: broadcast block before insertion/validation
1 parent 5e7db8f commit 059a1e9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

miner/worker.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,16 @@ func (self *worker) wait() {
239239
continue
240240
}
241241

242+
// broadcast before waiting for validation
243+
go self.mux.Post(core.NewMinedBlockEvent{block})
244+
// insert mined block in to our own chain
242245
if _, err := self.chain.InsertChain(types.Blocks{block}); err == nil {
246+
// remove uncles we've previously inserted
243247
for _, uncle := range block.Uncles() {
244248
delete(self.possibleUncles, uncle.Hash())
245249
}
246-
self.mux.Post(core.NewMinedBlockEvent{block})
247250

251+
// check staleness and display confirmation
248252
var stale, confirm string
249253
canonBlock := self.chain.GetBlockByNumber(block.NumberU64())
250254
if canonBlock != nil && canonBlock.Hash() != block.Hash() {
@@ -256,6 +260,7 @@ func (self *worker) wait() {
256260

257261
glog.V(logger.Info).Infof("🔨 Mined %sblock (#%v / %x). %s", stale, block.Number(), block.Hash().Bytes()[:4], confirm)
258262

263+
// XXX remove old structured json logging
259264
jsonlogger.LogJson(&logger.EthMinerNewBlock{
260265
BlockHash: block.Hash().Hex(),
261266
BlockNumber: block.Number(),

0 commit comments

Comments
 (0)