Skip to content

Commit 4197df0

Browse files
committed
rfq+taprpc: add 'public' oracle error flag
Adds a flag (defaulting to false) that indicates that the error returned by a price oracle should be considered public, and can be safely forwarded to peers. Updates proto definitions accordingly.
1 parent 0844915 commit 4197df0

File tree

5 files changed

+77
-49
lines changed

5 files changed

+77
-49
lines changed

rfq/negotiator.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,12 @@ func customRejectErr(err error) rfqmsg.RejectErr {
556556
return rfqmsg.ErrUnknownReject
557557
}
558558

559+
// If the price oracle has indicated that this error should not be
560+
// forwarded to peers, then return an opaque rejection error.
561+
if !oracleError.Public {
562+
return rfqmsg.ErrUnknownReject
563+
}
564+
559565
switch oracleError.Code {
560566
// The price oracle has indicated that it doesn't support the asset,
561567
// so return a rejection error indicating that.

rfq/oracle.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ type OracleError struct {
8989
// Code is a code which uniquely identifies the error type.
9090
Code OracleErrorCode
9191

92+
// Public is a flag that indicates the error can be relayed to
93+
// peers.
94+
Public bool
95+
9296
// Msg is a human-readable error message.
9397
Msg string
9498
}
@@ -395,8 +399,9 @@ func (r *RpcPriceOracle) QuerySellPrice(ctx context.Context,
395399

396400
return &OracleResponse{
397401
Err: &OracleError{
398-
Msg: result.Error.Message,
399-
Code: marshallErrorCode(result.Error.Code),
402+
Msg: result.Error.Message,
403+
Public: result.Error.Public,
404+
Code: marshallErrorCode(result.Error.Code),
400405
},
401406
}, nil
402407

taprpc/priceoraclerpc/price_oracle.pb.go

Lines changed: 56 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

taprpc/priceoraclerpc/price_oracle.proto

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,11 @@ message QueryAssetRatesErrResponse {
238238
// error is the error message.
239239
string message = 1;
240240

241+
// public is a flag indicating that the error can be forwarded to peers.
242+
bool public = 2;
243+
241244
// code is the error code.
242-
ErrorCode code = 2;
245+
ErrorCode code = 3;
243246
}
244247

245248
// QueryAssetRatesResponse is the response from a QueryAssetRates RPC call.

taprpc/priceoraclerpc/price_oracle.swagger.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@
289289
"type": "string",
290290
"description": "error is the error message."
291291
},
292+
"public": {
293+
"type": "boolean",
294+
"description": "public is a flag indicating that the error can be forwarded to peers."
295+
},
292296
"code": {
293297
"$ref": "#/definitions/priceoraclerpcErrorCode",
294298
"description": "code is the error code."

0 commit comments

Comments
 (0)