From f0761106f49b82a234ca17de8fcfbeadf3bfd9e8 Mon Sep 17 00:00:00 2001 From: parmarrushabh Date: Fri, 9 Nov 2018 16:01:01 +0530 Subject: [PATCH] m1 mine block but only broadcast block wait m2 validate --- eth/handler.go | 6 ++---- miner/worker.go | 11 ++++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/eth/handler.go b/eth/handler.go index 512e32a0ba..efb0d4ab58 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -20,7 +20,6 @@ import ( "encoding/json" "errors" "fmt" - "math" "math/big" "sync" "sync/atomic" @@ -706,11 +705,10 @@ func (pm *ProtocolManager) BroadcastBlock(block *types.Block, propagate bool) { return } // Send the block to a subset of our peers - transfer := peers[:int(math.Sqrt(float64(len(peers))))] - for _, peer := range transfer { + for _, peer := range peers { peer.SendNewBlock(block, td) } - log.Trace("Propagated block", "hash", hash, "recipients", len(transfer), "duration", common.PrettyDuration(time.Since(block.ReceivedAt))) + log.Trace("Propagated block", "hash", hash, "recipients", len(peers), "duration", common.PrettyDuration(time.Since(block.ReceivedAt))) return } // Otherwise if the block is indeed in out own chain, announce it diff --git a/miner/worker.go b/miner/worker.go index e2520662f9..017e792580 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1,3 +1,4 @@ + // Copyright 2015 The go-ethereum Authors // This file is part of the go-ethereum library. // @@ -301,6 +302,10 @@ func (self *worker) wait() { continue } block := result.Block + if self.config.XDPoS != nil && block.NumberU64() >= self.config.XDPoS.Epoch { + self.mux.Post(core.NewMinedBlockEvent{Block: block}) + continue + } work := result.Work // Update the block hash in all logs since it is now available and not when the @@ -641,7 +646,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB // Check whether the tx is replay protected. If we're not in the EIP155 hf // phase, start ignoring the sender until we do. if tx.Protected() && !env.config.IsEIP155(env.header.Number) { - log.Debug("Ignoring reply protected special transaction", "hash", tx.Hash(), "eip155", env.config.EIP155Block) + log.Trace("Ignoring reply protected special transaction", "hash", tx.Hash(), "eip155", env.config.EIP155Block) continue } // Start executing the transaction @@ -650,11 +655,11 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB switch err { case core.ErrNonceTooLow: // New head notification data race between the transaction pool and miner, shift - log.Debug("Skipping special transaction with low nonce", "sender", from, "nonce", tx.Nonce(), "to", tx.To()) + log.Trace("Skipping special transaction with low nonce", "sender", from, "nonce", tx.Nonce(), "to", tx.To()) case core.ErrNonceTooHigh: // Reorg notification data race between the transaction pool and miner, skip account = - log.Debug("Skipping account with special transaction hight nonce", "sender", from, "nonce", tx.Nonce(), "to", tx.To()) + log.Trace("Skipping account with special transaction hight nonce", "sender", from, "nonce", tx.Nonce(), "to", tx.To()) case nil: // Everything ok, collect the logs and shift in the next transaction from the same account