Skip to content

Commit

Permalink
fix: time calculation for fetching events
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Sep 12, 2023
1 parent 75486f8 commit 2aea2f5
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,22 @@ func (mf *MembershipFetcher) loadOldEvents(ctx context.Context, fromBlock, toBlo
if err != nil {
return err
}
t1Since := time.Since(t1)

t2 := time.Now()
if err := handler(events); err != nil {
return err
}

mf.log.Info("fetching events", zap.Uint64("from", fromBlock), zap.Uint64("to", fromBlock+maxBatchSize), zap.Int("numEvents", len(events)), zap.Duration("timeToFetch", time.Since(t1)), zap.Duration("timeToProcess", time.Since(t2)))
mf.log.Info("fetching events", zap.Uint64("from", fromBlock), zap.Uint64("to", fromBlock+maxBatchSize), zap.Int("numEvents", len(events)), zap.Duration("timeToFetch", t1Since), zap.Duration("timeToProcess", time.Since(t2)))
}

t1 := time.Now()
events, err := mf.getEvents(ctx, fromBlock, toBlock)
if err != nil {
return err
}
t1Since := time.Since(t1)

// process all the fetched events
t2 := time.Now()
Expand All @@ -112,7 +114,7 @@ func (mf *MembershipFetcher) loadOldEvents(ctx context.Context, fromBlock, toBlo
return err
}

mf.log.Info("fetching events", zap.Uint64("from", fromBlock), zap.Uint64("to", fromBlock+maxBatchSize), zap.Int("numEvents", len(events)), zap.Duration("timeToFetch", time.Since(t1)), zap.Duration("timeToProcess", time.Since(t2)))
mf.log.Info("fetching events", zap.Uint64("from", fromBlock), zap.Uint64("to", fromBlock+maxBatchSize), zap.Int("numEvents", len(events)), zap.Duration("timeToFetch", t1Since), zap.Duration("timeToProcess", time.Since(t2)))
return nil
}

Expand Down

0 comments on commit 2aea2f5

Please sign in to comment.