Skip to content

Commit 56784ab

Browse files
committed
sweepbatcher: add sweep batch
1 parent 26e239c commit 56784ab

File tree

4 files changed

+1421
-0
lines changed

4 files changed

+1421
-0
lines changed

labels/lnd_labels.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const (
1717
// loopInTimeout is the label used for loop in swaps to sweep an HTLC
1818
// that has timed out.
1919
loopInSweepTimeout = "InSweepTimeout"
20+
21+
loopOutBatchSweepSuccess = "BatchOutSweepSuccess -- %d"
2022
)
2123

2224
// LoopOutSweepSuccess returns the label used for loop out swaps to sweep the
@@ -25,6 +27,11 @@ func LoopOutSweepSuccess(swapHash string) string {
2527
return fmt.Sprintf(loopdLabelPattern, loopOutSweepSuccess, swapHash)
2628
}
2729

30+
// LoopOutBatchSweepSuccess returns the label used for loop out sweep batcher.
31+
func LoopOutBatchSweepSuccess(batchID int32) string {
32+
return fmt.Sprintf(loopOutBatchSweepSuccess, batchID)
33+
}
34+
2835
// LoopInHtlcLabel returns the label used for loop in swaps to publish an HTLC.
2936
func LoopInHtlcLabel(swapHash string) string {
3037
return fmt.Sprintf(loopdLabelPattern, loopInHtlc, swapHash)

loopd/log.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/lightninglabs/loop/instantout/reservation"
1010
"github.com/lightninglabs/loop/liquidity"
1111
"github.com/lightninglabs/loop/loopdb"
12+
"github.com/lightninglabs/loop/sweepbatcher"
1213
"github.com/lightningnetwork/lnd"
1314
"github.com/lightningnetwork/lnd/build"
1415
"github.com/lightningnetwork/lnd/signal"
@@ -32,6 +33,7 @@ func SetupLoggers(root *build.RotatingLogWriter, intercept signal.Interceptor) {
3233

3334
lnd.SetSubLogger(root, Subsystem, log)
3435
lnd.AddSubLogger(root, "LOOP", intercept, loop.UseLogger)
36+
lnd.AddSubLogger(root, "SWEEP", intercept, sweepbatcher.UseLogger)
3537
lnd.AddSubLogger(root, "LNDC", intercept, lndclient.UseLogger)
3638
lnd.AddSubLogger(root, "STORE", intercept, loopdb.UseLogger)
3739
lnd.AddSubLogger(root, lsat.Subsystem, intercept, lsat.UseLogger)

sweepbatcher/log.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package sweepbatcher
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/btcsuite/btclog"
7+
"github.com/lightningnetwork/lnd/build"
8+
)
9+
10+
// log is a logger that is initialized with no output filters. This
11+
// means the package will not perform any logging by default until the
12+
// caller requests it.
13+
var log btclog.Logger
14+
15+
// The default amount of logging is none.
16+
func init() {
17+
UseLogger(build.NewSubLogger("SWEEP", nil))
18+
}
19+
20+
// batchPrefixLogger returns a logger that prefixes all log messages with the ID.
21+
func batchPrefixLogger(batchID string) btclog.Logger {
22+
return build.NewPrefixLog(fmt.Sprintf("[Batch %s]", batchID), log)
23+
}
24+
25+
// UseLogger uses a specified Logger to output package logging info.
26+
// This should be used in preference to SetLogWriter if the caller is also
27+
// using btclog.
28+
func UseLogger(logger btclog.Logger) {
29+
log = logger
30+
}

0 commit comments

Comments
 (0)