From 1f83ebf6a6f2853d9df2b18fd658a82a32c4f530 Mon Sep 17 00:00:00 2001 From: Minh Doan <40258599+mikedoan@users.noreply.github.com> Date: Sat, 4 Apr 2020 14:38:55 -0700 Subject: [PATCH] change explorer node storage folder (#2720) --- api/service/explorer/storage.go | 3 ++- api/service/explorer/storage_test.go | 2 ++ cmd/harmony/main.go | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api/service/explorer/storage.go b/api/service/explorer/storage.go index b94b0ad8d..e76209066 100644 --- a/api/service/explorer/storage.go +++ b/api/service/explorer/storage.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/rlp" "github.com/harmony-one/harmony/core/types" + nodeconfig "github.com/harmony-one/harmony/internal/configs/node" "github.com/harmony-one/harmony/internal/utils" staking "github.com/harmony-one/harmony/staking/types" "github.com/syndtr/goleveldb/leveldb" @@ -46,7 +47,7 @@ func GetStorageInstance(ip, port string, remove bool) *Storage { // Init initializes the block update. func (storage *Storage) Init(ip, port string, remove bool) { - dbFileName := "/tmp/explorer_storage_" + ip + "_" + port + dbFileName := nodeconfig.GetDefaultConfig().DBDir + "/explorer_storage_" + ip + "_" + port var err error if remove { var err = os.RemoveAll(dbFileName) diff --git a/api/service/explorer/storage_test.go b/api/service/explorer/storage_test.go index 68bd33a71..e910e3e7d 100644 --- a/api/service/explorer/storage_test.go +++ b/api/service/explorer/storage_test.go @@ -4,6 +4,7 @@ import ( "bytes" "testing" + nodeconfig "github.com/harmony-one/harmony/internal/configs/node" "github.com/stretchr/testify/assert" ) @@ -14,6 +15,7 @@ func TestGetAddressKey(t *testing.T) { // TestInit .. func TestInit(t *testing.T) { + nodeconfig.GetDefaultConfig().DBDir = "/tmp" ins := GetStorageInstance("1.1.1.1", "3333", true) if err := ins.GetDB().Put([]byte{1}, []byte{2}, nil); err != nil { t.Fatal("(*LDBDatabase).Put failed:", err) diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index e4c755e57..9a4117744 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.go @@ -523,6 +523,7 @@ func setupConsensusAndNode(nodeConfig *nodeconfig.ConfigType) *node.Node { nodeconfig.NewGroupIDByShardID(shard.BeaconChainShardID), ) + nodeconfig.GetDefaultConfig().DBDir = nodeConfig.DBDir switch *nodeType { case "explorer": nodeconfig.SetDefaultRole(nodeconfig.ExplorerNode)