Skip to content

Commit

Permalink
CR's fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Oct 11, 2023
1 parent 83fb11d commit 0e0018f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions service/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/kava-labs/kava-proxy-service/config"
"github.com/kava-labs/kava-proxy-service/decode"
"github.com/kava-labs/kava-proxy-service/logging"
"github.com/kava-labs/kava-proxy-service/service/cachemdw"
)

const (
Expand Down Expand Up @@ -228,8 +229,11 @@ func createProxyRequestMiddleware(next http.Handler, config config.Config, servi
serviceLogger.Trace().Msg("request body is empty, skipping before request interceptors")
}

// proxy request to backend origin servers
proxy.ServeHTTP(lrw, r)
// Only proxy the request if it's not cached
isCached := cachemdw.IsRequestCached(r.Context())
if !isCached {
proxy.ServeHTTP(lrw, r)
}

serviceLogger.Trace().Msg(fmt.Sprintf("response %+v \nheaders %+v \nstatus %+v for request %+v", lrw.Status(), lrw.Header(), lrw.body, r))

Expand Down Expand Up @@ -383,6 +387,7 @@ func createAfterProxyFinalizer(service *ProxyService, config config.Config) http
}

var blockNumber *int64
// TODO: Redundant ExtractBlockNumberFromEVMRPCRequest call here if request is cached
rawBlockNumber, err := decodedRequestBody.ExtractBlockNumberFromEVMRPCRequest(r.Context(), service.evmClient)

if err != nil {
Expand Down

0 comments on commit 0e0018f

Please sign in to comment.