From 690cb92bad8ed152b4eb24e2989f857cbff63f0c Mon Sep 17 00:00:00 2001 From: Jeff Woo Date: Fri, 17 Dec 2021 16:04:20 +0900 Subject: [PATCH] feat: set height header for GRPC query --- bin/v0.34.x/rpc/register.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/v0.34.x/rpc/register.go b/bin/v0.34.x/rpc/register.go index 48d315c..066fc3d 100644 --- a/bin/v0.34.x/rpc/register.go +++ b/bin/v0.34.x/rpc/register.go @@ -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)