added RPC/IPC support
This commit is contained in:
committed by
Bas van Kervel
parent
2f55a1d798
commit
8ebf2d8fad
37
rpc/comms/ipc.go
Normal file
37
rpc/comms/ipc.go
Normal file
@ -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)
|
||||
}
|
Reference in New Issue
Block a user