Skip to content

Commit

Permalink
Merge pull request #434 from getAlby/remove-getinfo-lnd-cluster
Browse files Browse the repository at this point in the history
remove getinfo call when initializing cluster
  • Loading branch information
kiwiidb authored Oct 2, 2023
2 parents 5273f45 + c87ded7 commit d2d9b03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions lnd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Config struct {
LNDCertHex string `envconfig:"LND_CERT_HEX"`
LNDClusterLivenessPeriod int `envconfig:"LND_CLUSTER_LIVENESS_PERIOD" default:"10"`
LNDClusterActiveChannelRatio float64 `envconfig:"LND_CLUSTER_ACTIVE_CHANNEL_RATIO" default:"0.5"`
LNDClusterPubkeys string `envconfig:"LND_CLUSTER_PUBKEYS"` //comma-seperated list of public keys of the cluster
}

func LoadConfig() (c *Config, err error) {
Expand Down
16 changes: 8 additions & 8 deletions lnd/ln_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ func InitSingleLNDClient(c *Config, ctx context.Context) (result LightningClient
}
func InitLNDCluster(c *Config, logger *lecho.Logger, ctx context.Context) (result LightningClientWrapper, err error) {
nodes := []LightningClientWrapper{}
//interpret lnd address, macaroon file & cert file as comma seperated values
//interpret lnd address, macaroon file, cert file, pubkeys as comma seperated values
addresses := strings.Split(c.LNDAddress, ",")
macaroons := strings.Split(c.LNDMacaroonFile, ",")
pubkeys := strings.Split(c.LNDClusterPubkeys, ",")
certs := strings.Split(c.LNDCertFile, ",")
if len(addresses) != len(macaroons) || len(addresses) != len(certs) || len(certs) != len(macaroons) {
return nil, fmt.Errorf("Error parsing LND cluster config: addresses, macaroons or certs array length mismatch")
if len(addresses) != len(macaroons) ||
len(addresses) != len(certs) ||
len(certs) != len(macaroons) ||
len(pubkeys) != len(macaroons) {
return nil, fmt.Errorf("Error parsing LND cluster config: addresses, macaroons, certs or pubkeys array length mismatch")
}
for i := 0; i < len(addresses); i++ {
n, err := NewLNDclient(LNDoptions{
Expand All @@ -77,11 +81,7 @@ func InitLNDCluster(c *Config, logger *lecho.Logger, ctx context.Context) (resul
if err != nil {
return nil, err
}
getInfo, err := n.GetInfo(ctx, &lnrpc.GetInfoRequest{})
if err != nil {
return nil, err
}
n.IdentityPubkey = getInfo.IdentityPubkey
n.IdentityPubkey = pubkeys[i]
nodes = append(nodes, n)
}
logger.Infof("Initialized LND cluster with %d nodes", len(nodes))
Expand Down

0 comments on commit d2d9b03

Please sign in to comment.