Skip to content

Commit 8160525

Browse files
committed
hyperloop: create hyperloop package
This commit adds the initial logger and interfaces to the hyperloop package.
1 parent 35d27fa commit 8160525

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

hyperloop/interfaces.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package hyperloop
2+
3+
import (
4+
"context"
5+
6+
"github.com/lightninglabs/lndclient"
7+
"github.com/lightningnetwork/lnd/input"
8+
"github.com/lightningnetwork/lnd/keychain"
9+
)
10+
11+
// Store is the interface that stores the hyperloop.
12+
type Store interface {
13+
// CreateHyperloop stores the hyperloop in the database.
14+
CreateHyperloop(ctx context.Context, hyperloop *HyperLoop) error
15+
16+
// UpdateHyperloop updates the hyperloop in the database.
17+
UpdateHyperloop(ctx context.Context, hyperloop *HyperLoop) error
18+
19+
// CreateHyperloopParticipant stores the hyperloop participant in the
20+
// database.
21+
CreateHyperloopParticipant(ctx context.Context,
22+
participant *HyperLoopParticipant) error
23+
24+
// UpdateHyperloopParticipant updates the hyperloop participant in the
25+
// database.
26+
UpdateHyperloopParticipant(ctx context.Context,
27+
participant *HyperLoopParticipant) error
28+
29+
// GetHyperloop retrieves the hyperloop from the database.
30+
GetHyperloop(ctx context.Context, id ID) (*HyperLoop, error)
31+
32+
// ListHyperloops lists all existing hyperloops the client has ever
33+
// made.
34+
ListHyperloops(ctx context.Context) ([]*HyperLoop, error)
35+
}
36+
37+
type Wallet interface {
38+
DeriveNextKey(ctx context.Context, family int32) (
39+
*keychain.KeyDescriptor, error)
40+
}
41+
type Musig2Signer interface {
42+
MuSig2Sign(ctx context.Context, sessionID [32]byte,
43+
message [32]byte, cleanup bool) ([]byte, error)
44+
45+
MuSig2CreateSession(ctx context.Context, version input.MuSig2Version,
46+
signerLoc *keychain.KeyLocator, signers [][]byte,
47+
opts ...lndclient.MuSig2SessionOpts) (*input.MuSig2SessionInfo, error)
48+
49+
MuSig2RegisterNonces(ctx context.Context, sessionID [32]byte,
50+
nonces [][66]byte) (bool, error)
51+
}

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: 5 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"
@@ -48,6 +49,10 @@ func SetupLoggers(root *build.RotatingLogWriter, intercept signal.Interceptor) {
4849
lnd.AddSubLogger(
4950
root, instantout.Subsystem, intercept, instantout.UseLogger,
5051
)
52+
53+
lnd.AddSubLogger(
54+
root, hyperloop.Subsystem, intercept, hyperloop.UseLogger,
55+
)
5156
}
5257

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

0 commit comments

Comments
 (0)