fix discovery issue for legacy sync

pull/4377/head
“GheisMohammadi” 2 years ago committed by Casey Gardiner
parent 4bb360d137
commit 5361044376
  1. 2
      api/service/legacysync/epoch_syncing.go
  2. 4
      p2p/discovery/option.go
  3. 2
      p2p/stream/common/streammanager/cooldown.go

@ -112,7 +112,7 @@ func syncLoop(bc core.BlockChain, syncConfig *SyncConfig) (timeout int) {
}
if otherEpoch < curEpoch {
for _, peerCfg := range syncConfig.GetPeers() {
syncConfig.RemovePeer(peerCfg, fmt.Sprintf("[EPOCHSYNC]: current height is higher that others, remove peers: %s", peerCfg.String()))
syncConfig.RemovePeer(peerCfg, fmt.Sprintf("[EPOCHSYNC]: current height is higher than others, remove peers: %s", peerCfg.String()))
}
return 2
}

@ -42,7 +42,9 @@ func (opt DHTConfig) GetLibp2pRawOptions() ([]libp2p_dht.Option, error) {
opts = append(opts, libp2p_dht.Concurrency(opt.DiscConcurrency))
}
opts = append(opts, libp2p_dht.DisableAutoRefresh())
// TODO: to disable auto refresh to make sure there is no conflicts with protocol discovery functions
// it's not applicable for legacy sync
// opts = append(opts, libp2p_dht.DisableAutoRefresh())
return opts, nil
}

@ -36,6 +36,8 @@ func (cache *coolDownCache) Has(id peer.ID) bool {
// Add adds the peer ID to the cache
func (cache *coolDownCache) Add(id peer.ID) {
cache.mu.Lock()
defer cache.mu.Unlock()
has := cache.timeCache.Has(string(id))
if !has {
cache.timeCache.Add(string(id))

Loading…
Cancel
Save