mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 02:10:46 +00:00
m1 mine block but only broadcast block wait m2 validate
This commit is contained in:
parent
3f1aadb861
commit
f0761106f4
2 changed files with 10 additions and 7 deletions
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
@ -706,11 +705,10 @@ func (pm *ProtocolManager) BroadcastBlock(block *types.Block, propagate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Send the block to a subset of our peers
|
// Send the block to a subset of our peers
|
||||||
transfer := peers[:int(math.Sqrt(float64(len(peers))))]
|
for _, peer := range peers {
|
||||||
for _, peer := range transfer {
|
|
||||||
peer.SendNewBlock(block, td)
|
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
|
return
|
||||||
}
|
}
|
||||||
// Otherwise if the block is indeed in out own chain, announce it
|
// Otherwise if the block is indeed in out own chain, announce it
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
// Copyright 2015 The go-ethereum Authors
|
// Copyright 2015 The go-ethereum Authors
|
||||||
// This file is part of the go-ethereum library.
|
// This file is part of the go-ethereum library.
|
||||||
//
|
//
|
||||||
|
|
@ -301,6 +302,10 @@ func (self *worker) wait() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
block := result.Block
|
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
|
work := result.Work
|
||||||
|
|
||||||
// Update the block hash in all logs since it is now available and not when the
|
// 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
|
// Check whether the tx is replay protected. If we're not in the EIP155 hf
|
||||||
// phase, start ignoring the sender until we do.
|
// phase, start ignoring the sender until we do.
|
||||||
if tx.Protected() && !env.config.IsEIP155(env.header.Number) {
|
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
|
continue
|
||||||
}
|
}
|
||||||
// Start executing the transaction
|
// Start executing the transaction
|
||||||
|
|
@ -650,11 +655,11 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
|
||||||
switch err {
|
switch err {
|
||||||
case core.ErrNonceTooLow:
|
case core.ErrNonceTooLow:
|
||||||
// New head notification data race between the transaction pool and miner, shift
|
// 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:
|
case core.ErrNonceTooHigh:
|
||||||
// Reorg notification data race between the transaction pool and miner, skip account =
|
// 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:
|
case nil:
|
||||||
// Everything ok, collect the logs and shift in the next transaction from the same account
|
// Everything ok, collect the logs and shift in the next transaction from the same account
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue