Skip to content

Commit

Permalink
Make GetStakePoolInfo generic by replacing blobber_id with provider info
Browse files Browse the repository at this point in the history
  • Loading branch information
iamrz1 committed Nov 4, 2022
1 parent 17b2500 commit f58e516
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions zboxcore/sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,12 @@ type StakePoolDelegatePoolInfo struct {

// StakePool full info.
type StakePoolInfo struct {
ID common.Key `json:"pool_id"` // pool ID
Balance common.Balance `json:"balance"` // total balance
Unstake common.Balance `json:"unstake"` // total unstake amount

Free int64 `json:"free"` // free staked space
Capacity int64 `json:"capacity"` // blobber bid
WritePrice common.Balance `json:"write_price"` // its write price

OffersTotal common.Balance `json:"offers_total"` //
ID common.Key `json:"pool_id"` // pool ID
Balance common.Balance `json:"balance"` // total balance
StakeTotal common.Balance `json:"stake_total"`
UnstakeTotal common.Balance `json:"unstake_total"`
// delegate pools
Delegate []StakePoolDelegatePoolInfo `json:"delegate"`
Penalty common.Balance `json:"penalty"` // total for all
// rewards
Rewards common.Balance `json:"rewards"`

Expand All @@ -280,17 +273,14 @@ type StakePoolInfo struct {

// GetStakePoolInfo for given client, or, if the given clientID is empty,
// for current client of the sdk.
func GetStakePoolInfo(blobberID string) (info *StakePoolInfo, err error) {
func GetStakePoolInfo(providerType ProviderType, providerID string) (info *StakePoolInfo, err error) {
if !sdkInitialized {
return nil, sdkNotInitialized
}
if blobberID == "" {
return nil, errors.New("", "blobber_id is required")
}

var b []byte
b, err = zboxutil.MakeSCRestAPICall(STORAGE_SCADDRESS, "/getStakePoolStat",
map[string]string{"blobber_id": blobberID}, nil)
map[string]string{"provider_type": strconv.Itoa(int(providerType)), "provider_id": providerID}, nil)
if err != nil {
return nil, errors.Wrap(err, "error requesting stake pool info:")
}
Expand Down

0 comments on commit f58e516

Please sign in to comment.