Skip to content

Commit 82f9246

Browse files
committed
hyperloop: create hyperloop package
This commit adds the initial logger and interfaces to the hyperloop package.
1 parent 7037ecb commit 82f9246

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

hyperloop/interfaces.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package hyperloop
2+
3+
import (
4+
"context"
5+
6+
"github.com/btcsuite/btcd/btcutil"
7+
)
8+
9+
// Store is the interface that stores the hyperloop.
10+
type Store interface {
11+
// CreateHyperloop stores the hyperloop in the database.
12+
CreateHyperloop(ctx context.Context, hyperloop *Hyperloop) error
13+
14+
// UpdateHyperloop updates the hyperloop in the database.
15+
UpdateHyperloop(ctx context.Context, hyperloop *Hyperloop) error
16+
17+
// CreateHyperloopParticipant stores the hyperloop participant in the
18+
// database.
19+
CreateHyperloopParticipant(ctx context.Context,
20+
participant *HyperloopParticipant) error
21+
22+
// UpdateHyperloopParticipant updates the hyperloop participant in the
23+
// database.
24+
UpdateHyperloopParticipant(ctx context.Context,
25+
participant *HyperloopParticipant) error
26+
27+
// GetHyperloop retrieves the hyperloop from the database.
28+
GetHyperloop(ctx context.Context, id ID) (*Hyperloop, error)
29+
30+
// ListHyperloops lists all existing hyperloops the client has ever
31+
// made.
32+
ListHyperloops(ctx context.Context) ([]*Hyperloop, error)
33+
}
34+
35+
type HyperloopManager interface {
36+
fetchHyperLoopTotalSweepAmt(hyperloopID ID,
37+
sweepAddr btcutil.Address) (btcutil.Amount, error)
38+
}

hyperloop/log.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package hyperloop
2+
3+
import (
4+
"github.com/btcsuite/btclog"
5+
"github.com/lightningnetwork/lnd/build"
6+
)
7+
8+
// Subsystem defines the sub system name of this package.
9+
const Subsystem = "HYPRL"
10+
11+
// log is a logger that is initialized with no output filters. This
12+
// means the package will not perform any logging by default until the caller
13+
// requests it.
14+
var log btclog.Logger
15+
16+
// The default amount of logging is none.
17+
func init() {
18+
UseLogger(build.NewSubLogger(Subsystem, nil))
19+
}
20+
21+
// UseLogger uses a specified Logger to output package logging info.
22+
// This should be used in preference to SetLogWriter if the caller is also
23+
// using btclog.
24+
func UseLogger(logger btclog.Logger) {
25+
log = logger
26+
}

loopd/log.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/lightninglabs/lndclient"
77
"github.com/lightninglabs/loop"
88
"github.com/lightninglabs/loop/fsm"
9+
"github.com/lightninglabs/loop/hyperloop"
910
"github.com/lightninglabs/loop/instantout"
1011
"github.com/lightninglabs/loop/instantout/reservation"
1112
"github.com/lightninglabs/loop/liquidity"
@@ -54,6 +55,9 @@ func SetupLoggers(root *build.RotatingLogWriter, intercept signal.Interceptor) {
5455
lnd.AddSubLogger(
5556
root, sweep.Subsystem, intercept, sweep.UseLogger,
5657
)
58+
lnd.AddSubLogger(
59+
root, hyperloop.Subsystem, intercept, hyperloop.UseLogger,
60+
)
5761
}
5862

5963
// genSubLogger creates a logger for a subsystem. We provide an instance of

0 commit comments

Comments
 (0)