geth,cmd/status: IPC-RPC server enabled

This commit is contained in:
Victor Farazdagi 2017-01-26 05:46:37 +03:00
parent cf7b8fb96c
commit e38864fec2
3 changed files with 20 additions and 7 deletions

View File

@ -202,6 +202,7 @@ func StartNode(datadir *C.char) *C.char {
// This starts a geth node with the given datadir // This starts a geth node with the given datadir
err := geth.CreateAndRunNode(&geth.NodeConfig{ err := geth.CreateAndRunNode(&geth.NodeConfig{
DataDir: C.GoString(datadir), DataDir: C.GoString(datadir),
IPCEnabled: true,
HTTPPort: geth.HTTPPort, HTTPPort: geth.HTTPPort,
WSEnabled: true, WSEnabled: true,
WSPort: geth.WSPort, WSPort: geth.WSPort,

View File

@ -33,13 +33,13 @@ const (
VersionMinor = 2 // Minor version component of the current release VersionMinor = 2 // Minor version component of the current release
VersionPatch = 0 // Patch 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 VersionMeta = "unstable" // Version metadata to append to the version string
IPCFile = "geth.ipc" // Filename of exposed IPC-RPC Server
HTTPPort = 8545 // HTTP-RPC port (replaced in unit tests) HTTPPort = 8545 // HTTP-RPC port (replaced in unit tests)
WSPort = 8546 // WS-RPC port (replaced in unit tests) WSPort = 8546 // WS-RPC port (replaced in unit tests)
NetworkPort = 30303 NetworkPort = 30303
MaxPeers = 25 MaxPeers = 25
MaxLightPeers = 20 MaxLightPeers = 20
MaxPendingPeers = 0 MaxPendingPeers = 0
ProcessFileDescriptorLimit = uint64(2048) ProcessFileDescriptorLimit = uint64(2048)
DatabaseCacheSize = 128 // Megabytes of memory allocated to internal caching (min 16MB / database forced) 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 // NodeConfig stores configuration options for a node
type NodeConfig struct { type NodeConfig struct {
DataDir string // base data directory DataDir string // base data directory
IPCEnabled bool // whether IPC-RPC Server is enabled or not
HTTPPort int // HTTP-RPC Server port HTTPPort int // HTTP-RPC Server port
WSPort int // WS-RPC Server port WSPort int // WS-RPC Server port
WSEnabled bool // whether WS-RPC Server is enabled or not WSEnabled bool // whether WS-RPC Server is enabled or not
@ -127,6 +128,7 @@ func MakeNode(config *NodeConfig) *Node {
ListenAddr: fmt.Sprintf(":%d", NetworkPort), ListenAddr: fmt.Sprintf(":%d", NetworkPort),
MaxPeers: MaxPeers, MaxPeers: MaxPeers,
MaxPendingPeers: MaxPendingPeers, MaxPendingPeers: MaxPendingPeers,
IPCPath: makeIPCPath(dataDir, config.IPCEnabled),
HTTPHost: node.DefaultHTTPHost, HTTPHost: node.DefaultHTTPHost,
HTTPPort: config.HTTPPort, HTTPPort: config.HTTPPort,
HTTPCors: "*", HTTPCors: "*",
@ -211,6 +213,15 @@ func activateShhService(stack *node.Node) error {
return nil 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 // makeWSHost returns WS-RPC Server host, given enabled/disabled flag
func makeWSHost(wsEnabled bool) string { func makeWSHost(wsEnabled bool) string {
if !wsEnabled { if !wsEnabled {

View File

@ -131,6 +131,7 @@ func PrepareTestNode() (err error) {
// start geth node and wait for it to initialize // start geth node and wait for it to initialize
err = CreateAndRunNode(&NodeConfig{ err = CreateAndRunNode(&NodeConfig{
DataDir: dataDir, DataDir: dataDir,
IPCEnabled: true,
HTTPPort: TestNodeHTTPPort, // to avoid conflicts with running app, using different port in tests HTTPPort: TestNodeHTTPPort, // to avoid conflicts with running app, using different port in tests
WSEnabled: true, WSEnabled: true,
WSPort: TestNodeWSPort, // ditto WSPort: TestNodeWSPort, // ditto