@@ -1972,46 +1972,41 @@ func (fsh *StorageHandler) Rollback(ctx context.Context, r *http.Request) (*blob
1972
1972
writemarkerEntity .ClientPublicKey = clientKey
1973
1973
Logger .Info ("rollback_writemarker" , zap .Any ("writemarker" , writemarkerEntity .WM ))
1974
1974
1975
- alloc , err := allocation .Repo .GetByIdAndLock (c , allocationID )
1976
- Logger .Info ("[rollback]Lock Allocation" , zap .Bool ("is_redeem_required" , alloc .IsRedeemRequired ), zap .String ("allocation_root" , alloc .AllocationRoot ), zap .String ("latest_wm_redeemed" , alloc .LatestRedeemedWM ))
1977
- if err != nil {
1978
- txn .Rollback ()
1979
- return & result , common .NewError ("allocation_read_error" , "Error reading the allocation object" )
1980
- }
1975
+ Logger .Info ("[rollback]Lock Allocation" , zap .Bool ("is_redeem_required" , allocationObj .IsRedeemRequired ), zap .String ("allocation_root" , allocationObj .AllocationRoot ), zap .String ("latest_wm_redeemed" , allocationObj .LatestRedeemedWM ))
1981
1976
1982
- alloc .BlobberSizeUsed -= latestWriteMarkerEntity .WM .Size
1983
- alloc .UsedSize -= latestWriteMarkerEntity .WM .Size
1984
- alloc .AllocationRoot = allocationRoot
1985
- alloc .FileMetaRoot = fileMetaRoot
1986
- alloc .IsRedeemRequired = false
1987
- alloc .NumObjects = alloc .PrevNumObjects
1988
- alloc .NumBlocks = alloc .PrevNumBlocks
1977
+ allocationObj .BlobberSizeUsed -= latestWriteMarkerEntity .WM .Size
1978
+ allocationObj .UsedSize -= latestWriteMarkerEntity .WM .Size
1979
+ allocationObj .AllocationRoot = allocationRoot
1980
+ allocationObj .FileMetaRoot = fileMetaRoot
1981
+ allocationObj .IsRedeemRequired = false
1982
+ allocationObj .NumObjects = allocationObj .PrevNumObjects
1983
+ allocationObj .NumBlocks = allocationObj .PrevNumBlocks
1989
1984
updateMap := map [string ]interface {}{
1990
- "blobber_size_used" : alloc .BlobberSizeUsed ,
1991
- "used_size" : alloc .UsedSize ,
1992
- "allocation_root" : alloc .AllocationRoot ,
1993
- "file_meta_root" : alloc .FileMetaRoot ,
1985
+ "blobber_size_used" : allocationObj .BlobberSizeUsed ,
1986
+ "used_size" : allocationObj .UsedSize ,
1987
+ "allocation_root" : allocationObj .AllocationRoot ,
1988
+ "file_meta_root" : allocationObj .FileMetaRoot ,
1994
1989
"is_redeem_required" : false ,
1995
- "num_objects" : alloc .NumObjects ,
1996
- "num_blocks" : alloc .NumBlocks ,
1990
+ "num_objects" : allocationObj .NumObjects ,
1991
+ "num_blocks" : allocationObj .NumBlocks ,
1997
1992
}
1998
1993
1999
1994
updateOption := func (a * allocation.Allocation ) {
2000
- a .BlobberSizeUsed = alloc .BlobberSizeUsed
2001
- a .UsedSize = alloc .UsedSize
2002
- a .AllocationRoot = alloc .AllocationRoot
2003
- a .FileMetaRoot = alloc .FileMetaRoot
2004
- a .IsRedeemRequired = alloc .IsRedeemRequired
2005
- a .NumObjects = alloc .NumObjects
2006
- a .NumBlocks = alloc .NumBlocks
1995
+ a .BlobberSizeUsed = allocationObj .BlobberSizeUsed
1996
+ a .UsedSize = allocationObj .UsedSize
1997
+ a .AllocationRoot = allocationObj .AllocationRoot
1998
+ a .FileMetaRoot = allocationObj .FileMetaRoot
1999
+ a .IsRedeemRequired = allocationObj .IsRedeemRequired
2000
+ a .NumObjects = allocationObj .NumObjects
2001
+ a .NumBlocks = allocationObj .NumBlocks
2007
2002
}
2008
2003
writemarkerEntity .Latest = true
2009
2004
err = txn .Create (writemarkerEntity ).Error
2010
2005
if err != nil {
2011
2006
txn .Rollback ()
2012
2007
return & result , common .NewError ("write_marker_error" , "Error persisting the write marker " + err .Error ())
2013
2008
}
2014
- if err = allocation .Repo .UpdateAllocation (c , alloc , updateMap , updateOption ); err != nil {
2009
+ if err = allocation .Repo .UpdateAllocation (c , allocationObj , updateMap , updateOption ); err != nil {
2015
2010
txn .Rollback ()
2016
2011
return & result , common .NewError ("allocation_write_error" , "Error persisting the allocation object " + err .Error ())
2017
2012
}
@@ -2024,7 +2019,7 @@ func (fsh *StorageHandler) Rollback(ctx context.Context, r *http.Request) (*blob
2024
2019
var node wmpt.Node
2025
2020
if len (fileMetaRoot ) > 0 {
2026
2021
decodedRoot , _ := hex .DecodeString (fileMetaRoot )
2027
- node = wmpt .NewHashNode (decodedRoot , alloc .NumBlocks )
2022
+ node = wmpt .NewHashNode (decodedRoot , allocationObj .NumBlocks )
2028
2023
}
2029
2024
trie .RollbackTrie (node )
2030
2025
}
0 commit comments