aboutsummaryrefslogtreecommitdiffstats
path: root/node
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-11-11 00:03:24 +0800
committerFelix Lange <fjl@twurst.com>2016-11-11 00:47:07 +0800
commitcc0064b267aa0f9b5899e430f5e179d5229bc204 (patch)
treef66402579feb66ff56e6fc979fe383360784f7c5 /node
parent1aaa5991472e5b4f379b3e5d7e3d20545f2a8099 (diff)
downloaddexon-cc0064b267aa0f9b5899e430f5e179d5229bc204.tar.gz
dexon-cc0064b267aa0f9b5899e430f5e179d5229bc204.tar.zst
dexon-cc0064b267aa0f9b5899e430f5e179d5229bc204.zip
node: add InstanceDir method
Diffstat (limited to 'node')
-rw-r--r--node/config.go11
-rw-r--r--node/node.go6
2 files changed, 15 insertions, 2 deletions
diff --git a/node/config.go b/node/config.go
index 8af9215a0..dbefcb8a5 100644
--- a/node/config.go
+++ b/node/config.go
@@ -268,7 +268,7 @@ func (c *Config) name() string {
return c.Name
}
-// These resources are resolved differently for the "geth" and "geth-testnet" instances.
+// These resources are resolved differently for "geth" instances.
var isOldGethResource = map[string]bool{
"chaindata": true,
"nodes": true,
@@ -297,7 +297,14 @@ func (c *Config) resolvePath(path string) string {
return oldpath
}
}
- return filepath.Join(c.DataDir, c.name(), path)
+ return filepath.Join(c.instanceDir(), path)
+}
+
+func (c *Config) instanceDir() string {
+ if c.DataDir == "" {
+ return ""
+ }
+ return filepath.Join(c.DataDir, c.name())
}
// NodeKey retrieves the currently configured private key of the node, checking
diff --git a/node/node.go b/node/node.go
index 15f43fc6b..fb11696fa 100644
--- a/node/node.go
+++ b/node/node.go
@@ -601,10 +601,16 @@ func (n *Node) Service(service interface{}) error {
}
// DataDir retrieves the current datadir used by the protocol stack.
+// Deprecated: No files should be stored in this directory, use InstanceDir instead.
func (n *Node) DataDir() string {
return n.config.DataDir
}
+// InstanceDir retrieves the instance directory used by the protocol stack.
+func (n *Node) InstanceDir() string {
+ return n.config.instanceDir()
+}
+
// AccountManager retrieves the account manager used by the protocol stack.
func (n *Node) AccountManager() *accounts.Manager {
return n.accman