Skip to content

Commit 42c07a5

Browse files
committed
rfq+rpcserver: rename helper methods/structs for readability
We rename some of the existing structures or helper methods to be shorter and more directly indicate their purpose.
1 parent 945fdd3 commit 42c07a5

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

rfq/manager.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ func (m *Manager) addScidAlias(scidAlias uint64, assetSpecifier asset.Specifier,
553553
peer route.Vertex) error {
554554

555555
ctxb := context.Background()
556-
peerChans, err := m.RfqChannel(
556+
peerChans, err := m.FetchChannel(
557557
ctxb, assetSpecifier, &peer, NoIntention,
558558
)
559559
if err != nil && !strings.Contains(
@@ -568,7 +568,7 @@ func (m *Manager) addScidAlias(scidAlias uint64, assetSpecifier asset.Specifier,
568568
// is okay, because non-strict forwarding will ask each channel if the
569569
// bandwidth matches the provided specifier.
570570
if len(peerChans[peer]) == 0 {
571-
peerChans, err = m.RfqChannel(
571+
peerChans, err = m.FetchChannel(
572572
ctxb, asset.Specifier{}, &peer, NoIntention,
573573
)
574574
if err != nil {
@@ -1033,10 +1033,10 @@ func (m *Manager) ChannelMatchesFully(ctx context.Context,
10331033
return true, nil
10341034
}
10351035

1036-
// ChannelWithSpecifier is a helper struct that combines the information of an
1037-
// asset specifier that is satisfied by a channel with the channels' general
1036+
// TapChannel is a helper struct that combines the information of an asset
1037+
// specifier that is satisfied by a channel with the channels' general
10381038
// information.
1039-
type ChannelWithSpecifier struct {
1039+
type TapChannel struct {
10401040
// Specifier is the asset Specifier that is satisfied by this channels'
10411041
// assets.
10421042
Specifier asset.Specifier
@@ -1051,11 +1051,11 @@ type ChannelWithSpecifier struct {
10511051

10521052
// PeerChanMap is a structure that maps peers to channels. This is used for
10531053
// filtering asset channels against an asset specifier.
1054-
type PeerChanMap map[route.Vertex][]ChannelWithSpecifier
1054+
type PeerChanMap map[route.Vertex][]TapChannel
10551055

1056-
// ComputeCompatibleChannelAssetBalance computes the total local and remote
1057-
// balance for each asset channel that matches the provided asset specifier.
1058-
func (m *Manager) ComputeCompatibleChannelAssetBalance(ctx context.Context,
1056+
// ComputeChannelAssetBalance computes the total local and remote balance for
1057+
// each asset channel that matches the provided asset specifier.
1058+
func (m *Manager) ComputeChannelAssetBalance(ctx context.Context,
10591059
activeChannels []lndclient.ChannelInfo,
10601060
specifier asset.Specifier) (PeerChanMap, bool, error) {
10611061

@@ -1106,7 +1106,7 @@ func (m *Manager) ComputeCompatibleChannelAssetBalance(ctx context.Context,
11061106
if pass || !specifier.IsSome() {
11071107
peerChanMap[openChan.PubKeyBytes] = append(
11081108
peerChanMap[openChan.PubKeyBytes],
1109-
ChannelWithSpecifier{
1109+
TapChannel{
11101110
Specifier: specifier,
11111111
ChannelInfo: openChan,
11121112
AssetInfo: assetData,
@@ -1135,10 +1135,10 @@ const (
11351135
ReceiveIntention
11361136
)
11371137

1138-
// RfqChannel returns the channel to use for RFQ operations. It returns a map of
1139-
// peers and their eligible channels. If a peerPubKey is specified then the map
1140-
// will only contain one entry for that peer.
1141-
func (m *Manager) RfqChannel(ctx context.Context, specifier asset.Specifier,
1138+
// FetchChannel returns the channel to use for RFQ operations. It returns a map
1139+
// of peers and their eligible channels. If a peerPubKey is specified then the
1140+
// map will only contain one entry for that peer.
1141+
func (m *Manager) FetchChannel(ctx context.Context, specifier asset.Specifier,
11421142
peerPubKey *route.Vertex,
11431143
intention ChanIntention) (PeerChanMap, error) {
11441144

@@ -1149,8 +1149,7 @@ func (m *Manager) RfqChannel(ctx context.Context, specifier asset.Specifier,
11491149
return nil, err
11501150
}
11511151

1152-
// nolint:lll
1153-
balancesMap, haveGroupChans, err := m.ComputeCompatibleChannelAssetBalance(
1152+
balancesMap, haveGroupChans, err := m.ComputeChannelAssetBalance(
11541153
ctx, activeChannels, specifier,
11551154
)
11561155
if err != nil {

rfq/manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func assertComputeChannelAssetBalance(t *testing.T,
149149
)
150150
defer cancel()
151151

152-
chanMap, _, err := manager.ComputeCompatibleChannelAssetBalance(
152+
chanMap, _, err := manager.ComputeChannelAssetBalance(
153153
ctxt, tc.activeChannels, tc.specifier,
154154
)
155155
require.NoError(t, err)

rpcserver.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6934,7 +6934,7 @@ func (r *rpcServer) checkPeerChannel(ctx context.Context, peer route.Vertex,
69346934
// If we don't get an error here, it means we do have an asset
69356935
// channel with the peer. The intention doesn't matter as we're
69366936
// just checking whether a channel exists.
6937-
_, err := r.cfg.RfqManager.RfqChannel(
6937+
_, err := r.cfg.RfqManager.FetchChannel(
69386938
ctx, specifier, &peer, rfq.NoIntention,
69396939
)
69406940
if err != nil {
@@ -7641,7 +7641,7 @@ func (r *rpcServer) SendPayment(req *tchrpc.SendPaymentRequest,
76417641
rpcSpecifier := marshalAssetSpecifier(specifier)
76427642

76437643
// We can now query the asset channels we have.
7644-
chanMap, err := r.cfg.RfqManager.RfqChannel(
7644+
chanMap, err := r.cfg.RfqManager.FetchChannel(
76457645
ctx, specifier, peerPubKey, rfq.SendIntention,
76467646
)
76477647
if err != nil {
@@ -7776,7 +7776,7 @@ func (r *rpcServer) SendPayment(req *tchrpc.SendPaymentRequest,
77767776

77777777
// We check that we have the asset amount available in the
77787778
// channel.
7779-
_, err = r.cfg.RfqManager.RfqChannel(
7779+
_, err = r.cfg.RfqManager.FetchChannel(
77807780
ctx, specifier, &dest, rfq.SendIntention,
77817781
)
77827782
if err != nil {
@@ -8010,7 +8010,7 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
80108010
}
80118011

80128012
// We can now query the asset channels we have.
8013-
chanMap, err := r.cfg.RfqManager.RfqChannel(
8013+
chanMap, err := r.cfg.RfqManager.FetchChannel(
80148014
ctx, specifier, peerPubKey, rfq.ReceiveIntention,
80158015
)
80168016
if err != nil {
@@ -8044,7 +8044,7 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
80448044
type quoteWithInfo struct {
80458045
quote *rfqrpc.PeerAcceptedBuyQuote
80468046
rate *rfqmath.BigIntFixedPoint
8047-
channel rfq.ChannelWithSpecifier
8047+
channel rfq.TapChannel
80488048
}
80498049

80508050
var acquiredQuotes []quoteWithInfo

0 commit comments

Comments
 (0)