-
Notifications
You must be signed in to change notification settings - Fork 128
tools: adopt llformat formatting targets #1136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ _testmain.go | |
|
|
||
| /loop-debug | ||
| /loopd-debug | ||
| /tools/llformat | ||
|
|
||
| output*.log | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,7 @@ type TapdConfig struct { | |
| // assets daemon. | ||
| func DefaultTapdConfig() *TapdConfig { | ||
| defaultConf := tapcfg.DefaultConfig() | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you pls regenerate this commit with only the baseline and then add the lint diff as a separate commit? This'd help with just mechanical validation that the diff is indeed created with llformat.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This now contains the lint-diff only. |
||
| return &TapdConfig{ | ||
| Activate: false, | ||
| Host: "localhost:10029", | ||
|
|
@@ -83,14 +84,18 @@ func NewTapdClient(config *TapdConfig) (*TapdClient, error) { | |
|
|
||
| // Create the TapdClient. | ||
| client := &TapdClient{ | ||
| assetNameCache: make(map[string]string), | ||
| cc: conn, | ||
| cfg: config, | ||
| TaprootAssetsClient: taprpc.NewTaprootAssetsClient(conn), | ||
| TaprootAssetChannelsClient: tapchannelrpc.NewTaprootAssetChannelsClient(conn), | ||
| PriceOracleClient: priceoraclerpc.NewPriceOracleClient(conn), | ||
| RfqClient: rfqrpc.NewRfqClient(conn), | ||
| UniverseClient: universerpc.NewUniverseClient(conn), | ||
| assetNameCache: make(map[string]string), | ||
| cc: conn, | ||
| cfg: config, | ||
| TaprootAssetsClient: taprpc.NewTaprootAssetsClient(conn), | ||
| TaprootAssetChannelsClient: tapchannelrpc.NewTaprootAssetChannelsClient( | ||
| conn, | ||
| ), | ||
| PriceOracleClient: priceoraclerpc.NewPriceOracleClient( | ||
| conn, | ||
| ), | ||
| RfqClient: rfqrpc.NewRfqClient(conn), | ||
| UniverseClient: universerpc.NewUniverseClient(conn), | ||
| } | ||
|
|
||
| return client, nil | ||
|
|
@@ -104,9 +109,8 @@ func (c *TapdClient) Close() { | |
| // GetRfqForAsset returns a RFQ for the given asset with the given amount and | ||
| // to the given peer. | ||
| func (c *TapdClient) GetRfqForAsset(ctx context.Context, | ||
| satAmount btcutil.Amount, assetId, peerPubkey []byte, | ||
| expiry int64, feeLimitMultiplier float64) ( | ||
| *rfqrpc.PeerAcceptedSellQuote, error) { | ||
| satAmount btcutil.Amount, assetId, peerPubkey []byte, expiry int64, | ||
| feeLimitMultiplier float64) (*rfqrpc.PeerAcceptedSellQuote, error) { | ||
|
|
||
| // paymentMaxAmt is the maximum amount we are willing to pay for the | ||
| // payment. | ||
|
|
@@ -149,8 +153,8 @@ func (c *TapdClient) GetRfqForAsset(ctx context.Context, | |
| } | ||
|
|
||
| // GetAssetName returns the human-readable name of the asset. | ||
| func (c *TapdClient) GetAssetName(ctx context.Context, | ||
| assetId []byte) (string, error) { | ||
| func (c *TapdClient) GetAssetName(ctx context.Context, assetId []byte) (string, | ||
| error) { | ||
|
|
||
| c.assetNameMutex.Lock() | ||
| defer c.assetNameMutex.Unlock() | ||
|
|
@@ -220,13 +224,15 @@ func (c *TapdClient) GetAssetPrice(ctx context.Context, assetID string, | |
| } | ||
|
|
||
| if rfq.GetInvalidQuote() != nil { | ||
| return 0, fmt.Errorf("peer %v sent an invalid quote response %v for "+ | ||
| "asset %v", peerPubkey, rfq.GetInvalidQuote(), assetID) | ||
| return 0, fmt.Errorf("peer %v sent an invalid quote response "+ | ||
| "%v for asset %v", peerPubkey, rfq.GetInvalidQuote(), | ||
| assetID) | ||
| } | ||
|
|
||
| if rfq.GetRejectedQuote() != nil { | ||
| return 0, fmt.Errorf("peer %v rejected the quote request for "+ | ||
| "asset %v, %v", peerPubkey, assetID, rfq.GetRejectedQuote()) | ||
| "asset %v, %v", peerPubkey, assetID, | ||
| rfq.GetRejectedQuote()) | ||
| } | ||
|
|
||
| acceptedRes := rfq.GetAcceptedQuote() | ||
|
|
@@ -240,8 +246,8 @@ func (c *TapdClient) GetAssetPrice(ctx context.Context, assetID string, | |
|
|
||
| // getSatsFromAssetAmt returns the amount in satoshis for the given asset amount | ||
| // and asset rate. | ||
| func getSatsFromAssetAmt(assetAmt uint64, assetRate *rfqrpc.FixedPoint) ( | ||
| btcutil.Amount, error) { | ||
| func getSatsFromAssetAmt(assetAmt uint64, | ||
| assetRate *rfqrpc.FixedPoint) (btcutil.Amount, error) { | ||
|
|
||
| rateFP, err := rpcutils.UnmarshalRfqFixedPoint(assetRate) | ||
| if err != nil { | ||
|
|
@@ -257,8 +263,8 @@ func getSatsFromAssetAmt(assetAmt uint64, assetRate *rfqrpc.FixedPoint) ( | |
|
|
||
| // getPaymentMaxAmount returns the milisat amount we are willing to pay for the | ||
| // payment. | ||
| func getPaymentMaxAmount(satAmount btcutil.Amount, feeLimitMultiplier float64) ( | ||
| lnwire.MilliSatoshi, error) { | ||
| func getPaymentMaxAmount(satAmount btcutil.Amount, | ||
| feeLimitMultiplier float64) (lnwire.MilliSatoshi, error) { | ||
|
|
||
| if satAmount == 0 { | ||
| return 0, fmt.Errorf("satAmount cannot be zero") | ||
|
|
@@ -273,7 +279,10 @@ func getPaymentMaxAmount(satAmount btcutil.Amount, feeLimitMultiplier float64) ( | |
| // The resulting maximum amount we're willing to pay is 300k sats. | ||
| // The response asset amount will be for those 300k sats. | ||
| return lnrpc.UnmarshallAmt( | ||
| int64(satAmount.MulF64(feeLimitMultiplier)), 0, | ||
| int64( | ||
| satAmount.MulF64(feeLimitMultiplier), | ||
| ), | ||
| 0, | ||
| ) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invoking the formatter with
xargs -n 1is inefficient as it forks a new process for every single file. Formatter tools likellformattypically support multiple file arguments, so you should allowxargsto pass as many files as possible in a single invocation to improve performance.