From daf4767a519451571524c91274eb1fa08fc14f14 Mon Sep 17 00:00:00 2001 From: Dennis Won Date: Sat, 31 Aug 2019 17:12:08 -0700 Subject: [PATCH] close peer sync config connections to prevent duplicate peer sync config creation --- api/service/syncing/syncing.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/service/syncing/syncing.go b/api/service/syncing/syncing.go index 0f87c8a6a..a1c1e7b04 100644 --- a/api/service/syncing/syncing.go +++ b/api/service/syncing/syncing.go @@ -217,6 +217,9 @@ func (ss *StateSync) CreateSyncConfig(peers []p2p.Peer, isBeacon bool) error { if len(peers) == 0 { return ctxerror.New("[SYNC] no peers to connect to") } + if ss.syncConfig != nil { + ss.syncConfig.CloseConnections() + } ss.syncConfig = &SyncConfig{} var wg sync.WaitGroup for _, peer := range peers {