Skip to content

Commit 5b1aa97

Browse files
ellemoutonpositiveblue
authored andcommitted
subserver: add pool
1 parent 046ec27 commit 5b1aa97

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

subservers/pool.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package subservers
2+
3+
import (
4+
"github.com/lightninglabs/lndclient"
5+
"github.com/lightninglabs/pool"
6+
"github.com/lightninglabs/pool/poolrpc"
7+
"github.com/lightningnetwork/lnd/lnrpc"
8+
"google.golang.org/grpc"
9+
)
10+
11+
// poolSubServer implements the SubServer interface.
12+
type poolSubServer struct {
13+
*pool.Server
14+
remote bool
15+
cfg *pool.Config
16+
remoteCfg *RemoteDaemonConfig
17+
}
18+
19+
// A compile-time check to ensure that poolSubServer implements SubServer.
20+
var _ SubServer = (*poolSubServer)(nil)
21+
22+
// NewPoolSubServer returns a new pool implementation of the SubServer
23+
// interface.
24+
func NewPoolSubServer(cfg *pool.Config, remoteCfg *RemoteDaemonConfig,
25+
remote bool) SubServer {
26+
27+
return &poolSubServer{
28+
Server: pool.NewServer(cfg),
29+
cfg: cfg,
30+
remoteCfg: remoteCfg,
31+
remote: remote,
32+
}
33+
}
34+
35+
// Name returns the name of the sub-server.
36+
//
37+
// NOTE: this is part of the SubServer interface.
38+
func (p *poolSubServer) Name() string {
39+
return POOL
40+
}
41+
42+
// Remote returns true if the sub-server is running remotely and so should be
43+
// connected to instead of spinning up an integrated server.
44+
//
45+
// NOTE: this is part of the SubServer interface.
46+
func (p *poolSubServer) Remote() bool {
47+
return p.remote
48+
}
49+
50+
// RemoteConfig returns the config required to connect to the sub-server if it
51+
// is running in remote mode.
52+
//
53+
// NOTE: this is part of the SubServer interface.
54+
func (p *poolSubServer) RemoteConfig() *RemoteDaemonConfig {
55+
return p.remoteCfg
56+
}
57+
58+
// Start starts the sub-server in integrated mode.
59+
//
60+
// NOTE: this is part of the SubServer interface.
61+
func (p *poolSubServer) Start(lnClient lnrpc.LightningClient,
62+
lndGrpc *lndclient.GrpcLndServices, withMacaroonService bool) error {
63+
64+
return p.StartAsSubserver(lnClient, lndGrpc, withMacaroonService)
65+
}
66+
67+
// RegisterGrpcService must register the sub-server's GRPC server with the given
68+
// registrar.
69+
//
70+
// NOTE: this is part of the SubServer interface.
71+
func (p *poolSubServer) RegisterGrpcService(registrar grpc.ServiceRegistrar) {
72+
poolrpc.RegisterTraderServer(registrar, p)
73+
}
74+
75+
// ServerErrChan returns an error channel that should be listened on after
76+
// starting the sub-server to listen for any runtime errors. It is optional and
77+
// may be set to nil. This only applies in integrated mode.
78+
//
79+
// NOTE: this is part of the SubServer interface.
80+
func (p *poolSubServer) ServerErrChan() chan error {
81+
return nil
82+
}
83+
84+
// MacPath returns the path to the sub-server's macaroon if it is not running in
85+
// remote mode.
86+
//
87+
// NOTE: this is part of the SubServer interface.
88+
func (p *poolSubServer) MacPath() string {
89+
return p.cfg.MacaroonPath
90+
}

subservers/subserver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
const (
1414
LND string = "lnd"
1515
LIT string = "lit"
16+
POOL string = "pool"
1617
FARADAY string = "faraday"
1718
)
1819

0 commit comments

Comments
 (0)