From e38864fec2a97b71b21119231d5d34dc62463891 Mon Sep 17 00:00:00 2001 From: Victor Farazdagi Date: Thu, 26 Jan 2017 05:46:37 +0300 Subject: [PATCH] geth,cmd/status: IPC-RPC server enabled --- cmd/status/library.go | 1 + geth/node.go | 25 ++++++++++++++++++------- geth/utils.go | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cmd/status/library.go b/cmd/status/library.go index 8c028ff03..30afb10d6 100644 --- a/cmd/status/library.go +++ b/cmd/status/library.go @@ -202,6 +202,7 @@ func StartNode(datadir *C.char) *C.char { // This starts a geth node with the given datadir err := geth.CreateAndRunNode(&geth.NodeConfig{ DataDir: C.GoString(datadir), + IPCEnabled: true, HTTPPort: geth.HTTPPort, WSEnabled: true, WSPort: geth.WSPort, diff --git a/geth/node.go b/geth/node.go index 376046cf9..acab5d731 100644 --- a/geth/node.go +++ b/geth/node.go @@ -33,13 +33,13 @@ const ( VersionMinor = 2 // Minor version component of the current release VersionPatch = 0 // Patch version component of the current release VersionMeta = "unstable" // Version metadata to append to the version string - - HTTPPort = 8545 // HTTP-RPC port (replaced in unit tests) - WSPort = 8546 // WS-RPC port (replaced in unit tests) - NetworkPort = 30303 - MaxPeers = 25 - MaxLightPeers = 20 - MaxPendingPeers = 0 + IPCFile = "geth.ipc" // Filename of exposed IPC-RPC Server + HTTPPort = 8545 // HTTP-RPC port (replaced in unit tests) + WSPort = 8546 // WS-RPC port (replaced in unit tests) + NetworkPort = 30303 + MaxPeers = 25 + MaxLightPeers = 20 + MaxPendingPeers = 0 ProcessFileDescriptorLimit = uint64(2048) DatabaseCacheSize = 128 // Megabytes of memory allocated to internal caching (min 16MB / database forced) @@ -81,6 +81,7 @@ var ( // NodeConfig stores configuration options for a node type NodeConfig struct { DataDir string // base data directory + IPCEnabled bool // whether IPC-RPC Server is enabled or not HTTPPort int // HTTP-RPC Server port WSPort int // WS-RPC Server port WSEnabled bool // whether WS-RPC Server is enabled or not @@ -127,6 +128,7 @@ func MakeNode(config *NodeConfig) *Node { ListenAddr: fmt.Sprintf(":%d", NetworkPort), MaxPeers: MaxPeers, MaxPendingPeers: MaxPendingPeers, + IPCPath: makeIPCPath(dataDir, config.IPCEnabled), HTTPHost: node.DefaultHTTPHost, HTTPPort: config.HTTPPort, HTTPCors: "*", @@ -211,6 +213,15 @@ func activateShhService(stack *node.Node) error { return nil } +// makeIPCPath returns IPC-RPC filename +func makeIPCPath(dataDir string, ipcEnabled bool) string { + if !ipcEnabled { + return "" + } + + return path.Join(dataDir, IPCFile) +} + // makeWSHost returns WS-RPC Server host, given enabled/disabled flag func makeWSHost(wsEnabled bool) string { if !wsEnabled { diff --git a/geth/utils.go b/geth/utils.go index 77ef15db5..37c2f66a8 100644 --- a/geth/utils.go +++ b/geth/utils.go @@ -131,6 +131,7 @@ func PrepareTestNode() (err error) { // start geth node and wait for it to initialize err = CreateAndRunNode(&NodeConfig{ DataDir: dataDir, + IPCEnabled: true, HTTPPort: TestNodeHTTPPort, // to avoid conflicts with running app, using different port in tests WSEnabled: true, WSPort: TestNodeWSPort, // ditto