liquidity: move loopout swap suggestion out of interface file

This commit is contained in:
carla 2021-09-06 14:05:39 +02:00
parent 7ac6e26e90
commit 4df6a4e7ca
No known key found for this signature in database
GPG key ID: 4CA7FE54A6213C91
2 changed files with 66 additions and 52 deletions

View file

@ -50,55 +50,3 @@ type swapSuggestion interface {
// can be looked up.
peers(knownChans map[uint64]route.Vertex) []route.Vertex
}
// Compile-time assertion that loopOutSwapSuggestion satisfies the
// swapSuggestion interface.
var _ swapSuggestion = (*loopOutSwapSuggestion)(nil)
type loopOutSwapSuggestion struct {
loop.OutRequest
}
func (l *loopOutSwapSuggestion) amount() btcutil.Amount {
return l.Amount
}
func (l *loopOutSwapSuggestion) fees() btcutil.Amount {
return worstCaseOutFees(
l.MaxPrepayRoutingFee, l.MaxSwapRoutingFee, l.MaxSwapFee,
l.MaxMinerFee, l.MaxPrepayAmount,
)
}
func (l *loopOutSwapSuggestion) channels() []lnwire.ShortChannelID {
channels := make([]lnwire.ShortChannelID, len(l.OutgoingChanSet))
for i, id := range l.OutgoingChanSet {
channels[i] = lnwire.NewShortChanIDFromInt(id)
}
return channels
}
// peers returns the set of peers that the loop out swap is restricted to.
func (l *loopOutSwapSuggestion) peers(
knownChans map[uint64]route.Vertex) []route.Vertex {
peers := make(map[route.Vertex]struct{}, len(knownChans))
for _, channel := range l.OutgoingChanSet {
peer, ok := knownChans[channel]
if !ok {
log.Warnf("peer for channel: %v unknown", channel)
}
peers[peer] = struct{}{}
}
peerList := make([]route.Vertex, 0, len(peers))
for peer := range peers {
peerList = append(peerList, peer)
}
return peerList
}