Add Global Access to OS Temp Directory Variable and Move DHT Files Into Temp Directory

pull/1585/head
charleszqwang 5 years ago
parent 64976342c6
commit 469714261f
  1. 3
      api/service/networkinfo/service.go
  2. 6
      internal/configs/node/config.go

@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/rpc"
msg_pb "github.com/harmony-one/harmony/api/proto/message"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/p2p"
badger "github.com/ipfs/go-ds-badger"
@ -60,7 +61,7 @@ const (
func New(h p2p.Host, rendezvous p2p.GroupID, peerChan chan p2p.Peer, bootnodes utils.AddrList) *Service {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(context.Background(), connectionTimeout)
dataStore, err := badger.NewDatastore(fmt.Sprintf(".dht-%s-%s", h.GetSelfPeer().IP, h.GetSelfPeer().Port), nil)
dataStore, err := badger.NewDatastore(fmt.Sprintf("%s/.dht-%s-%s", nodeconfig.GetTempDir(), h.GetSelfPeer().IP, h.GetSelfPeer().Port), nil)
if err != nil {
panic(err)
}

@ -7,6 +7,7 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"os"
"sync"
"github.com/harmony-one/bls/ffi/go/bls"
@ -246,3 +247,8 @@ func SetVersion(ver string) {
func GetVersion() string {
return version
}
// GetTempDir return temporary directory
func GetTempDir() string {
return os.TempDir()
}

Loading…
Cancel
Save