Merge the two loops in CreateSyncConfig

pull/686/head
Eugene Kim 6 years ago
parent 56f1c60928
commit 5d5fe918ae
  1. 8
      api/service/syncing/syncing.go

@ -159,17 +159,13 @@ func (ss *StateSync) CreateSyncConfig(peers []p2p.Peer) error {
ss.syncConfig = &SyncConfig{
peers: make([]*SyncPeerConfig, ss.peerNumber),
}
var wg sync.WaitGroup
wg.Add(ss.peerNumber)
for id := range ss.syncConfig.peers {
ss.syncConfig.peers[id] = &SyncPeerConfig{
ip: peers[id].IP,
port: peers[id].Port,
}
}
utils.GetLogInstance().Info("[SYNC] Finished creating SyncConfig")
var wg sync.WaitGroup
wg.Add(ss.peerNumber)
for id := range ss.syncConfig.peers {
go func(peerConfig *SyncPeerConfig) {
defer wg.Done()
peerConfig.client = downloader.ClientSetup(peerConfig.ip, peerConfig.port)

Loading…
Cancel
Save