aboutsummaryrefslogtreecommitdiffstats
path: root/node
diff options
context:
space:
mode:
Diffstat (limited to 'node')
-rw-r--r--node/api.go14
-rw-r--r--node/config.go17
-rw-r--r--node/defaults.go2
-rw-r--r--node/doc.go2
-rw-r--r--node/node.go10
-rw-r--r--node/service.go4
6 files changed, 28 insertions, 21 deletions
diff --git a/node/api.go b/node/api.go
index e5f388463..2656c2120 100644
--- a/node/api.go
+++ b/node/api.go
@@ -188,7 +188,7 @@ func (api *PrivateAdminAPI) StartRPC(host *string, port *int, cors *string, apis
}
}
- if err := api.node.startHTTP(fmt.Sprintf("%s:%d", *host, *port), api.node.rpcAPIs, modules, allowedOrigins, allowedVHosts); err != nil {
+ if err := api.node.startHTTP(fmt.Sprintf("%s:%d", *host, *port), api.node.rpcAPIs, modules, allowedOrigins, allowedVHosts, api.node.config.HTTPTimeouts); err != nil {
return false, err
}
return true, nil
@@ -374,13 +374,13 @@ func (api *PublicDebugAPI) Metrics(raw bool) (map[string]interface{}, error) {
ps := t.Percentiles([]float64{5, 20, 50, 80, 95})
root[name] = map[string]interface{}{
"Measurements": len(t.Values()),
- "Mean": time.Duration(t.Mean()).String(),
+ "Mean": t.Mean(),
"Percentiles": map[string]interface{}{
- "5": time.Duration(ps[0]).String(),
- "20": time.Duration(ps[1]).String(),
- "50": time.Duration(ps[2]).String(),
- "80": time.Duration(ps[3]).String(),
- "95": time.Duration(ps[4]).String(),
+ "5": ps[0],
+ "20": ps[1],
+ "50": ps[2],
+ "80": ps[3],
+ "95": ps[4],
},
}
diff --git a/node/config.go b/node/config.go
index 486eddf92..a4d5920a8 100644
--- a/node/config.go
+++ b/node/config.go
@@ -33,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
+ "github.com/ethereum/go-ethereum/rpc"
)
const (
@@ -119,6 +120,10 @@ type Config struct {
// exposed.
HTTPModules []string `toml:",omitempty"`
+ // HTTPTimeouts allows for customization of the timeout values used by the HTTP RPC
+ // interface.
+ HTTPTimeouts rpc.HTTPTimeouts
+
// WSHost is the host interface on which to start the websocket RPC server. If
// this field is empty, no websocket API endpoint will be started.
WSHost string `toml:",omitempty"`
@@ -179,7 +184,7 @@ func (c *Config) NodeDB() string {
if c.DataDir == "" {
return "" // ephemeral
}
- return c.resolvePath(datadirNodeDatabase)
+ return c.ResolvePath(datadirNodeDatabase)
}
// DefaultIPCEndpoint returns the IPC path used by default.
@@ -262,8 +267,8 @@ var isOldGethResource = map[string]bool{
"trusted-nodes.json": true,
}
-// resolvePath resolves path in the instance directory.
-func (c *Config) resolvePath(path string) string {
+// ResolvePath resolves path in the instance directory.
+func (c *Config) ResolvePath(path string) string {
if filepath.IsAbs(path) {
return path
}
@@ -309,7 +314,7 @@ func (c *Config) NodeKey() *ecdsa.PrivateKey {
return key
}
- keyfile := c.resolvePath(datadirPrivateKey)
+ keyfile := c.ResolvePath(datadirPrivateKey)
if key, err := crypto.LoadECDSA(keyfile); err == nil {
return key
}
@@ -332,12 +337,12 @@ func (c *Config) NodeKey() *ecdsa.PrivateKey {
// StaticNodes returns a list of node enode URLs configured as static nodes.
func (c *Config) StaticNodes() []*discover.Node {
- return c.parsePersistentNodes(c.resolvePath(datadirStaticNodes))
+ return c.parsePersistentNodes(c.ResolvePath(datadirStaticNodes))
}
// TrustedNodes returns a list of node enode URLs configured as trusted nodes.
func (c *Config) TrustedNodes() []*discover.Node {
- return c.parsePersistentNodes(c.resolvePath(datadirTrustedNodes))
+ return c.parsePersistentNodes(c.ResolvePath(datadirTrustedNodes))
}
// parsePersistentNodes parses a list of discovery node URLs loaded from a .json
diff --git a/node/defaults.go b/node/defaults.go
index 887560580..c1376dba0 100644
--- a/node/defaults.go
+++ b/node/defaults.go
@@ -24,6 +24,7 @@ import (
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/nat"
+ "github.com/ethereum/go-ethereum/rpc"
)
const (
@@ -39,6 +40,7 @@ var DefaultConfig = Config{
HTTPPort: DefaultHTTPPort,
HTTPModules: []string{"net", "web3"},
HTTPVirtualHosts: []string{"localhost"},
+ HTTPTimeouts: rpc.DefaultHTTPTimeouts,
WSPort: DefaultWSPort,
WSModules: []string{"net", "web3"},
P2P: p2p.Config{
diff --git a/node/doc.go b/node/doc.go
index 41a88c19a..e3cc58e5f 100644
--- a/node/doc.go
+++ b/node/doc.go
@@ -69,7 +69,7 @@ unless its location is changed through the KeyStoreDir configuration option.
Data Directory Sharing Example
In this example, two node instances named A and B are started with the same data
-directory. Mode instance A opens the database "db", node instance B opens the databases
+directory. Node instance A opens the database "db", node instance B opens the databases
"db" and "db-2". The following files will be created in the data directory:
data-directory/
diff --git a/node/node.go b/node/node.go
index c4368189f..ada383721 100644
--- a/node/node.go
+++ b/node/node.go
@@ -263,7 +263,7 @@ func (n *Node) startRPC(services map[reflect.Type]Service) error {
n.stopInProc()
return err
}
- if err := n.startHTTP(n.httpEndpoint, apis, n.config.HTTPModules, n.config.HTTPCors, n.config.HTTPVirtualHosts); err != nil {
+ if err := n.startHTTP(n.httpEndpoint, apis, n.config.HTTPModules, n.config.HTTPCors, n.config.HTTPVirtualHosts, n.config.HTTPTimeouts); err != nil {
n.stopIPC()
n.stopInProc()
return err
@@ -331,12 +331,12 @@ func (n *Node) stopIPC() {
}
// startHTTP initializes and starts the HTTP RPC endpoint.
-func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors []string, vhosts []string) error {
+func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors []string, vhosts []string, timeouts rpc.HTTPTimeouts) error {
// Short circuit if the HTTP endpoint isn't being exposed
if endpoint == "" {
return nil
}
- listener, handler, err := rpc.StartHTTPEndpoint(endpoint, apis, modules, cors, vhosts)
+ listener, handler, err := rpc.StartHTTPEndpoint(endpoint, apis, modules, cors, vhosts, timeouts)
if err != nil {
return err
}
@@ -570,12 +570,12 @@ func (n *Node) OpenDatabase(name string, cache, handles int) (ethdb.Database, er
if n.config.DataDir == "" {
return ethdb.NewMemDatabase(), nil
}
- return ethdb.NewLDBDatabase(n.config.resolvePath(name), cache, handles)
+ return ethdb.NewLDBDatabase(n.config.ResolvePath(name), cache, handles)
}
// ResolvePath returns the absolute path of a resource in the instance directory.
func (n *Node) ResolvePath(x string) string {
- return n.config.resolvePath(x)
+ return n.config.ResolvePath(x)
}
// apis returns the collection of RPC descriptors this node offers.
diff --git a/node/service.go b/node/service.go
index afc43e848..6a96d9b1e 100644
--- a/node/service.go
+++ b/node/service.go
@@ -43,7 +43,7 @@ func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int) (et
if ctx.config.DataDir == "" {
return ethdb.NewMemDatabase(), nil
}
- db, err := ethdb.NewLDBDatabase(ctx.config.resolvePath(name), cache, handles)
+ db, err := ethdb.NewLDBDatabase(ctx.config.ResolvePath(name), cache, handles)
if err != nil {
return nil, err
}
@@ -54,7 +54,7 @@ func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int) (et
// and if the user actually uses persistent storage. It will return an empty string
// for emphemeral storage and the user's own input for absolute paths.
func (ctx *ServiceContext) ResolvePath(path string) string {
- return ctx.config.resolvePath(path)
+ return ctx.config.ResolvePath(path)
}
// Service retrieves a currently running service registered of a specific type.