mirror of
https://github.com/arnaucube/go-ethereum.git
synced 2026-02-28 05:56:45 +01:00
fix node/node.go flock dependency
This commit is contained in:
13
node/node.go
13
node/node.go
@@ -34,7 +34,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/prometheus/prometheus/util/flock"
|
||||
"github.com/gofrs/flock"
|
||||
)
|
||||
|
||||
// Node is a container on which services can be registered.
|
||||
@@ -43,8 +43,8 @@ type Node struct {
|
||||
config *Config
|
||||
accman *accounts.Manager
|
||||
|
||||
ephemeralKeystore string // if non-empty, the key directory that will be removed by Stop
|
||||
instanceDirLock flock.Releaser // prevents concurrent use of instance directory
|
||||
ephemeralKeystore string // if non-empty, the key directory that will be removed by Stop
|
||||
instanceDirLock *flock.Flock // prevents concurrent use of instance directory
|
||||
|
||||
serverConfig p2p.Config
|
||||
server *p2p.Server // Currently running P2P networking layer
|
||||
@@ -262,10 +262,7 @@ func (n *Node) openDataDir() error {
|
||||
}
|
||||
// Lock the instance directory to prevent concurrent use by another instance as well as
|
||||
// accidental use of the instance directory as a database.
|
||||
release, _, err := flock.New(filepath.Join(instdir, "LOCK"))
|
||||
if err != nil {
|
||||
return convertFileLockError(err)
|
||||
}
|
||||
release := flock.New(filepath.Join(instdir, "LOCK"))
|
||||
n.instanceDirLock = release
|
||||
return nil
|
||||
}
|
||||
@@ -450,7 +447,7 @@ func (n *Node) Stop() error {
|
||||
|
||||
// Release instance directory lock.
|
||||
if n.instanceDirLock != nil {
|
||||
if err := n.instanceDirLock.Release(); err != nil {
|
||||
if err := n.instanceDirLock.Unlock(); err != nil {
|
||||
n.log.Error("Can't release datadir lock", "err", err)
|
||||
}
|
||||
n.instanceDirLock = nil
|
||||
|
||||
Reference in New Issue
Block a user