Skip to content

Commit 49519dc

Browse files
authored
Merge pull request #19 from Arkiv-Network/log-batch-stats
log batch processing time
2 parents 2695c4a + 1c1eec5 commit 49519dc

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

sqlitestore.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"os"
1111
"path/filepath"
1212
"strings"
13+
"time"
1314

1415
"github.com/Arkiv-Network/sqlite-bitmap-store/store"
1516
"github.com/ethereum/go-ethereum/common"
@@ -103,6 +104,7 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat
103104
for batch := range iterator {
104105
if batch.Error != nil {
105106
return fmt.Errorf("failed to follow events: %w", batch.Error)
107+
106108
}
107109

108110
err := func() error {
@@ -129,6 +131,8 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat
129131

130132
cache := newBitmapCache(st)
131133

134+
startTime := time.Now()
135+
132136
mainLoop:
133137
for _, block := range batch.Batch.Blocks {
134138

@@ -459,6 +463,8 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat
459463
return fmt.Errorf("failed to commit transaction: %w", err)
460464
}
461465

466+
s.log.Info("batch processed", "firstBlock", firstBlock, "lastBlock", lastBlock, "processingTime", time.Since(startTime))
467+
462468
return nil
463469
}()
464470
if err != nil {

0 commit comments

Comments
 (0)