diff --git a/app/workers/pool_transaction_check_worker.rb b/app/workers/pool_transaction_check_worker.rb index d23eeef0d..e6ce84869 100644 --- a/app/workers/pool_transaction_check_worker.rb +++ b/app/workers/pool_transaction_check_worker.rb @@ -5,14 +5,11 @@ class PoolTransactionCheckWorker def perform pending_transactions = CkbTransaction.tx_pending.where("created_at < ?", - 2.minutes.ago) + 2.minutes.ago).limit(100) pending_transactions.each do |tx| response_string = CkbSync::Api.instance.directly_single_call_rpc method: "get_transaction", params: [tx.tx_hash] reason = response_string["result"]["tx_status"] - if reason["status"] == "committed" && CkbTransaction.where(tx_hash: tx.tx_hash, tx_status: :committed).exists? - tx.destroy - end if reason["status"] == "rejected" ApplicationRecord.transaction do @@ -27,6 +24,10 @@ def perform tx.create_reject_reason!(message: "unknown") end end + + if reason["status"] == "committed" && CkbTransaction.where(tx_hash: tx.tx_hash).count == 2 && CkbTransaction.where(tx_hash: tx.tx_hash, tx_status: :committed).exists? + tx.destroy + end end end end diff --git a/lib/scheduler.rb b/lib/scheduler.rb index 3b6f9fab7..52b44683b 100644 --- a/lib/scheduler.rb +++ b/lib/scheduler.rb @@ -67,10 +67,6 @@ def call_worker(clz) call_worker PoolTransactionCheckWorker end -s.every "1h", overlap: false do - call_worker CleanUpWorker -end - s.interval "10s", overlap: false do puts "reset transactions_count_per_minute, average_block_time, transaction_fee_rates" StatisticInfo.default.reset! :transactions_count_per_minute,