Skip to content

Commit

Permalink
Merge pull request #291 from celestiaorg/hlib/remove-init-with
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan authored Dec 23, 2021
2 parents 7e176b4 + 3a6b4f6 commit 06cc49f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Month, DD, YYYY

- [chore: rename Repository to Store #296](https://github.com/celestiaorg/celestia-node/pull/296) [@Wondertan](https://github.com/Wondertan)
- [chore: rename Full node to Bridge node #294](https://github.com/celestiaorg/celestia-node/pull/294) [@Wondertan](https://github.com/Wondertan)
- [node: remove InitWith #291](https://github.com/celestiaorg/celestia-node/pull/291) [@Wondertan](https://github.com/Wondertan)

### FEATURES

Expand Down
6 changes: 3 additions & 3 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ func Init(storeFlagName string, tp node.Type) *cobra.Command {
return fmt.Errorf("store path must be specified")
}

var opts []node.Option

nodeConfig := cmd.Flag(nodeConfigFlag.Name).Value.String()
if nodeConfig != "" {
cfg, err := node.LoadConfig(nodeConfig)
if err != nil {
return err
}

return node.InitWith(storePath, tp, cfg)
opts = append(opts, node.WithConfig(cfg))
}

var opts []node.Option

trustedHash := cmd.Flag(trustedHashFlag.Name).Value.String()
if trustedHash != "" {
opts = append(opts, node.WithTrustedHash(trustedHash))
Expand Down
18 changes: 8 additions & 10 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ func Start(storeFlagName string, tp node.Type) *cobra.Command {
logs.SetAllLoggers(level)

var opts []node.Option

nodeConfig := cmd.Flag(nodeConfigFlag.Name).Value.String()
if nodeConfig != "" {
cfg, err := node.LoadConfig(nodeConfig)
if err != nil {
return err
}
opts = append(opts, node.WithConfig(cfg))
}
trustedHash := cmd.Flag(trustedHashFlag.Name).Value.String()
if trustedHash != "" {
opts = append(opts, node.WithTrustedHash(trustedHash))
Expand All @@ -65,15 +72,6 @@ func Start(storeFlagName string, tp node.Type) *cobra.Command {
}
opts = append(opts, node.WithRemoteCore(protocol, ip))
}
nodeConfig := cmd.Flag(nodeConfigFlag.Name).Value.String()
if nodeConfig != "" {
cfg, err := node.LoadConfig(nodeConfig)
if err != nil {
return err
}
opts = append(opts, node.WithConfig(cfg))
}

mutualPeersStr := cmd.Flag(mutualPeersFlag.Name).Value.String()
if mutualPeersStr != "" {
mutualPeers := strings.Split(mutualPeersStr, ",")
Expand Down
6 changes: 0 additions & 6 deletions node/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ func Init(path string, tp Type, options ...Option) error {
}
}

return InitWith(path, tp, cfg)
}

// InitWith initializes the Node FileSystem Store for the given Node Type 'tp' in the directory under 'path'
// with the given Config 'cfg'.
func InitWith(path string, tp Type, cfg *Config) error {
path, err := storePath(path)
if err != nil {
return err
Expand Down
9 changes: 0 additions & 9 deletions node/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ func TestInitErrForInvalidPath(t *testing.T) {
}
}

func TestInitWithNilConfig(t *testing.T) {
dir := t.TempDir()
nodes := []Type{Light, Bridge}

for _, node := range nodes {
require.Error(t, InitWith(dir, node, nil))
}
}

func TestIsInitWithBrokenConfig(t *testing.T) {
dir := t.TempDir()
f, err := os.Create(configPath(dir))
Expand Down

0 comments on commit 06cc49f

Please sign in to comment.