Skip to content

Commit

Permalink
chore: include esplora url in sync failed events (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz authored Jul 25, 2024
1 parent 570ca78 commit 6b1aa0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
25 changes: 14 additions & 11 deletions lnclient/ldk/ldk.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type LDKService struct {

const resetRouterKey = "ResetRouter"

func NewLDKService(ctx context.Context, cfg config.Config, eventPublisher events.EventPublisher, mnemonic, workDir string, network string, esploraServer string, gossipSource string) (result lnclient.LNClient, err error) {
func NewLDKService(ctx context.Context, cfg config.Config, eventPublisher events.EventPublisher, mnemonic, workDir string, network string) (result lnclient.LNClient, err error) {
if mnemonic == "" || workDir == "" {
return nil, errors.New("one or more required LDK configuration are missing")
}
Expand Down Expand Up @@ -103,10 +103,10 @@ func NewLDKService(ctx context.Context, cfg config.Config, eventPublisher events
builder := ldk_node.BuilderFromConfig(ldkConfig)
builder.SetEntropyBip39Mnemonic(mnemonic, nil)
builder.SetNetwork(network)
builder.SetEsploraServer(esploraServer)
if gossipSource != "" {
logger.Logger.WithField("gossipSource", gossipSource).Warn("LDK RGS instance set")
builder.SetGossipSourceRgs(gossipSource)
builder.SetEsploraServer(cfg.GetEnv().LDKEsploraServer)
if cfg.GetEnv().LDKGossipSource != "" {
logger.Logger.WithField("gossipSource", cfg.GetEnv().LDKGossipSource).Warn("LDK RGS instance set")
builder.SetGossipSourceRgs(cfg.GetEnv().LDKGossipSource)
} else {
logger.Logger.Warn("No LDK RGS instance set")
}
Expand Down Expand Up @@ -202,6 +202,7 @@ func NewLDKService(ctx context.Context, cfg config.Config, eventPublisher events
"sync_type": "full",
"initial_sync": true,
"node_type": config.LDKBackendType,
"esplora_url": ls.cfg.GetEnv().LDKEsploraServer,
},
})

Expand Down Expand Up @@ -268,9 +269,10 @@ func NewLDKService(ctx context.Context, cfg config.Config, eventPublisher events
ls.eventPublisher.Publish(&events.Event{
Event: "nwc_node_sync_failed",
Properties: map[string]interface{}{
"error": err.Error(),
"sync_type": "fee_estimates",
"node_type": config.LDKBackendType,
"error": err.Error(),
"sync_type": "fee_estimates",
"node_type": config.LDKBackendType,
"esplora_url": ls.cfg.GetEnv().LDKEsploraServer,
},
})
}
Expand All @@ -289,9 +291,10 @@ func NewLDKService(ctx context.Context, cfg config.Config, eventPublisher events
ls.eventPublisher.Publish(&events.Event{
Event: "nwc_node_sync_failed",
Properties: map[string]interface{}{
"error": err.Error(),
"sync_type": "full",
"node_type": config.LDKBackendType,
"error": err.Error(),
"sync_type": "full",
"node_type": config.LDKBackendType,
"esplora_url": ls.cfg.GetEnv().LDKEsploraServer,
},
})

Expand Down
2 changes: 1 addition & 1 deletion service/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (svc *service) launchLNBackend(ctx context.Context, encryptionKey string) e
Mnemonic, _ := svc.cfg.Get("Mnemonic", encryptionKey)
LDKWorkdir := path.Join(svc.cfg.GetEnv().Workdir, "ldk")

lnClient, err = ldk.NewLDKService(ctx, svc.cfg, svc.eventPublisher, Mnemonic, LDKWorkdir, svc.cfg.GetEnv().LDKNetwork, svc.cfg.GetEnv().LDKEsploraServer, svc.cfg.GetEnv().LDKGossipSource)
lnClient, err = ldk.NewLDKService(ctx, svc.cfg, svc.eventPublisher, Mnemonic, LDKWorkdir, svc.cfg.GetEnv().LDKNetwork)
case config.GreenlightBackendType:
Mnemonic, _ := svc.cfg.Get("Mnemonic", encryptionKey)
GreenlightInviteCode, _ := svc.cfg.Get("GreenlightInviteCode", encryptionKey)
Expand Down

0 comments on commit 6b1aa0e

Please sign in to comment.