From d97aadb8dc4fb5fa110f8a69b53dfb9a071da3e2 Mon Sep 17 00:00:00 2001 From: jules01 Date: Wed, 28 Sep 2022 20:11:38 +0300 Subject: [PATCH] - fixed preferred peers handling --- node/nodeRunner.go | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/node/nodeRunner.go b/node/nodeRunner.go index f5ade5d572f..7f0a183e41c 100644 --- a/node/nodeRunner.go +++ b/node/nodeRunner.go @@ -1212,11 +1212,6 @@ func (nr *nodeRunner) CreateManagedBootstrapComponents( func (nr *nodeRunner) CreateManagedNetworkComponents( coreComponents mainFactory.CoreComponentsHolder, ) (mainFactory.NetworkComponentsHandler, error) { - decodedPreferredPeers, err := decodePreferredPeers(*nr.configs.PreferencesConfig, coreComponents.ValidatorPubKeyConverter()) - if err != nil { - return nil, err - } - networkComponentsFactoryArgs := mainFactory.NetworkComponentsFactoryArgs{ P2pConfig: *nr.configs.P2pConfig, MainConfig: *nr.configs.GeneralConfig, @@ -1224,7 +1219,7 @@ func (nr *nodeRunner) CreateManagedNetworkComponents( StatusHandler: coreComponents.StatusHandler(), Marshalizer: coreComponents.InternalMarshalizer(), Syncer: coreComponents.SyncTimer(), - PreferredPeersSlices: decodedPreferredPeers, + PreferredPeersSlices: nr.configs.PreferencesConfig.Preferences.PreferredConnections, BootstrapWaitTime: common.TimeToWaitForP2PBootstrap, NodeOperationMode: p2p.NormalOperation, ConnectionWatcherType: nr.configs.PreferencesConfig.Preferences.ConnectionWatcherType, @@ -1492,20 +1487,6 @@ func enableGopsIfNeeded(gopsEnabled bool) { log.Trace("gops", "enabled", gopsEnabled) } -func decodePreferredPeers(prefConfig config.Preferences, validatorPubKeyConverter core.PubkeyConverter) ([]string, error) { - decodedPeers := make([]string, 0) - for _, connectionSlice := range prefConfig.Preferences.PreferredConnections { - peerBytes, err := validatorPubKeyConverter.Decode(connectionSlice) - if err != nil { - return nil, fmt.Errorf("cannot decode preferred peer(%s) : %w", connectionSlice, err) - } - - decodedPeers = append(decodedPeers, string(peerBytes)) - } - - return decodedPeers, nil -} - func createWhiteListerVerifiedTxs(generalConfig *config.Config) (process.WhiteListHandler, error) { whiteListCacheVerified, err := storageUnit.NewCache(storageFactory.GetCacherFromConfig(generalConfig.WhiteListerVerifiedTxs)) if err != nil {