Correct btcctl getblockhash.
Also run gofmt while here.
This commit is contained in:
parent
d81a2c9067
commit
af311078b4
1 changed files with 23 additions and 11 deletions
|
@ -51,17 +51,16 @@ var commandHandlers = map[string]*handlerData{
|
||||||
"addnode": &handlerData{2, 0, displaySpewDump, nil, makeAddNode, "<ip> <add/remove/onetry>"},
|
"addnode": &handlerData{2, 0, displaySpewDump, nil, makeAddNode, "<ip> <add/remove/onetry>"},
|
||||||
"decoderawtransaction": &handlerData{1, 0, displaySpewDump, nil, makeDecodeRawTransaction, "<txhash>"},
|
"decoderawtransaction": &handlerData{1, 0, displaySpewDump, nil, makeDecodeRawTransaction, "<txhash>"},
|
||||||
"getbestblockhash": &handlerData{0, 0, displayGeneric, nil, makeGetBestBlockHash, ""},
|
"getbestblockhash": &handlerData{0, 0, displayGeneric, nil, makeGetBestBlockHash, ""},
|
||||||
"getblock": &handlerData{1, 0, displaySpewDump, nil, makeGetBlock,
|
"getblock": &handlerData{1, 0, displaySpewDump, nil, makeGetBlock, "<blockhash>"},
|
||||||
"<blockhash>"},
|
"getblockcount": &handlerData{0, 0, displayFloat64, nil, makeGetBlockCount, ""},
|
||||||
"getblockcount": &handlerData{0, 0, displayFloat64, nil, makeGetBlockCount, ""},
|
"getblockhash": &handlerData{1, 0, displayGeneric, []conversionHandler{toInt64}, makeGetBlockHash, "<blocknumber>"},
|
||||||
"getblockhash": &handlerData{1, 0, displayGeneric, []conversionHandler{toInt}, makeGetBlockHash, "<blocknumber>"},
|
"getconnectioncount": &handlerData{0, 0, displayFloat64, nil, makeGetConnectionCount, ""},
|
||||||
"getconnectioncount": &handlerData{0, 0, displayFloat64, nil, makeGetConnectionCount, ""},
|
"getdifficulty": &handlerData{0, 0, displayFloat64, nil, makeGetDifficulty, ""},
|
||||||
"getdifficulty": &handlerData{0, 0, displayFloat64, nil, makeGetDifficulty, ""},
|
"getgenerate": &handlerData{0, 0, displayGeneric, nil, makeGetGenerate, ""},
|
||||||
"getgenerate": &handlerData{0, 0, displayGeneric, nil, makeGetGenerate, ""},
|
"getpeerinfo": &handlerData{0, 0, displaySpewDump, nil, makeGetPeerInfo, ""},
|
||||||
"getpeerinfo": &handlerData{0, 0, displaySpewDump, nil, makeGetPeerInfo, ""},
|
"getrawmempool": &handlerData{0, 0, displaySpewDump, nil, makeGetRawMempool, ""},
|
||||||
"getrawmempool": &handlerData{0, 0, displaySpewDump, nil, makeGetRawMempool, ""},
|
"getrawtransaction": &handlerData{1, 1, displaySpewDump, []conversionHandler{nil, toInt}, makeGetRawTransaction, "<txhash> [verbose=0]"},
|
||||||
"getrawtransaction": &handlerData{1, 1, displaySpewDump, []conversionHandler{nil, toInt}, makeGetRawTransaction, "<txhash> [verbose=0]"},
|
"stop": &handlerData{0, 0, displayGeneric, nil, makeStop, ""},
|
||||||
"stop": &handlerData{0, 0, displayGeneric, nil, makeStop, ""},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// toInt attempts to convert the passed string to an integer. It returns the
|
// toInt attempts to convert the passed string to an integer. It returns the
|
||||||
|
@ -77,6 +76,19 @@ func toInt(val string) (interface{}, error) {
|
||||||
return idx, nil
|
return idx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// toInt64 attempts to convert the passed string to an int64. It returns the
|
||||||
|
// integer packed into an interface so it can be used in the calls which expect
|
||||||
|
// interfaces. An error will be returned if the string can't be converted to an
|
||||||
|
// integer.
|
||||||
|
func toInt64(val string) (interface{}, error) {
|
||||||
|
idx, err := strconv.ParseInt(val, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return idx, nil
|
||||||
|
}
|
||||||
|
|
||||||
// displayGeneric is a displayHandler that simply displays the passed interface
|
// displayGeneric is a displayHandler that simply displays the passed interface
|
||||||
// using fmt.Println.
|
// using fmt.Println.
|
||||||
func displayGeneric(reply interface{}) error {
|
func displayGeneric(reply interface{}) error {
|
||||||
|
|
Loading…
Add table
Reference in a new issue