Skip to content

Commit

Permalink
Adding kv pairs to metadata now only happens if client is in grpc mode
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhuie19 committed Jun 11, 2024
1 parent e6773d3 commit bd6865b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions core/services/relay/evm/mercury/wsrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bd6865b

Please sign in to comment.