2015-10-15 16:07:19 +02:00
|
|
|
// Copyright 2015 The go-ethereum Authors
|
2016-04-14 18:18:24 +02:00
|
|
|
// This file is part of the go-ethereum library.
|
2015-10-15 16:07:19 +02:00
|
|
|
//
|
2016-04-14 18:18:24 +02:00
|
|
|
// 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
|
2015-10-15 16:07:19 +02:00
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
2016-04-14 18:18:24 +02:00
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
2015-10-15 16:07:19 +02:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2016-04-14 18:18:24 +02:00
|
|
|
// GNU Lesser General Public License for more details.
|
2015-10-15 16:07:19 +02:00
|
|
|
//
|
2016-04-14 18:18:24 +02:00
|
|
|
// 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/>.
|
2015-10-15 16:07:19 +02:00
|
|
|
|
|
|
|
package eth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2016-12-17 15:39:55 +01:00
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
2015-10-15 16:07:19 +02:00
|
|
|
)
|
|
|
|
|
2022-06-21 11:05:43 +02:00
|
|
|
// EthereumAPI provides an API to access Ethereum full node-related information.
|
|
|
|
type EthereumAPI struct {
|
2016-06-30 13:03:26 +03:00
|
|
|
e *Ethereum
|
2016-01-27 18:01:30 +02:00
|
|
|
}
|
|
|
|
|
2022-06-21 11:05:43 +02:00
|
|
|
// NewEthereumAPI creates a new Ethereum protocol API for full nodes.
|
|
|
|
func NewEthereumAPI(e *Ethereum) *EthereumAPI {
|
|
|
|
return &EthereumAPI{e}
|
2015-10-15 16:07:19 +02:00
|
|
|
}
|
|
|
|
|
2023-05-30 13:55:03 +01:00
|
|
|
// Etherbase is the address that mining rewards will be sent to.
|
2022-06-21 11:05:43 +02:00
|
|
|
func (api *EthereumAPI) Etherbase() (common.Address, error) {
|
2017-04-05 01:16:29 +03:00
|
|
|
return api.e.Etherbase()
|
2015-10-15 16:07:19 +02:00
|
|
|
}
|
|
|
|
|
2023-05-30 13:55:03 +01:00
|
|
|
// Coinbase is the address that mining rewards will be sent to (alias for Etherbase).
|
2022-06-21 11:05:43 +02:00
|
|
|
func (api *EthereumAPI) Coinbase() (common.Address, error) {
|
2017-04-05 01:16:29 +03:00
|
|
|
return api.Etherbase()
|
2015-10-15 16:07:19 +02:00
|
|
|
}
|
|
|
|
|
2022-06-15 09:29:23 +02:00
|
|
|
// Hashrate returns the POW hashrate.
|
2022-06-21 11:05:43 +02:00
|
|
|
func (api *EthereumAPI) Hashrate() hexutil.Uint64 {
|
2021-04-29 12:02:30 +03:00
|
|
|
return hexutil.Uint64(api.e.Miner().Hashrate())
|
|
|
|
}
|
|
|
|
|
2016-02-09 16:03:04 +02:00
|
|
|
// Mining returns an indication if this node is currently mining.
|
2022-06-21 11:05:43 +02:00
|
|
|
func (api *EthereumAPI) Mining() bool {
|
2017-04-05 01:16:29 +03:00
|
|
|
return api.e.IsMining()
|
2016-02-09 16:03:04 +02:00
|
|
|
}
|