From 4868ed4d3d6d00a7bf3102493b4e9da2a21259ca Mon Sep 17 00:00:00 2001 From: Alex Yocom-Piatt Date: Wed, 17 Feb 2016 14:31:20 -0600 Subject: [PATCH] Remove rpc cmd Results that only have 1 field Instead just return field value in rpc handler --- dcrjson/dcrdextresults.go | 18 ------------------ dcrjson/dcrwalletextresults.go | 23 ----------------------- rpcserver.go | 11 ++++------- rpcserverhelp.go | 18 ++++++++---------- 4 files changed, 12 insertions(+), 58 deletions(-) diff --git a/dcrjson/dcrdextresults.go b/dcrjson/dcrdextresults.go index 44fd088d..c5d9f299 100644 --- a/dcrjson/dcrdextresults.go +++ b/dcrjson/dcrdextresults.go @@ -5,24 +5,6 @@ package dcrjson -// ExistsAddressResult models the data returned from the existsaddress -// command. -type ExistsAddressResult struct { - Exists bool `json:"exists"` -} - -// GetCoinSupplyResult models the data returned from the getcoinsupply -// command. -type GetCoinSupplyResult struct { - CoinSupply int64 `json:"coinsupply"` -} - -// GetStakeDifficultyResult models the data returned from the getstakedifficulty -// command. -type GetStakeDifficultyResult struct { - Difficulty float64 `json:"difficulty"` -} - // MissedTicketsResult models the data returned from the missedtickets // command. type MissedTicketsResult struct { diff --git a/dcrjson/dcrwalletextresults.go b/dcrjson/dcrwalletextresults.go index 5e82e766..ecb346d5 100644 --- a/dcrjson/dcrwalletextresults.go +++ b/dcrjson/dcrwalletextresults.go @@ -22,24 +22,6 @@ type GetMultisigOutInfoResult struct { Amount float64 `json:"amount"` } -// GetSeedResult models the data returned from the getseed -// command. -type GetSeedResult struct { - Seed string `json:"seed"` -} - -// GetMasterPubkeyResult models the data returned from the getmasterpubkey -// command. -type GetMasterPubkeyResult struct { - MasterPubkey string `json:"key"` -} - -// GetTicketMaxPriceResult models the data returned from the getticketmaxprice -// command. -type GetTicketMaxPriceResult struct { - Price float64 `json:"price"` -} - // GetTicketsResult models the data returned from the gettickets // command. type GetTicketsResult struct { @@ -53,11 +35,6 @@ type GetTicketVoteBitsResult struct { VoteBitsExt string `json:"votebitsext"` } -// GetWalletFeeResult models the data returned from the getwalletfee command -type GetWalletFeeResult struct { - Fee float64 `json:"fee"` -} - // RedeemMultiSigOutResult models the data returned from the redeemmultisigout // command. type RedeemMultiSigOutResult struct { diff --git a/rpcserver.go b/rpcserver.go index f30fe8f9..efe8913e 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1467,9 +1467,9 @@ func handleExistsAddress(s *rpcServer, cmd interface{}, // Check the blockchain for the relevant address usage. tlr, err := s.server.db.FetchTxsForAddr(addr, numToSkip, numRequested) if err == nil && tlr != nil { - return &dcrjson.ExistsAddressResult{Exists: true}, nil + return true, nil } - return &dcrjson.ExistsAddressResult{Exists: false}, nil + return false, nil } // handleGenerate handles generate commands. @@ -2874,10 +2874,7 @@ func handleGetCoinSupply(s *rpcServer, cmd interface{}, closeChan <-chan struct{ supply += (work + stake + tax) } } - ret := &dcrjson.GetCoinSupplyResult{ - CoinSupply: supply, - } - return ret, nil + return supply, nil } // handleGetConnectionCount implements the getconnectioncount command. @@ -3316,7 +3313,7 @@ func handleGetStakeDifficulty(s *rpcServer, cmd interface{}, closeChan <-chan st } sDiff := dcrutil.Amount(blockHeader.SBits) - return &dcrjson.GetStakeDifficultyResult{Difficulty: sDiff.ToCoin()}, nil + return sDiff.ToCoin(), nil } // bigToLEUint256 returns the passed big integer as an unsigned 256-bit integer diff --git a/rpcserverhelp.go b/rpcserverhelp.go index 87e600ed..fc2c136c 100644 --- a/rpcserverhelp.go +++ b/rpcserverhelp.go @@ -145,9 +145,7 @@ var helpDescsEnUS = map[string]string{ // ExistsAddressCmd help. "existsaddress--synopsis": "Test for the existance of the provided address", "existsaddress-address": "The address to check", - - // ExistsAddressResult help. - "existsaddressresult-exists": "Bool showing if address exists or not", + "existsaddress--result0": "Bool showing if address exists or not", // GenerateCmd help "generate--synopsis": "Generates a set number of blocks (simnet or regtest only) and returns a JSON\n" + @@ -318,8 +316,8 @@ var helpDescsEnUS = map[string]string{ "getdifficulty--result0": "The difficulty", // GetStakeDifficultyCmd help. - "getstakedifficulty--synopsis": "Returns the proof-of-stake difficulty.", - "getstakedifficultyresult-difficulty": "The stake difficulty", + "getstakedifficulty--synopsis": "Returns the proof-of-stake difficulty.", + "getstakedifficulty--result0": "The stake difficulty", // GetGenerateCmd help. "getgenerate--synopsis": "Returns if the server is set to generate coins (mine) or not.", @@ -641,8 +639,8 @@ var helpDescsEnUS = map[string]string{ "missedticketsresult-tickets": "List of missed tickets", // GetCoinSupply help - "getcoinsupply--synopsis": "Returns current total coin supply in atoms", - "getcoinsupplyresult-coinsupply": "Current coin supply in atoms", + "getcoinsupply--synopsis": "Returns current total coin supply in atoms", + "getcoinsupply--result0": "Current coin supply in atoms", } // rpcResultTypes specifies the result types that each RPC command can return. @@ -658,7 +656,7 @@ var rpcResultTypes = map[string][]interface{}{ "decoderawtransaction": []interface{}{(*dcrjson.TxRawDecodeResult)(nil)}, "decodescript": []interface{}{(*dcrjson.DecodeScriptResult)(nil)}, "estimatefee": []interface{}{(*float64)(nil)}, - "existsaddress": []interface{}{(*dcrjson.ExistsAddressResult)(nil)}, + "existsaddress": []interface{}{(*bool)(nil)}, "getaddednodeinfo": []interface{}{(*[]string)(nil), (*[]dcrjson.GetAddedNodeInfoResult)(nil)}, "getbestblock": []interface{}{(*dcrjson.GetBestBlockResult)(nil)}, "generate": []interface{}{(*[]string)(nil)}, @@ -670,7 +668,7 @@ var rpcResultTypes = map[string][]interface{}{ "getconnectioncount": []interface{}{(*int32)(nil)}, "getcurrentnet": []interface{}{(*uint32)(nil)}, "getdifficulty": []interface{}{(*float64)(nil)}, - "getstakedifficulty": []interface{}{(*dcrjson.GetStakeDifficultyResult)(nil)}, + "getstakedifficulty": []interface{}{(*float64)(nil)}, "getgenerate": []interface{}{(*bool)(nil)}, "gethashespersec": []interface{}{(*float64)(nil)}, "getinfo": []interface{}{(*dcrjson.InfoChainResult)(nil)}, @@ -682,7 +680,7 @@ var rpcResultTypes = map[string][]interface{}{ "getrawtransaction": []interface{}{(*string)(nil), (*dcrjson.TxRawResult)(nil)}, "gettxout": []interface{}{(*dcrjson.GetTxOutResult)(nil)}, "getwork": []interface{}{(*dcrjson.GetWorkResult)(nil), (*bool)(nil)}, - "getcoinsupply": []interface{}{(*dcrjson.GetCoinSupplyResult)(nil)}, + "getcoinsupply": []interface{}{(*int64)(nil)}, "missedtickets": []interface{}{(*dcrjson.MissedTicketsResult)(nil)}, "node": nil, "help": []interface{}{(*string)(nil), (*string)(nil)},