mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 21:17:16 +00:00
34 lines
994 B
Go
34 lines
994 B
Go
package ethutils
|
|
|
|
import (
|
|
"github.com/ledgerwatch/erigon/common"
|
|
"github.com/ledgerwatch/erigon/consensus"
|
|
"github.com/ledgerwatch/erigon/core/types"
|
|
"github.com/ledgerwatch/log/v3"
|
|
)
|
|
|
|
// 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 IsLocalBlock(engine consensus.Engine, etherbase common.Address, txPoolLocals []common.Address, header *types.Header) bool {
|
|
author, err := engine.Author(header)
|
|
if err != nil {
|
|
log.Warn("Failed to retrieve block author", "number", header.Number, "header_hash", header.Hash(), "err", err)
|
|
return false
|
|
}
|
|
// Check whether the given address is etherbase.
|
|
if author == etherbase {
|
|
return true
|
|
}
|
|
// Check whether the given address is specified by `txpool.local`
|
|
// CLI flag.
|
|
for _, account := range txPoolLocals {
|
|
if account == author {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|