@@ -71,11 +71,25 @@ func Create(ctx context.Context, c *CreateInfo) (*Service, error) {
7171func (s * Service ) Alive () bool { return true }
7272func (s * Service ) Ready () bool { return true }
7373func (s * Service ) Reload () []error { return nil }
74+
75+ // Tick executes the Validator main logic of producing claims and/or proofs
76+ // for processed epochs of all running applications. It is meant to be executed
77+ // inside a loop. If an error occurs while processing any epoch, it halts and
78+ // returns the error.
7479func (s * Service ) Tick () []error {
75- if err := s .Run (s .Context ); err != nil {
76- return []error {err }
80+ apps , err := getAllRunningApplications (s .Context , s .repository )
81+ if err != nil {
82+ return []error {fmt .Errorf ("failed to get running applications. %w" , err )}
7783 }
78- return []error {}
84+
85+ // validate each application
86+ errs := []error {}
87+ for idx := range apps {
88+ if err := s .validateApplication (s .Context , apps [idx ]); err != nil {
89+ errs = append (errs , err )
90+ }
91+ }
92+ return errs
7993}
8094func (s * Service ) Stop (b bool ) []error {
8195 return nil
@@ -105,24 +119,6 @@ func getAllRunningApplications(ctx context.Context, er ValidatorRepository) ([]*
105119 return er .ListApplications (ctx , f , repository.Pagination {})
106120}
107121
108- // Run executes the Validator main logic of producing claims and/or proofs
109- // for processed epochs of all running applications. It is meant to be executed
110- // inside a loop. If an error occurs while processing any epoch, it halts and
111- // returns the error.
112- func (v * Service ) Run (ctx context.Context ) error {
113- apps , err := getAllRunningApplications (ctx , v .repository )
114- if err != nil {
115- return fmt .Errorf ("failed to get running applications. %w" , err )
116- }
117-
118- for idx := range apps {
119- if err := v .validateApplication (ctx , apps [idx ]); err != nil {
120- return err
121- }
122- }
123- return nil
124- }
125-
126122func getProcessedEpochs (ctx context.Context , er ValidatorRepository , address string ) ([]* Epoch , error ) {
127123 f := repository.EpochFilter {Status : Pointer (EpochStatus_InputsProcessed )}
128124 return er .ListEpochs (ctx , address , f , repository.Pagination {})
0 commit comments