From 83396485b88e9378341a7c6b77e358031c056ad0 Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 29 Oct 2024 16:57:11 +0300 Subject: [PATCH] Improve rollback performance --- internal/storage/postgres/rollback.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/storage/postgres/rollback.go b/internal/storage/postgres/rollback.go index 33c5eeb..2a5bcac 100644 --- a/internal/storage/postgres/rollback.go +++ b/internal/storage/postgres/rollback.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "strings" + "time" models "github.com/dipdup-io/starknet-indexer/internal/storage" "github.com/dipdup-net/indexer-sdk/pkg/storage" @@ -212,6 +213,7 @@ func (rm RollbackManager) rollbackTokenBalances(ctx context.Context, height uint end = false ) + maxRollbackTime := time.Now().AddDate(1, -1, 0) updates := make(map[string]*models.TokenBalance, 0) for !end { transfers, err := rm.transfers.Filter(ctx, @@ -220,6 +222,9 @@ func (rm RollbackManager) rollbackTokenBalances(ctx context.Context, height uint Height: models.IntegerFilter{ Gt: height, }, + Time: models.TimeFilter{ + Gt: uint64(maxRollbackTime.Unix()), + }, }, }, models.WithLimitFilter(limit),