Skip to content

Commit

Permalink
cleanup preferred blobbers from chain config (#1099)
Browse files Browse the repository at this point in the history
* cleanup preferred blobbers from chain config

* fix mobilesdk/CreateAllocation

* fix lint
  • Loading branch information
boddumanohar committed Jul 7, 2023
1 parent 66d842e commit 4f49785
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 40 deletions.
2 changes: 1 addition & 1 deletion core/version/version.go
Expand Up @@ -2,5 +2,5 @@
//====== THIS IS AUTOGENERATED FILE. DO NOT MODIFY ========

package version
const VERSIONSTR = "v1.8.16-89-gf07bbb2d"
const VERSIONSTR = "v1.8.16-101-g66d842ec"

13 changes: 12 additions & 1 deletion mobilesdk/sdk/sdk.go
Expand Up @@ -151,7 +151,18 @@ func (s *StorageSDK) CreateAllocation(datashards, parityshards int, size, expira
return nil, err
}

sdkAllocationID, _, _, err := sdk.CreateAllocation(datashards, parityshards, size, expiration, readPrice, writePrice, l, false, &sdk.FileOptionsParameters{})
options := sdk.CreateAllocationOptions{
DataShards: datashards,
ParityShards: parityshards,
Size: size,
Expiry: expiration,
ReadPrice: readPrice,
WritePrice: writePrice,
Lock: uint64(l),
BlobberIds: []string{},
}

sdkAllocationID, _, _, err := sdk.CreateAllocationWith(options)
if err != nil {
return nil, err
}
Expand Down
9 changes: 0 additions & 9 deletions zboxcore/blockchain/entity.go
Expand Up @@ -11,7 +11,6 @@ type ChainConfig struct {
BlockWorker string
Sharders []string
Miners []string
PreferredBlobbers []string
MinSubmit int
MinConfirmation int
ChainID string
Expand Down Expand Up @@ -107,10 +106,6 @@ func GetQuerySleepTime() int {
return chain.QuerySleepTime
}

func GetPreferredBlobbers() []string {
return chain.PreferredBlobbers
}

func GetMinSubmit() int {
return chain.MinSubmit
}
Expand All @@ -131,10 +126,6 @@ func SetMiners(minerArray []string) {
chain.Miners = minerArray
}

func SetPreferredBlobbers(preferredBlobberArray []string) {
chain.PreferredBlobbers = preferredBlobberArray
}

func SetChainID(id string) {
chain.ChainID = id
}
Expand Down
32 changes: 3 additions & 29 deletions zboxcore/sdk/sdk.go
Expand Up @@ -98,7 +98,6 @@ func InitStorageSDK(walletJSON string,
}

blockchain.SetChainID(chainID)
blockchain.SetPreferredBlobbers(preferredBlobbers)
blockchain.SetBlockWorker(blockWorker)

err = UpdateNetworkDetails()
Expand Down Expand Up @@ -926,35 +925,10 @@ type CreateAllocationOptions struct {
func CreateAllocationWith(options CreateAllocationOptions) (
string, int64, *transaction.Transaction, error) {

if len(options.BlobberIds) > 0 {
return CreateAllocationForOwner(client.GetClientID(),
client.GetClientPublicKey(), options.DataShards, options.ParityShards,
options.Size, options.Expiry, options.ReadPrice, options.WritePrice, options.Lock,
options.BlobberIds, options.ThirdPartyExtendable, options.FileOptionsParams)
}

return CreateAllocation(options.DataShards, options.ParityShards,
options.Size, options.Expiry, options.ReadPrice, options.WritePrice, options.Lock,
options.ThirdPartyExtendable, options.FileOptionsParams)

}

func CreateAllocation(datashards, parityshards int, size, expiry int64,
readPrice, writePrice PriceRange, lock uint64, thirdPartyExtendable bool, fileOptionsParams *FileOptionsParameters) (
string, int64, *transaction.Transaction, error) {

if lock > math.MaxInt64 {
return "", 0, nil, errors.New("invalid_lock", "int64 overflow on lock value")
}

preferredBlobberIds, err := GetBlobberIds(blockchain.GetPreferredBlobbers())
if err != nil {
return "", 0, nil, errors.New("failed_get_blobber_ids", "failed to get preferred blobber ids: "+err.Error())
}
return CreateAllocationForOwner(client.GetClientID(),
client.GetClientPublicKey(), datashards, parityshards,
size, expiry, readPrice, writePrice, lock,
preferredBlobberIds, thirdPartyExtendable, fileOptionsParams)
client.GetClientPublicKey(), options.DataShards, options.ParityShards,
options.Size, options.Expiry, options.ReadPrice, options.WritePrice, options.Lock,
options.BlobberIds, options.ThirdPartyExtendable, options.FileOptionsParams)
}

func CreateAllocationForOwner(
Expand Down

0 comments on commit 4f49785

Please sign in to comment.