2023-09-12 19:14:08 +00:00
|
|
|
//go:build !gowaku_no_rln
|
|
|
|
// +build !gowaku_no_rln
|
2022-08-12 12:44:13 +00:00
|
|
|
|
2023-07-06 21:40:57 +00:00
|
|
|
package main
|
2022-08-12 12:44:13 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"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
|
|
|
)
|
|
|
|
|
2023-10-18 19:21:37 +00:00
|
|
|
func checkForRLN(logger *zap.Logger, options NodeOptions, nodeOpts *[]node.WakuNodeOption) error {
|
2022-08-12 12:44:13 +00:00
|
|
|
if options.RLNRelay.Enable {
|
|
|
|
if !options.Relay.Enable {
|
2023-10-18 19:21:37 +00:00
|
|
|
return errors.New("waku relay is required to enable RLN relay")
|
2022-08-12 12:44:13 +00:00
|
|
|
}
|
2023-10-18 19:21:37 +00:00
|
|
|
|
2022-08-12 12:44:13 +00:00
|
|
|
if !options.RLNRelay.Dynamic {
|
2023-09-04 21:44:41 +00:00
|
|
|
*nodeOpts = append(*nodeOpts, node.WithStaticRLNRelay((*rln.MembershipIndex)(options.RLNRelay.MembershipIndex), nil))
|
2022-08-12 12:44:13 +00:00
|
|
|
} else {
|
2023-08-18 13:59:37 +00:00
|
|
|
// TODO: too many parameters in this function
|
|
|
|
// consider passing a config struct instead
|
2022-08-12 12:44:13 +00:00
|
|
|
*nodeOpts = append(*nodeOpts, node.WithDynamicRLNRelay(
|
2023-04-05 19:44:46 +00:00
|
|
|
options.RLNRelay.CredentialsPath,
|
|
|
|
options.RLNRelay.CredentialsPassword,
|
2023-08-18 13:59:37 +00:00
|
|
|
options.RLNRelay.TreePath,
|
2023-04-05 19:44:46 +00:00
|
|
|
options.RLNRelay.MembershipContractAddress,
|
2023-09-04 21:44:41 +00:00
|
|
|
options.RLNRelay.MembershipIndex,
|
2022-08-12 12:44:13 +00:00
|
|
|
nil,
|
|
|
|
options.RLNRelay.ETHClientAddress,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
2023-10-18 19:21:37 +00:00
|
|
|
|
|
|
|
return nil
|
2022-08-12 12:44:13 +00:00
|
|
|
}
|