Skip to content

Commit

Permalink
rename import
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Sep 22, 2023
1 parent 709ac98 commit c906581
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 125 deletions.
40 changes: 18 additions & 22 deletions nodebuilder/blob/cmd/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package cmd

import (
"encoding/base64"
"encoding/hex"
"fmt"
"reflect"
"strconv"

"github.com/spf13/cobra"

"github.com/celestiaorg/celestia-node/blob"
util "github.com/celestiaorg/celestia-node/cmd"
cmdnode "github.com/celestiaorg/celestia-node/cmd"
"github.com/celestiaorg/celestia-node/share"
)

Expand Down Expand Up @@ -57,15 +56,15 @@ var Cmd = &cobra.Command{
Use: "blob [command]",
Short: "Allows to interact with the Blob Service via JSON-RPC",
Args: cobra.NoArgs,
PersistentPreRunE: util.InitClient,
PersistentPreRunE: cmdnode.InitClient,
}

var getCmd = &cobra.Command{
Use: "get [height, namespace, commitment]",
Use: "get [height] [namespace] [commitment]",
Args: cobra.ExactArgs(3),
Short: "Returns the blob for the given namespace by commitment at a particular height.",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
if err != nil {
return err
}
Expand All @@ -76,7 +75,7 @@ var getCmd = &cobra.Command{
return fmt.Errorf("error parsing a height:%v", err)
}

namespace, err := util.ParseV0Namespace(args[1])
namespace, err := cmdnode.ParseV0Namespace(args[1])
if err != nil {
return fmt.Errorf("error parsing a namespace:%v", err)
}
Expand All @@ -92,16 +91,16 @@ var getCmd = &cobra.Command{
if base64Flag || err != nil {
formatter = nil
}
return util.PrintOutput(blob, err, formatter)
return cmdnode.PrintOutput(blob, err, formatter)
},
}

var getAllCmd = &cobra.Command{
Use: "get-all [height, namespace]",
Use: "get-all [height] [namespace]",
Args: cobra.ExactArgs(2),
Short: "Returns all blobs for the given namespace at a particular height.",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
if err != nil {
return err
}
Expand All @@ -112,35 +111,32 @@ var getAllCmd = &cobra.Command{
return fmt.Errorf("error parsing a height:%v", err)
}

namespace, err := util.ParseV0Namespace(args[1])
namespace, err := cmdnode.ParseV0Namespace(args[1])
if err != nil {
return fmt.Errorf("error parsing a namespace:%v", err)
}

blobs, err := client.Blob.GetAll(cmd.Context(), height, []share.Namespace{namespace})
fmt.Println(hex.EncodeToString(blobs[0].Namespace().ID()))
fmt.Println(blobs[0].Namespace().ID())
fmt.Println(blobs[0].Namespace())
formatter := formatData
if base64Flag || err != nil {
formatter = nil
}
return util.PrintOutput(blobs, err, formatter)
return cmdnode.PrintOutput(blobs, err, formatter)
},
}

var submitCmd = &cobra.Command{
Use: "submit [namespace, blobData]",
Use: "submit [namespace] [blobData]",
Args: cobra.ExactArgs(2),
Short: "Submit the blob at the given namespace. Note: only one blob is allowed to submit through the RPC.",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
if err != nil {
return err
}
defer client.Close()

namespace, err := util.ParseV0Namespace(args[0])
namespace, err := cmdnode.ParseV0Namespace(args[0])
if err != nil {
return fmt.Errorf("error parsing a namespace:%v", err)
}
Expand All @@ -163,16 +159,16 @@ var submitCmd = &cobra.Command{
Height: height,
Commitment: parsedBlob.Commitment,
}
return util.PrintOutput(response, err, nil)
return cmdnode.PrintOutput(response, err, nil)
},
}

var getProofCmd = &cobra.Command{
Use: "get-proof [height, namespace, commitment]",
Use: "get-proof [height] [namespace] [commitment]",
Args: cobra.ExactArgs(3),
Short: "Retrieves the blob in the given namespaces at the given height by commitment and returns its Proof.",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
if err != nil {
return err
}
Expand All @@ -183,7 +179,7 @@ var getProofCmd = &cobra.Command{
return fmt.Errorf("error parsing a height:%v", err)
}

namespace, err := util.ParseV0Namespace(args[1])
namespace, err := cmdnode.ParseV0Namespace(args[1])
if err != nil {
return fmt.Errorf("error parsing a namespace:%v", err)
}
Expand All @@ -194,7 +190,7 @@ var getProofCmd = &cobra.Command{
}

proof, err := client.Blob.GetProof(cmd.Context(), height, namespace, commitment)
return util.PrintOutput(proof, err, nil)
return cmdnode.PrintOutput(proof, err, nil)
},
}

Expand Down
8 changes: 4 additions & 4 deletions nodebuilder/das/cmd/das.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"github.com/spf13/cobra"

util "github.com/celestiaorg/celestia-node/cmd"
cmdnode "github.com/celestiaorg/celestia-node/cmd"
)

func init() {
Expand All @@ -14,21 +14,21 @@ var Cmd = &cobra.Command{
Use: "das [command]",
Short: "Allows to interact with the Daser via JSON-RPC",
Args: cobra.NoArgs,
PersistentPreRunE: util.InitClient,
PersistentPreRunE: cmdnode.InitClient,
}

var samplingStatsCmd = &cobra.Command{
Use: "sampling-stats",
Short: "Returns the current statistics over the DA sampling process",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
if err != nil {
return err
}
defer client.Close()

stats, err := client.DAS.SamplingStats(cmd.Context())
return util.PrintOutput(stats, err, nil)
return cmdnode.PrintOutput(stats, err, nil)
},
}
24 changes: 12 additions & 12 deletions nodebuilder/header/cmd/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/spf13/cobra"

util "github.com/celestiaorg/celestia-node/cmd"
cmdnode "github.com/celestiaorg/celestia-node/cmd"
)

func init() {
Expand All @@ -24,22 +24,22 @@ var Cmd = &cobra.Command{
Use: "header [command]",
Short: "Allows interaction with the Header Module via JSON-RPC",
Args: cobra.NoArgs,
PersistentPreRunE: util.InitClient,
PersistentPreRunE: cmdnode.InitClient,
}

var localHeadCmd = &cobra.Command{
Use: "local-head",
Short: "Returns the ExtendedHeader from the chain head.",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
if err != nil {
return err
}
defer client.Close()

header, err := client.Header.LocalHead(cmd.Context())
return util.PrintOutput(header, err, nil)
return cmdnode.PrintOutput(header, err, nil)
},
}

Expand All @@ -48,14 +48,14 @@ var networkHeadCmd = &cobra.Command{
Short: "Provides the Syncer's view of the current network head.",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
if err != nil {
return err
}
defer client.Close()

header, err := client.Header.NetworkHead(cmd.Context())
return util.PrintOutput(header, err, nil)
return cmdnode.PrintOutput(header, err, nil)
},
}

Expand All @@ -64,7 +64,7 @@ var getByHashCmd = &cobra.Command{
Short: "Returns the header of the given hash from the node's header store.",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
if err != nil {
return err
}
Expand All @@ -75,7 +75,7 @@ var getByHashCmd = &cobra.Command{
return fmt.Errorf("error decoding a hash: expected a hex encoded string:%v", err)
}
header, err := client.Header.GetByHash(cmd.Context(), hash)
return util.PrintOutput(header, err, nil)
return cmdnode.PrintOutput(header, err, nil)
},
}

Expand All @@ -84,7 +84,7 @@ var getByHeightCmd = &cobra.Command{
Short: "Returns the ExtendedHeader at the given height if it is currently available.",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
if err != nil {
return err
}
Expand All @@ -96,7 +96,7 @@ var getByHeightCmd = &cobra.Command{
}

header, err := client.Header.GetByHeight(cmd.Context(), height)
return util.PrintOutput(header, err, nil)
return cmdnode.PrintOutput(header, err, nil)
},
}

Expand All @@ -105,13 +105,13 @@ var syncStateCmd = &cobra.Command{
Short: "Returns the current state of the header Syncer.",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
if err != nil {
return err
}
defer client.Close()

header, err := client.Header.SyncState(cmd.Context())
return util.PrintOutput(header, err, nil)
return cmdnode.PrintOutput(header, err, nil)
},
}
18 changes: 9 additions & 9 deletions nodebuilder/node/cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/spf13/cobra"

util "github.com/celestiaorg/celestia-node/cmd"
cmdnode "github.com/celestiaorg/celestia-node/cmd"
)

func init() {
Expand All @@ -18,22 +18,22 @@ var Cmd = &cobra.Command{
Use: "node [command]",
Short: "Allows administrating running node.",
Args: cobra.NoArgs,
PersistentPreRunE: util.InitClient,
PersistentPreRunE: cmdnode.InitClient,
}

var nodeInfoCmd = &cobra.Command{
Use: "info",
Args: cobra.NoArgs,
Short: "Returns administrative information about the node.",
RunE: func(c *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(c.Context())
client, err := cmdnode.ParseClientFromCtx(c.Context())
if err != nil {
return err
}
defer client.Close()

info, err := client.Node.Info(c.Context())
return util.PrintOutput(info, err, nil)
return cmdnode.PrintOutput(info, err, nil)
},
}

Expand All @@ -45,7 +45,7 @@ var logCmd = &cobra.Command{
"`DEBUG, INFO, WARN, ERROR, DPANIC, PANIC, FATAL and their lower-case forms`.\n" +
"To set all modules to a particular level `*:<log.level>` should be passed",
RunE: func(c *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(c.Context())
client, err := cmdnode.ParseClientFromCtx(c.Context())
if err != nil {
return err
}
Expand All @@ -72,14 +72,14 @@ var verifyCmd = &cobra.Command{
Short: "Returns the permissions assigned to the given token.",

RunE: func(c *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(c.Context())
client, err := cmdnode.ParseClientFromCtx(c.Context())
if err != nil {
return err
}
defer client.Close()

perms, err := client.Node.AuthVerify(c.Context(), args[0])
return util.PrintOutput(perms, err, nil)
return cmdnode.PrintOutput(perms, err, nil)
},
}

Expand All @@ -88,7 +88,7 @@ var authCmd = &cobra.Command{
Args: cobra.MinimumNArgs(1),
Short: "Signs and returns a new token with the given permissions.",
RunE: func(c *cobra.Command, args []string) error {
client, err := util.ParseClientFromCtx(c.Context())
client, err := cmdnode.ParseClientFromCtx(c.Context())
if err != nil {
return err
}
Expand All @@ -100,6 +100,6 @@ var authCmd = &cobra.Command{
}

result, err := client.Node.AuthNew(c.Context(), perms)
return util.PrintOutput(result, err, nil)
return cmdnode.PrintOutput(result, err, nil)
},
}
Loading

0 comments on commit c906581

Please sign in to comment.