Skip to content

Commit

Permalink
Fix reset allocation stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed May 1, 2024
1 parent a2a01a6 commit da57d34
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions code/go/0chain.net/smartcontract/storagesc/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -1558,12 +1558,18 @@ func emitUpdateAllocationStatEvent(allocation *StorageAllocation, balances chain
}

func (sc *StorageSmartContract) resetAllocationStats(t *transaction.Transaction, input []byte, balances chainstate.StateContextI) (string, error) {
var allocationID string
if err := json.Unmarshal(input, &allocationID); err != nil {
var allocation map[string]string
if err := json.Unmarshal(input, &allocation); err != nil {
return "", common.NewError("reset_blobber_stats_failed",
"malformed request: "+err.Error())
}

allocationID, ok := allocation["allocation_id"]
if !ok {
return "", common.NewError("reset_allocation_stats_failed",
"missing allocation_id in request")
}

alloc, err := sc.getAllocation(allocationID, balances)
if err != nil {
return "", common.NewError("reset_allocation_stats_failed", err.Error())
Expand Down

0 comments on commit da57d34

Please sign in to comment.