diff --git a/protocol/common/endpoints.go b/protocol/common/endpoints.go index 16777b3387..99cd6504ac 100644 --- a/protocol/common/endpoints.go +++ b/protocol/common/endpoints.go @@ -260,6 +260,7 @@ type RelayResult struct { StatusCode int Quorum int ProviderTrailer metadata.MD // the provider trailer attached to the request. used to transfer useful information (which is not signed so shouldn't be trusted completely). + IsNodeError bool } func (rr *RelayResult) GetReplyServer() pairingtypes.Relayer_RelaySubscribeClient { diff --git a/protocol/rpcconsumer/rpcconsumer_server.go b/protocol/rpcconsumer/rpcconsumer_server.go index 0166ffde47..b9ece3956b 100644 --- a/protocol/rpcconsumer/rpcconsumer_server.go +++ b/protocol/rpcconsumer/rpcconsumer_server.go @@ -757,9 +757,9 @@ func (rpccs *RPCConsumerServer) sendRelayToProvider( } errResponse = rpccs.consumerSessionManager.OnSessionDone(singleConsumerSession, latestBlock, chainlib.GetComputeUnits(protocolMessage), relayLatency, singleConsumerSession.CalculateExpectedLatency(expectedRelayTimeoutForQOS), expectedBH, numOfProviders, pairingAddressesLen, protocolMessage.GetApi().Category.HangingApi) // session done successfully - + isNodeError, _ := protocolMessage.CheckResponseError(localRelayResult.Reply.Data, localRelayResult.StatusCode) + localRelayResult.IsNodeError = isNodeError if rpccs.cache.CacheActive() && rpcclient.ValidateStatusCodes(localRelayResult.StatusCode, true) == nil { - isNodeError, _ := protocolMessage.CheckResponseError(localRelayResult.Reply.Data, localRelayResult.StatusCode) // in case the error is a node error we don't want to cache if !isNodeError { // copy reply data so if it changes it doesn't panic mid async send @@ -1314,8 +1314,7 @@ func (rpccs *RPCConsumerServer) appendHeadersToRelayResult(ctx context.Context, }) // add is node error flag - isNodeError, _ := protocolMessage.CheckResponseError(relayResult.Reply.Data, relayResult.StatusCode) - if isNodeError { + if relayResult.IsNodeError { metadataReply = append(metadataReply, pairingtypes.Metadata{ Name: common.LAVA_IDENTIFIED_NODE_ERROR_HEADER,