@@ -252,13 +252,18 @@ func (syncService *SyncService[H]) initStore(ctx context.Context, initial H) (bo
252252// but does not start the Subscriber. Returns peer IDs for later use.
253253func (syncService * SyncService [H ]) setupP2PInfrastructure (ctx context.Context ) ([]peer.ID , error ) {
254254 ps := syncService .p2p .PubSub ()
255- var err error
255+
256+ _ , _ , chainID , err := syncService .p2p .Info ()
257+ if err != nil {
258+ return nil , fmt .Errorf ("error while fetching the network: %w" , err )
259+ }
260+ networkID := syncService .getNetworkID (chainID )
256261
257262 // Create subscriber but DON'T start it yet
258263 syncService .sub , err = goheaderp2p .NewSubscriber [H ](
259264 ps ,
260265 pubsub .DefaultMsgIdFn ,
261- goheaderp2p .WithSubscriberNetworkID (syncService . getChainID () ),
266+ goheaderp2p .WithSubscriberNetworkID (networkID ),
262267 goheaderp2p .WithSubscriberMetrics (),
263268 )
264269 if err != nil {
@@ -269,12 +274,6 @@ func (syncService *SyncService[H]) setupP2PInfrastructure(ctx context.Context) (
269274 return nil , fmt .Errorf ("error while starting store: %w" , err )
270275 }
271276
272- _ , _ , network , err := syncService .p2p .Info ()
273- if err != nil {
274- return nil , fmt .Errorf ("error while fetching the network: %w" , err )
275- }
276- networkID := syncService .getNetworkID (network )
277-
278277 if syncService .p2pServer , err = newP2PServer (syncService .p2p .Host (), syncService .store , networkID ); err != nil {
279278 return nil , fmt .Errorf ("error while creating p2p server: %w" , err )
280279 }
@@ -446,10 +445,6 @@ func (syncService *SyncService[H]) getNetworkID(network string) string {
446445 return network + "-" + string (syncService .syncType )
447446}
448447
449- func (syncService * SyncService [H ]) getChainID () string {
450- return syncService .genesis .ChainID + "-" + string (syncService .syncType )
451- }
452-
453448func (syncService * SyncService [H ]) getPeerIDs () []peer.ID {
454449 peerIDs := syncService .p2p .PeerIDs ()
455450 if ! syncService .conf .Node .Aggregator {
0 commit comments