From 3368d11a8dafee09e5d4fd723442c292b8fd44bf Mon Sep 17 00:00:00 2001 From: Calin Martinconi Date: Wed, 9 Oct 2024 13:08:27 +0300 Subject: [PATCH] fix: rename chunk count --- openapi/SwarmCommon.yaml | 2 +- pkg/api/status.go | 8 ++++---- pkg/storer/reserve.go | 6 +++--- pkg/storer/reserve_test.go | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openapi/SwarmCommon.yaml b/openapi/SwarmCommon.yaml index 230119c788..2ef4e155f3 100644 --- a/openapi/SwarmCommon.yaml +++ b/openapi/SwarmCommon.yaml @@ -938,7 +938,7 @@ components: properties: address: type: string - chunkCount: + reserveSizeWithinRadius: type: integer StatusNeighborhoodsResponse: diff --git a/pkg/api/status.go b/pkg/api/status.go index a28041e3f6..3a61e62d35 100644 --- a/pkg/api/status.go +++ b/pkg/api/status.go @@ -38,8 +38,8 @@ type statusResponse struct { } type statusNeighborhoodResponse struct { - Address string `json:"address"` - ChunkCount int `json:"chunkCount"` + Address string `json:"address"` + ReserveSizeWithinRadius int `json:"reserveSizeWithinRadius"` } type neighborhoodsResponse struct { @@ -201,8 +201,8 @@ func (s *Service) statusGetNeighborhoods(w http.ResponseWriter, _ *http.Request) binaryAddr += fmt.Sprintf("%08b ", b) } neighborhoods = append(neighborhoods, statusNeighborhoodResponse{ - Address: binaryAddr, - ChunkCount: n.ChunkCount, + Address: binaryAddr, + ReserveSizeWithinRadius: n.ReserveSizeWithinRadius, }) } diff --git a/pkg/storer/reserve.go b/pkg/storer/reserve.go index a3e75ee239..8f85e72f7a 100644 --- a/pkg/storer/reserve.go +++ b/pkg/storer/reserve.go @@ -498,8 +498,8 @@ func (db *DB) SubscribeBin(ctx context.Context, bin uint8, start uint64) (<-chan } type NeighborhoodStat struct { - Address swarm.Address - ChunkCount int + Address swarm.Address + ReserveSizeWithinRadius int } func (db *DB) NeighborhoodsStat(ctx context.Context) ([]*NeighborhoodStat, error) { @@ -517,7 +517,7 @@ func (db *DB) NeighborhoodsStat(ctx context.Context) ([]*NeighborhoodStat, error err := db.reserve.IterateChunksItems(0, func(ch *reserve.ChunkBinItem) (bool, error) { for _, n := range neighs { if swarm.Proximity(ch.Address.Bytes(), n.Address.Bytes()) >= networkRadius { - n.ChunkCount++ + n.ReserveSizeWithinRadius++ break } } diff --git a/pkg/storer/reserve_test.go b/pkg/storer/reserve_test.go index 1514e09cbb..72f569b720 100644 --- a/pkg/storer/reserve_test.go +++ b/pkg/storer/reserve_test.go @@ -723,8 +723,8 @@ func TestNeighborhoodStats(t *testing.T) { } for _, n := range neighs { - if n.ChunkCount != chunkCountPerPO { - t.Fatalf("chunk count does not match. wanted %d, got %d", chunkCountPerPO, n.ChunkCount) + if n.ReserveSizeWithinRadius != chunkCountPerPO { + t.Fatalf("chunk count does not match. wanted %d, got %d", chunkCountPerPO, n.ReserveSizeWithinRadius) } } @@ -735,7 +735,7 @@ func TestNeighborhoodStats(t *testing.T) { t.Run("disk", func(t *testing.T) { t.Parallel() - opts := dbTestOps(baseAddr, 10000, nil, nil, time.Minute) + opts := dbTestOps(baseAddr, 100000, nil, nil, time.Minute) opts.ReserveCapacityDoubling = int(doublingFactor) storer, err := diskStorer(t, opts)() if err != nil { @@ -746,7 +746,7 @@ func TestNeighborhoodStats(t *testing.T) { }) t.Run("mem", func(t *testing.T) { t.Parallel() - opts := dbTestOps(baseAddr, 10000, nil, nil, time.Minute) + opts := dbTestOps(baseAddr, 100000, nil, nil, time.Minute) opts.ReserveCapacityDoubling = int(doublingFactor) storer, err := memStorer(t, opts)() if err != nil {