MCPcopy Create free account
hub / github.com/CPChain/chain / openDataDir

Method openDataDir

node/node.go:523–540  ·  view source on GitHub ↗

creates the directory and adds the lock

()

Source from the content-addressed store, hash-verified

521
522// creates the directory and adds the lock
523func (n *Node) openDataDir() error {
524 if n.config.DataDir == "" {
525 return nil // ephemeral
526 }
527
528 instdir := filepath.Join(n.config.DataDir, n.config.name())
529 if err := os.MkdirAll(instdir, 0700); err != nil {
530 return err
531 }
532 // lock the instance directory to prevent concurrent use by another instance as well as
533 // accidental use of the instance directory as a database.
534 release, _, err := flock.New(filepath.Join(instdir, "LOCK"))
535 if err != nil {
536 return convertFileLockError(err)
537 }
538 n.instanceDirLock = release
539 return nil
540}
541
542// InstanceDir retrieves the instance directory used by the protocol stack.
543// It resides inside the DataDir.

Callers 1

StartMethod · 0.95

Calls 2

convertFileLockErrorFunction · 0.85
nameMethod · 0.80

Tested by

no test coverage detected