From 6348128c482b2ecaaadeeb3fba386f001498868a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CGheisMohammadi=E2=80=9D?= <36589218+GheisMohammadi@users.noreply.github.com> Date: Wed, 4 Oct 2023 20:05:12 +0800 Subject: [PATCH] improve stage handling for create new instance of staged stream sync --- api/service/stagedstreamsync/staged_stream_sync.go | 6 +++--- api/service/stagedstreamsync/syncing.go | 13 +------------ 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/api/service/stagedstreamsync/staged_stream_sync.go b/api/service/stagedstreamsync/staged_stream_sync.go index a4e04dff3..03340eb15 100644 --- a/api/service/stagedstreamsync/staged_stream_sync.go +++ b/api/service/stagedstreamsync/staged_stream_sync.go @@ -266,7 +266,7 @@ func New( logger zerolog.Logger, ) *StagedStreamSync { - forwardStages := make([]*Stage, len(stagesList)) + forwardStages := make([]*Stage, len(StagesForwardOrder)) for i, stageIndex := range StagesForwardOrder { for _, s := range stagesList { if s.ID == stageIndex { @@ -276,7 +276,7 @@ func New( } } - revertStages := make([]*Stage, len(stagesList)) + revertStages := make([]*Stage, len(StagesRevertOrder)) for i, stageIndex := range StagesRevertOrder { for _, s := range stagesList { if s.ID == stageIndex { @@ -286,7 +286,7 @@ func New( } } - pruneStages := make([]*Stage, len(stagesList)) + pruneStages := make([]*Stage, len(StagesCleanUpOrder)) for i, stageIndex := range StagesCleanUpOrder { for _, s := range stagesList { if s.ID == stageIndex { diff --git a/api/service/stagedstreamsync/syncing.go b/api/service/stagedstreamsync/syncing.go index d2457a526..03043525b 100644 --- a/api/service/stagedstreamsync/syncing.go +++ b/api/service/stagedstreamsync/syncing.go @@ -118,22 +118,11 @@ func CreateStagedSync(ctx context.Context, Int("minStreams", config.MinStreams). Msg(WrapStagedSyncMsg("staged sync created successfully")) - var stages []*Stage - // if any of the default stages doesn't exist in forward order, delete it from the list of stages - for _, stg := range defaultStages { - for _, stageID := range StagesForwardOrder { - if stg.ID == stageID { - stages = append(stages, stg) - break - } - } - } - return New( bc, consensus, mainDB, - stages, + defaultStages, isBeaconNode, protocol, isBeaconNode,