Skip to content

Commit 4cef759

Browse files
committed
update blobber size
1 parent 132b212 commit 4cef759

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

code/go/0chain.net/blobbercore/allocation/protocol.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,22 @@ func FetchAllocationFromEventsDB(ctx context.Context, allocationID string, alloc
7777

7878
isExist = a.ID != ""
7979

80-
if !isExist {
81-
foundBlobber := false
82-
for _, blobberConnection := range sa.BlobberDetails {
83-
if blobberConnection.BlobberID != node.Self.ID {
84-
continue
85-
}
86-
foundBlobber = true
80+
foundBlobber := false
81+
for _, blobberConnection := range sa.BlobberDetails {
82+
if blobberConnection.BlobberID != node.Self.ID {
83+
continue
84+
}
85+
foundBlobber = true
86+
a.BlobberSize = int64(math.Ceil(float64(sa.Size) / float64(sa.DataShards)))
87+
if !isExist {
8788
a.AllocationRoot = ""
88-
a.BlobberSize = int64(math.Ceil(float64(sa.Size) / float64(sa.DataShards)))
8989
a.BlobberSizeUsed = 0
90-
break
91-
}
92-
if !foundBlobber {
93-
return nil, common.NewError("invalid_blobber",
94-
"Blobber is not part of the open connection transaction")
9590
}
91+
break
92+
}
93+
if !foundBlobber {
94+
return nil, common.NewError("invalid_blobber",
95+
"Blobber is not part of the open connection transaction")
9696
}
9797

9898
// set/update fields
@@ -151,6 +151,7 @@ func FetchAllocationFromEventsDB(ctx context.Context, allocationID string, alloc
151151
"time_unit": a.TimeUnit,
152152
"file_options": a.FileOptions,
153153
"start_time": a.StartTime,
154+
"blobber_size": a.BlobberSize,
154155
}
155156

156157
updateOption := func(alloc *Allocation) {
@@ -164,6 +165,7 @@ func FetchAllocationFromEventsDB(ctx context.Context, allocationID string, alloc
164165
alloc.TimeUnit = a.TimeUnit
165166
alloc.FileOptions = a.FileOptions
166167
alloc.StartTime = a.StartTime
168+
alloc.BlobberSize = a.BlobberSize
167169
}
168170
err = Repo.UpdateAllocation(ctx, a, updateMap, updateOption)
169171
}

0 commit comments

Comments
 (0)