Skip to content

Commit

Permalink
rollup: fix cache eviction logic (ethereum#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
tynes committed Nov 12, 2020
1 parent 7320d02 commit a867a0d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions rollup/sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
eth1NetworkId: cfg.Eth1NetworkId,
ctcDeployHeight: cfg.CanonicalTransactionChainDeployHeight,
db: db,
clearTransactionsAfter: (5760 * 15), // 15 days worth of blocks
clearTransactionsAfter: (5760 * 18), // 18 days worth of blocks
clearTransactionsTicker: time.NewTicker(time.Hour),
sequencerIngestTicker: time.NewTicker(15 * time.Second),
txCache: NewTransactionCache(),
Expand Down Expand Up @@ -556,10 +556,9 @@ func (s *SyncService) ClearTransactionLoop() {
continue
}
currentHeight := tip.Number.Uint64()

count := 0
s.txCache.Range(func(index uint64, rtx *RollupTransaction) {
if rtx.blockHeight+s.clearTransactionsAfter > currentHeight {
if rtx.executed && rtx.blockHeight+s.clearTransactionsAfter <= currentHeight {
log.Debug("Clearing transaction from transaction cache", "hash", rtx.tx.Hash(), "index", index)
s.txCache.Delete(index)
count++
Expand Down

0 comments on commit a867a0d

Please sign in to comment.