Skip to content

Commit 26759e0

Browse files
committed
fix: clear cell_outputs cache when rollback
Signed-off-by: Miles Zhang <mingchang555@hotmail.com>
1 parent 992b4f3 commit 26759e0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/models/block.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,16 @@ def invalid!
285285
uncle_blocks.delete_all
286286
# delete_address_txs_cache
287287
ckb_transaction_ids = ckb_transactions.pluck(:id)
288+
tx_hashes = ckb_transactions.pluck(:tx_hash)
288289
CellOutput.where(ckb_transaction_id: ckb_transaction_ids).delete_all
289290
CellInput.where(ckb_transaction_id: ckb_transaction_ids).delete_all
290291
AccountBook.where(ckb_transaction_id: ckb_transaction_ids).delete_all
291292
CellDependency.where(ckb_transaction_id: ckb_transaction_ids).delete_all
293+
cell_deps = CellDepsOutPoint.where(tx_hash: tx_hashes).select(:tx_hash, :cell_index)
294+
cell_deps.each do |cell_dep|
295+
Rails.cache.delete(["CellOutput", cell_dep.tx_hash, cell_dep.cell_index])
296+
end
297+
292298
HeaderDependency.where(ckb_transaction_id: ckb_transaction_ids).delete_all
293299
TokenTransfer.where(transaction_id: ckb_transaction_ids).delete_all
294300
Witness.where(ckb_transaction_id: ckb_transaction_ids).delete_all

0 commit comments

Comments
 (0)