api.go 996 Bytes
Newer Older
1 2
package api

Bas van Kervel's avatar
Bas van Kervel committed
3 4 5 6 7
import (
	"strings"

	"github.com/ethereum/go-ethereum/rpc/shared"
)
8

9
const (
Bas van Kervel's avatar
Bas van Kervel committed
10
	AdminApiName    = "admin"
Bas van Kervel's avatar
Bas van Kervel committed
11 12 13 14 15
	EthApiName      = "eth"
	DebugApiName    = "debug"
	MergedApiName   = "merged"
	MinerApiName    = "miner"
	NetApiName      = "net"
Bas van Kervel's avatar
Bas van Kervel committed
16
	txPoolApiName   = "txpool"
Bas van Kervel's avatar
Bas van Kervel committed
17 18 19 20 21
	PersonalApiName = "personal"
	Web3ApiName     = "web3"
)

var (
22
	// List with all API's which are offered over the IPC interface by default
Bas van Kervel's avatar
Bas van Kervel committed
23
	DefaultIpcApis = strings.Join([]string{
Bas van Kervel's avatar
Bas van Kervel committed
24
		AdminApiName, EthApiName, DebugApiName, MinerApiName, NetApiName, txPoolApiName, PersonalApiName, Web3ApiName,
Bas van Kervel's avatar
Bas van Kervel committed
25
	}, ",")
26 27
)

28 29
// Ethereum RPC API interface
type EthereumApi interface {
Bas van Kervel's avatar
Bas van Kervel committed
30 31 32
	// API identifier
	Name() string

33 34 35 36 37 38
	// Execute the given request and returns the response or an error
	Execute(*shared.Request) (interface{}, error)

	// List of supported RCP methods this API provides
	Methods() []string
}
Bas van Kervel's avatar
Bas van Kervel committed
39 40 41 42 43

// Merge multiple API's to a single API instance
func Merge(apis ...EthereumApi) EthereumApi {
	return newMergedApi(apis...)
}