Skip to content

Commit

Permalink
fix: clear cell_outputs cache when rollback
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid committed Jan 7, 2025
1 parent 992b4f3 commit 26759e0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,16 @@ def invalid!
uncle_blocks.delete_all
# delete_address_txs_cache
ckb_transaction_ids = ckb_transactions.pluck(:id)
tx_hashes = ckb_transactions.pluck(:tx_hash)
CellOutput.where(ckb_transaction_id: ckb_transaction_ids).delete_all
CellInput.where(ckb_transaction_id: ckb_transaction_ids).delete_all
AccountBook.where(ckb_transaction_id: ckb_transaction_ids).delete_all
CellDependency.where(ckb_transaction_id: ckb_transaction_ids).delete_all
cell_deps = CellDepsOutPoint.where(tx_hash: tx_hashes).select(:tx_hash, :cell_index)
cell_deps.each do |cell_dep|
Rails.cache.delete(["CellOutput", cell_dep.tx_hash, cell_dep.cell_index])
end

HeaderDependency.where(ckb_transaction_id: ckb_transaction_ids).delete_all
TokenTransfer.where(transaction_id: ckb_transaction_ids).delete_all
Witness.where(ckb_transaction_id: ckb_transaction_ids).delete_all
Expand Down

0 comments on commit 26759e0

Please sign in to comment.