mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth: get rid of miner.setEtherbase
This commit is contained in:
parent
7ee6dcdd31
commit
4f248a8a8a
7 changed files with 16 additions and 48 deletions
|
|
@ -121,6 +121,7 @@ var (
|
||||||
utils.MinerEtherbaseFlag, // deprecated
|
utils.MinerEtherbaseFlag, // deprecated
|
||||||
utils.MinerExtraDataFlag,
|
utils.MinerExtraDataFlag,
|
||||||
utils.MinerRecommitIntervalFlag,
|
utils.MinerRecommitIntervalFlag,
|
||||||
|
utils.MinerPendingBlockProducerFlag,
|
||||||
utils.MinerNewPayloadTimeoutFlag, // deprecated
|
utils.MinerNewPayloadTimeoutFlag, // deprecated
|
||||||
utils.NATFlag,
|
utils.NATFlag,
|
||||||
utils.NoDiscoverFlag,
|
utils.NoDiscoverFlag,
|
||||||
|
|
|
||||||
|
|
@ -448,6 +448,11 @@ var (
|
||||||
Value: ethconfig.Defaults.Miner.Recommit,
|
Value: ethconfig.Defaults.Miner.Recommit,
|
||||||
Category: flags.MinerCategory,
|
Category: flags.MinerCategory,
|
||||||
}
|
}
|
||||||
|
MinerPendingBlockProducerFlag = &cli.StringFlag{
|
||||||
|
Name: "miner.pendingBlockProducer",
|
||||||
|
Usage: "0x prefixed public address for the pending block producer (not used for actual block production)",
|
||||||
|
Category: flags.MinerCategory,
|
||||||
|
}
|
||||||
|
|
||||||
// Account settings
|
// Account settings
|
||||||
UnlockedAccountFlag = &cli.StringFlag{
|
UnlockedAccountFlag = &cli.StringFlag{
|
||||||
|
|
@ -1252,17 +1257,20 @@ func MakeAddress(ks *keystore.KeyStore, account string) (accounts.Account, error
|
||||||
|
|
||||||
// setEtherbase retrieves the etherbase from the directly specified command line flags.
|
// setEtherbase retrieves the etherbase from the directly specified command line flags.
|
||||||
func setEtherbase(ctx *cli.Context, cfg *ethconfig.Config) {
|
func setEtherbase(ctx *cli.Context, cfg *ethconfig.Config) {
|
||||||
if !ctx.IsSet(MinerEtherbaseFlag.Name) {
|
if ctx.IsSet(MinerEtherbaseFlag.Name) {
|
||||||
|
log.Warn("Option --miner.etherbase is deprecated as the etherbase is set by the consensus client post-merge")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Warn("Option --miner.etherbase is deprecated as the etherbase is set by the consensus client post-merge")
|
if !ctx.IsSet(MinerPendingBlockProducerFlag.Name) {
|
||||||
addr := ctx.String(MinerEtherbaseFlag.Name)
|
return
|
||||||
|
}
|
||||||
|
addr := ctx.String(MinerPendingBlockProducerFlag.Name)
|
||||||
if strings.HasPrefix(addr, "0x") || strings.HasPrefix(addr, "0X") {
|
if strings.HasPrefix(addr, "0x") || strings.HasPrefix(addr, "0X") {
|
||||||
addr = addr[2:]
|
addr = addr[2:]
|
||||||
}
|
}
|
||||||
b, err := hex.DecodeString(addr)
|
b, err := hex.DecodeString(addr)
|
||||||
if err != nil || len(b) != common.AddressLength {
|
if err != nil || len(b) != common.AddressLength {
|
||||||
Fatalf("-%s: invalid etherbase address %q", MinerEtherbaseFlag.Name, addr)
|
Fatalf("-%s: invalid pending block producer address %q", MinerPendingBlockProducerFlag.Name, addr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cfg.Miner.Etherbase = common.BytesToAddress(b)
|
cfg.Miner.Etherbase = common.BytesToAddress(b)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ package eth
|
||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -57,14 +56,3 @@ func (api *MinerAPI) SetGasLimit(gasLimit hexutil.Uint64) bool {
|
||||||
api.e.Miner().SetGasCeil(uint64(gasLimit))
|
api.e.Miner().SetGasCeil(uint64(gasLimit))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetEtherbase sets the etherbase of the miner.
|
|
||||||
func (api *MinerAPI) SetEtherbase(etherbase common.Address) bool {
|
|
||||||
api.e.SetEtherbase(etherbase)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Etherbase is the address that mining rewards will be sent to.
|
|
||||||
func (api *MinerAPI) Etherbase() common.Address {
|
|
||||||
return api.e.Miner().Etherbase()
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -402,15 +402,6 @@ func (s *Ethereum) shouldPreserve(header *types.Header) bool {
|
||||||
return s.isLocalBlock(header)
|
return s.isLocalBlock(header)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetEtherbase sets the mining reward address.
|
|
||||||
func (s *Ethereum) SetEtherbase(etherbase common.Address) {
|
|
||||||
s.lock.Lock()
|
|
||||||
s.etherbase = etherbase
|
|
||||||
s.lock.Unlock()
|
|
||||||
|
|
||||||
s.miner.SetEtherbase(etherbase)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Ethereum) Miner() *miner.Miner { return s.miner }
|
func (s *Ethereum) Miner() *miner.Miner { return s.miner }
|
||||||
|
|
||||||
func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager }
|
func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager }
|
||||||
|
|
|
||||||
|
|
@ -447,7 +447,9 @@ func startEthService(t *testing.T, genesis *core.Genesis, blocks []*types.Block)
|
||||||
t.Fatal("can't create node:", err)
|
t.Fatal("can't create node:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ethcfg := ðconfig.Config{Genesis: genesis, SyncMode: downloader.FullSync, TrieTimeout: time.Minute, TrieDirtyCache: 256, TrieCleanCache: 256}
|
mcfg := miner.DefaultConfig
|
||||||
|
mcfg.Etherbase = testAddr
|
||||||
|
ethcfg := ðconfig.Config{Genesis: genesis, SyncMode: downloader.FullSync, TrieTimeout: time.Minute, TrieDirtyCache: 256, TrieCleanCache: 256, Miner: mcfg}
|
||||||
ethservice, err := eth.New(n, ethcfg)
|
ethservice, err := eth.New(n, ethcfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("can't create eth service:", err)
|
t.Fatal("can't create eth service:", err)
|
||||||
|
|
@ -460,7 +462,6 @@ func startEthService(t *testing.T, genesis *core.Genesis, blocks []*types.Block)
|
||||||
t.Fatal("can't import test blocks:", err)
|
t.Fatal("can't import test blocks:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ethservice.SetEtherbase(testAddr)
|
|
||||||
ethservice.SetSynced()
|
ethservice.SetSynced()
|
||||||
return n, ethservice
|
return n, ethservice
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -649,12 +649,6 @@ const MinerJs = `
|
||||||
web3._extend({
|
web3._extend({
|
||||||
property: 'miner',
|
property: 'miner',
|
||||||
methods: [
|
methods: [
|
||||||
new web3._extend.Method({
|
|
||||||
name: 'setEtherbase',
|
|
||||||
call: 'miner_setEtherbase',
|
|
||||||
params: 1,
|
|
||||||
inputFormatter: [web3._extend.formatters.inputAddressFormatter]
|
|
||||||
}),
|
|
||||||
new web3._extend.Method({
|
new web3._extend.Method({
|
||||||
name: 'setExtra',
|
name: 'setExtra',
|
||||||
call: 'miner_setExtra',
|
call: 'miner_setExtra',
|
||||||
|
|
|
||||||
|
|
@ -107,21 +107,6 @@ func (miner *Miner) SetExtra(extra []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Etherbase returns the address of fee recipient.
|
|
||||||
func (miner *Miner) Etherbase() common.Address {
|
|
||||||
miner.confMu.RLock()
|
|
||||||
addr := miner.config.Etherbase
|
|
||||||
miner.confMu.RUnlock()
|
|
||||||
return addr
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetEtherbase sets the address of fee recipient.
|
|
||||||
func (miner *Miner) SetEtherbase(addr common.Address) {
|
|
||||||
miner.confMu.Lock()
|
|
||||||
miner.config.Etherbase = addr
|
|
||||||
miner.confMu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetGasCeil sets the gaslimit to strive for when mining blocks post 1559.
|
// SetGasCeil sets the gaslimit to strive for when mining blocks post 1559.
|
||||||
// For pre-1559 blocks, it sets the ceiling.
|
// For pre-1559 blocks, it sets the ceiling.
|
||||||
func (miner *Miner) SetGasCeil(ceil uint64) {
|
func (miner *Miner) SetGasCeil(ceil uint64) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue