github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/gossip/api.go (about)

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