diff --git a/app/controllers/api/v2/bitcoin_transactions_controller.rb b/app/controllers/api/v2/bitcoin_transactions_controller.rb index cdec650fb..2b14ad10a 100644 --- a/app/controllers/api/v2/bitcoin_transactions_controller.rb +++ b/app/controllers/api/v2/bitcoin_transactions_controller.rb @@ -8,12 +8,14 @@ def query not_cached = cache_keys - res.keys to_cache = {} - get_raw_transactions(not_cached).each do |tx| - next if tx.dig("error").present? + if not_cached.present? + get_raw_transactions(not_cached).each do |tx| + next if tx.dig("error").present? - txid = tx.dig("result", "txid") - res[txid] = tx - to_cache[txid] = tx + txid = tx.dig("result", "txid") + res[txid] = tx + to_cache[txid] = tx + end end Rails.cache.write_multi(to_cache, expires_in: 10.minutes) unless to_cache.empty? diff --git a/app/controllers/api/v2/ckb_transactions_controller.rb b/app/controllers/api/v2/ckb_transactions_controller.rb index 7c9a3429d..0d5145a1c 100644 --- a/app/controllers/api/v2/ckb_transactions_controller.rb +++ b/app/controllers/api/v2/ckb_transactions_controller.rb @@ -64,7 +64,7 @@ def rgb_digest end op_return = @ckb_transaction.bitcoin_vouts.find_by(op_return: true) - bitcoin_transaction = BitcoinTransaction.includes(:bitcoin_vouts).find_by(bitcoin_vouts: { ckb_transaction_id: tx.id }) + bitcoin_transaction = BitcoinTransaction.includes(:bitcoin_vouts).find_by(bitcoin_vouts: { ckb_transaction_id: @ckb_transaction.id }) render json: { data: {