mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
interface: create a new Litd Client interface
This commit is contained in:
parent
6de34a89e2
commit
f3d2aeb00a
1 changed files with 63 additions and 0 deletions
63
litrpc/interface.go
Normal file
63
litrpc/interface.go
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
package litrpc
|
||||
|
||||
import (
|
||||
"github.com/lightninglabs/faraday/frdrpc"
|
||||
"github.com/lightninglabs/loop/looprpc"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// LitdClient is an interface that can be used to access all the subservers
|
||||
// of Litd.
|
||||
type LitdClient interface {
|
||||
// Lnd returns an lnrpc.LightingClient implementation.
|
||||
Lnd() lnrpc.LightningClient
|
||||
|
||||
// Loop returns a looprpc.SwapClientClient implementation.
|
||||
Loop() looprpc.SwapClientClient
|
||||
|
||||
// Pool returns a poolrpc.TraderClient implementation.
|
||||
Pool() poolrpc.TraderClient
|
||||
|
||||
// Faraday returns a frdrpc.FaradayServerClient implementation.
|
||||
Faraday() frdrpc.FaradayServerClient
|
||||
}
|
||||
|
||||
// client is an implementation of the LitdClient.
|
||||
type client struct {
|
||||
lnd lnrpc.LightningClient
|
||||
loop looprpc.SwapClientClient
|
||||
pool poolrpc.TraderClient
|
||||
faraday frdrpc.FaradayServerClient
|
||||
}
|
||||
|
||||
// Lnd returns an lnrpc.LightingClient implementation.
|
||||
func (c *client) Lnd() lnrpc.LightningClient {
|
||||
return c.lnd
|
||||
}
|
||||
|
||||
// Loop returns a looprpc.SwapClientClient implementation.
|
||||
func (c *client) Loop() looprpc.SwapClientClient {
|
||||
return c.loop
|
||||
}
|
||||
|
||||
// Pool returns a poolrpc.TraderClient implementation.
|
||||
func (c *client) Pool() poolrpc.TraderClient {
|
||||
return c.pool
|
||||
}
|
||||
|
||||
// Faraday returns a frdrpc.FaradayServerClient implementation.
|
||||
func (c *client) Faraday() frdrpc.FaradayServerClient {
|
||||
return c.faraday
|
||||
}
|
||||
|
||||
// NewLitdClient constructs a new LitdClient from the passed grpc ClientConn.
|
||||
func NewLitdClient(cc grpc.ClientConnInterface) LitdClient {
|
||||
return &client{
|
||||
lnd: lnrpc.NewLightningClient(cc),
|
||||
loop: looprpc.NewSwapClientClient(cc),
|
||||
pool: poolrpc.NewTraderClient(cc),
|
||||
faraday: frdrpc.NewFaradayServerClient(cc),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue