diff --git a/app/jobs/import_block_job.rb b/app/jobs/import_block_job.rb index d39e9cd0f..58bd09cda 100644 --- a/app/jobs/import_block_job.rb +++ b/app/jobs/import_block_job.rb @@ -1,3 +1,4 @@ +# No used class ImportBlockJob < ApplicationJob def perform(block_hash) if block_hash.is_a?(Integer) diff --git a/app/jobs/revert_block_job.rb b/app/jobs/revert_block_job.rb index 49ac115c7..cfabb33e0 100644 --- a/app/jobs/revert_block_job.rb +++ b/app/jobs/revert_block_job.rb @@ -11,8 +11,6 @@ def perform(local_tip_block = nil) end ApplicationRecord.transaction do - CkbTransaction.tx_pending. - where(tx_hash: CkbUtils.hexes_to_bins(local_tip_block.ckb_transactions.pluck(:tx_hash))).update_all(tx_status: "pending") benchmark :revert_dao_contract_related_operations, local_tip_block benchmark :revert_mining_info, local_tip_block diff --git a/app/models/ckb_sync/new_node_data_processor.rb b/app/models/ckb_sync/new_node_data_processor.rb index b355a297b..736d3c68e 100644 --- a/app/models/ckb_sync/new_node_data_processor.rb +++ b/app/models/ckb_sync/new_node_data_processor.rb @@ -77,7 +77,8 @@ def process_block(node_block, refresh_balance: true) @contained_udt_ids = contained_udt_ids = [] @contained_address_ids = contained_address_ids = [] - process_ckb_txs(node_block, ckb_txs, contained_address_ids, contained_udt_ids, dao_address_ids, tags, udt_address_ids) + process_ckb_txs(node_block, ckb_txs, contained_address_ids, contained_udt_ids, dao_address_ids, tags, + udt_address_ids) addrs_changes = Hash.new { |hash, key| hash[key] = {} } input_capacities, output_capacities = build_cells_and_locks!(local_block, node_block, ckb_txs, inputs, outputs, tags, udt_address_ids, dao_address_ids, contained_udt_ids, contained_address_ids, addrs_changes) @@ -136,7 +137,10 @@ def generate_statistics_data(local_block) GenerateStatisticsDataWorker.perform_async(local_block.id) end - def process_ckb_txs(node_block, ckb_txs, contained_address_ids, contained_udt_ids, dao_address_ids, tags, udt_address_ids) + def process_ckb_txs( + node_block, ckb_txs, contained_address_ids, contained_udt_ids, dao_address_ids, tags, +udt_address_ids + ) tx_index = 0 ckb_txs.each do |cbk_tx| cbk_tx["tx_hash"][0] = "0" @@ -1182,7 +1186,6 @@ def cell_input_attributes(input, ckb_transaction_id, local_block_id, prev_output def build_ckb_transactions!(node_block, local_block, inputs, outputs, outputs_data) cycles = CkbSync::Api.instance.get_block_cycles node_block.header.hash - txs = nil ckb_transactions_attributes = [] tx_index = 0 hashes = [] @@ -1209,7 +1212,7 @@ def build_ckb_transactions!(node_block, local_block, inputs, outputs, outputs_da # locate correct record according to tx_hash binary_hashes = CkbUtils.hexes_to_bins(hashes) pending_txs = CkbTransaction.where(tx_hash: binary_hashes, tx_status: :pending).pluck(:tx_hash, :created_at) - CkbTransaction.where(tx_hash: hashes).update_all tx_status: "committed" + CkbTransaction.where(tx_hash: binary_hashes).update_all tx_status: "committed" txs = CkbTransaction.upsert_all(ckb_transactions_attributes, unique_by: [:tx_status, :tx_hash], returning: %w(id tx_hash block_timestamp created_at)) diff --git a/app/workers/clean_up_worker.rb b/app/workers/clean_up_worker.rb index 0f3afb2a7..187fbd992 100644 --- a/app/workers/clean_up_worker.rb +++ b/app/workers/clean_up_worker.rb @@ -3,7 +3,7 @@ class CleanUpWorker def perform TokenCollection.remove_corrupted - CkbTransaction.tx_pending.where("created_at < ?", 2.weeks.ago).destroy_all + CkbTransaction.tx_pending.where("created_at < ?", 1.day.ago).destroy_all CkbTransaction.tx_rejected.where("created_at < ?", 3.months.ago).destroy_all end end diff --git a/app/workers/pool_transaction_check_worker.rb b/app/workers/pool_transaction_check_worker.rb index d5445503e..12d2a2a09 100644 --- a/app/workers/pool_transaction_check_worker.rb +++ b/app/workers/pool_transaction_check_worker.rb @@ -14,12 +14,6 @@ def perform includes(:cell_dependencies, cell_inputs: :previous_cell_output). order(id: :asc).limit(150) pending_transactions.each do |tx| - # FIXME: remove this code - if CkbTransaction.tx_committed.exists?(tx_hash: tx.tx_hash) - tx.destroy! - next - end - is_rejected = false rejected_transaction = nil # check if any input is used by other transactions