From bd6865b7318bbfb2f8b1bddd785c787b9ef2fadd Mon Sep 17 00:00:00 2001 From: patrickhuie19 Date: Wed, 24 Apr 2024 13:17:54 -0400 Subject: [PATCH] Adding kv pairs to metadata now only happens if client is in grpc mode --- .../relay/evm/mercury/wsrpc/client.go | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/core/services/relay/evm/mercury/wsrpc/client.go b/core/services/relay/evm/mercury/wsrpc/client.go index 06e30c1e0ef..1aa674f1958 100644 --- a/core/services/relay/evm/mercury/wsrpc/client.go +++ b/core/services/relay/evm/mercury/wsrpc/client.go @@ -384,11 +384,13 @@ func (w *client) Transmit(ctx context.Context, req *pb.TransmitRequest) (resp *p return nil, errors.Wrap(err, "Transmit call failed") } - signature, err := w.Sign(req) - if err != nil { - return nil, errors.Wrap(err, "Transmit call failed") + if w.tlsCertFile != nil { + signature, err := w.Sign(req) + if err != nil { + return nil, errors.Wrap(err, "Transmit call failed") + } + ctx = metadata.AppendToOutgoingContext(ctx, "csa-key", w.csaKey.PublicKeyString(), "signature", signature) } - ctx = metadata.AppendToOutgoingContext(ctx, "csa-key", w.csaKey.PublicKeyString(), "signature", signature) resp, err = w.rawClient.Transmit(ctx, req) w.handleTimeout(err) if err != nil { @@ -442,11 +444,13 @@ func (w *client) LatestReport(ctx context.Context, req *pb.LatestReportRequest) return nil, errors.Wrap(err, "LatestReport failed") } - signature, err := w.Sign(req) - if err != nil { - return nil, errors.Wrap(err, "Transmit call failed") + if w.tlsCertFile != nil { + signature, err := w.Sign(req) + if err != nil { + return nil, errors.Wrap(err, "Transmit call failed") + } + ctx = metadata.AppendToOutgoingContext(ctx, "csa-key", w.csaKey.PublicKeyString(), "signature", signature) } - ctx = metadata.AppendToOutgoingContext(ctx, "csa-key", w.csaKey.PublicKeyString(), "signature", signature) var cached bool if w.cache == nil { resp, err = w.rawClient.LatestReport(ctx, req)