diff --git a/openapi/SwarmCommon.yaml b/openapi/SwarmCommon.yaml index b32fa88c8a4..6bec5c4f595 100644 --- a/openapi/SwarmCommon.yaml +++ b/openapi/SwarmCommon.yaml @@ -1,6 +1,6 @@ openapi: 3.0.3 info: - version: 3.2.8 + version: 4.0.0 title: Common Data Types description: | \*****bzzz***** @@ -731,8 +731,8 @@ components: type: integer lastSelectedRound: type: integer - lastSampleDuration: - $ref: "#/components/schemas/Duration" + lastSampleDurationSeconds: + type: number block: type: integer reward: @@ -835,7 +835,7 @@ components: StatusSnapshotResponse: type: object properties: - peer: + overlay: $ref: "#/components/schemas/SwarmAddress" beeMode: type: string diff --git a/pkg/api/redistribution.go b/pkg/api/redistribution.go index 5df3fbf0682..bce920e1d72 100644 --- a/pkg/api/redistribution.go +++ b/pkg/api/redistribution.go @@ -6,7 +6,6 @@ package api import ( "net/http" - "time" "github.com/ethersphere/bee/v2/pkg/bigint" "github.com/ethersphere/bee/v2/pkg/jsonhttp" @@ -14,21 +13,21 @@ import ( ) type redistributionStatusResponse struct { - MinimumGasFunds *bigint.BigInt `json:"minimumGasFunds"` - HasSufficientFunds bool `json:"hasSufficientFunds"` - IsFrozen bool `json:"isFrozen"` - IsFullySynced bool `json:"isFullySynced"` - Phase string `json:"phase"` - Round uint64 `json:"round"` - LastWonRound uint64 `json:"lastWonRound"` - LastPlayedRound uint64 `json:"lastPlayedRound"` - LastFrozenRound uint64 `json:"lastFrozenRound"` - LastSelectedRound uint64 `json:"lastSelectedRound"` - LastSampleDuration time.Duration `json:"lastSampleDuration"` - Block uint64 `json:"block"` - Reward *bigint.BigInt `json:"reward"` - Fees *bigint.BigInt `json:"fees"` - IsHealthy bool `json:"isHealthy"` + MinimumGasFunds *bigint.BigInt `json:"minimumGasFunds"` + HasSufficientFunds bool `json:"hasSufficientFunds"` + IsFrozen bool `json:"isFrozen"` + IsFullySynced bool `json:"isFullySynced"` + Phase string `json:"phase"` + Round uint64 `json:"round"` + LastWonRound uint64 `json:"lastWonRound"` + LastPlayedRound uint64 `json:"lastPlayedRound"` + LastFrozenRound uint64 `json:"lastFrozenRound"` + LastSelectedRound uint64 `json:"lastSelectedRound"` + LastSampleDurationSeconds float64 `json:"lastSampleDurationSeconds"` + Block uint64 `json:"block"` + Reward *bigint.BigInt `json:"reward"` + Fees *bigint.BigInt `json:"fees"` + IsHealthy bool `json:"isHealthy"` } func (s *Service) redistributionStatusHandler(w http.ResponseWriter, r *http.Request) { @@ -56,20 +55,20 @@ func (s *Service) redistributionStatusHandler(w http.ResponseWriter, r *http.Req } jsonhttp.OK(w, redistributionStatusResponse{ - MinimumGasFunds: bigint.Wrap(minGasFunds), - HasSufficientFunds: hasSufficientFunds, - IsFrozen: status.IsFrozen, - IsFullySynced: status.IsFullySynced, - Phase: status.Phase.String(), - LastWonRound: status.LastWonRound, - LastPlayedRound: status.LastPlayedRound, - LastFrozenRound: status.LastFrozenRound, - LastSelectedRound: status.LastSelectedRound, - LastSampleDuration: status.SampleDuration, - Round: status.Round, - Block: status.Block, - Reward: bigint.Wrap(status.Reward), - Fees: bigint.Wrap(status.Fees), - IsHealthy: status.IsHealthy, + MinimumGasFunds: bigint.Wrap(minGasFunds), + HasSufficientFunds: hasSufficientFunds, + IsFrozen: status.IsFrozen, + IsFullySynced: status.IsFullySynced, + Phase: status.Phase.String(), + LastWonRound: status.LastWonRound, + LastPlayedRound: status.LastPlayedRound, + LastFrozenRound: status.LastFrozenRound, + LastSelectedRound: status.LastSelectedRound, + LastSampleDurationSeconds: status.SampleDuration.Seconds(), + Round: status.Round, + Block: status.Block, + Reward: bigint.Wrap(status.Reward), + Fees: bigint.Wrap(status.Fees), + IsHealthy: status.IsHealthy, }) } diff --git a/pkg/api/status.go b/pkg/api/status.go index b20cafb15a7..38c34fd7d9d 100644 --- a/pkg/api/status.go +++ b/pkg/api/status.go @@ -17,8 +17,8 @@ import ( ) type statusSnapshotResponse struct { - Peer string `json:"peer"` - Proximity uint8 `json:"proximity"` + Overlay string `json:"overlay"` + Proximity uint `json:"proximity"` BeeMode string `json:"beeMode"` ReserveSize uint64 `json:"reserveSize"` ReserveSizeWithinRadius uint64 `json:"reserveSizeWithinRadius"` @@ -71,7 +71,8 @@ func (s *Service) statusGetHandler(w http.ResponseWriter, _ *http.Request) { } jsonhttp.OK(w, statusSnapshotResponse{ - Peer: s.overlay.String(), + Proximity: 256, + Overlay: s.overlay.String(), BeeMode: ss.BeeMode, ReserveSize: ss.ReserveSize, ReserveSizeWithinRadius: ss.ReserveSizeWithinRadius, @@ -109,8 +110,8 @@ func (s *Service) statusGetPeersHandler(w http.ResponseWriter, r *http.Request) defer wg.Done() snapshot := statusSnapshotResponse{ - Peer: address.String(), - Proximity: po, + Overlay: address.String(), + Proximity: uint(po), } ss, err := s.statusService.PeerSnapshot(ctx, address) diff --git a/pkg/api/status_test.go b/pkg/api/status_test.go index 8dadff7484c..1c404ca9039 100644 --- a/pkg/api/status_test.go +++ b/pkg/api/status_test.go @@ -26,13 +26,14 @@ func TestGetStatus(t *testing.T) { mode := api.FullMode ssr := api.StatusSnapshotResponse{ + Proximity: 256, BeeMode: mode.String(), ReserveSize: 128, ReserveSizeWithinRadius: 64, PullsyncRate: 64, StorageRadius: 8, ConnectedPeers: 0, - NeighborhoodSize: 0, + NeighborhoodSize: 1, BatchCommitment: 1, IsReachable: true, } diff --git a/pkg/status/status.go b/pkg/status/status.go index a8321dc98bc..b6eeef6bd30 100644 --- a/pkg/status/status.go +++ b/pkg/status/status.go @@ -124,7 +124,7 @@ func (s *Service) LocalSnapshot() (*Snapshot, error) { PullsyncRate: syncRate, StorageRadius: uint32(storageRadius), ConnectedPeers: connectedPeers, - NeighborhoodSize: neighborhoodSize, + NeighborhoodSize: neighborhoodSize + 1, // include self BatchCommitment: commitment, IsReachable: s.topologyDriver.IsReachable(), }, nil diff --git a/pkg/status/status_test.go b/pkg/status/status_test.go index 927ddb09ca5..ff98816226d 100644 --- a/pkg/status/status_test.go +++ b/pkg/status/status_test.go @@ -24,12 +24,13 @@ func TestStatus(t *testing.T) { t.Parallel() want := &pb.Snapshot{ - BeeMode: api.FullMode.String(), - ReserveSize: 128, - PullsyncRate: 64, - StorageRadius: 8, - BatchCommitment: 1024, - IsReachable: true, + BeeMode: api.FullMode.String(), + ReserveSize: 128, + PullsyncRate: 64, + StorageRadius: 8, + BatchCommitment: 1024, + NeighborhoodSize: 1, + IsReachable: true, } sssMock := &statusSnapshotMock{want} @@ -96,12 +97,13 @@ func TestStatusLightNode(t *testing.T) { t.Parallel() want := &pb.Snapshot{ - BeeMode: api.LightMode.String(), - ReserveSize: 0, - PullsyncRate: 0, - StorageRadius: 0, - BatchCommitment: 1024, - IsReachable: true, + BeeMode: api.LightMode.String(), + ReserveSize: 0, + PullsyncRate: 0, + StorageRadius: 0, + BatchCommitment: 1024, + IsReachable: true, + NeighborhoodSize: 1, } sssMock := &statusSnapshotMock{&pb.Snapshot{