eth/backend_mining_pow.go — Version Comparison
|
v1.17.3 |
v1.17.4 |
| Branch |
etc/v1.17.3-full-node |
etc/v1.17.4-full-node |
| Delta |
+149 -0 |
+174 -0 |
Diff between branches
diff --git a/eth/backend_mining_pow.go b/eth/backend_mining_pow.go
index b32e72cd1..85b7dffb9 100644
--- a/eth/backend_mining_pow.go
+++ b/eth/backend_mining_pow.go
@@ -21,10 +21,35 @@ import (
"sync"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/log"
)
+// We regard two types of accounts as local miner account: etherbase
+// and accounts specified via `txpool.locals` flag.
+func (s *Ethereum) isLocalBlock(header *types.Header) bool {
+ author, err := s.engine.Author(header)
+ if err != nil {
+ log.Warn("Failed to retrieve block author", "number", header.Number.Uint64(), "hash", header.Hash(), "err", err)
+ return false
+ }
+ // Check whether the given address is etherbase.
+ etherbaseMu.RLock()
+ eb := etherbase
+ etherbaseMu.RUnlock()
+ if author == eb {
+ return true
+ }
+ // Check whether the given address is specified by `txpool.local` CLI flag.
+ for _, account := range s.config.TxPool.Locals {
+ if account == author {
+ return true
+ }
+ }
+ return false
+}
+
// etherbase is the mining reward address, protected by etherbaseMu.
var (
etherbaseMu sync.RWMutex
← Back to Version Comparison