From 7c06249dba3c8507269c21fdf0582567da1acc2f Mon Sep 17 00:00:00 2001 From: NanZhang Date: Thu, 16 Nov 2023 19:37:05 +0800 Subject: [PATCH] fix: locate cell_output in committed transaction (#1502) --- app/models/cell_output.rb | 3 +-- app/models/deployed_cell.rb | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/models/cell_output.rb b/app/models/cell_output.rb index 78252f0e3..2f6bd8a3b 100644 --- a/app/models/cell_output.rb +++ b/app/models/cell_output.rb @@ -131,8 +131,7 @@ def self.find_by_pointer(tx_hash, index) Rails.cache.fetch(["cell_output", tx_hash, index], skip_nil: true, race_condition_ttl: 10.seconds, expires_in: 1.day) do - tx_id = CkbTransaction.find_by_tx_hash(tx_hash)&.id - + tx_id = CkbTransaction.tx_committed.find_by_tx_hash(tx_hash)&.id Rails.logger.info("find_by_pointer: tx_hash: #{tx_hash}, index: #{index}, tx_id: #{tx_id}") find_by(ckb_transaction_id: tx_id, cell_index: index.is_a?(String) ? index.hex : index) if tx_id end diff --git a/app/models/deployed_cell.rb b/app/models/deployed_cell.rb index 53fa3cf6d..45c3ce6cc 100644 --- a/app/models/deployed_cell.rb +++ b/app/models/deployed_cell.rb @@ -51,7 +51,6 @@ def self.create_initial_data(ckb_transaction_id = 0) def self.create_initial_data_for_ckb_transaction(ckb_transaction, cell_deps) return if cell_deps.blank? - Rails.logger.info("create cell deps cell_deps: #{cell_deps}") deployed_cells = [] cell_dependencies_attrs = [] @@ -67,7 +66,6 @@ def self.create_initial_data_for_ckb_transaction(ckb_transaction, cell_deps) parse_code_dep = ->(cell_dep) do # this cell output is the contract cell, i.e. one of deployed cells of the contract - Rails.logger.info("parse_code_dep cell_dep: #{cell_dep}") cell_output = CellOutput.find_by_pointer cell_dep["out_point"]["tx_hash"], cell_dep["out_point"]["index"] attr = {