Skip to content

Commit

Permalink
fix: reserve repair to use LoadWithStampHash
Browse files Browse the repository at this point in the history
  • Loading branch information
istae committed Nov 11, 2024
1 parent a53ba8e commit 4e60465
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/storer/internal/reserve/reserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ func New(
// if the new chunk has a higher stamp timestamp (regardless of batch type and chunk type, eg CAC & SOC).
func (r *Reserve) Put(ctx context.Context, chunk swarm.Chunk) error {

chunkType := storage.ChunkType(chunk)

// batchID lock, Put vs Eviction
r.multx.Lock(string(chunk.Stamp().BatchID()))
defer r.multx.Unlock(string(chunk.Stamp().BatchID()))
Expand All @@ -119,6 +117,8 @@ func (r *Reserve) Put(ctx context.Context, chunk swarm.Chunk) error {
return nil
}

chunkType := storage.ChunkType(chunk)

bin := swarm.Proximity(r.baseAddr.Bytes(), chunk.Address().Bytes())

// bin lock
Expand Down
7 changes: 6 additions & 1 deletion pkg/storer/internal/reserve/reserve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,12 @@ func checkChunk(t *testing.T, s transaction.ReadOnlyStore, ch swarm.Chunk, gone
t.Fatal(err)
}

_, err = chunkstamp.LoadWithBatchID(s.IndexStore(), "reserve", ch.Address(), ch.Stamp().BatchID())
hash, err := ch.Stamp().Hash()
if err != nil {
t.Fatal(err)
}

_, err = chunkstamp.LoadWithStampHash(s.IndexStore(), "reserve", ch.Address(), hash)
if !gone && err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storer/migration/reserveRepair.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func ReserveRepairer(

item.BinID = newID(int(item.Bin))
if bytes.Equal(item.StampHash, swarm.EmptyAddress.Bytes()) {
stamp, err := chunkstamp.LoadWithBatchID(s.IndexStore(), "reserve", item.Address, item.BatchID)
stamp, err := chunkstamp.LoadWithStampHash(s.IndexStore(), "reserve", item.Address, item.StampHash)
if err != nil {
return err
}
Expand Down

0 comments on commit 4e60465

Please sign in to comment.