Skip to content

Commit 2bb5375

Browse files
authored
fix: clear cell_outputs cache when rollback (#2395)
Signed-off-by: Miles Zhang <mingchang555@hotmail.com>
1 parent 992b4f3 commit 2bb5375

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

app/models/block.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,15 @@ 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(["cell_output", cell_dep.tx_hash, cell_dep.cell_index])
296+
end
292297
HeaderDependency.where(ckb_transaction_id: ckb_transaction_ids).delete_all
293298
TokenTransfer.where(transaction_id: ckb_transaction_ids).delete_all
294299
Witness.where(ckb_transaction_id: ckb_transaction_ids).delete_all

0 commit comments

Comments
 (0)