mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
cmd console, eth, internal/web3ext les miner: changed etherbase to coinbase
Changed etherbase to coinbase, leaving the command line flag in place for now to avoid a hard cutover. Fixes #1420
This commit is contained in:
parent
5f8888e116
commit
36e5bdf859
17 changed files with 87 additions and 82 deletions
|
|
@ -96,7 +96,7 @@ Specifying the `--testnet` flag however will reconfigure your Geth instance a bi
|
||||||
`geth attach <datadir>/testnet/geth.ipc`. Windows users are not affected by this.
|
`geth attach <datadir>/testnet/geth.ipc`. Windows users are not affected by this.
|
||||||
* Instead of connecting the main Ethereum network, the client will connect to the test network,
|
* Instead of connecting the main Ethereum network, the client will connect to the test network,
|
||||||
which uses different P2P bootnodes, different network IDs and genesis states.
|
which uses different P2P bootnodes, different network IDs and genesis states.
|
||||||
|
|
||||||
*Note: Although there are some internal protective measures to prevent transactions from crossing
|
*Note: Although there are some internal protective measures to prevent transactions from crossing
|
||||||
over between the main network and test network, you should make sure to always use separate accounts
|
over between the main network and test network, you should make sure to always use separate accounts
|
||||||
for play-money and real-money. Unless you manually move accounts, Geth will by default correctly
|
for play-money and real-money. Unless you manually move accounts, Geth will by default correctly
|
||||||
|
|
@ -263,11 +263,11 @@ resources (consider running on a single thread, no need for multiple ones either
|
||||||
instance for mining, run it with all your usual flags, extended by:
|
instance for mining, run it with all your usual flags, extended by:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ geth <usual-flags> --mine --minerthreads=1 --etherbase=0x0000000000000000000000000000000000000000
|
$ geth <usual-flags> --mine --minerthreads=1 --coinbase=0x0000000000000000000000000000000000000000
|
||||||
```
|
```
|
||||||
|
|
||||||
Which will start mining blocks and transactions on a single CPU thread, crediting all proceedings to
|
Which will start mining blocks and transactions on a single CPU thread, crediting all proceedings to
|
||||||
the account specified by `--etherbase`. You can further tune the mining by changing the default gas
|
the account specified by `--coinbase`. You can further tune the mining by changing the default gas
|
||||||
limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`).
|
limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`).
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ func TestConsoleWelcome(t *testing.T) {
|
||||||
// Start a geth console, make sure it's cleaned up and terminate the console
|
// Start a geth console, make sure it's cleaned up and terminate the console
|
||||||
geth := runGeth(t,
|
geth := runGeth(t,
|
||||||
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
|
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
|
||||||
"--etherbase", coinbase, "--shh",
|
"--coinbase", coinbase, "--shh",
|
||||||
"console")
|
"console")
|
||||||
|
|
||||||
// Gather all the infos the welcome message needs to contain
|
// Gather all the infos the welcome message needs to contain
|
||||||
|
|
@ -59,7 +59,7 @@ func TestConsoleWelcome(t *testing.T) {
|
||||||
Welcome to the Geth JavaScript console!
|
Welcome to the Geth JavaScript console!
|
||||||
|
|
||||||
instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
|
instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
|
||||||
coinbase: {{.Etherbase}}
|
coinbase: {{.Coinbase}}
|
||||||
at block: 0 ({{niltime}})
|
at block: 0 ({{niltime}})
|
||||||
datadir: {{.Datadir}}
|
datadir: {{.Datadir}}
|
||||||
modules: {{apis}}
|
modules: {{apis}}
|
||||||
|
|
@ -85,7 +85,7 @@ func TestIPCAttachWelcome(t *testing.T) {
|
||||||
// list of ipc modules and shh is included there.
|
// list of ipc modules and shh is included there.
|
||||||
geth := runGeth(t,
|
geth := runGeth(t,
|
||||||
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
|
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
|
||||||
"--etherbase", coinbase, "--shh", "--ipcpath", ipc)
|
"--coinbase", coinbase, "--shh", "--ipcpath", ipc)
|
||||||
|
|
||||||
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
|
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
|
||||||
testAttachWelcome(t, geth, "ipc:"+ipc, ipcAPIs)
|
testAttachWelcome(t, geth, "ipc:"+ipc, ipcAPIs)
|
||||||
|
|
@ -99,7 +99,7 @@ func TestHTTPAttachWelcome(t *testing.T) {
|
||||||
port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P
|
port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P
|
||||||
geth := runGeth(t,
|
geth := runGeth(t,
|
||||||
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
|
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
|
||||||
"--etherbase", coinbase, "--rpc", "--rpcport", port)
|
"--coinbase", coinbase, "--rpc", "--rpcport", port)
|
||||||
|
|
||||||
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
|
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
|
||||||
testAttachWelcome(t, geth, "http://localhost:"+port, httpAPIs)
|
testAttachWelcome(t, geth, "http://localhost:"+port, httpAPIs)
|
||||||
|
|
@ -114,7 +114,7 @@ func TestWSAttachWelcome(t *testing.T) {
|
||||||
|
|
||||||
geth := runGeth(t,
|
geth := runGeth(t,
|
||||||
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
|
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
|
||||||
"--etherbase", coinbase, "--ws", "--wsport", port)
|
"--coinbase", coinbase, "--ws", "--wsport", port)
|
||||||
|
|
||||||
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
|
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
|
||||||
testAttachWelcome(t, geth, "ws://localhost:"+port, httpAPIs)
|
testAttachWelcome(t, geth, "ws://localhost:"+port, httpAPIs)
|
||||||
|
|
@ -134,7 +134,7 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
|
||||||
attach.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
attach.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
|
||||||
attach.SetTemplateFunc("gover", runtime.Version)
|
attach.SetTemplateFunc("gover", runtime.Version)
|
||||||
attach.SetTemplateFunc("gethver", func() string { return params.Version })
|
attach.SetTemplateFunc("gethver", func() string { return params.Version })
|
||||||
attach.SetTemplateFunc("etherbase", func() string { return geth.Etherbase })
|
attach.SetTemplateFunc("coinbase", func() string { return geth.Coinbase })
|
||||||
attach.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
|
attach.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
|
||||||
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
|
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
|
||||||
attach.SetTemplateFunc("datadir", func() string { return geth.Datadir })
|
attach.SetTemplateFunc("datadir", func() string { return geth.Datadir })
|
||||||
|
|
@ -145,7 +145,7 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
|
||||||
Welcome to the Geth JavaScript console!
|
Welcome to the Geth JavaScript console!
|
||||||
|
|
||||||
instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
|
instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
|
||||||
coinbase: {{etherbase}}
|
coinbase: {{coinbase}}
|
||||||
at block: 0 ({{niltime}}){{if ipc}}
|
at block: 0 ({{niltime}}){{if ipc}}
|
||||||
datadir: {{datadir}}{{end}}
|
datadir: {{datadir}}{{end}}
|
||||||
modules: {{apis}}
|
modules: {{apis}}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ var (
|
||||||
utils.ListenPortFlag,
|
utils.ListenPortFlag,
|
||||||
utils.MaxPeersFlag,
|
utils.MaxPeersFlag,
|
||||||
utils.MaxPendingPeersFlag,
|
utils.MaxPendingPeersFlag,
|
||||||
utils.EtherbaseFlag,
|
utils.CoinbaseFlag,
|
||||||
utils.GasPriceFlag,
|
utils.GasPriceFlag,
|
||||||
utils.MinerThreadsFlag,
|
utils.MinerThreadsFlag,
|
||||||
utils.MiningEnabledFlag,
|
utils.MiningEnabledFlag,
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ type testgeth struct {
|
||||||
*cmdtest.TestCmd
|
*cmdtest.TestCmd
|
||||||
|
|
||||||
// template variables for expect
|
// template variables for expect
|
||||||
Datadir string
|
Datadir string
|
||||||
Etherbase string
|
Coinbase string
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -72,9 +72,13 @@ func runGeth(t *testing.T, args ...string) *testgeth {
|
||||||
if i < len(args)-1 {
|
if i < len(args)-1 {
|
||||||
tt.Datadir = args[i+1]
|
tt.Datadir = args[i+1]
|
||||||
}
|
}
|
||||||
|
case arg == "-coinbase" || arg == "--coinbase":
|
||||||
|
if i < len(args)-1 {
|
||||||
|
tt.Coinbase = args[i+1]
|
||||||
|
}
|
||||||
case arg == "-etherbase" || arg == "--etherbase":
|
case arg == "-etherbase" || arg == "--etherbase":
|
||||||
if i < len(args)-1 {
|
if i < len(args)-1 {
|
||||||
tt.Etherbase = args[i+1]
|
tt.Coinbase = args[i+1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ var AppHelpFlagGroups = []flagGroup{
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.MiningEnabledFlag,
|
utils.MiningEnabledFlag,
|
||||||
utils.MinerThreadsFlag,
|
utils.MinerThreadsFlag,
|
||||||
utils.EtherbaseFlag,
|
utils.CoinbaseFlag,
|
||||||
utils.TargetGasLimitFlag,
|
utils.TargetGasLimitFlag,
|
||||||
utils.GasPriceFlag,
|
utils.GasPriceFlag,
|
||||||
utils.ExtraDataFlag,
|
utils.ExtraDataFlag,
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ ADD genesis.json /genesis.json
|
||||||
RUN \
|
RUN \
|
||||||
echo 'geth --cache 512 init /genesis.json' > geth.sh && \{{if .Unlock}}
|
echo 'geth --cache 512 init /genesis.json' > geth.sh && \{{if .Unlock}}
|
||||||
echo 'mkdir -p /root/.ethereum/keystore/ && cp /signer.json /root/.ethereum/keystore/' >> geth.sh && \{{end}}
|
echo 'mkdir -p /root/.ethereum/keystore/ && cp /signer.json /root/.ethereum/keystore/' >> geth.sh && \{{end}}
|
||||||
echo $'geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .BootV4}}--bootnodesv4 {{.BootV4}}{{end}} {{if .BootV5}}--bootnodesv5 {{.BootV5}}{{end}} {{if .Etherbase}}--etherbase {{.Etherbase}} --mine --minerthreads 1{{end}} {{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --targetgaslimit {{.GasTarget}} --gasprice {{.GasPrice}}' >> geth.sh
|
echo $'geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .BootV4}}--bootnodesv4 {{.BootV4}}{{end}} {{if .BootV5}}--bootnodesv5 {{.BootV5}}{{end}} {{if .Coinbase}}--coinbase {{.Coinbase}} --mine --minerthreads 1{{end}} {{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --targetgaslimit {{.GasTarget}} --gasprice {{.GasPrice}}' >> geth.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/sh", "geth.sh"]
|
ENTRYPOINT ["/bin/sh", "geth.sh"]
|
||||||
`
|
`
|
||||||
|
|
@ -68,7 +68,7 @@ services:
|
||||||
- TOTAL_PEERS={{.TotalPeers}}
|
- TOTAL_PEERS={{.TotalPeers}}
|
||||||
- LIGHT_PEERS={{.LightPeers}}
|
- LIGHT_PEERS={{.LightPeers}}
|
||||||
- STATS_NAME={{.Ethstats}}
|
- STATS_NAME={{.Ethstats}}
|
||||||
- MINER_NAME={{.Etherbase}}
|
- MINER_NAME={{.Coinbase}}
|
||||||
- GAS_TARGET={{.GasTarget}}
|
- GAS_TARGET={{.GasTarget}}
|
||||||
- GAS_PRICE={{.GasPrice}}
|
- GAS_PRICE={{.GasPrice}}
|
||||||
logging:
|
logging:
|
||||||
|
|
@ -84,7 +84,7 @@ services:
|
||||||
// already exists there, it will be overwritten!
|
// already exists there, it will be overwritten!
|
||||||
func deployNode(client *sshClient, network string, bootv4, bootv5 []string, config *nodeInfos, nocache bool) ([]byte, error) {
|
func deployNode(client *sshClient, network string, bootv4, bootv5 []string, config *nodeInfos, nocache bool) ([]byte, error) {
|
||||||
kind := "sealnode"
|
kind := "sealnode"
|
||||||
if config.keyJSON == "" && config.etherbase == "" {
|
if config.keyJSON == "" && config.coinbase == "" {
|
||||||
kind = "bootnode"
|
kind = "bootnode"
|
||||||
bootv4 = make([]string, 0)
|
bootv4 = make([]string, 0)
|
||||||
bootv5 = make([]string, 0)
|
bootv5 = make([]string, 0)
|
||||||
|
|
@ -106,7 +106,7 @@ func deployNode(client *sshClient, network string, bootv4, bootv5 []string, conf
|
||||||
"BootV4": strings.Join(bootv4, ","),
|
"BootV4": strings.Join(bootv4, ","),
|
||||||
"BootV5": strings.Join(bootv5, ","),
|
"BootV5": strings.Join(bootv5, ","),
|
||||||
"Ethstats": config.ethstats,
|
"Ethstats": config.ethstats,
|
||||||
"Etherbase": config.etherbase,
|
"Coinbase": config.coinbase,
|
||||||
"GasTarget": uint64(1000000 * config.gasTarget),
|
"GasTarget": uint64(1000000 * config.gasTarget),
|
||||||
"GasPrice": uint64(1000000000 * config.gasPrice),
|
"GasPrice": uint64(1000000000 * config.gasPrice),
|
||||||
"Unlock": config.keyJSON != "",
|
"Unlock": config.keyJSON != "",
|
||||||
|
|
@ -125,7 +125,7 @@ func deployNode(client *sshClient, network string, bootv4, bootv5 []string, conf
|
||||||
"LightPort": config.portFull + 1,
|
"LightPort": config.portFull + 1,
|
||||||
"LightPeers": config.peersLight,
|
"LightPeers": config.peersLight,
|
||||||
"Ethstats": config.ethstats[:strings.Index(config.ethstats, ":")],
|
"Ethstats": config.ethstats[:strings.Index(config.ethstats, ":")],
|
||||||
"Etherbase": config.etherbase,
|
"Coinbase": config.coinbase,
|
||||||
"GasTarget": config.gasTarget,
|
"GasTarget": config.gasTarget,
|
||||||
"GasPrice": config.gasPrice,
|
"GasPrice": config.gasPrice,
|
||||||
})
|
})
|
||||||
|
|
@ -163,7 +163,7 @@ type nodeInfos struct {
|
||||||
enodeLight string
|
enodeLight string
|
||||||
peersTotal int
|
peersTotal int
|
||||||
peersLight int
|
peersLight int
|
||||||
etherbase string
|
coinbase string
|
||||||
keyJSON string
|
keyJSON string
|
||||||
keyPass string
|
keyPass string
|
||||||
gasTarget float64
|
gasTarget float64
|
||||||
|
|
@ -189,10 +189,10 @@ func (info *nodeInfos) Report() map[string]string {
|
||||||
report["Gas limit (baseline target)"] = fmt.Sprintf("%0.3f MGas", info.gasTarget)
|
report["Gas limit (baseline target)"] = fmt.Sprintf("%0.3f MGas", info.gasTarget)
|
||||||
report["Gas price (minimum accepted)"] = fmt.Sprintf("%0.3f GWei", info.gasPrice)
|
report["Gas price (minimum accepted)"] = fmt.Sprintf("%0.3f GWei", info.gasPrice)
|
||||||
|
|
||||||
if info.etherbase != "" {
|
if info.coinbase != "" {
|
||||||
// Ethash proof-of-work miner
|
// Ethash proof-of-work miner
|
||||||
report["Ethash directory"] = info.ethashdir
|
report["Ethash directory"] = info.ethashdir
|
||||||
report["Miner account"] = info.etherbase
|
report["Miner account"] = info.coinbase
|
||||||
}
|
}
|
||||||
if info.keyJSON != "" {
|
if info.keyJSON != "" {
|
||||||
// Clique proof-of-authority signer
|
// Clique proof-of-authority signer
|
||||||
|
|
@ -264,7 +264,7 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error)
|
||||||
peersTotal: totalPeers,
|
peersTotal: totalPeers,
|
||||||
peersLight: lightPeers,
|
peersLight: lightPeers,
|
||||||
ethstats: infos.envvars["STATS_NAME"],
|
ethstats: infos.envvars["STATS_NAME"],
|
||||||
etherbase: infos.envvars["MINER_NAME"],
|
coinbase: infos.envvars["MINER_NAME"],
|
||||||
keyJSON: keyJSON,
|
keyJSON: keyJSON,
|
||||||
keyPass: keyPass,
|
keyPass: keyPass,
|
||||||
gasTarget: gasTarget,
|
gasTarget: gasTarget,
|
||||||
|
|
|
||||||
|
|
@ -104,19 +104,19 @@ func (w *wizard) deployNode(boot bool) {
|
||||||
// If the node is a miner/signer, load up needed credentials
|
// If the node is a miner/signer, load up needed credentials
|
||||||
if !boot {
|
if !boot {
|
||||||
if w.conf.Genesis.Config.Ethash != nil {
|
if w.conf.Genesis.Config.Ethash != nil {
|
||||||
// Ethash based miners only need an etherbase to mine against
|
// Ethash based miners only need an coinbase to mine against
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
if infos.etherbase == "" {
|
if infos.coinbase == "" {
|
||||||
fmt.Printf("What address should the miner user?\n")
|
fmt.Printf("What address should the miner user?\n")
|
||||||
for {
|
for {
|
||||||
if address := w.readAddress(); address != nil {
|
if address := w.readAddress(); address != nil {
|
||||||
infos.etherbase = address.Hex()
|
infos.coinbase = address.Hex()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("What address should the miner user? (default = %s)\n", infos.etherbase)
|
fmt.Printf("What address should the miner user? (default = %s)\n", infos.coinbase)
|
||||||
infos.etherbase = w.readDefaultAddress(common.HexToAddress(infos.etherbase)).Hex()
|
infos.coinbase = w.readDefaultAddress(common.HexToAddress(infos.coinbase)).Hex()
|
||||||
}
|
}
|
||||||
} else if w.conf.Genesis.Config.Clique != nil {
|
} else if w.conf.Genesis.Config.Clique != nil {
|
||||||
// If a previous signer was already set, offer to reuse it
|
// If a previous signer was already set, offer to reuse it
|
||||||
|
|
|
||||||
|
|
@ -315,8 +315,8 @@ var (
|
||||||
Usage: "Target gas limit sets the artificial target gas floor for the blocks to mine",
|
Usage: "Target gas limit sets the artificial target gas floor for the blocks to mine",
|
||||||
Value: params.GenesisGasLimit.Uint64(),
|
Value: params.GenesisGasLimit.Uint64(),
|
||||||
}
|
}
|
||||||
EtherbaseFlag = cli.StringFlag{
|
CoinbaseFlag = cli.StringFlag{
|
||||||
Name: "etherbase",
|
Name: "coinbase",
|
||||||
Usage: "Public address for block mining rewards (default = first account created)",
|
Usage: "Public address for block mining rewards (default = first account created)",
|
||||||
Value: "0",
|
Value: "0",
|
||||||
}
|
}
|
||||||
|
|
@ -759,15 +759,15 @@ func MakeAddress(ks *keystore.KeyStore, account string) (accounts.Account, error
|
||||||
return accs[index], nil
|
return accs[index], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// setEtherbase retrieves the etherbase either from the directly specified
|
// setCoinbase retrieves the coinbase either from the directly specified
|
||||||
// command line flags or from the keystore if CLI indexed.
|
// command line flags or from the keystore if CLI indexed.
|
||||||
func setEtherbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *eth.Config) {
|
func setCoinbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *eth.Config) {
|
||||||
if ctx.GlobalIsSet(EtherbaseFlag.Name) {
|
if ctx.GlobalIsSet(CoinbaseFlag.Name) {
|
||||||
account, err := MakeAddress(ks, ctx.GlobalString(EtherbaseFlag.Name))
|
account, err := MakeAddress(ks, ctx.GlobalString(CoinbaseFlag.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("Option %q: %v", EtherbaseFlag.Name, err)
|
Fatalf("Option %q: %v", CoinbaseFlag.Name, err)
|
||||||
}
|
}
|
||||||
cfg.Etherbase = account.Address
|
cfg.Coinbase = account.Address
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -985,7 +985,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
|
||||||
checkExclusive(ctx, LightServFlag, SyncModeFlag, "light")
|
checkExclusive(ctx, LightServFlag, SyncModeFlag, "light")
|
||||||
|
|
||||||
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
|
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
|
||||||
setEtherbase(ctx, ks, cfg)
|
setCoinbase(ctx, ks, cfg)
|
||||||
setGPO(ctx, &cfg.GPO)
|
setGPO(ctx, &cfg.GPO)
|
||||||
setTxPool(ctx, &cfg.TxPool)
|
setTxPool(ctx, &cfg.TxPool)
|
||||||
setEthash(ctx, cfg)
|
setEthash(ctx, cfg)
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,8 @@ func newTester(t *testing.T, confOverride func(*eth.Config)) *tester {
|
||||||
t.Fatalf("failed to create node: %v", err)
|
t.Fatalf("failed to create node: %v", err)
|
||||||
}
|
}
|
||||||
ethConf := ð.Config{
|
ethConf := ð.Config{
|
||||||
Genesis: core.DeveloperGenesisBlock(15, common.Address{}),
|
Genesis: core.DeveloperGenesisBlock(15, common.Address{}),
|
||||||
Etherbase: common.HexToAddress(testAddress),
|
Coinbase: common.HexToAddress(testAddress),
|
||||||
Ethash: ethash.Config{
|
Ethash: ethash.Config{
|
||||||
PowMode: ethash.ModeTest,
|
PowMode: ethash.ModeTest,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
14
eth/api.go
14
eth/api.go
|
|
@ -49,14 +49,14 @@ func NewPublicEthereumAPI(e *Ethereum) *PublicEthereumAPI {
|
||||||
return &PublicEthereumAPI{e}
|
return &PublicEthereumAPI{e}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Etherbase is the address that mining rewards will be send to
|
// Etherbase is the address that mining rewards will be send to (alias for Coinbase)
|
||||||
func (api *PublicEthereumAPI) Etherbase() (common.Address, error) {
|
func (api *PublicEthereumAPI) Etherbase() (common.Address, error) {
|
||||||
return api.e.Etherbase()
|
return api.Coinbase()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Coinbase is the address that mining rewards will be send to (alias for Etherbase)
|
// Coinbase is the address that mining rewards will be send to (
|
||||||
func (api *PublicEthereumAPI) Coinbase() (common.Address, error) {
|
func (api *PublicEthereumAPI) Coinbase() (common.Address, error) {
|
||||||
return api.Etherbase()
|
return api.e.Coinbase()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hashrate returns the POW hashrate
|
// Hashrate returns the POW hashrate
|
||||||
|
|
@ -187,9 +187,9 @@ func (api *PrivateMinerAPI) SetGasPrice(gasPrice hexutil.Big) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetEtherbase sets the etherbase of the miner
|
// SetCoinbase sets the coinbase of the miner
|
||||||
func (api *PrivateMinerAPI) SetEtherbase(etherbase common.Address) bool {
|
func (api *PrivateMinerAPI) SetCoinbase(coinbase common.Address) bool {
|
||||||
api.e.SetEtherbase(etherbase)
|
api.e.SetCoinbase(coinbase)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,14 +84,14 @@ type Ethereum struct {
|
||||||
|
|
||||||
ApiBackend *EthApiBackend
|
ApiBackend *EthApiBackend
|
||||||
|
|
||||||
miner *miner.Miner
|
miner *miner.Miner
|
||||||
gasPrice *big.Int
|
gasPrice *big.Int
|
||||||
etherbase common.Address
|
coinbase common.Address
|
||||||
|
|
||||||
networkId uint64
|
networkId uint64
|
||||||
netRPCService *ethapi.PublicNetAPI
|
netRPCService *ethapi.PublicNetAPI
|
||||||
|
|
||||||
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
|
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and coinbase)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Ethereum) AddLesServer(ls LesServer) {
|
func (s *Ethereum) AddLesServer(ls LesServer) {
|
||||||
|
|
@ -130,7 +130,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||||
stopDbUpgrade: stopDbUpgrade,
|
stopDbUpgrade: stopDbUpgrade,
|
||||||
networkId: config.NetworkId,
|
networkId: config.NetworkId,
|
||||||
gasPrice: config.GasPrice,
|
gasPrice: config.GasPrice,
|
||||||
etherbase: config.Etherbase,
|
coinbase: config.Coinbase,
|
||||||
bloomRequests: make(chan chan *bloombits.Retrieval),
|
bloomRequests: make(chan chan *bloombits.Retrieval),
|
||||||
bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks),
|
bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks),
|
||||||
}
|
}
|
||||||
|
|
@ -300,48 +300,49 @@ func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block) {
|
||||||
s.blockchain.ResetWithGenesisBlock(gb)
|
s.blockchain.ResetWithGenesisBlock(gb)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Ethereum) Etherbase() (eb common.Address, err error) {
|
func (s *Ethereum) Coinbase() (eb common.Address, err error) {
|
||||||
s.lock.RLock()
|
s.lock.RLock()
|
||||||
etherbase := s.etherbase
|
coinbase := s.coinbase
|
||||||
s.lock.RUnlock()
|
s.lock.RUnlock()
|
||||||
|
|
||||||
if etherbase != (common.Address{}) {
|
if coinbase != (common.Address{}) {
|
||||||
return etherbase, nil
|
return coinbase, nil
|
||||||
}
|
}
|
||||||
if wallets := s.AccountManager().Wallets(); len(wallets) > 0 {
|
if wallets := s.AccountManager().Wallets(); len(wallets) > 0 {
|
||||||
if accounts := wallets[0].Accounts(); len(accounts) > 0 {
|
if accounts := wallets[0].Accounts(); len(accounts) > 0 {
|
||||||
etherbase := accounts[0].Address
|
coinbase := accounts[0].Address
|
||||||
|
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
s.etherbase = etherbase
|
s.coinbase = coinbase
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
|
|
||||||
log.Info("Etherbase automatically configured", "address", etherbase)
|
log.Info("Coinbase automatically configured", "address", coinbase)
|
||||||
return etherbase, nil
|
return coinbase, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return common.Address{}, fmt.Errorf("etherbase must be explicitly specified")
|
|
||||||
|
return common.Address{}, fmt.Errorf("coinbase address must be explicitly specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
// set in js console via admin interface or wrapper from cli flags
|
// set in js console via admin interface or wrapper from cli flags
|
||||||
func (self *Ethereum) SetEtherbase(etherbase common.Address) {
|
func (self *Ethereum) SetCoinbase(coinbase common.Address) {
|
||||||
self.lock.Lock()
|
self.lock.Lock()
|
||||||
self.etherbase = etherbase
|
self.coinbase = coinbase
|
||||||
self.lock.Unlock()
|
self.lock.Unlock()
|
||||||
|
|
||||||
self.miner.SetEtherbase(etherbase)
|
self.miner.SetCoinbase(coinbase)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Ethereum) StartMining(local bool) error {
|
func (s *Ethereum) StartMining(local bool) error {
|
||||||
eb, err := s.Etherbase()
|
eb, err := s.Coinbase()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Cannot start mining without etherbase", "err", err)
|
log.Error("Cannot start mining without coinbase", "err", err)
|
||||||
return fmt.Errorf("etherbase missing: %v", err)
|
return fmt.Errorf("coinbase missing: %v", err)
|
||||||
}
|
}
|
||||||
if clique, ok := s.engine.(*clique.Clique); ok {
|
if clique, ok := s.engine.(*clique.Clique); ok {
|
||||||
wallet, err := s.accountManager.Find(accounts.Account{Address: eb})
|
wallet, err := s.accountManager.Find(accounts.Account{Address: eb})
|
||||||
if wallet == nil || err != nil {
|
if wallet == nil || err != nil {
|
||||||
log.Error("Etherbase account unavailable locally", "err", err)
|
log.Error("Coinbase account unavailable locally", "err", err)
|
||||||
return fmt.Errorf("signer missing: %v", err)
|
return fmt.Errorf("signer missing: %v", err)
|
||||||
}
|
}
|
||||||
clique.Authorize(eb, wallet.SignHash)
|
clique.Authorize(eb, wallet.SignHash)
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ type Config struct {
|
||||||
DatabaseCache int
|
DatabaseCache int
|
||||||
|
|
||||||
// Mining-related options
|
// Mining-related options
|
||||||
Etherbase common.Address `toml:",omitempty"`
|
Coinbase common.Address `toml:",omitempty"`
|
||||||
MinerThreads int `toml:",omitempty"`
|
MinerThreads int `toml:",omitempty"`
|
||||||
ExtraData []byte `toml:",omitempty"`
|
ExtraData []byte `toml:",omitempty"`
|
||||||
GasPrice *big.Int
|
GasPrice *big.Int
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
||||||
SkipBcVersionCheck bool `toml:"-"`
|
SkipBcVersionCheck bool `toml:"-"`
|
||||||
DatabaseHandles int `toml:"-"`
|
DatabaseHandles int `toml:"-"`
|
||||||
DatabaseCache int
|
DatabaseCache int
|
||||||
Etherbase common.Address `toml:",omitempty"`
|
Coinbase common.Address `toml:",omitempty"`
|
||||||
MinerThreads int `toml:",omitempty"`
|
MinerThreads int `toml:",omitempty"`
|
||||||
ExtraData hexutil.Bytes `toml:",omitempty"`
|
ExtraData hexutil.Bytes `toml:",omitempty"`
|
||||||
GasPrice *big.Int
|
GasPrice *big.Int
|
||||||
|
|
@ -49,7 +49,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
||||||
enc.SkipBcVersionCheck = c.SkipBcVersionCheck
|
enc.SkipBcVersionCheck = c.SkipBcVersionCheck
|
||||||
enc.DatabaseHandles = c.DatabaseHandles
|
enc.DatabaseHandles = c.DatabaseHandles
|
||||||
enc.DatabaseCache = c.DatabaseCache
|
enc.DatabaseCache = c.DatabaseCache
|
||||||
enc.Etherbase = c.Etherbase
|
enc.Coinbase = c.Coinbase
|
||||||
enc.MinerThreads = c.MinerThreads
|
enc.MinerThreads = c.MinerThreads
|
||||||
enc.ExtraData = c.ExtraData
|
enc.ExtraData = c.ExtraData
|
||||||
enc.GasPrice = c.GasPrice
|
enc.GasPrice = c.GasPrice
|
||||||
|
|
@ -78,7 +78,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
||||||
SkipBcVersionCheck *bool `toml:"-"`
|
SkipBcVersionCheck *bool `toml:"-"`
|
||||||
DatabaseHandles *int `toml:"-"`
|
DatabaseHandles *int `toml:"-"`
|
||||||
DatabaseCache *int
|
DatabaseCache *int
|
||||||
Etherbase *common.Address `toml:",omitempty"`
|
Coinbase *common.Address `toml:",omitempty"`
|
||||||
MinerThreads *int `toml:",omitempty"`
|
MinerThreads *int `toml:",omitempty"`
|
||||||
ExtraData hexutil.Bytes `toml:",omitempty"`
|
ExtraData hexutil.Bytes `toml:",omitempty"`
|
||||||
GasPrice *big.Int
|
GasPrice *big.Int
|
||||||
|
|
@ -122,8 +122,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
||||||
if dec.DatabaseCache != nil {
|
if dec.DatabaseCache != nil {
|
||||||
c.DatabaseCache = *dec.DatabaseCache
|
c.DatabaseCache = *dec.DatabaseCache
|
||||||
}
|
}
|
||||||
if dec.Etherbase != nil {
|
if dec.Coinbase != nil {
|
||||||
c.Etherbase = *dec.Etherbase
|
c.Coinbase = *dec.Coinbase
|
||||||
}
|
}
|
||||||
if dec.MinerThreads != nil {
|
if dec.MinerThreads != nil {
|
||||||
c.MinerThreads = *dec.MinerThreads
|
c.MinerThreads = *dec.MinerThreads
|
||||||
|
|
|
||||||
|
|
@ -449,8 +449,8 @@ web3._extend({
|
||||||
call: 'miner_stop'
|
call: 'miner_stop'
|
||||||
}),
|
}),
|
||||||
new web3._extend.Method({
|
new web3._extend.Method({
|
||||||
name: 'setEtherbase',
|
name: 'setCoinbase',
|
||||||
call: 'miner_setEtherbase',
|
call: 'miner_setCoinbase',
|
||||||
params: 1,
|
params: 1,
|
||||||
inputFormatter: [web3._extend.formatters.inputAddressFormatter]
|
inputFormatter: [web3._extend.formatters.inputAddressFormatter]
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -150,12 +150,12 @@ func lesTopic(genesisHash common.Hash, protocolVersion uint) discv5.Topic {
|
||||||
|
|
||||||
type LightDummyAPI struct{}
|
type LightDummyAPI struct{}
|
||||||
|
|
||||||
// Etherbase is the address that mining rewards will be send to
|
// Etherbase is the address that mining rewards will be send to (alias for Coinbase)
|
||||||
func (s *LightDummyAPI) Etherbase() (common.Address, error) {
|
func (s *LightDummyAPI) Etherbase() (common.Address, error) {
|
||||||
return common.Address{}, fmt.Errorf("not supported")
|
return common.Address{}, fmt.Errorf("not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Coinbase is the address that mining rewards will be send to (alias for Etherbase)
|
// Coinbase is the address that mining rewards will be send to
|
||||||
func (s *LightDummyAPI) Coinbase() (common.Address, error) {
|
func (s *LightDummyAPI) Coinbase() (common.Address, error) {
|
||||||
return common.Address{}, fmt.Errorf("not supported")
|
return common.Address{}, fmt.Errorf("not supported")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ out:
|
||||||
|
|
||||||
func (self *Miner) Start(coinbase common.Address) {
|
func (self *Miner) Start(coinbase common.Address) {
|
||||||
atomic.StoreInt32(&self.shouldStart, 1)
|
atomic.StoreInt32(&self.shouldStart, 1)
|
||||||
self.worker.setEtherbase(coinbase)
|
self.worker.setCoinbase(coinbase)
|
||||||
self.coinbase = coinbase
|
self.coinbase = coinbase
|
||||||
|
|
||||||
if atomic.LoadInt32(&self.canStart) == 0 {
|
if atomic.LoadInt32(&self.canStart) == 0 {
|
||||||
|
|
@ -177,7 +177,7 @@ func (self *Miner) PendingBlock() *types.Block {
|
||||||
return self.worker.pendingBlock()
|
return self.worker.pendingBlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Miner) SetEtherbase(addr common.Address) {
|
func (self *Miner) SetCoinbase(addr common.Address) {
|
||||||
self.coinbase = addr
|
self.coinbase = addr
|
||||||
self.worker.setEtherbase(addr)
|
self.worker.setCoinbase(addr)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ func newWorker(config *params.ChainConfig, engine consensus.Engine, coinbase com
|
||||||
return worker
|
return worker
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *worker) setEtherbase(addr common.Address) {
|
func (self *worker) setCoinbase(addr common.Address) {
|
||||||
self.mu.Lock()
|
self.mu.Lock()
|
||||||
defer self.mu.Unlock()
|
defer self.mu.Unlock()
|
||||||
self.coinbase = addr
|
self.coinbase = addr
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue