tiny fixes

This commit is contained in:
rigel rozanski 2017-04-17 21:28:03 -04:00 committed by Ethan Buchman
parent 04f79f3ad2
commit 6da5f72de9
7 changed files with 23 additions and 13 deletions

View File

@ -91,7 +91,7 @@ func init() {
packetCreateFlags := []Flag2Register{
fromFlagReg,
{&ibcToFlag, "to", "", "Destination ChainID"},
{&ibcTypeFlag, "type", "", "IBC packet type (eg. coin},"},
{&ibcTypeFlag, "type", "", "IBC packet type (eg. coin)"},
{&ibcPayloadFlag, "payload", "", "IBC packet payload"},
{&ibcSequenceFlag, "ibc_sequence", -1, "sequence number for IBC packet"},
}

View File

@ -19,11 +19,10 @@ var (
}
)
// setupFile aborts on error... or should we return it??
// returns 1 iff it set a file, otherwise 0 (so we can add them)
func setupFile(path, data string, perm os.FileMode) (int, error) {
_, err := os.Stat(path)
if !os.IsNotExist(err) {
if !os.IsNotExist(err) { //permission errors generated if use os.IsExist
return 0, nil
}
err = ioutil.WriteFile(path, []byte(data), perm)

View File

@ -31,7 +31,6 @@ var (
func newKeyCmd(cmd *cobra.Command, args []string) error {
key := genKey()
keyJSON, err := json.MarshalIndent(key, "", "\t")
fmt.Println(&key)
if err != nil {
return err
}

View File

@ -198,6 +198,9 @@ func verifyCmd(cmd *cobra.Command, args []string) error {
}
proofBytes, err := hex.DecodeString(StripHex(proofFlag))
if err != nil {
return errors.Errorf("Proof (%v) is invalid hex: %v\n", proofBytes, err)
}
proof, err := merkle.ReadProof(proofBytes)
if err != nil {

View File

@ -43,12 +43,9 @@ func init() {
{&addrFlag, "address", "tcp://0.0.0.0:46658", "Listen address"},
{&eyesFlag, "eyes", "local", "MerkleEyes address, or 'local' for embedded"},
{&dirFlag, "dir", ".", "Root directory"},
{&withoutTendermintFlag, "without-tendermint", false, "RunE Tendermint in-process with the App"},
{&withoutTendermintFlag, "without-tendermint", false, "Run Tendermint in-process with the App"},
}
RegisterFlags(StartCmd, flags)
// TODO: move to config file
// eyesCacheSizePtr := flag.Int("eyes-cache-size", 10000, "MerkleEyes db cache size, for embedded")
}
func startCmd(cmd *cobra.Command, args []string) error {
@ -134,7 +131,7 @@ func startTendermint(dir string, basecoinApp *app.Basecoin) error {
_, err := n.Start()
if err != nil {
return errors.Errorf("%v\n", err)
return err
}
// Wait forever

View File

@ -58,10 +58,10 @@ func init() {
{&txNodeFlag, "node", "tcp://localhost:46657", "Tendermint RPC address"},
{&chainIDFlag, "chain_id", "test_chain_id", "ID of the chain for replay protection"},
{&fromFlag, "from", "key.json", "Path to a private key to sign the transaction"},
{&amountFlag, "amount", "", "Coins to send in transaction of the format <amt><coin>,<amt2><coin2>,... (eg: 1btc,2gold,5silver},"},
{&amountFlag, "amount", "", "Coins to send in transaction of the format <amt><coin>,<amt2><coin2>,... (eg: 1btc,2gold,5silver)"},
{&gasFlag, "gas", 0, "The amount of gas for the transaction"},
{&feeFlag, "fee", "", "Coins for the transaction fee of the format <amt><coin>"},
{&seqFlag, "sequence", -1, "Sequence number for the account (-1 to autocalculate},"},
{&seqFlag, "sequence", -1, "Sequence number for the account (-1 to autocalculate)"},
}
sendTxFlags := []Flag2Register{

View File

@ -4,6 +4,10 @@ import (
"encoding/hex"
"fmt"
"os"
"path"
"regexp"
"strconv"
"strings"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@ -22,14 +26,14 @@ import (
//This variable can be overwritten by plugin applications
// if they require a different working directory
var DefaultHome = "basecoin"
var DefaultHome = ".basecoin"
func BasecoinRoot(rootDir string) string {
if rootDir == "" {
rootDir = os.Getenv("BCHOME")
}
if rootDir == "" {
rootDir = os.Getenv("HOME") + "/." + DefaultHome
rootDir = path.Join(os.Getenv("HOME"), DefaultHome)
}
return rootDir
}
@ -48,6 +52,14 @@ func ExecuteWithDebug(RootCmd *cobra.Command) {
}
}
//Quickly registering flags can be quickly achieved through using the utility functions
//RegisterFlags, and RegisterPersistentFlags. Ex:
// flags := []Flag2Register{
// {&myStringFlag, "mystringflag", "foobar", "description of what this flag does"},
// {&myBoolFlag, "myboolflag", false, "description of what this flag does"},
// {&myInt64Flag, "myintflag", 333, "description of what this flag does"},
// }
// RegisterFlags(MyCobraCmd, flags)
type Flag2Register struct {
Pointer interface{}
Use string