Skip to content

Commit bd77578

Browse files
committed
rfqmsg: extend IncomingMsg interface with methods MsgPeer and MsgID
This modification simplifies incoming message handling in future commits.
1 parent e3f531b commit bd77578

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

rfqmsg/buy_request.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ func (q *BuyRequest) ToWire() (WireMessage, error) {
168168
}, nil
169169
}
170170

171+
// MsgPeer returns the peer that sent the message.
172+
func (q *BuyRequest) MsgPeer() route.Vertex {
173+
return q.Peer
174+
}
175+
176+
// MsgID returns the quote request session ID.
177+
func (q *BuyRequest) MsgID() ID {
178+
return q.ID
179+
}
180+
171181
// String returns a human-readable string representation of the message.
172182
func (q *BuyRequest) String() string {
173183
var groupKeyBytes []byte

rfqmsg/messages.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ func WireMsgDataVersionDecoder(r io.Reader, val any, buf *[8]byte,
156156
// IncomingMsg is an interface that represents an inbound wire message
157157
// that has been received from a peer.
158158
type IncomingMsg interface {
159+
// MsgPeer returns the peer that sent the message.
160+
MsgPeer() route.Vertex
161+
162+
// MsgID returns the quote request session ID.
163+
MsgID() ID
164+
159165
// String returns a human-readable string representation of the message.
160166
String() string
161167
}

rfqmsg/reject.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ func (q *Reject) ToWire() (WireMessage, error) {
243243
}, nil
244244
}
245245

246+
// MsgPeer returns the peer that sent the message.
247+
func (q *Reject) MsgPeer() route.Vertex {
248+
return q.Peer
249+
}
250+
251+
// MsgID returns the quote request session ID.
252+
func (q *Reject) MsgID() ID {
253+
return q.ID
254+
}
255+
246256
// String returns a human-readable string representation of the message.
247257
func (q *Reject) String() string {
248258
return fmt.Sprintf("Reject(id=%x, err_code=%d, err_msg=%s)",

rfqmsg/sell_request.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ func (q *SellRequest) ToWire() (WireMessage, error) {
174174
}, nil
175175
}
176176

177+
// MsgPeer returns the peer that sent the message.
178+
func (q *SellRequest) MsgPeer() route.Vertex {
179+
return q.Peer
180+
}
181+
182+
// MsgID returns the quote request session ID.
183+
func (q *SellRequest) MsgID() ID {
184+
return q.ID
185+
}
186+
177187
// String returns a human-readable string representation of the message.
178188
func (q *SellRequest) String() string {
179189
var groupKeyBytes []byte

0 commit comments

Comments
 (0)