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

Add file_options_changed #762

Merged
merged 4 commits into from Feb 11, 2023
Merged
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
10 changes: 5 additions & 5 deletions zboxcore/sdk/sdk.go
Expand Up @@ -941,7 +941,7 @@ func CreateAllocationForOwner(
allocationRequest["owner_id"] = owner
allocationRequest["owner_public_key"] = ownerpublickey
allocationRequest["third_party_extendable"] = thirdPartyExtendable
allocationRequest["file_options"] = calculateAllocationFileOptions(63 /*0011 1111*/, fileOptionsParams)
allocationRequest["file_options_changed"], allocationRequest["file_options"] = calculateAllocationFileOptions(63 /*0011 1111*/, fileOptionsParams)

var sn = transaction.SmartContractTxnData{
Name: transaction.NEW_ALLOCATION_REQUEST,
Expand Down Expand Up @@ -1143,7 +1143,7 @@ func UpdateAllocation(
updateAllocationRequest["add_blobber_id"] = addBlobberId
updateAllocationRequest["remove_blobber_id"] = removeBlobberId
updateAllocationRequest["set_third_party_extendable"] = setThirdPartyExtendable
updateAllocationRequest["file_options"] = calculateAllocationFileOptions(alloc.FileOptions, fileOptionsParams)
updateAllocationRequest["file_options_changed"], updateAllocationRequest["file_options"] = calculateAllocationFileOptions(alloc.FileOptions, fileOptionsParams)

sn := transaction.SmartContractTxnData{
Name: transaction.STORAGESC_UPDATE_ALLOCATION,
Expand Down Expand Up @@ -1475,9 +1475,9 @@ func GetAllocationMinLock(
}

// calculateAllocationFileOptions calculates the FileOptions 16-bit mask given the user input
func calculateAllocationFileOptions(initial uint16, fop *FileOptionsParameters) uint16 {
func calculateAllocationFileOptions(initial uint16, fop *FileOptionsParameters) (bool, uint16) {
if fop == nil {
return initial
return false, initial
}

mask := initial
Expand Down Expand Up @@ -1506,7 +1506,7 @@ func calculateAllocationFileOptions(initial uint16, fop *FileOptionsParameters)
mask = updateMaskBit(mask, 5, !fop.ForbidRename.Value)
}

return mask
return mask != initial, mask
}

// updateMaskBit Set/Clear (based on `value`) bit value of the bit of `mask` at `index` (starting with LSB as 0) and return the updated mask
Expand Down