Ethereum.isLocalBlock¶
| Source (upstream pre-purge) | Current | |
|---|---|---|
| File | eth/backend.go |
backend_mining_pow.go |
| Symbol | Ethereum.isLocalBlock |
Ethereum.isLocalBlock |
| Ref | f4d53133f~1 |
etc/v1.17.4-full-node |
Feeds the fork-choice preserve callback. Faithful revival, reading getc's package-level etherbase (via etherbaseMu) instead of the removed s.etherbase/s.lock fields.
3-way merge — purge → getc ← upstream¶
pre-purge≈ adapted (origin inferred by similarity)fork-only
↗// 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
}
core-geth validation — +5 -9
| | | |---|---| | File | [`backend.go`](https://github.com/etclabscore/core-geth/blob/v1.12.20/eth/backend.go) | | Symbol | `Ethereum.isLocalBlock` | | Ref | `v1.12.20` |--- a/core-geth/eth/backend.go
+++ b/etc/eth/backend_mining_pow.go
@@ -1,6 +1,3 @@
-// isLocalBlock checks whether the specified block is mined
-// by local miner accounts.
-//
// 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 {
@@ -10,14 +7,13 @@
return false
}
// Check whether the given address is etherbase.
- s.lock.RLock()
- etherbase := s.etherbase
- s.lock.RUnlock()
- if author == etherbase {
+ etherbaseMu.RLock()
+ eb := etherbase
+ etherbaseMu.RUnlock()
+ if author == eb {
return true
}
- // Check whether the given address is specified by `txpool.local`
- // CLI flag.
+ // Check whether the given address is specified by `txpool.local` CLI flag.
for _, account := range s.config.TxPool.Locals {
if account == author {
return true