api.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. DbApiName = "db"
  10. DebugApiName = "debug"
  11. MergedApiName = "merged"
  12. MinerApiName = "miner"
  13. NetApiName = "net"
  14. ShhApiName = "shh"
  15. TxPoolApiName = "txpool"
  16. PersonalApiName = "personal"
  17. Web3ApiName = "web3"
  18. )
  19. var (
  20. DefaultHttpRpcApis = strings.Join([]string{
  21. DbApiName, EthApiName, NetApiName, Web3ApiName,
  22. }, ",")
  23. // List with all API's which are offered over the IPC interface by default
  24. DefaultIpcApis = strings.Join([]string{
  25. AdminApiName, DbApiName, EthApiName, DebugApiName, MinerApiName, NetApiName,
  26. ShhApiName, TxPoolApiName, PersonalApiName, Web3ApiName,
  27. }, ",")
  28. )
  29. // Ethereum RPC API interface
  30. type EthereumApi interface {
  31. // API identifier
  32. Name() string
  33. // API version
  34. ApiVersion() string
  35. // Execute the given request and returns the response or an error
  36. Execute(*shared.Request) (interface{}, error)
  37. // List of supported RCP methods this API provides
  38. Methods() []string
  39. }
  40. // Merge multiple API's to a single API instance
  41. func Merge(apis ...EthereumApi) EthereumApi {
  42. return newMergedApi(apis...)
  43. }