api.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. JsonRpcVersion = "2.0"
  19. )
  20. var (
  21. // All API's
  22. AllApis = strings.Join([]string{
  23. AdminApiName, DbApiName, EthApiName, DebugApiName, MinerApiName, NetApiName,
  24. ShhApiName, TxPoolApiName, PersonalApiName, Web3ApiName,
  25. }, ",")
  26. )
  27. // Ethereum RPC API interface
  28. type EthereumApi interface {
  29. // API identifier
  30. Name() string
  31. // API version
  32. ApiVersion() string
  33. // Execute the given request and returns the response or an error
  34. Execute(*shared.Request) (interface{}, error)
  35. // List of supported RCP methods this API provides
  36. Methods() []string
  37. }
  38. // Merge multiple API's to a single API instance
  39. func Merge(apis ...EthereumApi) EthereumApi {
  40. return newMergedApi(apis...)
  41. }