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 d8c18aa
Showing 1 changed file with 5 additions and 0 deletions.
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 @@ 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])

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

0 comments on commit d8c18aa

Please sign in to comment.