diff --git a/app/models/ckb_sync/new_node_data_processor.rb b/app/models/ckb_sync/new_node_data_processor.rb index b67d32684..bebdd415d 100644 --- a/app/models/ckb_sync/new_node_data_processor.rb +++ b/app/models/ckb_sync/new_node_data_processor.rb @@ -801,43 +801,43 @@ def build_cells_and_locks!( lock_scripts_attributes.map! do |attr| attr.merge!(created_at: Time.current, updated_at: Time.current) end - lock_script_ids = LockScript.upsert_all(lock_scripts_attributes, unique_by: :script_hash, returning: [:id]) - - lock_script_ids.each do |row| - lock_script_id = row["id"] - lock_script = LockScript.find lock_script_id - contract = Contract.find_by code_hash: lock_script.code_hash - temp_hash = { script_hash: lock_script&.script_hash, is_contract: false } - if contract - temp_hash = temp_hash.merge is_contract: true, contract_id: contract.id - else - contract = Contract.create code_hash: lock_script.script_hash - temp_hash = temp_hash.merge contract_id: contract.id - end - # script = Script.find_or_create_by temp_hash - # lock_script.update script_id: script.id - end + LockScript.upsert_all(lock_scripts_attributes, unique_by: :script_hash, returning: [:id]) + + # lock_script_ids.each do |row| + # lock_script_id = row["id"] + # lock_script = LockScript.find lock_script_id + # contract = Contract.find_by code_hash: lock_script.code_hash + # temp_hash = { script_hash: lock_script&.script_hash, is_contract: false } + # if contract + # temp_hash = temp_hash.merge is_contract: true, contract_id: contract.id + # else + # contract = Contract.create code_hash: lock_script.script_hash + # temp_hash = temp_hash.merge contract_id: contract.id + # end + # # script = Script.find_or_create_by temp_hash + # # lock_script.update script_id: script.id + # end end if type_scripts_attributes.present? type_scripts_attributes.map! do |attr| attr.merge!(created_at: Time.current, updated_at: Time.current) end - type_script_ids = TypeScript.upsert_all(type_scripts_attributes, unique_by: :script_hash, returning: [:id]) - type_script_ids.each do |row| - type_script_id = row["id"] - type_script = TypeScript.find(type_script_id) - temp_hash = { script_hash: type_script&.script_hash, is_contract: false } - contract = Contract.find_by code_hash: type_script.code_hash - if contract - temp_hash = temp_hash.merge is_contract: true, contract_id: contract.id - else - contract = Contract.create code_hash: type_script.script_hash - temp_hash = temp_hash.merge contract_id: contract.id - end - # script = Script.find_or_create_by temp_hash - # type_script.update script_id: script.id - end + TypeScript.upsert_all(type_scripts_attributes, unique_by: :script_hash, returning: [:id]) + # type_script_ids.each do |row| + # type_script_id = row["id"] + # type_script = TypeScript.find(type_script_id) + # temp_hash = { script_hash: type_script&.script_hash, is_contract: false } + # contract = Contract.find_by code_hash: type_script.code_hash + # if contract + # temp_hash = temp_hash.merge is_contract: true, contract_id: contract.id + # else + # contract = Contract.create code_hash: type_script.script_hash + # temp_hash = temp_hash.merge contract_id: contract.id + # end + # # script = Script.find_or_create_by temp_hash + # # type_script.update script_id: script.id + # end end build_addresses!(outputs, local_block) # prepare script ids for insert cell_outputs @@ -910,8 +910,8 @@ def build_cells_and_locks!( record_timestamps: true) end - ScriptTransaction.create_from_scripts TypeScript.where(id: type_script_ids) - ScriptTransaction.create_from_scripts LockScript.where(id: lock_script_ids) + # ScriptTransaction.create_from_scripts TypeScript.where(id: type_script_ids) + # ScriptTransaction.create_from_scripts LockScript.where(id: lock_script_ids) [input_capacities, output_capacities] end