diff options
author | Bas van Kervel <basvankervel@ziggo.nl> | 2015-06-08 16:41:04 +0800 |
---|---|---|
committer | Bas van Kervel <basvankervel@gmail.com> | 2015-06-11 20:01:39 +0800 |
commit | 8ebf2d8fad729a8261f237bb05b6073e6c1b652f (patch) | |
tree | dd941d95eb9efdfb348caa94618d62b4523a02e8 /rpc/comms/ipc.go | |
parent | 2f55a1d79853c1348fb1a4332fff98110167da80 (diff) | |
download | go-tangerine-8ebf2d8fad729a8261f237bb05b6073e6c1b652f.tar.gz go-tangerine-8ebf2d8fad729a8261f237bb05b6073e6c1b652f.tar.zst go-tangerine-8ebf2d8fad729a8261f237bb05b6073e6c1b652f.zip |
added RPC/IPC support
Diffstat (limited to 'rpc/comms/ipc.go')
-rw-r--r-- | rpc/comms/ipc.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/rpc/comms/ipc.go b/rpc/comms/ipc.go new file mode 100644 index 000000000..a75039d17 --- /dev/null +++ b/rpc/comms/ipc.go @@ -0,0 +1,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) +} |