Skip to content

Commit

Permalink
feat: set height header for GRPC query (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Woo authored Dec 20, 2021
1 parent 98f46da commit 86f44af
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/v0.34.x/rpc/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ func StartRPC(
// caching middleware
apiSrv.Router.Use(func(next http.Handler) http.Handler {
return http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
height, err := strconv.ParseInt(request.URL.Query().Get("height"), 10, 64)
heightQuery := request.URL.Query().Get("height")
height, err := strconv.ParseInt(heightQuery, 10, 64)

// don't use archival cache if height is 0 or error
if err == nil && height > 0 {
// GRPC query parses height from header
request.Header.Add("x-cosmos-block-height", heightQuery)
archivalCache.HandleCachedHTTP(writer, request, next)
} else {
cache.HandleCachedHTTP(writer, request, next)
Expand Down

0 comments on commit 86f44af

Please sign in to comment.