Skip to content

Commit

Permalink
naming nit we agreed to do after merging rpc, my feeling is NewFromCo…
Browse files Browse the repository at this point in the history
…ntext is a more idiomatic name than ParseFromCtx
  • Loading branch information
ramin committed Oct 6, 2023
1 parent 0b5fc0b commit 5ee17e9
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion cmd/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func getToken(path string) (string, error) {

type rpcClientKey struct{}

func ParseClientFromCtx(ctx context.Context) (*rpc.Client, error) {
func NewClientFromContext(ctx context.Context) (*rpc.Client, error) {
client, ok := ctx.Value(rpcClientKey{}).(*rpc.Client)
if !ok {
return nil, errors.New("rpc client was not set")
Expand Down
8 changes: 4 additions & 4 deletions nodebuilder/blob/cmd/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var getCmd = &cobra.Command{
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 := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -104,7 +104,7 @@ var getAllCmd = &cobra.Command{
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 := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -137,7 +137,7 @@ var submitCmd = &cobra.Command{
"* only one blob is allowed to submit through the RPC.\n" +
"* fee and gas.limit params will be calculated automatically if they are not provided as arguments",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -175,7 +175,7 @@ var getProofCmd = &cobra.Command{
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 := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/das/cmd/das.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var samplingStatsCmd = &cobra.Command{
Short: "Returns the current statistics over the DA sampling process",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions nodebuilder/header/cmd/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var localHeadCmd = &cobra.Command{
Short: "Returns the ExtendedHeader from the chain head.",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand All @@ -48,7 +48,7 @@ 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 := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
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 := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
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 := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand All @@ -105,7 +105,7 @@ 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 := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions nodebuilder/node/cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var nodeInfoCmd = &cobra.Command{
Args: cobra.NoArgs,
Short: "Returns administrative information about the node.",
RunE: func(c *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(c.Context())
client, err := cmdnode.NewClientFromContext(c.Context())
if err != nil {
return err
}
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 := cmdnode.ParseClientFromCtx(c.Context())
client, err := cmdnode.NewClientFromContext(c.Context())
if err != nil {
return err
}
Expand All @@ -72,7 +72,7 @@ var verifyCmd = &cobra.Command{
Short: "Returns the permissions assigned to the given token.",

RunE: func(c *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(c.Context())
client, err := cmdnode.NewClientFromContext(c.Context())
if err != nil {
return err
}
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 := cmdnode.ParseClientFromCtx(c.Context())
client, err := cmdnode.NewClientFromContext(c.Context())
if err != nil {
return err
}
Expand Down
34 changes: 17 additions & 17 deletions nodebuilder/p2p/cmd/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var infoCmd = &cobra.Command{
Short: "Gets the node's peer info (peer id and multiaddresses)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -78,7 +78,7 @@ var peersCmd = &cobra.Command{
Short: "Lists the peers we are connected to",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -107,7 +107,7 @@ var peerInfoCmd = &cobra.Command{
Short: "Gets PeerInfo for a given peer",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -139,7 +139,7 @@ var connectCmd = &cobra.Command{
Short: "Establishes a connection with the given peer",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -173,7 +173,7 @@ var closePeerCmd = &cobra.Command{
Short: "Closes the connection with the given peer",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand All @@ -197,7 +197,7 @@ var connectednessCmd = &cobra.Command{
Short: "Checks the connection state between current and given peers",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -227,7 +227,7 @@ var natStatusCmd = &cobra.Command{
Short: "Gets the currrent NAT status",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand All @@ -252,7 +252,7 @@ var blockPeerCmd = &cobra.Command{
Short: "Blocks the given peer",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -290,7 +290,7 @@ var unblockPeerCmd = &cobra.Command{
Short: "Unblocks the given peer",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -329,7 +329,7 @@ var blockedPeersCmd = &cobra.Command{
Short: "Lists the node's blocked peers",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -359,7 +359,7 @@ var protectCmd = &cobra.Command{
Short: "Protects the given peer from being pruned by the given tag",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -399,7 +399,7 @@ var unprotectCmd = &cobra.Command{
"The return value indicates whether the peer continues to be protected after this call, by way of a different tag",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -437,7 +437,7 @@ var protectedCmd = &cobra.Command{
Short: "Ensures that a given peer is protected under a specific tag",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -467,7 +467,7 @@ var bandwidthStatsCmd = &cobra.Command{
"received by the local peer, regardless of protocol or remote peer IDs",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand All @@ -493,7 +493,7 @@ var peerBandwidthCmd = &cobra.Command{
Short: "Gets stats struct with bandwidth metrics associated with the given peer.ID",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -524,7 +524,7 @@ var bandwidthForProtocolCmd = &cobra.Command{
Short: "Gets stats struct with bandwidth metrics associated with the given protocol.ID",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand All @@ -550,7 +550,7 @@ var pubsubPeersCmd = &cobra.Command{
Short: "Lists the peers we are connected to in the given topic",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions nodebuilder/share/cmd/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var sharesAvailableCmd = &cobra.Command{
Short: "Subjectively validates if Shares committed to the given Root are available on the Network.",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -78,7 +78,7 @@ var probabilityOfAvailabilityCmd = &cobra.Command{
Short: "Calculates the probability of the data square being available based on the number of samples collected.",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand All @@ -94,7 +94,7 @@ var getSharesByNamespaceCmd = &cobra.Command{
Short: "Gets all shares from an EDS within the given namespace.",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -126,7 +126,7 @@ var getShare = &cobra.Command{
Short: "Gets a Share by coordinates in EDS.",
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down Expand Up @@ -180,7 +180,7 @@ var getEDS = &cobra.Command{
Short: "Gets the full EDS identified by the given root",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
client, err := cmdnode.NewClientFromContext(cmd.Context())
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 5ee17e9

Please sign in to comment.