Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get stakable blobbers #1429

Merged
merged 7 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mobilesdk/sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion mobilesdk/zbox/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions wasmsdk/blobber.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
17 changes: 10 additions & 7 deletions zboxcore/sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -820,15 +821,17 @@ 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
}
var b []byte
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")
Expand Down
15 changes: 9 additions & 6 deletions zcncore/wallet_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
Expand All @@ -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),
})
Expand Down
Loading