/
api.go
37 lines (30 loc) · 1.15 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package gossip
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
)
// PublicEthereumAPI provides an API to access Ethereum-like information.
// It is a github.com/ethereum/go-ethereum/eth simulation for console.
type PublicEthereumAPI struct {
s *Service
}
// NewPublicEthereumAPI creates a new Ethereum protocol API for gossip.
func NewPublicEthereumAPI(s *Service) *PublicEthereumAPI {
return &PublicEthereumAPI{s}
}
// Etherbase returns the zero address for web3 compatibility
func (api *PublicEthereumAPI) Etherbase() (common.Address, error) {
return common.Address{}, nil
}
// Coinbase returns the zero address for web3 compatibility
func (api *PublicEthereumAPI) Coinbase() (common.Address, error) {
return common.Address{}, nil
}
// Hashrate returns the zero POW hashrate for web3 compatibility
func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 {
return hexutil.Uint64(0)
}
// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
func (api *PublicEthereumAPI) ChainId() hexutil.Uint64 {
return hexutil.Uint64(api.s.store.GetRules().EvmChainConfig().ChainID.Uint64())
}