Skip to content

Commit

Permalink
Merge pull request #4529 from ElrondNetwork/fix-preferred-peers
Browse files Browse the repository at this point in the history
Fixed preferred peers loading
  • Loading branch information
iulianpascalau authored Oct 5, 2022
2 parents 3dfa1db + 7e81716 commit 1d59de2
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions node/nodeRunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1223,19 +1223,14 @@ 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,
RatingsConfig: *nr.configs.RatingsConfig,
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,
Expand Down Expand Up @@ -1503,20 +1498,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 {
Expand Down

0 comments on commit 1d59de2

Please sign in to comment.