mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth: get rid of most miner api
This commit is contained in:
parent
e4dad4492a
commit
84a95ee794
6 changed files with 14 additions and 53 deletions
|
|
@ -131,7 +131,6 @@ 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.VersionWithCommit("", "") })
|
attach.SetTemplateFunc("gethver", func() string { return params.VersionWithCommit("", "") })
|
||||||
attach.SetTemplateFunc("etherbase", func() string { return geth.Etherbase })
|
|
||||||
attach.SetTemplateFunc("niltime", func() string {
|
attach.SetTemplateFunc("niltime", func() string {
|
||||||
return time.Unix(1548854791, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)")
|
return time.Unix(1548854791, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)")
|
||||||
})
|
})
|
||||||
|
|
@ -144,7 +143,6 @@ 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}}
|
|
||||||
at block: 0 ({{niltime}}){{if ipc}}
|
at block: 0 ({{niltime}}){{if ipc}}
|
||||||
datadir: {{datadir}}{{end}}
|
datadir: {{datadir}}{{end}}
|
||||||
modules: {{apis}}
|
modules: {{apis}}
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,7 @@ func (c *Console) Welcome() {
|
||||||
if res, err := c.jsre.Run(`
|
if res, err := c.jsre.Run(`
|
||||||
var message = "instance: " + web3.version.node + "\n";
|
var message = "instance: " + web3.version.node + "\n";
|
||||||
try {
|
try {
|
||||||
message += "coinbase: " + eth.coinbase + "\n";
|
message += "coinbase: " + miner.etherbase() + "\n";
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
message += "at block: " + eth.blockNumber + " (" + new Date(1000 * eth.getBlock(eth.blockNumber).timestamp) + ")\n";
|
message += "at block: " + eth.blockNumber + " (" + new Date(1000 * eth.getBlock(eth.blockNumber).timestamp) + ")\n";
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
46
eth/api.go
46
eth/api.go
|
|
@ -1,46 +0,0 @@
|
||||||
// Copyright 2015 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
package eth
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
// EthereumAPI provides an API to access Ethereum full node-related information.
|
|
||||||
type EthereumAPI struct {
|
|
||||||
e *Ethereum
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewEthereumAPI creates a new Ethereum protocol API for full nodes.
|
|
||||||
func NewEthereumAPI(e *Ethereum) *EthereumAPI {
|
|
||||||
return &EthereumAPI{e}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Etherbase is the address that mining rewards will be sent to.
|
|
||||||
func (api *EthereumAPI) Etherbase() (common.Address, error) {
|
|
||||||
return api.e.Etherbase()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Coinbase is the address that mining rewards will be sent to (alias for Etherbase).
|
|
||||||
func (api *EthereumAPI) Coinbase() (common.Address, error) {
|
|
||||||
return api.Etherbase()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mining returns an indication if this node is currently mining.
|
|
||||||
func (api *EthereumAPI) Mining() bool {
|
|
||||||
return api.e.IsMining()
|
|
||||||
}
|
|
||||||
|
|
@ -63,3 +63,8 @@ func (api *MinerAPI) SetEtherbase(etherbase common.Address) bool {
|
||||||
api.e.SetEtherbase(etherbase)
|
api.e.SetEtherbase(etherbase)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Etherbase is the address that mining rewards will be sent to.
|
||||||
|
func (api *MinerAPI) Etherbase() common.Address {
|
||||||
|
return api.e.Miner().Etherbase()
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -315,9 +315,6 @@ func (s *Ethereum) APIs() []rpc.API {
|
||||||
// Append all the local APIs and return
|
// Append all the local APIs and return
|
||||||
return append(apis, []rpc.API{
|
return append(apis, []rpc.API{
|
||||||
{
|
{
|
||||||
Namespace: "eth",
|
|
||||||
Service: NewEthereumAPI(s),
|
|
||||||
}, {
|
|
||||||
Namespace: "miner",
|
Namespace: "miner",
|
||||||
Service: NewMinerAPI(s),
|
Service: NewMinerAPI(s),
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -414,7 +411,6 @@ func (s *Ethereum) SetEtherbase(etherbase common.Address) {
|
||||||
s.miner.SetEtherbase(etherbase)
|
s.miner.SetEtherbase(etherbase)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Ethereum) IsMining() bool { return true }
|
|
||||||
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 }
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,14 @@ 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.
|
// SetEtherbase sets the address of fee recipient.
|
||||||
func (miner *Miner) SetEtherbase(addr common.Address) {
|
func (miner *Miner) SetEtherbase(addr common.Address) {
|
||||||
miner.confMu.Lock()
|
miner.confMu.Lock()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue