@@ -47,6 +47,14 @@ type NodeHooks interface {
4747 Initialized () <- chan struct {}
4848}
4949
50+ // Config contains committee node specific configuration.
51+ type Config struct {
52+ ChainContext string
53+ Identity * identity.Identity
54+ TxPool tpConfig.Config
55+ WillRegisterComputeRuntime bool
56+ }
57+
5058// Node is a committee node.
5159type Node struct {
5260 * runtimeRegistry.RuntimeHostNode
@@ -643,17 +651,14 @@ func (n *Node) handleDispatchInfo() {
643651}
644652
645653func NewNode (
646- chainContext string ,
654+ cfg Config ,
647655 runtime runtimeRegistry.Runtime ,
648656 provisioner host.Provisioner ,
649657 rtRegistry runtimeRegistry.Registry ,
650- identity * identity.Identity ,
651658 keymanager keymanager.Backend ,
652659 consensus consensus.Service ,
653660 lightProvider consensus.LightProvider ,
654661 p2pHost p2pAPI.Service ,
655- txPoolCfg tpConfig.Config ,
656- willRegisterComputeRuntime bool ,
657662) (* Node , error ) {
658663 metricsOnce .Do (func () {
659664 prometheus .MustRegister (nodeCollectors ... )
@@ -662,25 +667,25 @@ func NewNode(
662667 ctx , cancel := context .WithCancel (context .Background ())
663668
664669 // Prepare committee group services.
665- group , err := NewGroup (ctx , runtime .ID (), identity , consensus , p2pHost )
670+ group , err := NewGroup (ctx , runtime .ID (), cfg . Identity , consensus , p2pHost )
666671 if err != nil {
667672 cancel ()
668673 return nil , err
669674 }
670675
671- txTopic := p2pProtocol .NewTopicKindTxID (chainContext , runtime .ID ())
676+ txTopic := p2pProtocol .NewTopicKindTxID (cfg . ChainContext , runtime .ID ())
672677
673678 n := & Node {
674- ChainContext : chainContext ,
679+ ChainContext : cfg . ChainContext ,
675680 Runtime : runtime ,
676681 RuntimeRegistry : rtRegistry ,
677- Identity : identity ,
682+ Identity : cfg . Identity ,
678683 KeyManager : keymanager ,
679684 Consensus : consensus ,
680685 LightProvider : lightProvider ,
681686 Group : group ,
682687 P2P : p2pHost ,
683- willRegisterComputeRuntime : willRegisterComputeRuntime ,
688+ willRegisterComputeRuntime : cfg . WillRegisterComputeRuntime ,
684689 txTopic : txTopic ,
685690 ctx : ctx ,
686691 cancelCtx : cancel ,
@@ -692,7 +697,7 @@ func NewNode(
692697 }
693698
694699 // Prepare the key manager client wrapper.
695- n .KeyManagerClient = NewKeyManagerClientWrapper (p2pHost , consensus , chainContext , n .logger )
700+ n .KeyManagerClient = NewKeyManagerClientWrapper (p2pHost , consensus , cfg . ChainContext , n .logger )
696701
697702 // Prepare the runtime host handler.
698703 handler := runtimeRegistry .NewRuntimeHostHandler (& nodeEnvironment {n }, n .Runtime , consensus )
@@ -715,13 +720,13 @@ func NewNode(
715720 n .services = service .NewGroup (notifier , lbNotifier , kmNotifier , n .roflNotifier )
716721
717722 // Prepare transaction pool.
718- n .TxPool = txpool .New (runtime .ID (), txPoolCfg , rhn .GetHostedRuntime (), runtime .History (), n )
723+ n .TxPool = txpool .New (runtime .ID (), cfg . TxPool , rhn .GetHostedRuntime (), runtime .History (), n )
719724
720725 // Register transaction message handler as that is something that all workers must handle.
721726 p2pHost .RegisterHandler (txTopic , & txMsgHandler {n })
722727
723728 // Register transaction sync service.
724- p2pHost .RegisterProtocolServer (txsync .NewServer (chainContext , runtime .ID (), n .TxPool ))
729+ p2pHost .RegisterProtocolServer (txsync .NewServer (cfg . ChainContext , runtime .ID (), n .TxPool ))
725730
726731 return n , nil
727732}
0 commit comments