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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup preferred blobbers from chain config #1099

Merged
merged 3 commits into from Jul 7, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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