Skip to content

Commit

Permalink
handler db deletions on reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Oct 3, 2024
1 parent 11d6ba0 commit d31039e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ func (b *Blockchain) Store(block *core.Block, blockCommitments *core.BlockCommit
return err
}

// Todo: also handle deletion / reverts etc
if err := storeL1HandlerMsgHashes(txn, block); err != nil {
return err
}
Expand Down Expand Up @@ -919,7 +918,6 @@ func (b *Blockchain) revertHead(txn db.Transaction) error {
}

// Revert chain height and pending.

if genesisBlock {
if err = txn.Delete(db.Pending.Key()); err != nil {
return err
Expand Down Expand Up @@ -962,6 +960,11 @@ func removeTxsAndReceipts(txn db.Transaction, blockNumber, numTxs uint64) error
if err = txn.Delete(db.TransactionBlockNumbersAndIndicesByHash.Key(reorgedTxn.Hash().Marshal())); err != nil {
return err
}
if l1handler, ok := reorgedTxn.(*core.L1HandlerTransaction); ok {
if err = txn.Delete(db.L1HandlerTxnHash.Key(l1handler.MessageHash())); err != nil {
return err
}
}
}

return nil
Expand Down

0 comments on commit d31039e

Please sign in to comment.