Skip to content

Commit

Permalink
refactor(nodebuilder): Allow custom networks to work over already-ini…
Browse files Browse the repository at this point in the history
…tialised store (#1270)

After conversation with @jbowen93 , we decided to allow using custom
networks over an already-initialised node store.

The issue this was originally attempting to prevent is accidental
corruption of chain data in the case that a user accidentally leaves
their environment variable set up and connects to another network over
an old node store.

This issue is actually currently prevented thanks to #1073 extending the
node store name with the network name.
  • Loading branch information
renaynay authored Oct 24, 2022
1 parent 0e48f9a commit f4e582e
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions nodebuilder/init.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package nodebuilder

import (
"fmt"
"os"
"path/filepath"

"github.com/celestiaorg/celestia-node/libs/fslock"
"github.com/celestiaorg/celestia-node/libs/utils"
"github.com/celestiaorg/celestia-node/nodebuilder/node"
"github.com/celestiaorg/celestia-node/nodebuilder/p2p"
)

// Init initializes the Node FileSystem Store for the given Node Type 'tp' in the directory under 'path'.
Expand Down Expand Up @@ -102,11 +100,6 @@ func initRoot(path string) error {
// initDir creates a dir if not exist
func initDir(path string) error {
if utils.Exists(path) {
// if the dir already exists and `CELESTIA_CUSTOM` env var is set,
// fail out to prevent store corruption
if _, ok := os.LookupEnv(p2p.EnvCustomNetwork); ok {
return fmt.Errorf("cannot run a custom network over an already-existing node store")
}
return nil
}
return os.Mkdir(path, perms)
Expand Down

0 comments on commit f4e582e

Please sign in to comment.