notifications: host notifications server

This commit is contained in:
Jesse de Wit
2023-06-15 12:55:58 +02:00
parent 5aa1c4ea28
commit d128848456
2 changed files with 9 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/breez/lspd/config" "github.com/breez/lspd/config"
"github.com/breez/lspd/lightning" "github.com/breez/lspd/lightning"
"github.com/breez/lspd/lnd" "github.com/breez/lspd/lnd"
"github.com/breez/lspd/notifications"
lspdrpc "github.com/breez/lspd/rpc" lspdrpc "github.com/breez/lspd/rpc"
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/caddyserver/certmagic" "github.com/caddyserver/certmagic"
@@ -32,6 +33,7 @@ type grpcServer struct {
s *grpc.Server s *grpc.Server
nodes map[string]*node nodes map[string]*node
c lspdrpc.ChannelOpenerServer c lspdrpc.ChannelOpenerServer
n notifications.NotificationsServer
} }
type nodeContext struct { type nodeContext struct {
@@ -54,6 +56,7 @@ func NewGrpcServer(
address string, address string,
certmagicDomain string, certmagicDomain string,
c lspdrpc.ChannelOpenerServer, c lspdrpc.ChannelOpenerServer,
n notifications.NotificationsServer,
) (*grpcServer, error) { ) (*grpcServer, error) {
if len(configs) == 0 { if len(configs) == 0 {
return nil, fmt.Errorf("no nodes supplied") return nil, fmt.Errorf("no nodes supplied")
@@ -115,6 +118,7 @@ func NewGrpcServer(
certmagicDomain: certmagicDomain, certmagicDomain: certmagicDomain,
nodes: nodes, nodes: nodes,
c: c, c: c,
n: n,
}, nil }, nil
} }
@@ -178,6 +182,7 @@ func (s *grpcServer) Start() error {
}), }),
) )
lspdrpc.RegisterChannelOpenerServer(srv, s.c) lspdrpc.RegisterChannelOpenerServer(srv, s.c)
notifications.RegisterNotificationsServer(srv, s.n)
s.s = srv s.s = srv
s.lis = lis s.lis = lis

View File

@@ -16,6 +16,7 @@ import (
"github.com/breez/lspd/interceptor" "github.com/breez/lspd/interceptor"
"github.com/breez/lspd/lnd" "github.com/breez/lspd/lnd"
"github.com/breez/lspd/mempool" "github.com/breez/lspd/mempool"
"github.com/breez/lspd/notifications"
"github.com/breez/lspd/postgresql" "github.com/breez/lspd/postgresql"
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
) )
@@ -77,6 +78,7 @@ func main() {
interceptStore := postgresql.NewPostgresInterceptStore(pool) interceptStore := postgresql.NewPostgresInterceptStore(pool)
forwardingStore := postgresql.NewForwardingEventStore(pool) forwardingStore := postgresql.NewForwardingEventStore(pool)
notificationsStore := postgresql.NewNotificationsStore(pool)
var interceptors []interceptor.HtlcInterceptor var interceptors []interceptor.HtlcInterceptor
for _, node := range nodes { for _, node := range nodes {
@@ -118,7 +120,8 @@ func main() {
address := os.Getenv("LISTEN_ADDRESS") address := os.Getenv("LISTEN_ADDRESS")
certMagicDomain := os.Getenv("CERTMAGIC_DOMAIN") certMagicDomain := os.Getenv("CERTMAGIC_DOMAIN")
cs := NewChannelOpenerServer(interceptStore) cs := NewChannelOpenerServer(interceptStore)
s, err := NewGrpcServer(nodes, address, certMagicDomain, cs) ns := notifications.NewNotificationsServer(notificationsStore)
s, err := NewGrpcServer(nodes, address, certMagicDomain, cs, ns)
if err != nil { if err != nil {
log.Fatalf("failed to initialize grpc server: %v", err) log.Fatalf("failed to initialize grpc server: %v", err)
} }