Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clear cell_outputs cache when rollback #2395

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/models/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,15 @@
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])

Check warning on line 295 in app/models/block.rb

View check run for this annotation

Codecov / codecov/patch

app/models/block.rb#L295

Added line #L295 was not covered by tests
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
Loading