aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/comms/ipc.go
blob: a0720380350364eb01bc70ccaef48a57fabd43a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package comms

import (
    "github.com/ethereum/go-ethereum/rpc/api"
    "github.com/ethereum/go-ethereum/rpc/codec"
)

type IpcConfig struct {
    Endpoint string
}

type ipcClient struct {
    codec codec.ApiCoder
}

func (self *ipcClient) Close() {
    self.codec.Close()
}

func (self *ipcClient) Send(req interface{}) error {
    return self.codec.WriteResponse(req)
}

func (self *ipcClient) Recv() (interface{}, error) {
    return self.codec.ReadResponse()
}

// Create a new IPC client, UNIX domain socket on posix, named pipe on Windows
func NewIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) {
    return newIpcClient(cfg, codec)
}

// Start IPC server
func StartIpc(cfg IpcConfig, codec codec.Codec, apis ...api.EthereumApi) error {
    offeredApi := api.Merge(apis...)
    return startIpc(cfg, codec, offeredApi)
}