aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/comms/ipc.go
blob: a75039d17f5d4e8c5c5e7b432d47981f39b04a84 (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 {
    c codec.ApiCoder
}

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

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

func (self *ipcClient) Recv() (interface{}, error) {
    return self.c.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)
}