Skip to content

Commit

Permalink
Correct the return type for estimatestakediff (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjepson authored and alexlyp committed May 9, 2016
1 parent e889894 commit b285971
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,20 @@ type FutureEstimateStakeDiffResult chan *response

// Receive waits for the response promised by the future and returns the hash
// and height of the block in the longest (best) chain.
func (r FutureEstimateStakeDiffResult) Receive() (dcrutil.Amount, error) {
func (r FutureEstimateStakeDiffResult) Receive() (*dcrjson.EstimateStakeDiffResult, error) {
res, err := receiveFuture(r)
if err != nil {
return 0, err
return nil, err
}

// Unmarsal result as a estimatestakediff result object.
var est float64
var est dcrjson.EstimateStakeDiffResult
err = json.Unmarshal(res, &est)
if err != nil {
return 0, err
}

// Convert to amount.
amt, err := dcrutil.NewAmount(est)
if err != nil {
return 0, err
return nil, err
}

return amt, nil
return &est, nil
}

// EstimateStakeDiffAsync returns an instance of a type that can be used to get the
Expand All @@ -143,7 +137,7 @@ func (c *Client) EstimateStakeDiffAsync(tickets *uint32) FutureEstimateStakeDiff
// difficulty.
//
// NOTE: This is a dcrd extension.
func (c *Client) EstimateStakeDiff(tickets *uint32) (dcrutil.Amount, error) {
func (c *Client) EstimateStakeDiff(tickets *uint32) (*dcrjson.EstimateStakeDiffResult, error) {
return c.EstimateStakeDiffAsync(tickets).Receive()
}

Expand Down

0 comments on commit b285971

Please sign in to comment.