2022-08-12 12:44:13 +00:00
|
|
|
//go:build gowaku_rln
|
|
|
|
// +build gowaku_rln
|
|
|
|
|
2023-07-06 21:40:57 +00:00
|
|
|
package main
|
2022-08-12 12:44:13 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/ecdsa"
|
|
|
|
"errors"
|
2022-09-11 21:08:58 +00:00
|
|
|
|
2022-11-09 19:53:01 +00:00
|
|
|
"github.com/waku-org/go-waku/waku/v2/node"
|
2022-10-27 15:23:20 +00:00
|
|
|
"github.com/waku-org/go-zerokit-rln/rln"
|
2022-09-11 21:08:58 +00:00
|
|
|
"go.uber.org/zap"
|
2022-08-12 12:44:13 +00:00
|
|
|
)
|
|
|
|
|
2022-09-11 21:08:58 +00:00
|
|
|
func checkForRLN(logger *zap.Logger, options Options, nodeOpts *[]node.WakuNodeOption) {
|
2022-08-12 12:44:13 +00:00
|
|
|
if options.RLNRelay.Enable {
|
|
|
|
if !options.Relay.Enable {
|
|
|
|
failOnErr(errors.New("relay not available"), "Could not enable RLN Relay")
|
|
|
|
}
|
|
|
|
if !options.RLNRelay.Dynamic {
|
2023-07-27 19:51:31 +00:00
|
|
|
*nodeOpts = append(*nodeOpts, node.WithStaticRLNRelay(options.RLNRelay.PubsubTopic, options.RLNRelay.ContentTopic, rln.MembershipIndex(options.RLNRelay.MembershipGroupIndex), nil))
|
2022-08-12 12:44:13 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
var ethPrivKey *ecdsa.PrivateKey
|
2022-08-15 17:13:45 +00:00
|
|
|
if options.RLNRelay.ETHPrivateKey != nil {
|
|
|
|
ethPrivKey = options.RLNRelay.ETHPrivateKey
|
2022-08-12 12:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*nodeOpts = append(*nodeOpts, node.WithDynamicRLNRelay(
|
|
|
|
options.RLNRelay.PubsubTopic,
|
|
|
|
options.RLNRelay.ContentTopic,
|
2023-04-05 19:44:46 +00:00
|
|
|
options.RLNRelay.CredentialsPath,
|
|
|
|
options.RLNRelay.CredentialsPassword,
|
2023-07-27 19:51:31 +00:00
|
|
|
options.RLNRelay.CredentialsIndex,
|
2023-04-05 19:44:46 +00:00
|
|
|
options.RLNRelay.MembershipContractAddress,
|
2023-07-27 19:51:31 +00:00
|
|
|
rln.MembershipIndex(options.RLNRelay.MembershipGroupIndex),
|
2022-08-12 12:44:13 +00:00
|
|
|
nil,
|
|
|
|
options.RLNRelay.ETHClientAddress,
|
|
|
|
ethPrivKey,
|
2022-09-11 21:08:58 +00:00
|
|
|
nil,
|
2022-08-12 12:44:13 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|