Skip to content

Commit 5f9aefb

Browse files
committed
fix: reserve repair to use LoadWithStampHash
1 parent 24658d5 commit 5f9aefb

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

pkg/storer/internal/reserve/reserve.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ func New(
9999
// if the new chunk has a higher stamp timestamp (regardless of batch type and chunk type, eg CAC & SOC).
100100
func (r *Reserve) Put(ctx context.Context, chunk swarm.Chunk) error {
101101

102-
chunkType := storage.ChunkType(chunk)
103-
104102
// batchID lock, Put vs Eviction
105103
r.multx.Lock(string(chunk.Stamp().BatchID()))
106104
defer r.multx.Unlock(string(chunk.Stamp().BatchID()))
@@ -119,6 +117,8 @@ func (r *Reserve) Put(ctx context.Context, chunk swarm.Chunk) error {
119117
return nil
120118
}
121119

120+
chunkType := storage.ChunkType(chunk)
121+
122122
bin := swarm.Proximity(r.baseAddr.Bytes(), chunk.Address().Bytes())
123123

124124
// bin lock

pkg/storer/internal/reserve/reserve_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,12 @@ func checkChunk(t *testing.T, s transaction.ReadOnlyStore, ch swarm.Chunk, gone
985985
t.Fatal(err)
986986
}
987987

988-
_, err = chunkstamp.LoadWithBatchID(s.IndexStore(), "reserve", ch.Address(), ch.Stamp().BatchID())
988+
hash, err := ch.Stamp().Hash()
989+
if err != nil {
990+
t.Fatal(err)
991+
}
992+
993+
_, err = chunkstamp.LoadWithStampHash(s.IndexStore(), "reserve", ch.Address(), hash)
989994
if !gone && err != nil {
990995
t.Fatal(err)
991996
}

pkg/storer/migration/reserveRepair.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func ReserveRepairer(
199199

200200
item.BinID = newID(int(item.Bin))
201201
if bytes.Equal(item.StampHash, swarm.EmptyAddress.Bytes()) {
202-
stamp, err := chunkstamp.LoadWithBatchID(s.IndexStore(), "reserve", item.Address, item.BatchID)
202+
stamp, err := chunkstamp.LoadWithStampHash(s.IndexStore(), "reserve", item.Address, item.StampHash)
203203
if err != nil {
204204
return err
205205
}

0 commit comments

Comments
 (0)