diff --git a/mobilesdk/sdk/sdk.go b/mobilesdk/sdk/sdk.go index 3a18186f0..c75561f0c 100644 --- a/mobilesdk/sdk/sdk.go +++ b/mobilesdk/sdk/sdk.go @@ -352,7 +352,7 @@ func (s *StorageSDK) UpdateAllocation(size int64, extend bool, allocationID stri // GetBlobbersList get list of active blobbers, and format them as array json string func (s *StorageSDK) GetBlobbersList() (string, error) { - blobbs, err := sdk.GetBlobbers(true) + blobbs, err := sdk.GetBlobbers(true, false) if err != nil { return "", err } diff --git a/mobilesdk/zbox/util.go b/mobilesdk/zbox/util.go index dafb63935..a59d48634 100644 --- a/mobilesdk/zbox/util.go +++ b/mobilesdk/zbox/util.go @@ -73,7 +73,7 @@ func GetNetwork() (string, error) { // GetBlobbers - get list of blobbers func GetBlobbers() (string, error) { - blobbers, err := sdk.GetBlobbers(true) + blobbers, err := sdk.GetBlobbers(true, false) if err != nil { return "", err } diff --git a/wasmsdk/blobber.go b/wasmsdk/blobber.go index 2e816be0e..fd27961ec 100644 --- a/wasmsdk/blobber.go +++ b/wasmsdk/blobber.go @@ -901,8 +901,8 @@ func downloadBlocks(allocId string, remotePath, authTicket, lookupHash string, s } // GetBlobbersList get list of active blobbers, and format them as array json string -func getBlobbers() ([]*sdk.Blobber, error) { - blobbs, err := sdk.GetBlobbers(true) +func getBlobbers(stakable bool) ([]*sdk.Blobber, error) { + blobbs, err := sdk.GetBlobbers(true, stakable) if err != nil { return nil, err } diff --git a/zboxcore/sdk/sdk.go b/zboxcore/sdk/sdk.go index 8d76b3a8e..f602e0b0b 100644 --- a/zboxcore/sdk/sdk.go +++ b/zboxcore/sdk/sdk.go @@ -710,15 +710,16 @@ func (v *UpdateValidator) ConvertToValidationNode() *blockchain.UpdateValidation return blockValidator } -func getBlobbersInternal(active bool, limit, offset int) (bs []*Blobber, err error) { +func getBlobbersInternal(active, stakable bool, limit, offset int) (bs []*Blobber, err error) { type nodes struct { Nodes []*Blobber } - url := fmt.Sprintf("/getblobbers?active=%s&limit=%d&offset=%d", + url := fmt.Sprintf("/getblobbers?active=%s&limit=%d&offset=%d&stakable=%s", strconv.FormatBool(active), limit, offset, + strconv.FormatBool(stakable), ) b, err := zboxutil.MakeSCRestAPICall(STORAGE_SCADDRESS, url, nil, nil) var wrap nodes @@ -736,14 +737,14 @@ func getBlobbersInternal(active bool, limit, offset int) (bs []*Blobber, err err return wrap.Nodes, nil } -func GetBlobbers(active bool) (bs []*Blobber, err error) { +func GetBlobbers(active, stakable bool) (bs []*Blobber, err error) { if !sdkInitialized { return nil, sdkNotInitialized } limit, offset := 20, 0 - blobbers, err := getBlobbersInternal(active, limit, offset) + blobbers, err := getBlobbersInternal(active, stakable, limit, offset) if err != nil { return nil, err } @@ -758,7 +759,7 @@ func GetBlobbers(active bool) (bs []*Blobber, err error) { // get the next set of blobbers offset += 20 - blobbers, err = getBlobbersInternal(active, limit, offset) + blobbers, err = getBlobbersInternal(active, stakable, limit, offset) if err != nil { return blobbers, err } @@ -820,7 +821,7 @@ func GetValidator(validatorID string) (validator *Validator, err error) { } // List all validators -func GetValidators() (validators []*Validator, err error) { +func GetValidators(stakable bool) (validators []*Validator, err error) { if !sdkInitialized { return nil, sdkNotInitialized } @@ -828,7 +829,9 @@ func GetValidators() (validators []*Validator, err error) { b, err = zboxutil.MakeSCRestAPICall( STORAGE_SCADDRESS, "/validators", - nil, + map[string]string{ + "stakable" : strconv.FormatBool(stakable), + }, nil) if err != nil { return nil, errors.Wrap(err, "requesting validator list") diff --git a/zcncore/wallet_base.go b/zcncore/wallet_base.go index 657c4306a..223a0ad97 100644 --- a/zcncore/wallet_base.go +++ b/zcncore/wallet_base.go @@ -851,17 +851,18 @@ func (p Params) Query() string { // - limit: how many miners should be fetched // - offset: how many miners should be skipped // - active: only fetch active miners -func GetMiners(cb GetInfoCallback, limit, offset int, active bool) { - getMinersInternal(cb, active, limit, offset) +func GetMiners(cb GetInfoCallback, limit, offset int, active bool, stakable bool) { + getMinersInternal(cb, active, stakable, limit, offset) } -func getMinersInternal(cb GetInfoCallback, active bool, limit, offset int) { +func getMinersInternal(cb GetInfoCallback, active, stakable bool, limit, offset int) { if err := CheckConfig(); err != nil { return } var url = withParams(GET_MINERSC_MINERS, Params{ "active": strconv.FormatBool(active), + "stakable": strconv.FormatBool(stakable), "offset": strconv.FormatInt(int64(offset), 10), "limit": strconv.FormatInt(int64(limit), 10), }) @@ -875,17 +876,19 @@ func getMinersInternal(cb GetInfoCallback, active bool, limit, offset int) { // - limit: how many sharders should be fetched // - offset: how many sharders should be skipped // - active: only fetch active sharders -func GetSharders(cb GetInfoCallback, limit, offset int, active bool) { - getShardersInternal(cb, active, limit, offset) +// - stakable: only fetch sharders that can be staked +func GetSharders(cb GetInfoCallback, limit, offset int, active, stakable bool) { + getShardersInternal(cb, active, stakable, limit, offset) } -func getShardersInternal(cb GetInfoCallback, active bool, limit, offset int) { +func getShardersInternal(cb GetInfoCallback, active, stakable bool, limit, offset int) { if err := CheckConfig(); err != nil { return } var url = withParams(GET_MINERSC_SHARDERS, Params{ "active": strconv.FormatBool(active), + "stakable": strconv.FormatBool(stakable), "offset": strconv.FormatInt(int64(offset), 10), "limit": strconv.FormatInt(int64(limit), 10), })