1+ import std/ options, waku/ factory/ waku_conf, waku/ factory/ conf_builder
2+
13type ShardingMode * = enum
24 AutoSharding
35 StaticSharding
@@ -20,3 +22,45 @@ type LibWakuConf* = object
2022 mode* : WakuMode
2123 networkConf* : NetworkConf
2224 storeConfirmation* : bool
25+
26+ proc toWakuConf * (libConf: LibWakuConf ): Result [WakuConf , string ] =
27+ let b = WakuConfBuilder .init ()
28+
29+ case mode
30+ of Relay :
31+ b.withRelayEnabled (true )
32+ b.filterServiceConf.withEnabled (true )
33+ b.lightPushServiceConf.withEnabled (true )
34+ b.withDiscv5Enabled (true )
35+ b.withPeerExchange (true )
36+
37+ # Values applied when used as a library - should probably become default values
38+ b.filterServiceConf.withMaxPeersToServe (20 )
39+ b.withRateLimits (
40+ @ [
41+
42+ ]
43+ )
44+ nwakuCfg.RateLimits .Filter = & bindingscommon.RateLimit {Volume : 100 , Period : 1 , TimeUnit : bindingscommon.Second }
45+ nwakuCfg.RateLimits .Lightpush = & bindingscommon.RateLimit {Volume : 5 , Period : 1 , TimeUnit : bindingscommon.Second }
46+ nwakuCfg.RateLimits .PeerExchange = & bindingscommon.RateLimit {Volume : 5 , Period : 1 , TimeUnit : bindingscommon.Second }
47+
48+
49+ of Edge :
50+ return err (" Edge mode is not implemented" )
51+
52+
53+
54+ # if !cfg.LightClient {
55+ nwakuCfg.Discv5Discovery = true
56+ nwakuCfg.Relay = true
57+ nwakuCfg.Filter = true
58+ nwakuCfg.FilterMaxPeersToServe = 20
59+ nwakuCfg.Lightpush = true
60+
61+ }
62+
63+ if cfg.EnablePeerExchangeServer {
64+ nwakuCfg.PeerExchange = true
65+
66+ }
0 commit comments