|
| 1 | +package litrpc |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/lightninglabs/faraday/frdrpc" |
| 5 | + "github.com/lightninglabs/loop/looprpc" |
| 6 | + "github.com/lightninglabs/pool/poolrpc" |
| 7 | + "github.com/lightningnetwork/lnd/lnrpc" |
| 8 | + "google.golang.org/grpc" |
| 9 | +) |
| 10 | + |
| 11 | +// LitdClient is an interface that can be used to access all the subservers |
| 12 | +// of Litd. |
| 13 | +type LitdClient interface { |
| 14 | + // Lnd returns an lnrpc.LightingClient implementation. |
| 15 | + Lnd() lnrpc.LightningClient |
| 16 | + |
| 17 | + // Loop returns a looprpc.SwapClientClient implementation. |
| 18 | + Loop() looprpc.SwapClientClient |
| 19 | + |
| 20 | + // Pool returns a poolrpc.TraderClient implementation. |
| 21 | + Pool() poolrpc.TraderClient |
| 22 | + |
| 23 | + // Faraday returns a frdrpc.FaradayServerClient implementation. |
| 24 | + Faraday() frdrpc.FaradayServerClient |
| 25 | +} |
| 26 | + |
| 27 | +// client is an implementation of the LitdClient. |
| 28 | +type client struct { |
| 29 | + lnd lnrpc.LightningClient |
| 30 | + loop looprpc.SwapClientClient |
| 31 | + pool poolrpc.TraderClient |
| 32 | + faraday frdrpc.FaradayServerClient |
| 33 | +} |
| 34 | + |
| 35 | +// Lnd returns an lnrpc.LightingClient implementation. |
| 36 | +func (c *client) Lnd() lnrpc.LightningClient { |
| 37 | + return c.lnd |
| 38 | +} |
| 39 | + |
| 40 | +// Loop returns a looprpc.SwapClientClient implementation. |
| 41 | +func (c *client) Loop() looprpc.SwapClientClient { |
| 42 | + return c.loop |
| 43 | +} |
| 44 | + |
| 45 | +// Pool returns a poolrpc.TraderClient implementation. |
| 46 | +func (c *client) Pool() poolrpc.TraderClient { |
| 47 | + return c.pool |
| 48 | +} |
| 49 | + |
| 50 | +// Faraday returns a frdrpc.FaradayServerClient implementation. |
| 51 | +func (c *client) Faraday() frdrpc.FaradayServerClient { |
| 52 | + return c.faraday |
| 53 | +} |
| 54 | + |
| 55 | +// NewLitdClient constructs a new LitdClient from the passed grpc ClientConn. |
| 56 | +func NewLitdClient(cc grpc.ClientConnInterface) LitdClient { |
| 57 | + return &client{ |
| 58 | + lnd: lnrpc.NewLightningClient(cc), |
| 59 | + loop: looprpc.NewSwapClientClient(cc), |
| 60 | + pool: poolrpc.NewTraderClient(cc), |
| 61 | + faraday: frdrpc.NewFaradayServerClient(cc), |
| 62 | + } |
| 63 | +} |
0 commit comments