Skip to content

Commit 1a71465

Browse files
gameofpointerswizeguyy
authored andcommitted
Removed IPC
1 parent 15abe41 commit 1a71465

14 files changed

+3
-386
lines changed

cmd/go-quai/config.go

-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ func defaultNodeConfig() node.Config {
108108
cfg.Version = params.VersionWithCommit(gitCommit, gitDate)
109109
cfg.HTTPModules = append(cfg.HTTPModules, "eth")
110110
cfg.WSModules = append(cfg.WSModules, "eth")
111-
cfg.IPCPath = "quai.ipc"
112111
return cfg
113112
}
114113

cmd/go-quai/main.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ var (
157157
utils.WSApiFlag,
158158
utils.WSAllowedOriginsFlag,
159159
utils.WSPathPrefixFlag,
160-
utils.IPCDisabledFlag,
161-
utils.IPCPathFlag,
162160
utils.InsecureUnlockAllowedFlag,
163161
utils.RPCGlobalGasCapFlag,
164162
utils.RPCGlobalTxFeeCapFlag,
@@ -293,7 +291,7 @@ func quai(ctx *cli.Context) error {
293291
}
294292

295293
// startNode boots up the system node and all registered protocols, after which
296-
// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
294+
// it unlocks any requested accounts, and starts the RPC interfaces and the
297295
// miner.
298296
func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend) {
299297
debug.Memsize.Add("node", stack)

cmd/go-quai/usage.go

-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ var AppHelpFlagGroups = []flags.FlagGroup{
104104
{
105105
Name: "API AND CONSOLE",
106106
Flags: []cli.Flag{
107-
utils.IPCDisabledFlag,
108-
utils.IPCPathFlag,
109107
utils.HTTPEnabledFlag,
110108
utils.HTTPListenAddrFlag,
111109
utils.HTTPPortFlag,

cmd/utils/flags.go

-21
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,6 @@ var (
427427
Usage: "Disables db compaction after import",
428428
}
429429
// RPC settings
430-
IPCDisabledFlag = cli.BoolFlag{
431-
Name: "ipcdisable",
432-
Usage: "Disable the IPC-RPC server",
433-
}
434-
IPCPathFlag = DirectoryFlag{
435-
Name: "ipcpath",
436-
Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
437-
}
438430
HTTPEnabledFlag = cli.BoolFlag{
439431
Name: "http",
440432
Usage: "Enable the HTTP-RPC server",
@@ -959,18 +951,6 @@ func makeSubUrls(ctx *cli.Context) []string {
959951
return strings.Split(ctx.GlobalString(SubUrls.Name), ",")
960952
}
961953

962-
// setIPC creates an IPC path configuration from the set command line flags,
963-
// returning an empty string if IPC was explicitly disabled, or the set path.
964-
func setIPC(ctx *cli.Context, cfg *node.Config) {
965-
CheckExclusive(ctx, IPCDisabledFlag, IPCPathFlag)
966-
switch {
967-
case ctx.GlobalBool(IPCDisabledFlag.Name):
968-
cfg.IPCPath = ""
969-
case ctx.GlobalIsSet(IPCPathFlag.Name):
970-
cfg.IPCPath = ctx.GlobalString(IPCPathFlag.Name)
971-
}
972-
}
973-
974954
// MakeDatabaseHandles raises out the number of allowed file handles per process
975955
// for Geth and returns half of the allowance to assign to the database.
976956
func MakeDatabaseHandles() int {
@@ -1099,7 +1079,6 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
10991079
// SetNodeConfig applies node-related command line flags to the config.
11001080
func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
11011081
SetP2PConfig(ctx, &cfg.P2P)
1102-
setIPC(ctx, cfg)
11031082
setHTTP(ctx, cfg)
11041083
setWS(ctx, cfg)
11051084
setNodeUserIdent(ctx, cfg)

node/config.go

-43
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ type Config struct {
9696
// USB enables hardware wallet monitoring and connectivity.
9797
USB bool `toml:",omitempty"`
9898

99-
// IPCPath is the requested location to place the IPC endpoint. If the path is
100-
// a simple file name, it is placed inside the data directory (or on the root
101-
// pipe path on Windows), whereas if it's a resolvable path name (absolute or
102-
// relative), then that specific path is enforced. An empty path disables IPC.
103-
IPCPath string
104-
10599
// HTTPHost is the host interface on which to start the HTTP RPC server. If this
106100
// field is empty, no HTTP API endpoint will be started.
107101
HTTPHost string
@@ -177,31 +171,6 @@ type Config struct {
177171
AllowUnprotectedTxs bool `toml:",omitempty"`
178172
}
179173

180-
// IPCEndpoint resolves an IPC endpoint based on a configured value, taking into
181-
// account the set data folders as well as the designated platform we're currently
182-
// running on.
183-
func (c *Config) IPCEndpoint() string {
184-
// Short circuit if IPC has not been enabled
185-
if c.IPCPath == "" {
186-
return ""
187-
}
188-
// On windows we can only use plain top-level pipes
189-
if runtime.GOOS == "windows" {
190-
if strings.HasPrefix(c.IPCPath, `\\.\pipe\`) {
191-
return c.IPCPath
192-
}
193-
return `\\.\pipe\` + c.IPCPath
194-
}
195-
// Resolve names into the data directory full paths otherwise
196-
if filepath.Base(c.IPCPath) == c.IPCPath {
197-
if c.DataDir == "" {
198-
return filepath.Join(os.TempDir(), c.IPCPath)
199-
}
200-
return filepath.Join(c.DataDir, c.IPCPath)
201-
}
202-
return c.IPCPath
203-
}
204-
205174
// NodeDB returns the path to the discovery node database.
206175
func (c *Config) NodeDB() string {
207176
if c.DataDir == "" {
@@ -210,18 +179,6 @@ func (c *Config) NodeDB() string {
210179
return c.ResolvePath(datadirNodeDatabase)
211180
}
212181

213-
// DefaultIPCEndpoint returns the IPC path used by default.
214-
func DefaultIPCEndpoint(clientIdentifier string) string {
215-
if clientIdentifier == "" {
216-
clientIdentifier = strings.TrimSuffix(filepath.Base(os.Args[0]), ".exe")
217-
if clientIdentifier == "" {
218-
panic("empty executable name")
219-
}
220-
}
221-
config := &Config{DataDir: DefaultDataDir(), IPCPath: clientIdentifier + ".ipc"}
222-
return config.IPCEndpoint()
223-
}
224-
225182
// HTTPEndpoint resolves an HTTP endpoint based on the configured host interface
226183
// and port parameters.
227184
func (c *Config) HTTPEndpoint() string {

node/doc.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ devp2p network has a unique identifier, the node key. The Node instance persists
7171
across restarts. Node also loads static and trusted node lists and ensures that knowledge
7272
about other hosts is persisted.
7373
74-
JSON-RPC servers which run HTTP, WebSocket or IPC can be started on a Node. RPC modules
74+
JSON-RPC servers which run HTTP, WebSocket can be started on a Node. RPC modules
7575
offered by registered services will be offered on those endpoints. Users can restrict any
7676
endpoint to a subset of RPC modules. Node itself offers the "debug", "admin" and "web3"
7777
modules.
@@ -114,14 +114,12 @@ directory. Node instance A opens the database "db", node instance B opens the da
114114
nodekey -- devp2p node key of instance A
115115
nodes/ -- devp2p discovery knowledge database of instance A
116116
db/ -- LevelDB content for "db"
117-
A.ipc -- JSON-RPC UNIX domain socket endpoint of instance A
118117
B/
119118
nodekey -- devp2p node key of node B
120119
nodes/ -- devp2p discovery knowledge database of instance B
121120
static-nodes.json -- devp2p static node list of instance B
122121
db/ -- LevelDB content for "db"
123122
db-2/ -- LevelDB content for "db-2"
124-
B.ipc -- JSON-RPC UNIX domain socket endpoint of instance B
125123
keystore/ -- account key store, used by both instances
126124
*/
127125
package node

node/node.go

-18
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ type Node struct {
5454
rpcAPIs []rpc.API // List of APIs currently provided by the node
5555
http *httpServer //
5656
ws *httpServer //
57-
ipc *ipcServer // Stores information about the ipc http server
5857
inprocHandler *rpc.Server // In-process RPC request handler to process the API requests
5958

6059
databases map[*closeTrackingDB]struct{} // All open databases
@@ -91,9 +90,6 @@ func New(conf *Config) (*Node, error) {
9190
if conf.Name == datadirDefaultKeyStore {
9291
return nil, errors.New(`Config.Name cannot be "` + datadirDefaultKeyStore + `"`)
9392
}
94-
if strings.HasSuffix(conf.Name, ".ipc") {
95-
return nil, errors.New(`Config.Name cannot end in ".ipc"`)
96-
}
9793

9894
node := &Node{
9995
config: conf,
@@ -146,7 +142,6 @@ func New(conf *Config) (*Node, error) {
146142
// Configure RPC servers.
147143
node.http = newHTTPServer(node.log, conf.HTTPTimeouts)
148144
node.ws = newHTTPServer(node.log, rpc.DefaultHTTPTimeouts)
149-
node.ipc = newIPCServer(node.log, conf.IPCEndpoint())
150145

151146
return node, nil
152147
}
@@ -341,13 +336,6 @@ func (n *Node) startRPC() error {
341336
return err
342337
}
343338

344-
// Configure IPC.
345-
if n.ipc.endpoint != "" {
346-
if err := n.ipc.start(n.rpcAPIs); err != nil {
347-
return err
348-
}
349-
}
350-
351339
// Configure HTTP.
352340
if n.config.HTTPHost != "" {
353341
config := httpConfig{
@@ -396,7 +384,6 @@ func (n *Node) wsServerForPort(port int) *httpServer {
396384
func (n *Node) stopRPC() {
397385
n.http.stop()
398386
n.ws.stop()
399-
n.ipc.stop()
400387
n.stopInProc()
401388
}
402389

@@ -519,11 +506,6 @@ func (n *Node) AccountManager() *accounts.Manager {
519506
return n.accman
520507
}
521508

522-
// IPCEndpoint retrieves the current IPC endpoint used by the protocol stack.
523-
func (n *Node) IPCEndpoint() string {
524-
return n.ipc.endpoint
525-
}
526-
527509
// HTTPEndpoint returns the URL of the HTTP server. Note that this URL does not
528510
// contain the JSON-RPC path prefix set by HTTPPathPrefix.
529511
func (n *Node) HTTPEndpoint() string {

node/rpcstack.go

-45
Original file line numberDiff line numberDiff line change
@@ -470,51 +470,6 @@ func newGzipHandler(next http.Handler) http.Handler {
470470
})
471471
}
472472

473-
type ipcServer struct {
474-
log log.Logger
475-
endpoint string
476-
477-
mu sync.Mutex
478-
listener net.Listener
479-
srv *rpc.Server
480-
}
481-
482-
func newIPCServer(log log.Logger, endpoint string) *ipcServer {
483-
return &ipcServer{log: log, endpoint: endpoint}
484-
}
485-
486-
// Start starts the httpServer's http.Server
487-
func (is *ipcServer) start(apis []rpc.API) error {
488-
is.mu.Lock()
489-
defer is.mu.Unlock()
490-
491-
if is.listener != nil {
492-
return nil // already running
493-
}
494-
listener, srv, err := rpc.StartIPCEndpoint(is.endpoint, apis)
495-
if err != nil {
496-
is.log.Warn("IPC opening failed", "url", is.endpoint, "error", err)
497-
return err
498-
}
499-
is.log.Info("IPC endpoint opened", "url", is.endpoint)
500-
is.listener, is.srv = listener, srv
501-
return nil
502-
}
503-
504-
func (is *ipcServer) stop() error {
505-
is.mu.Lock()
506-
defer is.mu.Unlock()
507-
508-
if is.listener == nil {
509-
return nil // not running
510-
}
511-
err := is.listener.Close()
512-
is.srv.Stop()
513-
is.listener, is.srv = nil, nil
514-
is.log.Info("IPC endpoint closed", "url", is.endpoint)
515-
return err
516-
}
517-
518473
// RegisterApis checks the given modules' availability, generates an allowlist based on the allowed modules,
519474
// and then registers all of the APIs exposed by the services.
520475
func RegisterApis(apis []rpc.API, modules []string, srv *rpc.Server, exposeAll bool) error {

rpc/client.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (op *requestOp) wait(ctx context.Context, c *Client) (*jsonrpcMessage, erro
153153
// The currently supported URL schemes are "http", "https", "ws" and "wss". If rawurl is a
154154
// file name with no URL scheme, a local socket connection is established using UNIX
155155
// domain sockets on supported platforms and named pipes on Windows. If you want to
156-
// configure transport options, use DialHTTP, DialWebsocket or DialIPC instead.
156+
// configure transport options, use DialHTTP, DialWebsocket.
157157
//
158158
// For websocket connections, the origin is set to the local host name.
159159
//
@@ -178,8 +178,6 @@ func DialContext(ctx context.Context, rawurl string) (*Client, error) {
178178
return DialWebsocket(ctx, rawurl, "")
179179
case "stdio":
180180
return DialStdIO(ctx)
181-
case "":
182-
return DialIPC(ctx, rawurl)
183181
default:
184182
return nil, fmt.Errorf("no known transport for URL scheme %q", u.Scheme)
185183
}

rpc/endpoints.go

-52
This file was deleted.

0 commit comments

Comments
 (0)