From 5edfc527b0b0eeec035d82792e7ab463f10073fe Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 21 Oct 2020 22:52:35 +0200 Subject: [PATCH] More than one bucket Signed-off-by: Jakub Sztandera --- chain/sync_manager.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/chain/sync_manager.go b/chain/sync_manager.go index 53fd07bc9..63bc377ec 100644 --- a/chain/sync_manager.go +++ b/chain/sync_manager.go @@ -199,13 +199,18 @@ func (sbs *syncBucketSet) removeBucket(toremove *syncTargetBucket) { } func (sbs *syncBucketSet) PopRelated(ts *types.TipSet) *syncTargetBucket { + var bOut *syncTargetBucket for _, b := range sbs.buckets { if b.sameChainAs(ts) { - sbs.removeBucket(b) - return b + if bOut == nil { + sbs.removeBucket(b) + bOut = b + } else { + log.Errorf("REPORT THIS more that one related bucket for %s", ts) + } } } - return nil + return bOut } func (sbs *syncBucketSet) Heaviest() *types.TipSet { @@ -312,7 +317,7 @@ func (sm *syncManager) syncScheduler() { log.Info("sync scheduler shutting down") return case <-t.C: - activeSyncs := make([]types.TipSetKey, len(sm.activeSyncs), 0) + activeSyncs := make([]types.TipSetKey, 0, len(sm.activeSyncs)) for tsk := range sm.activeSyncs { activeSyncs = append(activeSyncs, tsk) }