From d8c18aafe75e6d13790acf1bb08aa7f07d956d65 Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Tue, 7 Jan 2025 20:12:23 +0900 Subject: [PATCH] fix: clear cell_outputs cache when rollback Signed-off-by: Miles Zhang --- app/models/block.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/block.rb b/app/models/block.rb index 7f22d905a..bc0afc959 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -285,10 +285,15 @@ 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(["cell_output", 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