api.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package api
  2. import (
  3. "strings"
  4. "github.com/ethereum/go-ethereum/rpc/shared"
  5. )
  6. const (
  7. AdminApiName = "admin"
  8. EthApiName = "eth"
  9. DebugApiName = "debug"
  10. MergedApiName = "merged"
  11. MinerApiName = "miner"
  12. NetApiName = "net"
  13. ShhApiName = "shh"
  14. TxPoolApiName = "txpool"
  15. PersonalApiName = "personal"
  16. Web3ApiName = "web3"
  17. )
  18. var (
  19. // List with all API's which are offered over the IPC interface by default
  20. DefaultIpcApis = strings.Join([]string{
  21. AdminApiName, EthApiName, DebugApiName, MinerApiName, NetApiName,
  22. ShhApiName, TxPoolApiName, PersonalApiName, Web3ApiName,
  23. }, ",")
  24. )
  25. // Ethereum RPC API interface
  26. type EthereumApi interface {
  27. // API identifier
  28. Name() string
  29. // API version
  30. ApiVersion() string
  31. // Execute the given request and returns the response or an error
  32. Execute(*shared.Request) (interface{}, error)
  33. // List of supported RCP methods this API provides
  34. Methods() []string
  35. }
  36. // Merge multiple API's to a single API instance
  37. func Merge(apis ...EthereumApi) EthereumApi {
  38. return newMergedApi(apis...)
  39. }