Skip to content

Commit 6ab75cb

Browse files
authored
feat: add isWarmingUp to status response (#5047)
1 parent 0b54b10 commit 6ab75cb

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

openapi/SwarmCommon.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,8 @@ components:
914914
type: integer
915915
committedDepth:
916916
type: integer
917+
isWarmingUp:
918+
type: boolean
917919

918920
StatusPeersResponse:
919921
type: object

pkg/api/api.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ import (
5050
"github.com/ethersphere/bee/v2/pkg/settlement/swap/erc20"
5151
"github.com/ethersphere/bee/v2/pkg/status"
5252
"github.com/ethersphere/bee/v2/pkg/steward"
53-
storage "github.com/ethersphere/bee/v2/pkg/storage"
53+
"github.com/ethersphere/bee/v2/pkg/storage"
5454
"github.com/ethersphere/bee/v2/pkg/storageincentives"
5555
"github.com/ethersphere/bee/v2/pkg/storageincentives/staking"
56-
storer "github.com/ethersphere/bee/v2/pkg/storer"
56+
"github.com/ethersphere/bee/v2/pkg/storer"
5757
"github.com/ethersphere/bee/v2/pkg/swarm"
5858
"github.com/ethersphere/bee/v2/pkg/topology"
5959
"github.com/ethersphere/bee/v2/pkg/topology/lightnode"
@@ -220,6 +220,7 @@ type Service struct {
220220
redistributionAgent *storageincentives.Agent
221221

222222
statusService *status.Service
223+
isWarmingUp bool
223224
}
224225

225226
func (s *Service) SetP2P(p2p p2p.DebugService) {
@@ -387,6 +388,10 @@ func (s *Service) SetProbe(probe *Probe) {
387388
s.probe = probe
388389
}
389390

391+
func (s *Service) SetIsWarmingUp(v bool) {
392+
s.isWarmingUp = v
393+
}
394+
390395
// Close hangs up running websockets on shutdown.
391396
func (s *Service) Close() error {
392397
s.logger.Info("api shutting down")

pkg/api/status.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type statusSnapshotResponse struct {
3131
IsReachable bool `json:"isReachable"`
3232
LastSyncedBlock uint64 `json:"lastSyncedBlock"`
3333
CommittedDepth uint8 `json:"committedDepth"`
34+
IsWarmingUp bool `json:"isWarmingUp"`
3435
}
3536

3637
type statusResponse struct {
@@ -96,6 +97,7 @@ func (s *Service) statusGetHandler(w http.ResponseWriter, _ *http.Request) {
9697
IsReachable: ss.IsReachable,
9798
LastSyncedBlock: ss.LastSyncedBlock,
9899
CommittedDepth: uint8(ss.CommittedDepth),
100+
IsWarmingUp: s.isWarmingUp,
99101
})
100102
}
101103

pkg/node/node.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ func NewBee(
460460

461461
apiService.Mount()
462462
apiService.SetProbe(probe)
463-
463+
apiService.SetIsWarmingUp(true)
464464
apiService.SetSwarmAddress(&swarmAddress)
465465

466466
apiServer := &http.Server{
@@ -1003,6 +1003,10 @@ func NewBee(
10031003
return nil, fmt.Errorf("pullsync protocol: %w", err)
10041004
}
10051005

1006+
time.AfterFunc(warmupTime, func() {
1007+
apiService.SetIsWarmingUp(false)
1008+
})
1009+
10061010
stakingContractAddress := chainCfg.StakingAddress
10071011
if o.StakingContractAddress != "" {
10081012
if !common.IsHexAddress(o.StakingContractAddress) {

0 commit comments

Comments
 (0)