Skip to content

Commit

Permalink
Fix allocation min lock (#1297)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 authored Nov 24, 2023
1 parent 434dd6a commit 5a931d2
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions zboxcore/sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1571,28 +1571,10 @@ func GetAllocationMinLock(
) (int64, error) {
baSize := int64(math.Ceil(float64(size) / float64(datashards)))
totalSize := baSize * int64(datashards+parityshards)
config, err := GetStorageSCConfig()
if err != nil {
return 0, err
}
t := config.Fields["time_unit"]
timeunitStr, ok := t.(string)
if !ok {
return 0, fmt.Errorf("bad time_unit type")
}
timeunit, err := time.ParseDuration(timeunitStr)
if err != nil {
return 0, fmt.Errorf("bad time_unit format")
}

expiry := common.Timestamp(time.Now().Add(timeunit).Unix())
duration := expiry / common.Timestamp(timeunit.Milliseconds())
if expiry%common.Timestamp(timeunit.Milliseconds()) != 0 {
duration++
}

sizeInGB := float64(totalSize) / GB
cost := float64(duration) * (sizeInGB*float64(writePrice.Max) + sizeInGB*float64(readPrice.Max))

cost := sizeInGB * float64(writePrice.Max)
coin, err := currency.Float64ToCoin(cost)
if err != nil {
return 0, err
Expand Down

0 comments on commit 5a931d2

Please sign in to comment.