Skip to content

Commit 5e03af2

Browse files
committed
rpc+rfq: populate expiry field in BuyOder
Populate the expiry timestamp field in BuyOder and use type `time.Time`.
1 parent 5309183 commit 5e03af2

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

rfq/manager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ func (m *Manager) UpsertAssetBuyOffer(offer BuyOffer) error {
689689
}
690690

691691
// BuyOrder instructs the RFQ (Request For Quote) system to request a quote from
692-
// a peer for the acquisition of an asset.
692+
// one or more peers for the acquisition of an asset.
693693
//
694694
// The normal use of a buy order is as follows:
695695
// 1. Alice, operating a wallet node, wants to receive a Tap asset as payment
@@ -715,8 +715,8 @@ type BuyOrder struct {
715715
// be willing to offer.
716716
AssetMaxAmt uint64
717717

718-
// Expiry is the unix timestamp at which the buy order expires.
719-
Expiry uint64
718+
// Expiry is the time at which the order expires.
719+
Expiry time.Time
720720

721721
// Peer is the peer that the buy order is intended for. This field is
722722
// optional.

rfq/negotiator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ func (n *Negotiator) HandleOutgoingBuyOrder(buyOrder BuyOrder) error {
176176
buyOrder.AssetSpecifier.IsSome() {
177177

178178
// Query the price oracle for a bid price.
179+
//
180+
// TODO(ffranr): Pass the BuyOrder expiry to the price
181+
// oracle at this point.
179182
assetRate, err := n.queryBidFromPriceOracle(
180183
buyOrder.AssetSpecifier,
181184
fn.Some(buyOrder.AssetMaxAmt),

rpcserver.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6314,10 +6314,17 @@ func unmarshalAssetBuyOrder(
63146314
err)
63156315
}
63166316

6317+
// Convert expiry unix timestamp in seconds to time.Time.
6318+
if req.Expiry > math.MaxInt64 {
6319+
return nil, fmt.Errorf("expiry must be less than or equal to "+
6320+
"math.MaxInt64 (expiry=%d)", req.Expiry)
6321+
}
6322+
expiry := time.Unix(int64(req.Expiry), 0).UTC()
6323+
63176324
return &rfq.BuyOrder{
63186325
AssetSpecifier: assetSpecifier,
63196326
AssetMaxAmt: req.AssetMaxAmt,
6320-
Expiry: req.Expiry,
6327+
Expiry: expiry,
63216328
Peer: fn.MaybeSome(peer),
63226329
}, nil
63236330
}

0 commit comments

Comments
 (0)