rpcserver: marshall channel type in order list

This commit is contained in:
Oliver Gugger 2022-03-28 15:46:34 +02:00
parent a85a4ae60e
commit e8a0127c7d
No known key found for this signature in database
GPG key ID: 8E4256593F177720

View file

@ -1533,6 +1533,9 @@ func (s *rpcServer) ListOrders(ctx context.Context,
CreationTimestampNs: uint64(evt.Timestamp().UnixNano()),
Events: rpcEvents,
MinUnitsMatch: uint32(dbOrder.Details().MinUnitsMatch),
ChannelType: marshallChannelType(
dbOrder.Details().ChannelType,
),
}
switch o := dbOrder.(type) {
@ -2950,6 +2953,20 @@ func unmarshallNodeTier(nodeTier auctioneerrpc.NodeTier) (order.NodeTier,
}
}
// marshallChannelType maps the channel type into the RPC counterpart.
func marshallChannelType(
channelType order.ChannelType) auctioneerrpc.OrderChannelType {
switch channelType {
case order.ChannelTypePeerDependent:
return auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_PEER_DEPENDENT
case order.ChannelTypeScriptEnforced:
return auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_SCRIPT_ENFORCED
default:
return auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_UNKNOWN
}
}
// marshallChannelInfo turns the given channel information map into its RPC
// counterpart.
func marshallChannelInfo(chanInfos map[wire.OutPoint]*chaninfo.ChannelInfo) (