@@ -346,26 +346,47 @@ func GoCallback(ret C.int, msg *C.char, len C.size_t, resp unsafe.Pointer) {
346346type WakuNode struct {
347347 wakuCtx unsafe.Pointer
348348 config * common.WakuConfig
349+ extraOptions common.ExtraOptions
349350 MsgChan chan common.Envelope
350351 TopicHealthChan chan topicHealth
351352 ConnectionChangeChan chan connectionChange
352353 nodeName string
353354}
354355
355- func NewWakuNode (config * common.WakuConfig , nodeName string ) (* WakuNode , error ) {
356+ func NewWakuNode (config * common.WakuConfig , nodeName string , opts ... WakuNodeOption ) (* WakuNode , error ) {
356357 Debug ("Creating new WakuNode: %v" , nodeName )
357358 n := & WakuNode {
358359 config : config ,
359360 nodeName : nodeName ,
360361 }
361362
363+ for _ , o := range opts {
364+ o (n )
365+ }
366+
362367 wg := sync.WaitGroup {}
363368
364369 jsonConfig , err := json .Marshal (config )
365370 if err != nil {
366371 return nil , err
367372 }
368373
374+ if len (n .extraOptions ) > 0 {
375+ configMap := make (common.ExtraOptions )
376+ err = json .Unmarshal (jsonConfig , & configMap )
377+ if err != nil {
378+ return nil , err
379+ }
380+
381+ for k , v := range n .extraOptions {
382+ configMap [k ] = v
383+ }
384+ jsonConfig , err = json .Marshal (configMap )
385+ if err != nil {
386+ return nil , err
387+ }
388+ }
389+
369390 var cJsonConfig = C .CString (string (jsonConfig ))
370391 var resp = C .allocResp (unsafe .Pointer (& wg ))
371392
@@ -1314,7 +1335,7 @@ func GetFreePortIfNeeded(tcpPort int, discV5UDPPort int) (int, int, error) {
13141335}
13151336
13161337// Create & start node
1317- func StartWakuNode (nodeName string , customCfg * common.WakuConfig ) (* WakuNode , error ) {
1338+ func StartWakuNode (nodeName string , customCfg * common.WakuConfig , opts ... WakuNodeOption ) (* WakuNode , error ) {
13181339
13191340 Debug ("Initializing %s" , nodeName )
13201341
@@ -1339,7 +1360,7 @@ func StartWakuNode(nodeName string, customCfg *common.WakuConfig) (*WakuNode, er
13391360 }
13401361
13411362 Debug ("Creating %s" , nodeName )
1342- node , err := NewWakuNode (& nodeCfg , nodeName )
1363+ node , err := NewWakuNode (& nodeCfg , nodeName , opts ... )
13431364 if err != nil {
13441365 Error ("Failed to create %s: %v" , nodeName , err )
13451366 return nil , err
0 commit comments