Skip to content

Commit

Permalink
change explorer node storage folder (#2720)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedoan authored Apr 4, 2020
1 parent 3aa08e9 commit 1f83ebf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/service/explorer/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions api/service/explorer/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"testing"

nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/stretchr/testify/assert"
)

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions cmd/harmony/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1f83ebf

Please sign in to comment.