mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Move problematic ipc code that caused Mesh not to compile for Linux amd64 out of rpc package
This commit is contained in:
parent
6d8ecdbbf2
commit
19bb08defa
7 changed files with 48 additions and 41 deletions
|
|
@ -475,7 +475,7 @@ func signer(c *cli.Context) error {
|
|||
ipcapiURL = filepath.Join(configDir, "clef.ipc")
|
||||
}
|
||||
|
||||
listener, _, err := rpc.StartIPCEndpoint(ipcapiURL, rpcAPI)
|
||||
listener, _, err := endpoints.StartIPCEndpoint(ipcapiURL, rpcAPI)
|
||||
if err != nil {
|
||||
utils.Fatalf("Could not start IPC api: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ func (n *Node) startIPC(apis []rpc.API) error {
|
|||
if n.ipcEndpoint == "" {
|
||||
return nil // IPC disabled.
|
||||
}
|
||||
listener, handler, err := rpc.StartIPCEndpoint(n.ipcEndpoint, apis)
|
||||
listener, handler, err := endpoints.StartIPCEndpoint(n.ipcEndpoint, apis)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,8 +177,8 @@ func DialContext(ctx context.Context, rawurl string) (*Client, error) {
|
|||
return DialWebsocket(ctx, rawurl, "")
|
||||
case "stdio":
|
||||
return DialStdIO(ctx)
|
||||
case "":
|
||||
return DialIPC(ctx, rawurl)
|
||||
// case "":
|
||||
// return DialIPC(ctx, rawurl)
|
||||
default:
|
||||
return nil, fmt.Errorf("no known transport for URL scheme %q", u.Scheme)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,22 +81,3 @@ func StartWSEndpoint(endpoint string, apis []API, modules []string, wsOrigins []
|
|||
return listener, handler, err
|
||||
|
||||
}
|
||||
|
||||
// StartIPCEndpoint starts an IPC endpoint.
|
||||
func StartIPCEndpoint(ipcEndpoint string, apis []API) (net.Listener, *Server, error) {
|
||||
// Register all the APIs exposed by the services.
|
||||
handler := NewServer()
|
||||
for _, api := range apis {
|
||||
if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
log.Debug("IPC registered", "namespace", api.Namespace)
|
||||
}
|
||||
// All APIs registered, start the IPC listener.
|
||||
listener, err := ipcListen(ipcEndpoint)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
go handler.ServeListener(listener)
|
||||
return listener, handler, nil
|
||||
}
|
||||
|
|
|
|||
27
rpc/endpoints/endpoints.go
Normal file
27
rpc/endpoints/endpoints.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package endpoints
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/0xProject/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
)
|
||||
|
||||
// StartIPCEndpoint starts an IPC endpoint.
|
||||
func StartIPCEndpoint(ipcEndpoint string, apis []rpc.API) (net.Listener, *rpc.Server, error) {
|
||||
// Register all the APIs exposed by the services.
|
||||
handler := rpc.NewServer()
|
||||
for _, api := range apis {
|
||||
if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
log.Debug("IPC registered", "namespace", api.Namespace)
|
||||
}
|
||||
// All APIs registered, start the IPC listener.
|
||||
listener, err := ipcListen(ipcEndpoint)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
go handler.ServeListener(listener)
|
||||
return listener, handler, nil
|
||||
}
|
||||
31
rpc/ipc.go
31
rpc/ipc.go
|
|
@ -17,7 +17,6 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
|
|
@ -39,18 +38,18 @@ func (s *Server) ServeListener(l net.Listener) error {
|
|||
}
|
||||
}
|
||||
|
||||
// DialIPC create a new IPC client that connects to the given endpoint. On Unix it assumes
|
||||
// the endpoint is the full path to a unix socket, and Windows the endpoint is an
|
||||
// identifier for a named pipe.
|
||||
//
|
||||
// The context is used for the initial connection establishment. It does not
|
||||
// affect subsequent interactions with the client.
|
||||
func DialIPC(ctx context.Context, endpoint string) (*Client, error) {
|
||||
return newClient(ctx, func(ctx context.Context) (ServerCodec, error) {
|
||||
conn, err := newIPCConnection(ctx, endpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewJSONCodec(conn), err
|
||||
})
|
||||
}
|
||||
// // DialIPC create a new IPC client that connects to the given endpoint. On Unix it assumes
|
||||
// // the endpoint is the full path to a unix socket, and Windows the endpoint is an
|
||||
// // identifier for a named pipe.
|
||||
// //
|
||||
// // The context is used for the initial connection establishment. It does not
|
||||
// // affect subsequent interactions with the client.
|
||||
// func DialIPC(ctx context.Context, endpoint string) (*Client, error) {
|
||||
// return newClient(ctx, func(ctx context.Context) (ServerCodec, error) {
|
||||
// conn, err := newIPCConnection(ctx, endpoint)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// return NewJSONCodec(conn), err
|
||||
// })
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/0xProject/go-ethereum/rpc/endpoints"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/swarm/api"
|
||||
)
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ func TestNewSwarm(t *testing.T) {
|
|||
ipcEndpoint = `\\.\pipe\TestSwarm-` + hex.EncodeToString(b)
|
||||
}
|
||||
|
||||
_, server, err := rpc.StartIPCEndpoint(ipcEndpoint, nil)
|
||||
_, server, err := endpoints.StartIPCEndpoint(ipcEndpoint, nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue