Skip to content

Commit

Permalink
Remove rpc cmd Results that only have 1 field
Browse files Browse the repository at this point in the history
Instead just return field value in rpc handler
  • Loading branch information
alexlyp committed Feb 17, 2016
1 parent 2f9fc2d commit 4868ed4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 58 deletions.
18 changes: 0 additions & 18 deletions dcrjson/dcrdextresults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 0 additions & 23 deletions dcrjson/dcrwalletextresults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
11 changes: 4 additions & 7 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
18 changes: 8 additions & 10 deletions rpcserverhelp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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.
Expand All @@ -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)},
Expand All @@ -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)},
Expand All @@ -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)},
Expand Down

0 comments on commit 4868ed4

Please sign in to comment.