Skip to content

Commit

Permalink
give hint to user to wait
Browse files Browse the repository at this point in the history
  • Loading branch information
walldiss committed Apr 20, 2023
1 parent c55d0be commit 6922a0e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion api/gateway/availability.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ func (h *Handler) handleHeightAvailabilityRequest(w http.ResponseWriter, r *http
return
}

//TODO: change this to NetworkHead once the adjacency in the store is fixed.
head, err := h.header.LocalHead(r.Context())
if err != nil {
writeError(w, http.StatusInternalServerError, heightAvailabilityEndpoint, err)
return
}
if headHeight := int(head.Height()); headHeight < height {
err = fmt.Errorf(
"current header store head height: %v is lower then requested height: %v", headHeight, height)
"current head store head height: %v is lower then requested height: %v"+
" give header sync some time and retry later", headHeight, height)
writeError(w, http.StatusServiceUnavailable, heightAvailabilityEndpoint, err)
return
}
Expand Down
4 changes: 3 additions & 1 deletion api/gateway/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@ func (h *Handler) performGetHeaderRequest(
writeError(w, http.StatusBadRequest, endpoint, err)
return nil, err
}
//TODO: change this to NetworkHead once the adjacency in the store is fixed.
head, err := h.header.LocalHead(r.Context())
if err != nil {
writeError(w, http.StatusInternalServerError, heightAvailabilityEndpoint, err)
return nil, err
}
if headHeight := int(head.Height()); headHeight < height {
err = fmt.Errorf(
"current head store head height: %v is lower then requested height: %v", headHeight, height)
"current head store head height: %v is lower then requested height: %v"+
" give header sync some time and retry later", headHeight, height)
writeError(w, http.StatusServiceUnavailable, endpoint, err)
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions api/gateway/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (h *Handler) getShares(ctx context.Context, height uint64, nID namespace.ID
header *header.ExtendedHeader
)

//TODO: change this to NetworkHead once the adjacency in the store is fixed.
header, err = h.header.LocalHead(ctx)
if err != nil {
return nil, 0, err
Expand All @@ -108,9 +109,8 @@ func (h *Handler) getShares(ctx context.Context, height uint64, nID namespace.ID
if height > 0 {
if storeHeight := uint64(header.Height()); storeHeight < height {
return nil, 0, fmt.Errorf(
"current header store head height: %v is lower then requested height: %v",
storeHeight, height,
)
"current head store head height: %v is lower then requested height: %v"+
" give header sync some time and retry later", storeHeight, height)
}
header, err = h.header.GetByHeight(ctx, height)
}
Expand Down

0 comments on commit 6922a0e

Please sign in to comment.