-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added get_mempool_items_by_coin_name (#12)
- Loading branch information
1 parent
62a9d91
commit ae83dc8
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(getMempoolItemsByCoinName) | ||
} | ||
|
||
var getMempoolItemsByCoinName = &cobra.Command{ | ||
Use: "get_mempool_items_by_coin_name <coin_name>", | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if err := cobra.ExactArgs(1)(cmd, args); err != nil { | ||
return err | ||
} | ||
if isHex(args[0]) == true { | ||
return nil | ||
} | ||
return fmt.Errorf("invalid hex value specified: %s", args[0]) | ||
}, | ||
Short: "Returns mempool items by coin name", | ||
Long: "Returns mempool items by coin name", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
jsonData := map[string]interface{}{} | ||
jsonData["coin_name"] = formatHex(args[0]) | ||
makeRequest("get_mempool_items_by_coin_name", jsonData) | ||
}, | ||
} |