aboutsummaryrefslogtreecommitdiffstats
path: root/node
diff options
context:
space:
mode:
Diffstat (limited to 'node')
-rw-r--r--node/node.go7
-rw-r--r--node/service.go7
-rw-r--r--node/service_test.go4
3 files changed, 10 insertions, 8 deletions
diff --git a/node/node.go b/node/node.go
index 9227bf6bb..bd031bd0f 100644
--- a/node/node.go
+++ b/node/node.go
@@ -27,6 +27,7 @@ import (
"sync"
"github.com/ethereum/go-ethereum/accounts"
+ "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/internal/debug"
@@ -601,11 +602,11 @@ func (n *Node) EventMux() *event.TypeMux {
// OpenDatabase opens an existing database with the given name (or creates one if no
// previous can be found) from within the node's instance directory. If the node is
// ephemeral, a memory database is returned.
-func (n *Node) OpenDatabase(name string, cache, handles int) (ethdb.Database, error) {
+func (n *Node) OpenDatabase(name string, cache, handles int, namespace string) (ethdb.Database, error) {
if n.config.DataDir == "" {
- return ethdb.NewMemDatabase(), nil
+ return rawdb.NewMemoryDatabase(), nil
}
- return ethdb.NewLDBDatabase(n.config.ResolvePath(name), cache, handles)
+ return rawdb.NewLevelDBDatabase(n.config.ResolvePath(name), cache, handles, namespace)
}
// ResolvePath returns the absolute path of a resource in the instance directory.
diff --git a/node/service.go b/node/service.go
index 6a96d9b1e..4f6cb6676 100644
--- a/node/service.go
+++ b/node/service.go
@@ -20,6 +20,7 @@ import (
"reflect"
"github.com/ethereum/go-ethereum/accounts"
+ "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/p2p"
@@ -39,11 +40,11 @@ type ServiceContext struct {
// OpenDatabase opens an existing database with the given name (or creates one
// if no previous can be found) from within the node's data directory. If the
// node is an ephemeral one, a memory database is returned.
-func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int) (ethdb.Database, error) {
+func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int, namespace string) (ethdb.Database, error) {
if ctx.config.DataDir == "" {
- return ethdb.NewMemDatabase(), nil
+ return rawdb.NewMemoryDatabase(), nil
}
- db, err := ethdb.NewLDBDatabase(ctx.config.ResolvePath(name), cache, handles)
+ db, err := rawdb.NewLevelDBDatabase(ctx.config.ResolvePath(name), cache, handles, namespace)
if err != nil {
return nil, err
}
diff --git a/node/service_test.go b/node/service_test.go
index 73c51eccb..63004a51a 100644
--- a/node/service_test.go
+++ b/node/service_test.go
@@ -39,7 +39,7 @@ func TestContextDatabases(t *testing.T) {
}
// Request the opening/creation of a database and ensure it persists to disk
ctx := &ServiceContext{config: &Config{Name: "unit-test", DataDir: dir}}
- db, err := ctx.OpenDatabase("persistent", 0, 0)
+ db, err := ctx.OpenDatabase("persistent", 0, 0, "")
if err != nil {
t.Fatalf("failed to open persistent database: %v", err)
}
@@ -50,7 +50,7 @@ func TestContextDatabases(t *testing.T) {
}
// Request th opening/creation of an ephemeral database and ensure it's not persisted
ctx = &ServiceContext{config: &Config{DataDir: ""}}
- db, err = ctx.OpenDatabase("ephemeral", 0, 0)
+ db, err = ctx.OpenDatabase("ephemeral", 0, 0, "")
if err != nil {
t.Fatalf("failed to open ephemeral database: %v", err)
}