Skip to content

Commit

Permalink
Added cancelled boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed Aug 9, 2023
1 parent 53712b2 commit 2c6ddc3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions code/go/0chain.net/smartcontract/storagesc/allocation.go
Expand Up @@ -1256,6 +1256,7 @@ func (sc *StorageSmartContract) settleOpenChallengesAndGetPassRates(
now common.Timestamp,
maxChallengeCompletionTime time.Duration,
balances chainstate.StateContextI,
cancelled bool,
) (
passRates []float64, err error) {

Expand Down Expand Up @@ -1283,7 +1284,7 @@ func (sc *StorageSmartContract) settleOpenChallengesAndGetPassRates(
ba.Stats.OpenChallenges--
alloc.Stats.OpenChallenges--

if expire < now {
if expire < now && cancelled {
ba.Stats.FailedChallenges++
alloc.Stats.FailedChallenges++

Expand Down Expand Up @@ -1373,7 +1374,7 @@ func (sc *StorageSmartContract) cancelAllocationRequest(
return "", common.NewError("can't get config", err.Error())
}
var passRates []float64
passRates, err = sc.settleOpenChallengesAndGetPassRates(alloc, t.CreationDate, conf.MaxChallengeCompletionTime, balances)
passRates, err = sc.settleOpenChallengesAndGetPassRates(alloc, t.CreationDate, conf.MaxChallengeCompletionTime, balances, true)
if err != nil {
return "", common.NewError("alloc_cancel_failed",
"calculating rest challenges success/fail rates: "+err.Error())
Expand Down Expand Up @@ -1462,7 +1463,7 @@ func (sc *StorageSmartContract) finalizeAllocation(
}

var passRates []float64
passRates, err = sc.settleOpenChallengesAndGetPassRates(alloc, t.CreationDate, conf.MaxChallengeCompletionTime, balances)
passRates, err = sc.settleOpenChallengesAndGetPassRates(alloc, t.CreationDate, conf.MaxChallengeCompletionTime, balances, false)
if err != nil {
return "", common.NewError("fini_alloc_failed",
"calculating rest challenges success/fail rates: "+err.Error())
Expand Down

0 comments on commit 2c6ddc3

Please sign in to comment.