go-waku/cmd/waku/node_rln.go

39 lines
1017 B
Go
Raw Normal View History

2023-09-12 15:14:08 -04:00
//go:build !gowaku_no_rln
// +build !gowaku_no_rln
2022-08-12 08:44:13 -04:00
2023-07-06 17:40:57 -04:00
package main
2022-08-12 08:44:13 -04:00
import (
"errors"
2022-09-11 17:08:58 -04:00
"github.com/waku-org/go-waku/waku/v2/node"
"github.com/waku-org/go-zerokit-rln/rln"
2022-09-11 17:08:58 -04:00
"go.uber.org/zap"
2022-08-12 08:44:13 -04:00
)
func checkForRLN(logger *zap.Logger, options NodeOptions, nodeOpts *[]node.WakuNodeOption) error {
2022-08-12 08:44:13 -04:00
if options.RLNRelay.Enable {
if !options.Relay.Enable {
return errors.New("waku relay is required to enable RLN relay")
2022-08-12 08:44:13 -04:00
}
2022-08-12 08:44:13 -04:00
if !options.RLNRelay.Dynamic {
*nodeOpts = append(*nodeOpts, node.WithStaticRLNRelay((*rln.MembershipIndex)(options.RLNRelay.MembershipIndex), nil))
2022-08-12 08:44:13 -04:00
} else {
// TODO: too many parameters in this function
// consider passing a config struct instead
2022-08-12 08:44:13 -04:00
*nodeOpts = append(*nodeOpts, node.WithDynamicRLNRelay(
2023-04-05 15:44:46 -04:00
options.RLNRelay.CredentialsPath,
options.RLNRelay.CredentialsPassword,
options.RLNRelay.TreePath,
2023-04-05 15:44:46 -04:00
options.RLNRelay.MembershipContractAddress,
options.RLNRelay.MembershipIndex,
2022-08-12 08:44:13 -04:00
nil,
options.RLNRelay.ETHClientAddress,
))
}
}
return nil
2022-08-12 08:44:13 -04:00
}