mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
miner: no need to lock the coinbase
This commit is contained in:
parent
81276b36ba
commit
4a11409cac
2 changed files with 5 additions and 12 deletions
|
|
@ -65,7 +65,7 @@ var DefaultConfig = Config{
|
|||
// Miner is the main object which takes care of submitting new work to consensus
|
||||
// engine and gathering the sealing result.
|
||||
type Miner struct {
|
||||
confMu sync.RWMutex // The lock used to protect the config
|
||||
confMu sync.RWMutex // The lock used to protect the config fields: GasCeil, GasTip and Extradata
|
||||
config *Config
|
||||
chainConfig *params.ChainConfig
|
||||
engine consensus.Engine
|
||||
|
|
@ -133,14 +133,10 @@ func (miner *Miner) BuildPayload(args *BuildPayloadArgs) (*Payload, error) {
|
|||
// getPending retrieves the pending block based on the current head block.
|
||||
// The result might be nil if pending generation is failed.
|
||||
func (miner *Miner) getPending() *newPayloadResult {
|
||||
miner.confMu.RLock()
|
||||
coinbase := miner.config.PendingFeeRecipient
|
||||
miner.confMu.RUnlock()
|
||||
|
||||
header := miner.chain.CurrentHeader()
|
||||
miner.pendingMu.Lock()
|
||||
defer miner.pendingMu.Unlock()
|
||||
if cached := miner.pending.resolve(header.Hash(), coinbase); cached != nil {
|
||||
if cached := miner.pending.resolve(header.Hash()); cached != nil {
|
||||
return cached
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +151,7 @@ func (miner *Miner) getPending() *newPayloadResult {
|
|||
timestamp: timestamp,
|
||||
forceTime: false,
|
||||
parentHash: header.Hash(),
|
||||
coinbase: coinbase,
|
||||
coinbase: miner.config.PendingFeeRecipient,
|
||||
random: common.Hash{},
|
||||
withdrawals: withdrawal,
|
||||
beaconRoot: nil,
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ type pending struct {
|
|||
}
|
||||
|
||||
// resolve retrieves the cached pending result if it's available. Nothing will be
|
||||
// returned if the parentHash/coinbase is not matched or the result is already too old.
|
||||
// returned if the parentHash is not matched or the result is already too old.
|
||||
//
|
||||
// Note, don't modify the returned payload result.
|
||||
func (p *pending) resolve(parentHash common.Hash, coinbase common.Address) *newPayloadResult {
|
||||
func (p *pending) resolve(parentHash common.Hash) *newPayloadResult {
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
|
||||
|
|
@ -50,9 +50,6 @@ func (p *pending) resolve(parentHash common.Hash, coinbase common.Address) *newP
|
|||
if parentHash != p.parentHash {
|
||||
return nil
|
||||
}
|
||||
if p.result.block.Coinbase() != coinbase {
|
||||
return nil
|
||||
}
|
||||
if time.Since(p.created) > pendingTTL {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue