Skip to content

Commit

Permalink
Improve rollback performance
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Oct 29, 2024
1 parent 3008686 commit 8339648
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/storage/postgres/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit 8339648

Please sign in to comment.